日本語 English

Matrix calculations

This page introduces a matrix library for the OMRON NX/NJ series.
It can implement matrix addition, subtraction, scalar multiplication, Hadamard product, matrix product, transpose, inverse, determinant calculation and more.

Samples

Addition (matADD)

Matrix addition
In-out
a
Matrix [0..9,0..9]
b
Matrix [0..9,0..9]
result
Matrix [0..9,0..9]

Example

Example of matrix addition
In-out
a
\begin{bmatrix} 1,&2,&3 \\ 2,&3,&4 \\ 3,&4,&5 \\ \end{bmatrix}
b
\begin{bmatrix} 3,&2,&1 \\ 4,&3,&2 \\ 5,&4,&3 \\ \end{bmatrix}
result
\begin{bmatrix} 4,&4,&4 \\ 6,&6,&6 \\ 8,&8,&8 \\ \end{bmatrix}

Formulas

\[ \begin{bmatrix} a_{11} & a_{12} & \ldots & a_{1n} \\ a_{21} & a_{22} & \ldots & a_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{n1} & a_{n2} & \ldots & a_{nn} \end{bmatrix} + \begin{bmatrix} b_{11} & b_{12} & \ldots & b_{1n} \\ b_{21} & b_{22} & \ldots & b_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ b_{n1} & b_{n2} & \ldots & b_{nn} \end{bmatrix} = \begin{bmatrix} a_{11}+b_{11} & a_{12}+b_{12} & \ldots & a_{1n}+b_{1n} \\ a_{21}+b_{21} & a_{22}+b_{22} & \ldots & a_{2n}+b_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{n1}+b_{n1} & a_{n2}+b_{n2} & \ldots & a_{nn}+b_{nn} \end{bmatrix} \]


Subtraction (matSUB)

Matrix subtraction
In-out
a
Matrix [0..9,0..9]
b
Matrix [0..9,0..9]
result
Matrix [0..9,0..9]

Example

Example of matrix subtraction
In-out
a
\begin{bmatrix} 1,&2,&3 \\ 2,&3,&4 \\ 3,&4,&5 \\ \end{bmatrix}
b
\begin{bmatrix} 3,&2,&1 \\ 4,&3,&2 \\ 5,&4,&3 \\ \end{bmatrix}
result
\begin{bmatrix} -2,&0,&2 \\ -2,&0,&2 \\ -2,&0,&2 \\ \end{bmatrix}

Formulas

\[ \begin{bmatrix} a_{11} & a_{12} & \ldots & a_{1n} \\ a_{21} & a_{22} & \ldots & a_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{n1} & a_{n2} & \ldots & a_{nn} \end{bmatrix} - \begin{bmatrix} b_{11} & b_{12} & \ldots & b_{1n} \\ b_{21} & b_{22} & \ldots & b_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ b_{n1} & b_{n2} & \ldots & b_{nn} \end{bmatrix} = \begin{bmatrix} a_{11}-b_{11} & a_{12}-b_{12} & \ldots & a_{1n}-b_{1n} \\ a_{21}-b_{21} & a_{22}-b_{22} & \ldots & a_{2n}-b_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{n1}-b_{n1} & a_{n2}-b_{n2} & \ldots & a_{nn}-b_{nn} \end{bmatrix} \]


Scalar multiplication (matMUL)

Scalar multiplication of a matrix
Input
k
Multiplier
In-out
a
Matrix [0..9,0..9]
result
Matrix [0..9,0..9]

Example

Example of scalar multiplication of a matrix
Input
k
2.0
In-out
a
\begin{bmatrix} 1,&2,&3 \\ 2,&3,&4 \\ 3,&4,&5 \\ \end{bmatrix}
result
\begin{bmatrix} 2,&4,&6 \\ 4,&6,&8 \\ 6,&8,&10 \\ \end{bmatrix}

Formulas

\[ k \begin{bmatrix} a_{11} & a_{12} & \ldots & a_{1n} \\ a_{21} & a_{22} & \ldots & a_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{n1} & a_{n2} & \ldots & a_{nn} \end{bmatrix} = \begin{bmatrix} ka_{11} & ka_{12} & \ldots & ka_{1n} \\ ka_{21} & ka_{22} & \ldots & ka_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ ka_{n1} & ka_{n2} & \ldots & ka_{nn} \end{bmatrix} \]


Hadamard product (matMultiply)

Hadamard product
In-out
a
Matrix [0..9,0..9]
b
Matrix [0..9,0..9]
result
Matrix [0..9,0..9]

Example

Example of the Hadamard product
In-out
a
\begin{bmatrix} 1,&2,&3 \\ 2,&3,&4 \\ 3,&4,&5 \\ \end{bmatrix}
b
\begin{bmatrix} 3,&2,&1 \\ 4,&3,&2 \\ 5,&4,&3 \\ \end{bmatrix}
result
\begin{bmatrix} 3,&4,&3 \\ 8,&9,&8 \\ 15,&16,&15 \\ \end{bmatrix}

Formulas

\[ \begin{bmatrix} a_{11} & a_{12} & \ldots & a_{1n} \\ a_{21} & a_{22} & \ldots & a_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{n1} & a_{n2} & \ldots & a_{nn} \end{bmatrix} \circ \begin{bmatrix} b_{11} & b_{12} & \ldots & b_{1n} \\ b_{21} & b_{22} & \ldots & b_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ b_{n1} & b_{n2} & \ldots & b_{nn} \end{bmatrix} = \begin{bmatrix} a_{11}b_{11} & a_{12}b_{12} & \ldots & a_{1n}b_{1n} \\ a_{21}b_{21} & a_{22}b_{22} & \ldots & a_{2n}b_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{n1}b_{n1} & a_{n2}b_{n2} & \ldots & a_{nn}b_{nn} \end{bmatrix} \]


Dot product (matDot)

Inner product of matrices
In-out
a
Matrix [0..9,0..9]
b
Matrix [0..9,0..9]
Output
out
Result

Example

Example of the inner product of matrices
In-out
a
\begin{bmatrix} 1,&2,&3 \\ 2,&3,&4 \\ 3,&4,&5 \\ \end{bmatrix}
b
\begin{bmatrix} 3,&2,&1 \\ 4,&3,&2 \\ 5,&4,&3 \\ \end{bmatrix}
Output
out
81

Formulas

\[ \begin{bmatrix} a_{11} & a_{12} & \ldots & a_{1n} \\ a_{21} & a_{22} & \ldots & a_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{n1} & a_{n2} & \ldots & a_{nn} \end{bmatrix} \bullet \begin{bmatrix} b_{11} & b_{12} & \ldots & b_{1n} \\ b_{21} & b_{22} & \ldots & b_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ b_{n1} & b_{n2} & \ldots & b_{nn} \end{bmatrix} \]


Matrix product (matCross)

Matrix product
In-out
a
Matrix [0..9,0..9]
b
Matrix [0..9,0..9]
Output
result
Matrix [0..9,0..9]

Example

Example of the matrix product
In-out
a
\begin{bmatrix} 1,&2,&3 \\ 2,&3,&4 \\ 3,&4,&5 \\ \end{bmatrix}
b
\begin{bmatrix} 3,&2,&1 \\ 4,&3,&2 \\ 5,&4,&3 \\ \end{bmatrix}
Output
result
\begin{bmatrix} 26,&20,&14 \\ 38,&29,&20 \\ 50,&38,&26 \\ \end{bmatrix}

Formulas

\[ \begin{bmatrix} a_{11} & a_{12} & \ldots & a_{1n} \\ a_{21} & a_{22} & \ldots & a_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{n1} & a_{n2} & \ldots & a_{nn} \end{bmatrix} \times \begin{bmatrix} b_{11} & b_{12} & \ldots & b_{1n} \\ b_{21} & b_{22} & \ldots & b_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ b_{n1} & b_{n2} & \ldots & b_{nn} \end{bmatrix} \]


Transpose (matT)

Transpose of a matrix
In-out
a
Matrix [0..9,0..9]
result
Matrix [0..9,0..9]

Example

Example of the transpose of a matrix
In-out
a
\begin{bmatrix} 1,&2,&3 \\ 4,&5,&6 \\ 7,&8,&9 \\ \end{bmatrix}
result
\begin{bmatrix} 1,&4,&7 \\ 2,&5,&8 \\ 3,&6,&9 \\ \end{bmatrix}

Formulas

\[ ^tA= \begin{bmatrix} a_{11} & a_{12} & \ldots & a_{1n} \\ a_{21} & a_{22} & \ldots & a_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{n1} & a_{n2} & \ldots & a_{nn} \end{bmatrix} = \begin{bmatrix} a_{11} & a_{21} & \ldots & a_{n1} \\ a_{12} & a_{22} & \ldots & a_{n2} \\ \vdots & \vdots & \ddots & \vdots \\ a_{1n} & a_{2n} & \ldots & a_{nn} \end{bmatrix} \]


Inverse (matInv)

Inverse matrix
In-out
a
Matrix [0..9,0..9]
result
Matrix [0..9,0..9]

Example

Example of an inverse matrix
In-out
a
\begin{bmatrix} 1,&2,&0 \\ -1,&1,&2 \\ 2,&0,&1 \\ \end{bmatrix}
result
\begin{bmatrix} 0.09,&-0.18,&0.36 \\ 0.45,&0.09,&-0.18 \\ -0.18,&0.36,&0.27 \\ \end{bmatrix}

Formulas

\[ A^{-1}= \begin{bmatrix} a_{11} & a_{12} & \ldots & a_{1n} \\ a_{21} & a_{22} & \ldots & a_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{n1} & a_{n2} & \ldots & a_{nn} \end{bmatrix} \]


Determinant (matDet)

Determinant calculation
In-out
a
Matrix [0..9,0..9]
Output
out
Result

Example

Example of determinant calculation
In-out
a
\begin{bmatrix} 2,&-2,&4 \\ 2,&-1,&6 \\ 3,&-2,&12 \\ \end{bmatrix}
Output
out
8.0

Formulas

\[ \begin{bmatrix} a_{11} & a_{12} & \ldots & a_{1n} \\ a_{21} & a_{22} & \ldots & a_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{n1} & a_{n2} & \ldots & a_{nn} \end{bmatrix} \]



Comments