Class DynamicMatrix
The DynamicMatrix class uses the FB_DynMem_Manager2 to dynamically allocate as much memory as required for the given operation.
This amazing flexibility comes at the cost of some restrictions on use in order to avoid memory leaks.
Using the assignment operator (:=) to copy a DynamicMatrix will result in the new matrix retaining a pointer to the data of the old matrix! For this reason, the pragma {attribute 'no_assign'} is used to block assignment at compile-time, but inheriting sub-classes will need to include this pragma themselves.
Note that using DynamicMatrix as the return value of a function is essentially an assignment operation and will also not work. Therefore, it is recommended to always pass DynamicMatrix objects in and out of functions using the REFERENCE TO keyword. To alleviate the pain of these assignment rules there are a ton of 'Resultant' helper functions available to use which initialize a new DynamicMatrix as the result of some operation on other matrix objects.
warning
Inherited Members
Namespace: PlcDocu.TcMatrix
Assembly: TcMatrixConnector.dll
Syntax
public abstract class DynamicMatrix : Matrix
Properties
| Improve this Doc View SourceCols
note
This is PLC property. This method is accessible only from the PLC code.
Declaration
[IgnoreReflection]
public dynamic Cols { get; }
Property Value
| Type | Description |
|---|---|
| System.Object | Plc type UINT; Twin type: Vortex.Connector.ValueTypes.OnlinerUInt |
Rows
note
This is PLC property. This method is accessible only from the PLC code.
Declaration
[IgnoreReflection]
public dynamic Rows { get; }
Property Value
| Type | Description |
|---|---|
| System.Object | Plc type UINT; Twin type: Vortex.Connector.ValueTypes.OnlinerUInt |
Methods
| Improve this Doc View SourceFree()
Frees all dynamically allocated memory and resets the size of the matrix to 0x0
Declaration
[IgnoreReflection]
public void Free()
GetI(Object)
Gets the value of the element in this matrix at the supplied location as if the elements were stored in a 1D row-major array Prerequisites:
- I < Rows*Cols
- Matrix is not empty
note
If the supplied index is out of bounds the value 0 is returned and a warning is generated in the Error List
Declaration
[IgnoreReflection]
public dynamic GetI(dynamic I)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | I | The index of the element which should have its value returned |
Returns
| Type | Description |
|---|---|
| System.Object | The value of the element at the specified index, or 0 if an invalid index is supplied |
Init(Object, Object)
Initializes a RxC matrix, with potentially random non-zero values
Declaration
[IgnoreReflection]
public dynamic Init(dynamic Rows, dynamic Cols)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | Rows | The number of rows to create |
| System.Object | Cols | The number of collumns to create |
Returns
| Type | Description |
|---|---|
| System.Object | Returns True if success |
InitConstant(Object, Object, Object)
Initializes a RxC matrix where every element is equal to the supplied value
Declaration
[IgnoreReflection]
public dynamic InitConstant(dynamic Rows, dynamic Cols, dynamic Val)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | Rows | Number of rows to create |
| System.Object | Cols | Number of columns to create |
| System.Object | Val | The value to to initiliaze with |
Returns
| Type | Description |
|---|---|
| System.Object | Returns True if success |
InitCopy(Object)
Initializes a matrix with the exact size and contents of the supplied matrix
Declaration
[IgnoreReflection]
public dynamic InitCopy(dynamic M)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | M | Supplied matrix |
Returns
| Type | Description |
|---|---|
| System.Object | Returns True if success |
InitIdentity(Object)
Initializes a square identity matrix of size Size x Size
Declaration
[IgnoreReflection]
public dynamic InitIdentity(dynamic Size)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | Size | Size of the square matrix |
Returns
| Type | Description |
|---|---|
| System.Object | Returns True if success |
InitTrapezoidal(Object, Object, Object, Object, Object)
Initializes a RxC matrix then fills is using FillTrapezoidal()
Declaration
[IgnoreReflection]
public dynamic InitTrapezoidal(dynamic Rows, dynamic Cols, dynamic Diagonal, dynamic UpperRight, dynamic LowerLeft)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | Rows | Number of rows to create |
| System.Object | Cols | Number of columns to create |
| System.Object | Diagonal | Every element on the main diagonal of the matrix is set to this value. |
| System.Object | UpperRight | Every element above or to the right of the main diagonal is set to this value |
| System.Object | LowerLeft | Every element below or to the left of the main diagonal is set to this value |
Returns
| Type | Description |
|---|---|
| System.Object | Returns True if success |
InitVector(Object, Object, Object)
Initializes an Lx1 column vector where the 0th element is equal to Val and every subsequent element is Inc larger than the previous
Declaration
[IgnoreReflection]
public dynamic InitVector(dynamic Length, dynamic Value, dynamic Increment)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | Length | Length of the vector |
| System.Object | Value | Value of 0th element |
| System.Object | Increment | Value by witch every other value is incremented by |
Returns
| Type | Description |
|---|---|
| System.Object | Returns True if success |
InitZeros(Object, Object)
Initializes a RxC matrix where every element is equal to 0.0
Declaration
[IgnoreReflection]
public dynamic InitZeros(dynamic Rows, dynamic Cols)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | Rows | The number of rows to create |
| System.Object | Cols | The number of collumns to create |
Returns
| Type | Description |
|---|---|
| System.Object | Returns True if success |
Resize(Object, Object, Object, Object)
Changes the total number of Rows and Cols in the matrix. If Retain is seleced then any element within the bounds of both the initial and resulting matrix will have its value retained. If Init is selected then any newly created element will have its value set to zero.
Declaration
[IgnoreReflection]
public dynamic Resize(dynamic NewRows, dynamic NewCols, dynamic RetainVals, dynamic ClearVals)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | NewRows | The row of the element to fetch |
| System.Object | NewCols | The column of the element to fetch |
| System.Object | RetainVals | If selected then any element within the bounds of both the initial and resulting matrix will have its value retained. |
| System.Object | ClearVals | If selected then any newly created element will have its value set to zero. |
Returns
| Type | Description |
|---|---|
| System.Object | Returns TRUE on success |
SetI(Object, Object)
Sets the element specified BY the supplied index TO the suppleid value, assuming the data OF the matrix is stored in a 1D row-major ARRAY Prerequisites: - I < Rows*Cols
Declaration
[IgnoreReflection]
public dynamic SetI(dynamic I, dynamic Val)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | I | The index specifying which element should be modified |
| System.Object | Val | The value copied to the corresponding element |
Returns
| Type | Description |
|---|---|
| System.Object | TRUE if the specified index is valid and the data is copied. FLASE otherwise |
Shrink(Object, Object)
Removes the specified Row and Column from the matrix, resuling in a new size of (Rows-1,Cols-1). No dimension can be shrunk from 1 to 0 (therefore vectors only shrink in one direction).
Declaration
[IgnoreReflection]
public dynamic Shrink(dynamic Row, dynamic Col)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | Row | Plc type : UINT [VAR_INPUT]; Twin type : Vortex.Connector.ValueTypes.OnlinerUInt
|
| System.Object | Col | Plc type : UINT [VAR_INPUT]; Twin type : Vortex.Connector.ValueTypes.OnlinerUInt
|
Returns
| Type | Description |
|---|---|
| System.Object | Returns TRUE on success |
Transpose()
Similar to TransposeSquare(), however it works on rectangular matricies (swapping Rows and Cols)
Declaration
[IgnoreReflection]
public dynamic Transpose()
Returns
| Type | Description |
|---|---|
| System.Object | Returns TRUE on success |