matrix

MapdlMath.matrix(matrix, name=None, triu=False)

Send a scipy matrix or numpy array to MAPDL.

Parameters
matrixnp.ndarray

Numpy array to send as a matrix to MAPDL.

namestr, optional

APDLMath matrix name. Optional and defaults to a random name.

triubool, optional

True when the matrix is upper triangular, False when unsymmetric.

Returns
AnsMat

MapdlMath matrix.

Examples

Generate a random sparse matrix.

>>> from scipy import sparse
>>> sz = 5000
>>> mat = sparse.random(sz, sz, density=0.05, format='csr')
>>> ans_mat = mm.matrix(mat, name)
>>> ans_mat
APDLMath Matrix 5000 x 5000

Transfer the matrix back to Python.

>>> ans_mat.asarray()
<500x5000 sparse matrix of type '<class 'numpy.float64'>'
        with 1250000 stored elements in Compressed Sparse Row format>