`MATRIX`

data type encapsulates a two dimensional matrix of 32-bit
floating-point values (corresponding to the IEC 61131-3 data type
`REAL`

) in [row][column] format.
Literal values of
`MATRIX`

variables can be expressed in BNF syntax as follows:

```
``````
matrix_literal ::=
```

'[' [vector_literal
{',' vector_literal}] ']'

vector_literal ::=

'[' [float_value {',' float_value}] ']'

The syntax of
`float_value`

is any string accepted by the `java.lang.Float.valueOf(String)`

method.

Each
`vector_literal`

element represents a *row* of the matrix; for instance, the
literal
`[[1,2],[3,4]]`

represents the matrix

```
``````
1.0 2.0
```

3.0 4.0

Missing elements are assigned zero values; for instance, the literal
`[[],[1,2],[3,4,5]]`

represents the matrix

```
``````
0.0 0.0 0.0
```

1.0 2.0 0.0

3.0 4.0 5.0

For examples of the use of
`MATRIX`

literals, see the
```
MATRIX_DEMO
```

and
```
M_OPS_DEMO
```

system configurations.

MATRIX ::= [APPLICATION 23] IMPLICIT SEQUENCE {

rows IMPLICIT USINT,

cols IMPLICIT USINT,

IMPLICIT SEQUENCE OF IMPLICIT REAL}

The encoding of
rows IMPLICIT USINT,

cols IMPLICIT USINT,

IMPLICIT SEQUENCE OF IMPLICIT REAL}

`rows`

and`cols`

, representing the number of rows and columns in the matrix respectively, are encoded as values of the`USINT`type without identifier or length octets, i.e., as two successive 8-bit unsigned integers.- This restricts the maximum number of elements of a
`MATRIX`to 65025 (255×255). - If the matrix data is to be transferred via
`PUBLISH/SUBSCRIBE`

, the maximum number of elements is further restricted by the maximum number of octets (1472) that can be transferred in a single UDP packet without segmentation; otherwise, an`OVERFLOW`

error will be declared by the corresponding FB instance. - Since the encoding of a REAL value requires 32 bits (4
octets), the maximum number of elements in a
`MATRIX`instance to be transmitted via`PUBLISH/SUBSCRIBE`

would then be (maximum octets - tag octets - length octets)/(element length) = (1472-1-2)/4 = 367 elements. For instance, a square matrix with 19 rows and columns, containing 361 elements, would fit in a UDP packet. - MATRIX data larger than the allowed UDP transfer should be
transferred using the
`CLIENT/SERVER`

mechanism.

- This restricts the maximum number of elements of a
- The matrix contents are encoded using the COMPACT syntax for an ARRAY of IEC 61131-3 REAL values, without any tag or length subfields.
- Data is encoded in column order; for instance, the matrix
0.0 0.0 0.0would be encoded in the order

1.0 2.0 0.0

3.0 4.0 5.0`(0.0,1.0,3.0,0.0,2.0,4.0,0.0,0.0,5.0)`

.

```
CODEC_TEST2
```

system configuration.
*Last updated: 2015-02-09.*

©2011-2015 Holobloc Inc.

All rights reserved.