HyperWorks Solvers

Matrix

Matrix

Previous topic Next topic No expanding text in this topic  

Matrix

Previous topic Next topic JavaScript is required for expanding text JavaScript is required for the print function  

Model Element

Class Name

Matrix

Description

Matrix defines a general, real-valued, M x N matrix for use in MotionSolve.  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?

id    

Int ()

 

label

Str ()

full  

Enum ("RORDER CORDER", default=None)

rows  

Int (0)

columns

Int (0)

values

Double ([], count=0)

sparse

Bool (False)

i    

Int ([], count=0)

j    

Int ([], count=0)

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)

Attribute Description

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.


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 the Comments in the XML syntax section.

Example

1.Examples demonstrating XML syntax vs. Python Syntax.

 

XML Syntax

Python Syntax

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)

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)

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)