Matrix

Model ElementMatrix defines a general, real-valued, M x N matrix for use in MotionSolve.

Class Name

Matrix

Description

Matrices may be specified in two different ways in MotionSolve with this interface:
  • As a dense matrix in row or column order.
  • As a sparse matrix using Coordinate List (COO) format

Attribute Summary

Name Property Modifiable by command? Designable?
id Int ()    
label Str () Yes  
full Enum ("RORDER CORDER", default=None) Yes  
rows Int (0) Yes  
columns Int (0) Yes  
values Double ([], count=0) Yes FD Only
sparse Bool (False) Yes  
i Int ([], count=0) Yes  
j Int ([], count=0) Yes  

Usage

#1: Dense Matrix Format (row or column order)
Matrix (rows=integer, columns=integer, values=list, optional_attributes)

#2. Sparse matrix in COO format
Matrix (sparse=True, rows=integer, columns=integer, i=list, j=list, values=list, optional_attributes)

Attributes

Dense Matrix Format
rows
Integer
The number of rows in the matrix.
The attribute rows is mandatory. rows > 0
columns
Integer
The number of columns in the matrix.
The attribute columns is mandatory. columns > 0.
values
List of Doubles
Specifies the elements of the matrix. The ordering - by row or column is determined the argument full. The default ordering is by column.
The number of entries in the values list = rows x columns.
The attribute values is mandatory.
full
String
Set to full="RORDER" if the matrix is specified in row order.
The attribute full is optional.
When not specified or when full="CORDER", it implies that the matrix elements are specified in column order.
Sparse Matrix in COO Format
sparse
Boolean
Set to "TRUE".
The attribute sparse is mandatory.
rows
Integer
The number of rows in the matrix.
The attribute rows is mandatory. rows > 0
columns
Integer
The number of columns in the matrix.
The attribute columns is mandatory. columns > 0.
i
List of Integers
Specifies the row position of each element in the values attribute.
The i argument is mandatory.
Note: len (i) = len (j) = len (values) = Number of non-zero entries in the matrix. len (i) > 0
j
List of Integers
Specifies the column position of each element in the values attribute.
The j argument is mandatory.
Note: len (i) = len (j) = len (values) = Number of non-zero entries in the matrix. len (j) > 0
values
List of Doubles
Specifies the elements of the matrix.
The attribute values is mandatory.
Note: len (i) = len (j) = len (values) = Number of non-zero entries in the matrix. len (values) > 0
Optional Attributes - Available to all variants
id
Integer
Specifies the element identification number. This number must be unique among all the Matrix objects in the model.
This attribute is optional. MotionSolve will automatically create an ID when one is not specified.
Range of values: id > 0
label
String
Specifies the name of the Matrix object.
This attribute is optional. When not specified, MotionSolve will create a label for you.

Example

Examples demonstrating XML syntax vs. Python syntax.
XML Syntax Python Syntax
<Reference_Matrix     id                 = "1"     nrow               = "4"     ncol               = "5"     isroworder         = "TRUE" >        11 .0  12 .0  13 .0  14 .0  15 .0        21 .0  22 .0  23 .0  24 .0  25 .0        31 .0  32 .0  33 .0  34 .0  35 .0        41 .0  42 .0  43 .0  44 .0  45 .0 </Reference_Matrix> Values = [11, 12, 13, 14, 15,

21, 22, 23, 24, 25,

31, 32, 33, 34, 35,

41, 42, 43, 44, 45]

Mat1 = Matrix (label="Mat-1", rows=4, columns=5, full="RORDER", values=Values)

 <Reference_Matrix     id                 = "1"     nrow               = "4"     ncol               = "5" >        11 .0  21 .0  31 .0  41 .0        12 .0  22 .0  32 .0  42 .0        13 .0  23 .0  33 .0  43 .0        14 .0  24 .0  34 .0  44 .0        15 .0  25 .0  35 .0  45 .0  </Reference_Matrix> Values = [11, 21, 31, 41, 12,

22, 32, 42, 13, 23,

33, 43, 14, 24, 34,

44, 15, 25, 35, 45]

Mat2 = Matrix (label="Mat-2", rows=4, columns=5, values=Values)

<Reference_Matrix      id          = "1"      nrow        = "10"      ncol        = "10"      nval        = "13"      issparse    = "True" >         1   1   3 .3         1   7   7 .7         2   8   2 .9         3   9   1 .1         3   6   2 .2         4   4   4 .4         5   8   7 .6         6   2   1 .9         7  10   9 .2         8   7   5 .1         9   9   10 .         9   5   5 .1         10  3   4 .2      </Reference_Matrix> Irow = [1, 1, 2, 3, 3, 4, 5, 6, 7, 8, 9, 10]

Jcol = [1, 7, 8, 9, 6, 4, 8, 2, 10, 7, 9, 3]

Values = [3.3, 7.7, 2.9, 1.1, 2.2, 4.4, 7.6, 1.9, 9.2, 5.1, 10, 4.2]

Mat3 = Matrix (label="Mat-3", sparse=True, rows=10, columns=10, i=Irow, j=Jcol, values=Values)

Comments

  1. See Properties for an explanation about what properties are, why they are used, and how you can extend these.
  2. For a more detailed explanation about Matrix, see Reference: Matrix.