Skip to content

Matrix Operations

Dickson Law edited this page Sep 25, 2021 · 3 revisions

Matrix Operations

Builders

Operation r22 r33 r44 rnn rmn
Create a new matrix r22(...) r33(...) r44(...) rnn(...) rmn(...)
Create a new identity matrix r22() r33() r44() rnn(n) N/A
Create a new zero matrix r22_zero() r33_zero() r44_zero() rnn_zero(n) rmn_zero(m, n)
Clone/copy a matrix r22_clone(M, <Mout>) r33_clone(M, <Mout>) r44_clone(M, <Mout>) rnn_clone(M, <Mout>) rmn_clone(M, <Mout>)

Basic Operations

Operation r22 r33 r44 rnn rmn
Matrix addition r22_add(M1, M2, <Mout>) r33_add(M1, M2, <Mout>) r44_add(M1, M2, <Mout>) rnn_add(M1, M2, <Mout>) rmn_add(M1, M2, <Mout>)
Matrix subtraction r22_subtract(M1, M2, <Mout>) r33_subtract(M1, M2, <Mout>) r44_subtract(M1, M2, <Mout>) rnn_subtract(M1, M2, <Mout>) rmn_subtract(M1, M2, <Mout>)
Scalar-matrix multiplication r22_scale(M, r, <Mout>) r33_scale(M, r, <Mout>) r44_scale(M, r, <Mout>) rnn_scale(M, r, <Mout>) rmn_scale(M, r, <Mout>)
Matrix-matrix multiplication r22_multiply(M1, M2, <Mout>) r33_multiply(M1, M2, <Mout>) r44_multiply(M1, M2, <Mout>) rnn_multiply(M1, M2, <Mout>) rmn_multiply(M1, M2, <Mout>)
Matrix-vector multiplication r22_transform(M, v, <vout>) r33_transform(M, v, <vout>) r44_transform(M, v, <vout>) rnn_transform(M, v, <vout>) rmn_transform(M, v, <vout>)
Matrix transpose r22_transpose(M, <Mout>) r33_transpose(M, <Mout>) r44_transpose(M, <Mout>) rnn_transpose(M, <Mout>) rmn_transpose(M, <Mout>)
Matrix inverse r22_invert(M, <Mout>) r33_invert(M, <Mout>) r44_invert(M, <Mout>) rnn_invert(M, <Mout>) N/A

Encoding and Decoding

  • String format: Each entry is written with 14 decimal digits, separated by commas. Rows are separated by semicolons.
  • Base64 format: Each entry is written as a 64-bit float to the buffer in row-major order, then encoded as base64.
Operation r22 r33 r44 rnn rmn
Encode to string r22_encode_string(M) r33_encode_string(M) r44_encode_string(M) rnn_encode_string(M) rmn_encode_string(M)
Decode from string r22_decode_string(str, <Mout>) r33_decode_string(str, <Mout>) r44_decode_string(str, <Mout>) rnn_decode_string(str, <Mout>) rmn_decode_string(str, <Mout>)
Encode to base64 r22_encode_base64(M) r33_encode_base64(M) r44_encode_base64(M) rnn_encode_base64(M) rmn_encode_base64(M)
Decode from base64 r22_decode_base64(enc, <Mout>) r33_decode_base64(enc, <Mout>) r44_decode_base64(enc, <Mout>) rnn_decode_base64(enc, n, <Mout>) rmn_decode_base64(enc, m, n, <Mout>)
Clone this wiki locally