In addition to supporting new language targets, Maple 18 includes expanded support for some existing targets and new options for controlling output.
The Matlab translator now provides MATLAB® equivalents for a larger set of Maple functions, including commands in the LinearAlgebra and ArrayTools packages.
function cg = DimensionOfCharacteristicMatrix(M, n, lambda)
A = M - lambda * eye(n, n);
cg = size(A,1);
| |
In addition, the new libraryorder option allows the user to specify a preference on which standard libraries are used for translation in the case when matching translations are available from multiple libraries. This example from Python shows first a translation using both numpy.linalg and scipy.linalg libraries.
import numpy.linalg
import scipy.linalg
def HilbertDeterminant (M, n):
return(numpy.linalg.det(scipy.linalg.hilbert(n)))
| |
Typically, translating the determinant function to numpy.linalg is the preferable choice.
In this case, because scipy.linalg library is already being used and contains its own implementation of the determinant function, it is preferable to use that implementation. This may be achieved using the libraryorder option to specify the relative weight to assign to each library.
import scipy.linalg
def HilbertDeterminant (M, n):
return(scipy.linalg.det(scipy.linalg.hilbert(n)))
| |