Plan Documentation

Matrix Plans (0.9.2)

Plans to Get a Matrix


Custom Matrix

Summery

Make a custom matrix

Description

Make a matrix element-by-element. The output matrix is computed as the result of the text expression x.

Expression parser supports the following:

  • Arithmetic operations: addition (+), subtraction/negation (-), multiplication (*), division (/), exponentiation (^) and modulus (%)
  • Numerical operations: sign, abs, ceil, floor, trunc, round, erf, sinc
  • Exponentiation operations: exp, pow, sqrt, logistic, logit
  • Combinatorial operations: fac, ncr, npr
  • Logarithmic operations: exp, ln (natural logarithm), log (base-10 logarithm), log10
  • Trigonometric functions: sin, cos, tan, cot, sec, csc, asin, acos, atan, atan2, acot, asec, acsc
  • Hyperbolic functions: sinh, cosh, tanh, coth, sech, csch, asinh, acosh, atanh, acoth, asech, acsch
  • Conditional operations: clamp, clean, disc, replace, replaceri, replacerx
  • Constants: pi, e

Example

x = {1,2,3;4-2,5,6;0,7,8}{1,2,3;2,5,6;0,7,8}
x = {1,2;4*2,3^2*cos(pi)}{1,2;8,-9}

Fill Matrix

Summery

Fill a matrix with element values

Description

Fill an m×n matrix with elements of matrix a. If enough elements are not available in a, the last element of the last column is repeated.

Example

a = {3};m = {3};n = {2}{3,3;3,3;3,3}
a = {1,3,5};m = {3};n = {2}{1,3;1,3;1,3}

Zero Matrix

Summery

Fill a matrix with zeros

Description

Make an m×n matrix of zeros.

Example

m = {3};n = {2}{0,0;0,0;0,0}

Matrix of Ones

Summery

Fill a matrix with ones

Description

Make an m×n matrix of ones.

Example

m = {3};n = {2}{1,1;1,1;1,1}

Expression Matrix

Summery

Fill a matrix with an expression

Description

Make an m×n matrix with expression f(i,j) for each i and j. i and j are the row and column numbers counted from 0.

Expression parser supports the following:

  • Arithmetic operations: addition (+), subtraction/negation (-), multiplication (*), division (/), exponentiation (^) and modulus (%)
  • Numerical operations: sign, abs, ceil, floor, trunc, round, erf, sinc
  • Exponentiation operations: exp, pow, sqrt, logistic, logit
  • Combinatorial operations: fac, ncr, npr
  • Logarithmic operations: exp, ln (natural logarithm), log (base-10 logarithm), log10
  • Trigonometric functions: sin, cos, tan, cot, sec, csc, asin, acos, atan, atan2, acot, asec, acsc
  • Hyperbolic functions: sinh, cosh, tanh, coth, sech, csch, asinh, acosh, atanh, acoth, asech, acsch
  • Conditional operations: clamp, clean, disc, replace, replaceri, replacerx
  • Constants: pi, e

Example

m = {3};n = {2};f = {i*j-2}{-2,-2;-2,-1;-2,0}

Identity Matrix

Summery

Make an identity matrix

Description

Make an identity matrix, or an m×m (square) matrix with ones in the diagonal and zeros everywhere else.

Example

m = {3}{1,0,0;0,1,0;0,0,1}

Diagonal Matrix

Summery

Make a diagonal matrix

Description

Make a diagonal matrix, or an m×m (square) matrix with a[i] in the i-th row of the diagonal for each i or the last value in a[i] when not available, and zeros everywhere else.

Example

m = {3};a = {1,2};{1,0,0;0,2,0;0,0,2}

Convolution Matrix - Box Blur

Summery

Make a box blur filter kernel

Description

Make an m×n box blur filter kernel matrix used in image convolution.

Example

m = {2};n = {4}{0.125,0.125,0.125,0.125;0.125,0.125,0.125,0.125}

Convolution Matrix - Gaussian Blur

Summery

Make a Gaussian filter kernel

Description

Make an m×n Gaussian filter kernel matrix used in image convolution with standard deviations σ_m and σ_n.

Example

m = {3};n = {3};σ_m = {1};σ_n = {0.5}{0.02919,0.21569,0.02919;0.048127,0.35561,0.048127;0.02919,0.21569,0.02919}

Convolution Matrix - Derivative

Summery

Make a derivative filter kernel

Description

Make an m×n derivative filter kernel matrix used in image convolution, with orders o_m and o_n, and accuracy level a_m and a_n. This matrix is generated using central finite-difference coefficients. Accuracy levels from 0 (corresponding to 3×3 coefficients matrix for first-order derivative) up to 3 (corresponding to 9×9 coefficients matrix for first-order derivative) are supported.

Example

m = {3};n = {3};o_m = {1};o_n = {1};a_m = {0};a_n = {0}{0.25,0,-0.25;0,0,0;-0.25,0,0.25}
m = {3};n = {3};o_m = {2};o_n = {2};a_m = {0};a_n = {0}{0.0625,-0.125,0.0625;-0.125,0.25,-0.125;0.0625,-0.125,0.0625}

Randomized Elements With 𝑼(0,1)

Summery

Randomize a matrix with standard uniform distribution

Description

Make a randomized m×n matrix with continuous uniform distribution from 0 to 1.

Example

m = {2};n = {3}{0.78682,0.71067,0.019271;0.25048,0.94667,0.4049}

Randomized Elements With 𝑵(0,1)

Summery

Randomize a matrix with standard normal distribution

Description

Make a randomized m×n matrix with normal distribution with mean = 0 and variance = 1.

Example

m = {2};n = {3}{-2.1356,0.45484,0.1371;0.28382,-1.6828,-1.1253}

Import From Text File Along Rows

Summery

Import a matrix from text file with row numbers

Description

Import a matrix from a text file at file name with columns separated by delimiter. Import starts from column_start. If rows array is nonempty, import is limited to the row numbers in rows (counted from 0).

Example

file name = {tests\mnist_test.csv};delimiter = {,};rows = {1,2,3};column_start = {0}{2,0,0,...;1,0,0,...;0,0,0,...}
file name = {tests\output_mat.txt};delimiter = {,};rows = {};column_start = {1}{2,3,4;10,25,38}

Import From Text File Along Columns

Summery

Import a matrix from text file with column numbers

Description

Import a matrix from a text file at file name with columns separated by delimiter. Import starts from row_start. If columns array is nonempty, import is limited to the column numbers in columns (counted from 0).

Example

file name = {tests\data_sample.txt};delimiter = {;};columns = {1,2,4};row_start = {2}{0,2;7,-1}
file name = {tests\output_mat_w.txt};delimiter = {,};columns = {};row_start = {0}{3.14,2,3,4;-3.14,10,25,38}

Import With Armadillo Format Auto-Detect

Summery

Import a matrix with Armadillo library format auto-detect

Description

Import a matrix from file name with Armadillo library format auto-detect.

Example

file name = {tests\matrix.bin}{3.1416,2,3,4;-3.1416,10,25,38}

Import From Armadillo Binary File

Summery

Import a matrix from Armadillo library binary file

Description

Import a matrix from an Armadillo library binary file at file name.

Example

file name = {tests\matrix.bin}{3.1416,2,3,4;-3.1416,10,25,38}

Import From Armadillo Text File

Summery

Import a matrix from Armadillo library text file

Description

Import a matrix from an Armadillo library text file at file name.

Example

file name = {tests\matrix.txt}{3.1416,2,3,4;-3.1416,10,25,38}

Import From Armadillo Raw Binary File

Summery

Import a matrix from Armadillo library raw binary file

Description

Import a matrix from an Armadillo library raw binary file at file name. In this file format, the imported matrix is a column matrix.

Example

file name = {tests\matrix.raw_bin}{3.1416;-3.1416;2;10;3;25;4;38}

Import From Armadillo Raw Text File

Summery

Import a matrix from Armadillo library raw text file

Description

Import a matrix from an Armadillo library raw text file at file name. In this file format, matrix dimensions are interpreted from the text structure.

Example

file name = {tests\matrix.raw_txt}{3.1416,2,3,4;-3.1416,10,25,38}

Import From CSV File

Summery

Import a matrix from CSV file

Description

Import a matrix from a Comma-Separated Values (CSV) file at file name.

Example

file name = {tests\matrix.csv}{3.1416,2,3,4;-3.1416,10,25,38}

Import From Coordinate List File

Summery

Import a matrix from coordinate list file

Description

Import a matrix from a coordinate list file at file name. In this file format, a line describes a non-zero element as "row column value" with row and column numbers counted from 0.

Example

file name = {tests\matrix.coord}{3.1416,2,3,4;-3.1416,10,25,38}

Import From PGM File

Summery

Import a matrix from PGM file

Description

Import a matrix from a Portable Gray Map (PGM) file at file name. In this file format, elements are saved and stored as whole numbers between 0 and 255.

Example

file name = {tests\matrix.pgm}{3,2,3,4;253,10,25,38}

Convert From Array Along Rows

Summery

Convert from array row-by-row

Description

Make a matrix from array x by filling rows of size n one element after another. Fill the rest with a if needed.

Example

x = {1,2,3,4,5,6,7};n = {3};a = {0}{1,2,3;4,5,6;7,0,0}
x = {1,2,3,4,5,6,7};n = {4};a = {-1}{1,2,3,4;5,6,7,-1}

Convert From Array Along Columns

Summery

Convert from array column-by-column

Description

Make a matrix from array x by filling columns of size m one element after another. Fill the rest with a if needed.

Example

x = {1,2,3,4,5,6,7};m = {3};a = {0}{1,4,7;2,5,0;3,6,0}
x = {1,2,3,4,5,6,7};m = {4};a = {-1}{1,5;2,6;3,7;4,-1}

Convert From Image

Summery

Convert from image

Description

Make a matrix from image x where the RGBA channel values are scaled and shifted as r×R(x[i,j])+g×G(x[i,j])+b×B(x[i,j])+a×A(x[i,j])+shift for each i and j. R, G, B, and A are the color channels of the pixel at row i and column j with values in the range of 0-255.

Example

x = box(3,3,white);r = {0.1};g = {0.1};b = {0};a = {0};shift = {-1}{50,50,50;50,50,50;50,50,50}

Plans to Reorganize a Matrix


Copy

Summery

Copy matrix

Description

Copy elements of matrix x.

Example

x = {1,2,3;4,5,6}{1,2,3;4,5,6}

Resize

Summery

Resize matrix

Description

Resize matrix x, without changing elements, to m×n by cutting or filling with column c and row r. If there are not enough values available in c or r, the last value is repeated. When m or n is not provided, its value is preserved. When new rows and columns overlap, the overlapping elements are added to one another.

Example

x = {1,2,3;4,5,6};m = {1};r = {-1,1}{1,2,3}
x = {1,2,3;4,5,6};m = {3};r = {-1,1}{1,2,3;4,5,6;-1,1,1}
x = {1,2,3;4,5,6};n = {1};c = {-1,1}{1;4}
x = {1,2,3;4,5,6};n = {4};c = {-1,1}{1,2,3,-1;4,5,6,1}
x = {1,2,3;4,5,6;7,8,9};m = {2};n = {4};c = {1,2};r = {3,4}{1,2,3,1;4,5,6,2}
x = {1,2,3;4,5,6;7,8,9};m = {4};n = {4};c = {1,2};r = {3,4}{1,2,3,1;4,5,6,2;7,8,9,2;3,4,4,6}

Replicate Rows

Summery

Replicate matrix in height

Description

Replicate matrix x in height by repeating each row p times and the resulting matrix q times row-by-row.

Example

x = {1,2;3,4};p = {2};q = {3}{1,2;1,2;3,4;3,4;1,2;1,2;3,4;3,4;1,2;1,2;3,4;3,4}

Replicate Columns

Summery

Replicate matrix in width

Description

Replicate matrix x in width by repeating each column p times and the resulting matrix q times column-by-column.

Example

x = {1,2;3,4};p = {2};q = {3}{1,1,2,2,1,1,2,2,1,1,2,2;3,3,4,4,3,3,4,4,3,3,4,4}

Reshape

Summery

Reshape matrix

Description

Reshape matrix x to m×n and fill by zero if needed. When m or n is not provided, its value is preserved. In reshape, matrix dimensions are changed without modifying the order of values in the underlying array that stores the matrix elements column-after-column (column-major).

Example

x = {1,2,3;4,5,6};n = {2}{1,5;4,3;2,6}
x = {1,2,3;4,5,6};m = {3}{1,5;4,3;2,6}

Transpose

Summery

Transpose matrix

Description

Transpose matrix x by swapping x[i,j] with x[j,i] for each i and j.

Example

x = {1,2,3;4,5,6}{1,4;2,5;3,6}

Anti-Transpose

Summery

Anti-transpose matrix

Description

Anti-transpose matrix x by transposing over the anti-diagonal so that the anti-diagonal is preserved.

Example

x = {1,2,3;4,5,6}{6,3;5,2;4,1}

Mirror Horizontally (About Vertical Axis)

Summery

Mirror matrix horizontally (about vertical axis)

Description

Mirror matrix x horizontally so that rows are reversed.

Example

x = {1,2,3;4,5,6}{3,2,1;6,5,4}

Mirror Vertically (About Horizontal Axis)

Summery

Mirror matrix vertically (about horizontal axis)

Description

Mirror matrix x vertically so that columns are reversed.

Example

x = {1,2,3;4,5,6}{4,5,6;1,2,3}

Rotate +90°

Summery

Rotate matrix by +90° (90°CCW)

Description

Rotate matrix x by 90° counter-clockwise by moving the upper right corner element to upper left corner and so on.

Example

x = {1,2,3;4,5,6}{3,6;2,5;1,4}

Rotate -90°

Summery

Rotate matrix by -90° (90°CW)

Description

Rotate matrix x by 90° clockwise by moving the upper right corner element to lower right corner and so on.

Example

x = {1,2,3;4,5,6}{4,1;5,2;6,3}

Rotate 180°

Summery

Rotate matrix by 180°

Description

Rotate matrix x by 180° by moving the upper right corner element to lower left corner and so on.

Example

x = {1,2,3;4,5,6}{6,5,4;3,2,1}

Submatrix by Inclusion

Summery

Make a submatrix by keeping rows and columns

Description

Make a submatrix of matrix x with elements at rows i and columns j.

Example

x = {1,2,3;4,5,6;7,8,9;10,11,12};i = {1,2};j = {0,3}{4;7}

Submatrix by Exclusion

Summery

Make a submatrix by removing rows and columns

Description

Make a submatrix of matrix x by removing elements at rows i or columns j.

Example

x = {1,2,3;4,5,6;7,8,9;10,11,12};i = {1,2};j = {0,3}{2,3;11,12}

Crop From Top Left

Summery

Crop matrix from top left

Description

Carve an m×n submatrix out of matrix x starting from row i and column j counted from upper left corner.

Example

x = {1,2,3,4;5,6,7,8;9,10,11,12;13,14,15,16};m = {2};n = {2};i = {1};j = {1}{6,7;10,11}
x = {1,2,3,4;5,6,7,8;9,10,11,12;13,14,15,16};m = {1};n = {4};i = {1};j = {1}{6,7,8}

Crop From Top Right

Summery

Crop matrix from top right

Description

Carve an m×n submatrix out of matrix x starting from row i and column j counted from upper right corner.

Example

x = {1,2,3,4;5,6,7,8;9,10,11,12;13,14,15,16};m = {2};n = {2};i = {1};j = {1}{6,7;10,11}
x = {1,2,3,4;5,6,7,8;9,10,11,12;13,14,15,16};m = {1};n = {4};i = {1};j = {1}{5,6,7}

Crop From Bottom Left

Summery

Crop matrix from bottom left

Description

Carve an m×n submatrix out of matrix x starting from row i and column j counted from lower left corner.

Example

x = {1,2,3,4;5,6,7,8;9,10,11,12;13,14,15,16};m = {2};n = {2};i = {1};j = {1}{6,7;10,11}
x = {1,2,3,4;5,6,7,8;9,10,11,12;13,14,15,16};m = {1};n = {4};i = {1};j = {1}{10,11,12}

Crop From Bottom Right

Summery

Crop matrix from bottom right

Description

Carve an m×n submatrix out of matrix x starting from row i and column j counted from lower right corner.

Example

x = {1,2,3,4;5,6,7,8;9,10,11,12;13,14,15,16};m = {2};n = {2};i = {1};j = {1}{6,7;10,11}
x = {1,2,3,4;5,6,7,8;9,10,11,12;13,14,15,16};m = {1};n = {4};i = {1};j = {1}{9,10,11}

Crop From Center

Summery

Crop matrix from center

Description

Carve an m×n submatrix out of matrix x with a gap of i rows and j columns between centers. i = j = 0 centers the submatrix, i >0 shifts the submatrix downward, and j >0 shifts it rightward.

Example

x = {1,2,3,4;5,6,7,8;9,10,11,12;13,14,15,16};m = {2};n = {2};i = {0};j = {0}{6,7;10,11}
x = {1,2,3,4;5,6,7,8;9,10,11,12;13,14,15,16};m = {1};n = {4};i = {1};j = {1}{10,11,12}

Swap Elements

Summery

Swap matrix elements

Description

Swap elements at rows i1 and columns j1 with elements at rows i2 and columns j2 in matrix x. Element at row i1[k] and column j1[k] and element at row i2[k] and column j2[k] are swapped with one another for each k starting from k = 0.

Example

x = {1,2,3;4,5,6;7,8,9};i1 = {1,2,3};j1 = {0,1,2};i2 = {0,1,2};j2 = {1,2,3}{1,4,3;2,5,8;7,6,9}

Swap Rows

Summery

Swap matrix rows

Description

Swap elements in rows i1 with elements in rows i2 in matrix x. Rows i1[k] and i2[k] are swapped with one another for each k starting from k = 0.

Example

x = {1,2,3;4,5,6;7,8,9};i1 = {1,2,3};i2 = {0,1,2}{4,5,6;7,8,9;1,2,3}

Swap Columns

Summery

Swap matrix columns

Description

Swap elements in columns j1 with elements in columns j2 in matrix x. Columns j1[k] and j2[k] are swapped with one another for each k starting from k = 0.

Example

x = {1,2,3;4,5,6;7,8,9};j1 = {1,2,3};j2 = {0,1,2}{2,3,1;5,6,4;8,9,7}

Insert Rows From Top

Summery

Insert rows with row numbers counted from top

Description

Insert n[k] copies of array r at rows i[k] counted from top for each k. r is expanded with its last value if needed. Similarly, if n does not have enough values, the last value is repeated.

Example

x = {1,2,3;4,5,6;7,8,9};i = {0,2,3};n = {2,1};r = {-1,-2}{-1,-2,-2;-1,-2,-2;1,2,3;4,5,6;-1,-2,-2;7,8,9;-1,-2,-2}

Insert Rows From Bottom

Summery

Insert rows with row numbers counted from bottom

Description

Insert n[k] copies of array r at rows i[k] counted from bottom for each k. r is expanded with its last value if needed. Similarly, if n does not have enough values, the last value is repeated.

Example

x = {1,2,3;4,5,6;7,8,9};i = {0,2,3};n = {2,1};r = {-1,-2}{-1,-2,-2;1,2,3;-1,-2,-2;4,5,6;7,8,9;-1,-2,-2;-1,-2,-2}

Insert Columns From Left

Summery

Insert columns with column numbers counted from left

Description

Insert n[k] copies of array c at columns j[k] counted from left for each k. c is expanded with its last value if needed. Similarly, if n does not have enough values, the last value is repeated.

Example

x = {1,2,3;4,5,6;7,8,9};j = {0,2,3};n = {2,1};c = {-1,-2}{-1,-1,1,2,-1,3,-1;-2,-2,4,5,-2,6,-2;-2,-2,7,8,-2,9,-2}

Insert Columns From Right

Summery

Insert columns with column numbers counted from right

Description

Insert n[k] copies of array c at columns j[k] counted from right for each k. c is expanded with its last value if needed. Similarly, if n does not have enough values, the last value is repeated.

Example

x = {1,2,3;4,5,6;7,8,9};j = {0,2,3};n = {2,1};c = {-1,-2}{-1,1,-1,2,3,-1,-1;-2,4,-2,5,6,-2,-2;-2,7,-2,8,9,-2,-2}

Remove Rows From Top

Summery

Remove rows with row numbers counted from top

Description

Remove n[k] rows starting from rows i[k] counted from top for each k. If n does not have enough values, the last value is repeated.

Example

x = {1,2,3,2,1;4,5,6,5,4;7,8,9,8,7;4,5,6,5,-4;1,2,3,-2,-1};i = {2,0};n = {3,1}{4,5,6,5,4}

Remove Rows From Bottom

Summery

Remove rows with row numbers counted from bottom

Description

Remove n[k] rows starting from rows i[k] counted from bottom for each k. If n does not have enough values, the last value is repeated.

Example

x = {1,2,3,2,1;4,5,6,5,4;7,8,9,8,7;4,5,6,5,-4;1,2,3,-2,-1};i = {2,0};n = {3,1}{4,5,6,5,-4}

Remove Columns From Left

Summery

Remove columns with column numbers counted from left

Description

Remove n[k] columns starting from columns j[k] counted from left for each k. If n does not have enough values, the last value is repeated.

Example

x = {1,2,3,2,1;4,5,6,5,4;7,8,9,8,7;4,5,6,5,-4;1,2,3,-2,-1};j = {2,0};n = {3,1}{2;5;8;5;2}

Remove Columns From Right

Summery

Remove columns with column numbers counted from right

Description

Remove n[k] columns starting from columns j[k] counted from right for each k. If n does not have enough values, the last value is repeated.

Example

x = {1,2,3,2,1;4,5,6,5,4;7,8,9,8,7;4,5,6,5,-4;1,2,3,-2,-1};j = {2,0};n = {3,1}{2;5;8;5;-2}

Plans to Reorganize Across Matrices


Copy the Nth Matrix

Summery

Copy a matrix

Description

Copy elements of the nth matrix.

Example

x0 = {1,2,3;4,5,6};x1 = {4,5;6,7};n = {1}{4,5;6,7}

Copy the First Non-Empty Matrix

Summery

Copy the first non-empty matrix

Description

Copy elements of the first non-empty matrix between x0,x1,... . This plan does not cascade refresh requests to its parameters x0,x1,... .

Example

x0 = {};x1 = {};x2 = {7,6;8,1};x3 = {1,2}{7,6;8,1}

Stitch Matrices in a Row

Summery

Stitch matrices in a row (horizontally)

Description

Stitch matrices x0,x1,... side-by-side in a row (horizontally) and fill the gaps with a when matrix heights are different.

Example

a = {0};x0 = {1,2,3;4,5,6};x1 = {4,5;6,7}{1,2,3,4,5;4,5,6,6,7}

Stitch Matrices in a Column

Summery

Stitch matrices in a column (vertically)

Description

Stitch matrices x0,x1,... side-by-side in a column (vertically) and fill the gaps with a when matrix widths are different.

Example

a = {0};x0 = {1,2,3;4,5,6};x1 = {4,5;6,7}{1,2,3;4,5,6;4,5,0;6,7,0}

Stitch Matrices in a Block Matrix

Summery

Stitch matrices in a block matrix

Description

Stitch matrices x0,x1,... side-by-side in a block matrix and fill the gaps with a. Matrix x0 is located at row i[0] and column j[0] of the block matrix, matrix x1 is located at row i[1] and column j[1] of the block matrix, and so on.

Example

a = {0};i = {0,1,1};j = {0,0,1}x0 = {1,2,3;4,5,6};x1 = {4,5;6,7};x2 = {2,-2;-2,2};{1,2,3,0,0; 4,5,6,0,0; 4,5,0,2,-2; 6,7,0,-2,2}

Plans to Make a Matrix


Set Elements

Summery

Set element values

Description

Set elements of matrix x at rows i and columns j to values in array a. Element at row i[k] and column j[k] is set to a[k] for each k. If there is no corresponding value available in a, the last value is repeated.

Example

x = {1,2,3;4,5,6;7,8,9;3,2,1};i = {1,2,3};j = {0,1,2};a = {0,-1}{1,2,3;0,5,6;7,-1,9;3,2,-1}

Set Rows From Top

Summery

Set rows with row numbers counted from top

Description

Set array r as row i[k] counted from top for each k. If there are less values than the width of the matrix available in r, the last value is repeated.

Example

x = {1,2,3;4,5,6;7,8,9;3,2,1};i = {1,2};r = {0,-1}⇒{1,2,3;0,-1,-1;0,-1,-1;3,2,1}

Set Rows From Bottom

Summery

Set rows with row numbers counted from bottom

Description

Set array r as row i[k] counted from bottom for each k. If there are less values than the width of the matrix available in r, the last value is repeated.

Example

x = {1,2,3;4,5,6;7,8,9;3,2,1};i = {1,2};r = {0,-1}⇒{1,2,3;0,-1,-1;0,-1,-1;3,2,1}

Set Columns From Left

Summery

Set columns with column numbers counted from left

Description

Set array c as column j[k] counted from left for each k. If there are less values than the height of the matrix available in c, the last value is repeated.

Example

x = {1,2,3;4,5,6;7,8,9;3,2,1};j = {1,2};c = {0,-1}⇒{1,0,0;4,-1,-1;7,-1,-1;3,-1,-1}

Set Columns From Right

Summery

Set columns with column numbers counted from right

Description

Set array c as column j[k] counted from right for each k. If there are less values than the height of the matrix available in c, the last value is repeated.

Example

x = {1,2,3;4,5,6;7,8,9;3,2,1};j = {1,2};c = {0,-1}⇒{0,0,3;-1,-1,6;-1,-1,9;-1,-1,1}

Replace Elements

Summery

Replace element values

Description

Replace elements of matrix x equal to from[k] with a[k] for each k or the last value in a when not available.

Example

x = {1,2,3;4,5,6;7,8,9};from = {1};a = {-1}{-1,2,3;4,5,6;7,8,9}
x = {1,2,3;4,5,6;7,8,9};from = {4,2,3};a = {-1,-2}{1,-2,-2;-1,5,6;7,8,9}

Replace Element Ranges

Summery

Replace ranges of element values

Description

Replace elements of matrix x in ranges [from[k], to[k]] with a[k] for each k or the last value in a when not available.

Example

x = {1,2,3;4,5,6;7,8,9};from = {1,3.2};to = {1,10};a = {0}{0,2,3;0,0,0;0,0,0}
x = {1,2,3;4,5,6;7,8,9};from = {1,3.2};to = {1,10};a = {7,8,9}{7,2,3;8,8,8;8,8,8}

Replace High Elements

Summery

Replace high element values

Description

Replace matrix elements greater than or equal to b with a.

Example

x = {1,2,3;4,5,6;-7,-8,-9};b = {3};a = {0}{1,2,0;0,0,0;-7,-8,-9}

Replace Low Elements

Summery

Replace low element values

Description

Replace matrix elements less than or equal to b with a.

Example

x = {1,2,3;4,5,6;-7,-8,-9};b = {3};a = {0}{0,0,0;4,5,6;0,0,0}

Replace inf Elements

Summery

Replace ±inf element values

Description

Replace occurrences of +/-inf in matrix x with a.

Example

x = {1,1/0,3;4,5,6;7,8,-2/0};a = {0}{1,0,3;4,5,6;7,8,0}

Replace nan Elements

Summery

Replace nan element values

Description

Replace occurrences of nan in matrix x with a.

Example

x = {1,nan,3;4,5,nan;nan,7,8};a = {0}{1,0,3;4,5,0;0,7,8}

Replace Undefined Elements

Summery

Replace non-finite element values

Description

Replace occurrences of +/-inf and nan in matrix x with a.

Example

x = {1,1/0,nan;4,5,6;nan,8,-2/0};a = {0}{1,0,0;4,5,6;0,8,0}

Clean Elements

Summery

Zero small element values

Description

Replace matrix elements when their absolute value are less than or equal to a with 0.

Example

x = {0.1,0.2;1e-5,-0.4};a = {1e-3}{0.1,0.2;0,-0.4}

Clamp Elements

Summery

Limit element values

Description

Limit matrix elements to [a, b] so that out-of-range values are replaced with the closest of a or b.

Example

x = {1,2;3,4;5,6};a = {2};b = {4}{2,2;3,4;4,4}

Discretize Elements

Summery

Discretize element values

Description

Replace matrix elements with the closest value in a+h/2,.., b-h/2 where h = (b-a)/n.

Example

x = {1,2;3,4;5,6};a = {2};b = {6};n = {4};{2.5,2.5;3.5,4.5;5.5,5.5}

Scale Elements Linearly

Summery

Shift and scale element values

Description

Shift and, then, linearly scale matrix elements. The result is computed as scale×(x[i,j]+shift) for each row i and column j.

Example

x = {1,2;3,4;5,6};shift = {2};scale = {0.5}{1.5,2;2.5,3;3.5,4}

Scale Elements Linearly to Bounds

Summery

Linearly change the bounds of element values

Description

Shift and linearly scale matrix elements to a new minimum and a new maximum.

Example

x = {1,2;3,4;5,6};minimum = {-1};maximum = {1}{-1,-0.6;-0.2,0.2;0.6,1}

Scale Elements Uniformly

Summery

Uniformly change element values as polynomial

Description

Uniformly (but not necessarily linearly) scale matrix elements so that a[k] is moved to b[k] for each k. This scaling interpolates x[i,j] values on a Lagrange polynomial from values in array a to the corresponding values in array b.

Example

x = {1,2;3,4;5,6};a = {1,6};b = {-1,1}{-1,-0.6;-0.2,0.2;0.6,1}
x = {1,2;3,4;5,6};a = {1,2,6};b = {-1,0,1}{-1,0;0.7,1.1;1.2,1}

Element General Expression

Summery

Compute general-form expressions as element values

Description

Compute general-form expression f = {f[0,0],f[0,1],...;f[1,0],...} where f[i,j] is a function of i,j,x,x0_0,xp1_p1,xp1_n1,... . The output matrix is computed as f[i,j] for each row i < m and column j < n or the last function in f when filling column-by-column as column-major. x is the element of matrix x at the same row and column. Fixed references are represented by x0_0=x[0,0], x1_2=x[1,2], and so on, and relative references by xp1_p1=x[i-1,j-1], xn1_n1=x[i+1,j+1], and so on. Out-of-range elements are replaced with 0. If m or n are not provided, they are replaced with the number of rows or columns in x.

Expression parser supports the following:

  • Arithmetic operations: addition (+), subtraction/negation (-), multiplication (*), division (/), exponentiation (^) and modulus (%)
  • Numerical operations: sign, abs, ceil, floor, trunc, round, erf, sinc
  • Exponentiation operations: exp, pow, sqrt, logistic, logit
  • Combinatorial operations: fac, ncr, npr
  • Logarithmic operations: exp, ln (natural logarithm), log (base-10 logarithm), log10
  • Trigonometric functions: sin, cos, tan, cot, sec, csc, asin, acos, atan, atan2, acot, asec, acsc
  • Hyperbolic functions: sinh, cosh, tanh, coth, sech, csch, asinh, acosh, atanh, acoth, asech, acsch
  • Conditional operations: clamp, clean, disc, replace, replaceri, replacerx
  • Constants: pi, e

Example

x = {1,2;3,4};f = {i*x};m = {};n = {}{0,0;3,4}
x = {1,2;3,4};f = {1,2;j+i+2*x^2};m = {};n = {}{1,2;19,2}
x = {1,2;3,4};f = {1,2;j+i+2*x^2};m = {4};n = {3}{1,2,2;19,2,2;2,2,2;3,2,2}
x = {1,0,1,0; 0,0,1,0; 0,1,0,1; 0,0,1,0};f = {xp1_p1+xp1_p0+xp1_n1+xp0_p1+ xp0_n1+xn1_p1+xn1_p0+xn1_n1};m = {};n = {}{0,3,1,2; 2,4,3,3; 1,2,4,2; 1,2,2,2}

Element Normalize (Min-to-Max)

Summery

Min-max normalize element values

Description

Scale elements to [0,1] following (x[i,j]-min(x))/(max(x)-min(x)) for each row i and column j.

Example

x = {1,2,3;4,5,1}{0,0.25,0.5;0.75,1,0}

Element Normalize (Mean)

Summery

Mean normalize element values

Description

Scale elements to [-1,1] following (x[i,j]-mean(x))/(max(x)-min(x)) for each row i and column j.

Example

x = {1,2,3;4,5,3}{-0.5,-0.25,0;0.25,0.5,0}

Element Normalize (Z-Score)

Summery

Z-score normalize element values

Description

Compute z-scores of elements as (x[i,j]-mean(x))/σ(x) for each row i and column j. σ is the (population) standard deviation.

Example

x = {1,2,3;4,5,3}{-1.5492,-0.7746,0;0.7746,1.5492,0}

Element Normalize (P-Norm)

Summery

Normalize element values to unit p-norm

Description

Normalize matrix x to unit p-norm by dividing each element by matrix p-norm of x.

Example

x = {0,1;0,1};p = {2}{0,0.70711;0,0.70711}
x = {0,1;0,-1};p = {1}{0,0.5;0,-0.5}

Element Ceiling

Summery

Calculate ceiling of element values

Description

Find the least integer not less than x[i,j] for each row i and column j.

Example

x = {1.2,2.7;-3.1,-4.8;0.5,-0.5}{2,3;-3,-4;1,0}

Element Floor

Summery

Calculate floor of element values

Description

Find the greatest integer not greater than x[i,j] for each row i and column j.

Example

x = {1.2,2.7;-3.1,-4.8;0.5,-0.5}{1,2;-4,-5;0,-1}

Element Round

Summery

Round element values

Description

Find the nearest integer to x[i,j] for each row i and column j with halfway cases rounded away from zero.

Example

x = {1.2,2.7;-3.1,-4.8;0.5,-0.5}{1,3;-3,-5;1,-1}

Element Truncate

Summery

Truncate element values

Description

Find the integer part of x[i,j] for each row i and column j.

Example

x = {1.2,2.7;-3.1,-4.8;0.5,-0.5}{1,2;-3,-4;0,0}

Element Negate

Summery

Negate element values

Description

Apply - operator to x[i,j] for each row i and column j.

Example

x = {1,1.5;-3,-4}{-1,-1.5;3,4}

Element Add

Summery

Add constant value to element values

Description

Compute x[i,j]+a for each row i and column j.

Example

x = {1,2;3,4};a = {-1}{0,1;2,3}

Element Subtract

Summery

Subtract element values by constant value

Description

Compute x[i,j]-a for each row i and column j.

Example

x = {1,2;3,4};a = {-1}{2,3;4,5}

Element Subtract (From)

Summery

Subtract constant value by element values

Description

Compute a-x[i,j] for each row i and column j.

Example

x = {1,2;3,4};a = {-1}{-2,-3;-4,-5}

Element Multiply

Summery

Multiply element values by constant value

Description

Compute x[i,j]×a for each row i and column j.

Example

x = {1,2;3,4};a = {-1}{-1,-2;-3,-4}

Element Divide

Summery

Divide element values by constant value

Description

Compute x[i,j]/a for each row i and column j.

Example

x = {1,2;3,4};a = {-1}{-1,-2;-3,-4}

Element Divide (From)

Summery

Divide constant value by element values

Description

Compute a/x[i,j] for each row i and column j.

Example

x = {1,2;3,4};a = {-1}{-1,-0.5,-0.333333,-0.25}

Element Absolute Value

Summery

Compute absolute value of element values

Description

Compute the non-negative value of x[i,j] for each row i and column j.

Example

x = {1,-2,0;3,-4,0}{1,2,0;3,4,0}

Element Sign

Summery

Compute sign value of element values

Description

Compute the sign value, that is +1, -1 or 0 when x[i,j] is respectively positive, negative or 0, for each row i and column j.

Example

x = {1,-2,0;3,-4,0}{1,-1,0;1,-1,0}

Element Square

Summery

Compute square of element values

Description

Compute the square of x[i,j] for each row i and column j.

Example

x = {1,4;0.25,-1}{1,16;0.0625,1}

Element Square Root

Summery

Compute square root of element values

Description

Compute the square root of x[i,j] for each row i and column j.

Example

x = {1,4;0.25,-1}{1,2;0.5,nan}

Element Power

Summery

Compute power of element values

Description

Compute x[i,j] to the power of a as c×x[i,j]a for each row i and column j.

Example

x = {1,2;3,4};a = {-1};c = {1}{1,0.5;0.33333,0.25}

Element Power (to)

Summery

Compute powered element values

Description

Compute a to the power of x[i,j] as c×ax[i,j] for each row i and column j.

Example

x = {1,2;3,4};a = {-1};c = {1}{-1,1;-1,1}

Element Exponential

Summery

Compute exponential function of element values

Description

Compute e to the power of x[i,j] as c×ex[i,j]+a for each row i and column j.

Example

x = {0,1;2,-1/0};a = {0};c = {1}{1,2.7183;7.3891,0}

Element Logarithm

Summery

Compute logarithm of element values

Description

Compute the natural logarithm of x[i,j] as c×log(x[i,j]+a) for each row i and column j.

Example

x = {0,1;2,e};a = {0};c = {1}{-inf,0;0.69315,1}

Element Logistic

Summery

Compute logistic function of element values

Description

Compute the logistic function of x[i,j] as 1/(1+e-x[i,j]) for each row i and column j.

Example

x = {0,0.1;-1,1/0}{0.5,0.52498;0.26894,1}

Element Logit

Summery

Compute logit function of element values

Description

Compute the inverse logistic function of x[i,j] as log(x[i,j]/(1-x[i,j])) for each row i and column j.

Example

x = {0,0.1;-1,0.5}{-inf,-2.1972;nan,0}

Element Sine

Summery

Compute sine of element values

Description

Compute the sine of x[i,j] as c×sin(a×x[i,j]+b) for each row i and column j.

Example

x = {0,1;pi,-pi/2};a = {1};b = {0};c = {1}{0,0.84147;ε,-1}
ε is a very small, system-dependent, floating point number.

Element Cosine

Summery

Compute cosine of element values

Description

Compute the cosine of x[i,j] as c×cos(a×x[i,j]+b) for each row i and column j.

Example

x = {0,1;pi,-pi/2};a = {1};b = {0};c = {1}{1,0.5403;-1,ε}
ε is a very small, system-dependent, floating point number.

Element Tangent

Summery

Compute tangent of element values

Description

Compute the tangent of x[i,j] as c×tan(a×x[i,j]+b) for each row i and column j.

Example

x = {0,1;pi,-pi/2};a = {1};b = {0};c = {1}{0,1.5574;ε,-L}
ε is a very small, system-dependent, floating point number.
L is a very large, system-dependent, floating point number.

Element Cotangent

Summery

Compute cotangent of element values

Description

Compute the cotangent of x[i,j] as c×cot(a×x[i,j]+b) for each row i and column j.

Example

x = {0,1;pi,-pi/2};a = {1};b = {0};c = {1}{inf,0.64209;-L,ε}
ε is a very small, system-dependent, floating point number.
L is a very large, system-dependent, floating point number.

Element Secant

Summery

Compute secant of element values

Description

Compute the secant of x[i,j] as c×sec(a×x[i,j]+b) for each row i and column j.

Example

x = {0,1;pi,-pi/2};a = {1};b = {0};c = {1}{1,1.8508.0;-1,L}
L is a very large, system-dependent, floating point number.

Element Cosecant

Summery

Compute cosecant of element values

Description

Compute the cosecant of x[i,j] as c×csc(a×x[i,j]+b) for each row i and column j.

Example

x = {0,1,pi,-pi/2};a = {1};b = {0};c = {1}{inf,1.1884;L,-1}
L is a very large, system-dependent, floating point number.

Element Inverse Sine

Summery

Compute inverse sine of element values

Description

Compute the inverse sine of x[i,j] as c×sin-1(a×x[i,j]+b) for each row i and column j.

Example

x = {0,-1;0.5,2};a = {1};b = {0};c = {1}{0,-1.5708;0.5236,nan}

Element Inverse Cosine

Summery

Compute inverse cosine of element values

Description

Compute the inverse cosine of x[i,j] as c×cos-1(a×x[i,j]+b) for each row i and column j.

Example

x = {0,-1;0.5,2};a = {1};b = {0};c = {1}{1.5708,3.1416;1.0472,nan}

Element Inverse Tangent

Summery

Compute inverse tangent of element values

Description

Compute the inverse tangent of x[i,j] as c×tan-1(a×x[i,j]+b) for each row i and column j.

Example

x = {0,-1;0.5,2};a = {1};b = {0};c = {1}{0,-0.7854;0.46365,1.1071}

Element Inverse Cotangent

Summery

Compute inverse cotangent of element values

Description

Compute the inverse cotangent of x[i,j] as c×cot-1(a×x[i,j]+b) for each row i and column j.

Example

x = {0,-1;0.5,2};a = {1};b = {0};c = {1}{1.5708,-0.7854;1.1071,0.46365}

Element Inverse Secant

Summery

Compute inverse secant of element values

Description

Compute the inverse secant of x[i,j] as c×sec-1(a×x[i,j]+b) for each row i and column j.

Example

x = {0,-1;0.5,2};a = {1};b = {0};c = {1}{nan,3.1416;nan,1.0472}

Element Inverse Cosecant

Summery

Compute inverse cosecant of element values

Description

Compute the inverse cosecant of x[i,j] as c×csc-1(a×x[i,j]+b) for each row i and column j.

Example

x = {0,-1;0.5,2};a = {1};b = {0};c = {1}{nan,-1.5708;nan,0.5236}

Element Sinc

Summery

Compute normalized sinc of element values

Description

Compute the normalized sinc of x[i,j] as sin(πx[i,j])/(πx[i,j]) with sinc(0) = 1.

Example

x = {0,-1;0.5,2}{1,ε;0.63662,ε}
ε's are very small, system-dependent, floating point numbers.

Element Hyperbolic Sine

Summery

Compute hyperbolic sine of element values

Description

Compute the hyperbolic sine of x[i,j] as c×sinh(a×x[i,j]+b) for each row i and column j.

Example

x = {0,1;-1,ln(2)};a = {1};b = {0};c = {1}{0,1.1752;-1.1752,0.75}

Element Hyperbolic Cosine

Summery

Compute hyperbolic cosine of element values

Description

Compute the hyperbolic cosine of x[i,j] as c×cosh(a×x[i,j]+b) for each row i and column j.

Example

x = {0,1;-1,ln(2)};a = {1};b = {0};c = {1}{1,1.5431;1.5431,1.25}

Element Hyperbolic Tangent

Summery

Compute hyperbolic tangent of element values

Description

Compute the hyperbolic tangent of x[i,j] as c×tanh(a×x[i,j]+b) for each row i and column j.

Example

x = {0,1;-1,ln(2)};a = {1};b = {0};c = {1}{0,0.76159;-0.76159,0.6}

Element Hyperbolic Cotangent

Summery

Compute hyperbolic cotangent of element values

Description

Compute the hyperbolic cotangent of x[i,j] as c×coth(a×x[i,j]]+b) for each row i and column j.

Example

x = {0,1;-1,ln(2)};a = {1};b = {0};c = {1}{inf,1.313;-1.313,1.6667}

Element Hyperbolic Secant

Summery

Compute hyperbolic secant of element values

Description

Compute the hyperbolic secant of x[i,j] as c×sech(a×x[i,j]+b) for each row i and column j.

Example

x = {0,1;-1,ln(2)};a = {1};b = {0};c = {1}{1,0.64805;0.64805,0.8}

Element Hyperbolic Cosecant

Summery

Compute hyperbolic cosecant of element values

Description

Compute the hyperbolic cosecant of x[i,j] as c×csch(a×x[i,j]+b) for each row i and column j.

Example

x = {0,1;-1,ln(2)};a = {1};b = {0};c = {1}{inf,0.85092;-0.85092,1.3333}

Element Inverse Hyperbolic Sine

Summery

Compute inverse hyperbolic sine of element values

Description

Compute the inverse hyperbolic sine of x[i,j] as c×sinh-1(a×x[i,j]+b) for each row i and column j.

Example

x = {0,1,-1;0.5,2,0};a = {1};b = {0};c = {1}{0,0.88137,-0.88137;0.48121,1.4436,0}

Element Inverse Hyperbolic Cosine

Summery

Compute inverse hyperbolic cosine of element values

Description

Compute the inverse hyperbolic cosine of x[i,j] as c×cosh-1(a×x[i,j]+b) for each row i and column j.

Example

x = {0,1,-1;0.5,2,0};a = {1};b = {0};c = {1}{nan,0,nan;nan,1.317,nan}

Element Inverse Hyperbolic Tangent

Summery

Compute inverse hyperbolic tangent of element values

Description

Compute the inverse hyperbolic tangent of x[i,j] as c×tanh-1(a×x[i,j]+b) for each row i and column j.

Example

x = {0,1,-1;0.5,2,0};a = {1};b = {0};c = {1}{0,inf,-inf;0.54931,nan,0}

Element Inverse Hyperbolic Cotangent

Summery

Compute inverse hyperbolic cotangent of element values

Description

Compute the inverse hyperbolic cotangent of x[i,j] as c×coth-1(a×x[i,j]+b) for each row i and column j.

Example

x = {0,1,-1;0.5,2,0};a = {1};b = {0};c = {1}{nan,inf,-inf;nan,0.54931,nan}

Element Inverse Hyperbolic Secant

Summery

Compute inverse hyperbolic secant of element values

Description

Compute the inverse hyperbolic secant of x[i,j] as c×sech-1(a×x[i,j]+b) for each row i and column j.

Example

x = {0,1,-1;0.5,2,0};a = {1};b = {0};c = {1}{inf,0,nan;1.317,nan,inf}

Element Inverse Hyperbolic Cosecant

Summery

Compute inverse hyperbolic cosecant of element values

Description

Compute the inverse hyperbolic cosecant of x[i,j] as c×csch-1(a×x[i,j]+b) for each row i and column j.

Example

x = {0,1,-1;0.5,2,0};a = {1};b = {0};c = {1}{inf,0.88137,-0.88137;1.4436,0.48121,inf}

Element Polynomial Expression

Summery

Compute polynomial expression of element values

Description

Compute the polynomial expression defined as a[0]+a[1]×x[i,j]+a[2]×x[i,j]2+... for each row i and column j.

Example

x = {1,2;3,4};a = {2,1}{3,4;5,6}
x = {1,2;3,4};a = {0,1,1}{2,6;12,20}

Element Trigonometric Expression

Summery

Compute trigonometric expression of element values

Description

Compute the trigonometric expression defined as a[0]+a[1]×sin(a[2]×x[i,j]+a[3])+a[4]×sin(a[5]×x[i,j]+a[6])+... for each row i and column j.

Example

x = {0,pi/2;pi,2*pi};a = {2,1,1}{2,3;2,2}
x = {0,pi/2;pi,2*pi};a = {0,1,1,pi/2}{1,ε;-1,1}
ε is a very small, system-dependent, floating point number.

Translate (Nearest-Neighbor Interpolation)

Summery

Translate and apply nearest-neighbor interpolation

Description

Translate matrix x by di along columns and dj along rows without resizing. Empty spots are filled with a. The new values are interpolated to the nearest neighbor when needed.

Example

x = {1,0,0,0;0,1,0,0;0,0,1,0;0,0,0,1};di = {1};dj = {1};a = {0}{0,0,0,0;0,1,0,0;0,0,1,0;0,0,0,1}
x = {1,0,0,0;0,1,0,0;0,0,1,0;0,0,0,1};di = {0.5};dj = {0.5};a = {1}{1,0,0,0;0,1,0,0;0,0,1,0;0,0,0,1}

Translate (Bilinear Interpolation)

Summery

Translate and apply bilinear interpolation

Description

Translate matrix x by di along columns and dj along rows without resizing. Empty spots are filled with a. The new values are interpolated bilinearly when needed.

Example

x = {1,0,0,0;0,1,0,0;0,0,1,0;0,0,0,1};di = {1};dj = {1};a = {0}{0,0,0,0;0,1,0,0;0,0,1,0;0,0,0,1}
x = {1,0,0,0;0,1,0,0;0,0,1,0;0,0,0,1};di = {0.5};dj = {0.5};a = {1}{1,0.75,0.5,0.5; 0.75,0.5,0.25,0; 0.5,0.25,0.5,0.25; 0.5,0,0.25,0.5}

Translate (Bicubic Interpolation)

Summery

Translate and apply bicubic spline interpolation

Description

Translate matrix x by di along columns and dj along rows without resizing. Empty spots are filled with a. The new values are interpolated on a cubic spline when needed. Bilinear interpolation is applied for values next to the edges of the matrix.

Example

x = {1,0,0,0;0,1,0,0;0,0,1,0;0,0,0,1};di = {1};dj = {1};a = {0}{0,0,0,0;0,1,0,0;0,0,1,0;0,0,0,1}
x = {1,0,0,0;0,1,0,0;0,0,1,0;0,0,0,1};di = {0.5};dj = {0.5};a = {1}{1,0.75,0.5,0.5; 0.75,0.5,0.25,0; 0.5,0.25,0.64063,0.25; 0.5,0,0.25,0.5}

Scale (Nearest-Neighbor Interpolation)

Summery

Scale and apply nearest-neighbor interpolation

Description

Scale matrix x from center si times along columns and sj times along rows without resizing. Empty spots are filled with a. The new values are interpolated to the nearest neighbor when needed.

Example

x = {1,0,0,0;0,1,0,0;0,0,1,0;0,0,0,1};si = {0.5};sj = {0.5};a = {-1}{-1,-1,-1,-1;-1,1,0,-1;-1,0,1,-1;-1,-1,-1,-1}
x = {1,0,0,0;0,1,0,0;0,0,1,0;0,0,0,1};si = {2};sj = {2};a = {0}{1,1,0,0;1,1,0,0;0,0,1,1;0,0,1,1}

Scale (Bilinear Interpolation)

Summery

Scale and apply bilinear interpolation

Description

Scale matrix x from center si times along columns and sj times along rows without resizing. Empty spots are filled with a. The new values are interpolated bilinearly when needed.

Example

x = {1,0,0,0;0,1,0,0;0,0,1,0;0,0,0,1};si = {0.5};sj = {0.5};a = {-1}{-1,-1,-1,-1;-1,1,0,-1;-1,0,1,-1;-1,-1,-1,-1}
x = {1,0,0,0;0,1,0,0;0,0,1,0;0,0,0,1};si = {2};sj = {2};a = {0}{0.7551,0.61224,0.2449,0; 0.61224,0.59184,0.40816,0.2449; 0.2449,0.40816,0.59184,0.61224; 0,0.2449,0.61224,0.7551}

Scale (Bicubic Interpolation)

Summery

Scale and apply bicubic spline interpolation

Description

Scale matrix x from center si times along columns and sj times along rows without resizing. Empty spots are filled with a. The new values are interpolated on a cubic spline when needed. Bilinear interpolation is applied for values next to the edges of the matrix.

Example

x = {1,0,0,0;0,1,0,0;0,0,1,0;0,0,0,1};si = {0.5};sj = {0.5};a = {-1}{-1,-1,-1,-1;-1,1,0,-1;-1,0,1,-1;-1,-1,-1,-1}
x = {1,0,0,0;0,1,0,0;0,0,1,0;0,0,0,1};si = {2};sj = {2};a = {0}{0.7551,0.61224,0.2449,0; 0.61224,0.77008,0.45483,0.2449; 0.2449,0.45483,0.77008,0.61224; 0,0.2449,0.61224,0.7551}

Rotate (Nearest-Neighbor Interpolation)

Summery

Rotate and apply nearest-neighbor interpolation

Description

Rotate matrix x about center by angle in radians without resizing. Empty spots are filled with a. The new values are interpolated to the nearest neighbor when needed.

Example

x = {2,0,0,0;0,1,0,0;0,0,1,0;0,0,0,1};angle = {pi/2};a = {0}{0,0,0,1;0,0,1,0;0,1,0,0;2,0,0,0}
x = {0,1,1,0; 0,1,1,0; 0,1,1,0; 0,1,1,0; 0,1,1,0};angle = {pi/4}a = {0}{1,0,0,0; 1,1,0,0; 0,1,1,0; 0,0,1,1; 0,0,0,1}

Rotate (Bilinear Interpolation)

Summery

Rotate and apply bilinear interpolation

Description

Rotate matrix x about center by angle in radians without resizing. Empty spots are filled with a. The new values are interpolated bilinearly when needed.

Example

x = {2,0,0,0;0,1,0,0;0,0,1,0;0,0,0,1};angle = {pi/2};a = {0}{0,0,0,1;0,0,1,0;0,1,0,0;2,0,0,0}
x = {0,1,1,0; 0,1,1,0; 0,1,1,0; 0,1,1,0; 0,1,1,0};angle = {pi/4}a = {0}{0.52513,0.43934,0,0; 1,1,0.43934,0; 0.43934,1,1,0.43934; 0,0.43934,1,1; 0,0,0.43934,0.52513}

Rotate (Bicubic Interpolation)

Summery

Rotate and apply bicubic spline interpolation

Description

Rotate matrix x about center by angle in radians without resizing. Empty spots are filled with a. The new values are interpolated on a cubic spline when needed. Bilinear interpolation is applied for values next to the edges of the matrix.

Example

x = {2,0,0,0;0,1,0,0;0,0,1,0;0,0,0,1};angle = {pi/2};a = {0}{0,0,0,1;0,0,1,0;0,1,0,0;2,0,0,0}
x = {0,1,1,0; 0,1,1,0; 0,1,1,0; 0,1,1,0; 0,1,1,0};angle = {pi/4}a = {0}{0.52513,0.43934,0,0; 1,1,0.43934,0; 0.43934,1.0625,1.0625,0.43934; 0,0.43934,1,1; 0,0,0.43934,0.52513}

Shear (Nearest-Neighbor Interpolation)

Summery

Shear and apply nearest-neighbor interpolation

Description

Shear matrix x about center by shear factors si along columns and sj along rows without resizing. Empty spots are filled with a. The new values are interpolated to the nearest neighbor when needed.

Example

x = {0,1,1,0; 0,1,1,0; 0,1,1,0; 0,1,1,0};si = {0.5};sj = {0.5};a = {0}{1,1,0,0; 0,1,0,0; 0,1,1,0; 0,0,1,0}

Shear (Bilinear Interpolation)

Summery

Shear and apply bilinear interpolation

Description

Shear matrix x about center by shear factors si along columns and sj along rows without resizing. Empty spots are filled with a. The new values are interpolated bilinearly when needed.

Example

x = {0,1,1,0; 0,1,1,0; 0,1,1,0; 0,1,1,0};si = {0.5};sj = {0.5};a = {0}{0.5,0.83333,0,0; 0,1,0.5,0; 0,0.5,1,0; 0,0,0.83333,0.5}

Shear (Bicubic Interpolation)

Summery

Shear and apply bicubic spline interpolation

Description

Shear matrix x about center by shear factors si along columns and sj along rows without resizing. Empty spots are filled with a. The new values are interpolated on a cubic spline when needed. Bilinear interpolation is applied for values next to the edges of the matrix.

Example

x = {0,1,1,0; 0,1,1,0; 0,1,1,0; 0,1,1,0};si = {0.5};sj = {0.5};a = {0}{0.5,0.83333,0,0; 0,1.0694,0.5,0; 0,0.5,1.0694,0; 0,0,0.83333,0.5}

Transform (Nearest-Neighbor Interpolation)

Summery

Transform and apply nearest-neighbor interpolation

Description

Transform matrix x about center by transformation array t without resizing. t[0] and t[1] are scale factors along columns and rows, t[2] and t[3] are shear factors along columns and rows, and t[4] and t[5] are translations along columns and rows. The new values are interpolated to the nearest neighbor when needed.

Example

x = {0,1,1,0; 0,1,1,0; 0,1,1,0; 0,1,1,0};t = {1,1,0.5,0.5,0.5,0.5};a = {0}{0,1,0,0; 0,1,1,0; 0,0,1,0; 0,0,1,1}

Transform (Bilinear Interpolation)

Summery

Transform and apply bilinear interpolation

Description

Transform matrix x about center by transformation array t without resizing. t[0] and t[1] are scale factors along columns and rows, t[2] and t[3] are shear factors along columns and rows, and t[4] and t[5] are translations along columns and rows. The new values are interpolated bilinearly when needed.

Example

x = {0,1,1,0; 0,1,1,0; 0,1,1,0; 0,1,1,0};t = {1,1,0.5,0.5,0.5,0.5};a = {0}{0.16667,0.5,0,0; 0,0.83333,0.83333,0; 0,0.16667,1,0.16667; 0,0,0.83333,0.83333}

Transform (Bicubic Interpolation)

Summery

Transform and apply bicubic spline interpolation

Description

Transform matrix x about center by transformation array t without resizing. t[0] and t[1] are scale factors along columns and rows, t[2] and t[3] are shear factors along columns and rows, and t[4] and t[5] are translations along columns and rows. The new values are interpolated on a cubic spline when needed. Bilinear interpolation is applied for values next to the edges of the matrix.

Example

x = {0,1,1,0; 0,1,1,0; 0,1,1,0; 0,1,1,0};t = {1,1,0.5,0.5,0.5,0.5};a = {0}{0.16667,0.5,0,0; 0,0.83333,0.83333,0; 0,0.16667,1.125,0.16667; 0,0,0.83333,0.83333}

Resize (Fixed Aspect Ratio, Nearest-Neighbor Interpolation)

Summery

Resize with fixed aspect ratio and apply nearest-neighbor interpolation

Description

Stretch or shrink matrix x to m×n. When a dimension is not provided (empty), the aspect ratio is preserved. The new values are interpolated to the nearest neighbor when needed.

Example

x = {0,1,1,0; 0,1,1,0; 0,1,1,0; 0,1,1,0};m = {3}{0,1,0;0,1,0;0,1,0}
x = {1,0,0,0; 1,1,0,0; 0,1,1,0; 0,0,1,1; 0,0,0,1};n = {3}{1,0,0;0,1,0;0,0,1}

Resize (Fixed Aspect Ratio, Bilinear Interpolation)

Summery

Resize with fixed aspect ratio and apply bilinear interpolation

Description

Stretch or shrink matrix x to m×n. When a dimension is not provided (empty), the aspect ratio is preserved. The new values are interpolated bilinearly when needed.

Example

x = {0,1,1,0; 0,1,1,0; 0,1,1,0; 0,1,1,0};m = {3}{0,1,0;0,1,0;0,1,0}
x = {1,0,0,0; 1,1,0,0; 0,1,1,0; 0,0,1,1; 0,0,0,1};n = {3}{1,0,0;0,1,0;0,0,1}

Resize (Fixed Aspect Ratio, Bicubic Interpolation)

Summery

Resize with fixed aspect ratio and apply bicubic spline interpolation

Description

Stretch or shrink matrix x to m×n. When a dimension is not provided (empty), the aspect ratio is preserved. The new values are interpolated on a cubic spline when needed. Bilinear interpolation is applied for values next to the edges of the matrix.

Example

x = {0,1,1,0; 0,1,1,0; 0,1,1,0; 0,1,1,0};m = {3}{0,1,0;0,1.125,0;0,1,0}
x = {1,0,0,0; 1,1,0,0; 0,1,1,0; 0,0,1,1; 0,0,0,1};n = {3}{1,0,0;0,1.125,0;0,0,1}

Resize (Nearest-Neighbor Interpolation)

Summery

Resize and apply nearest-neighbor interpolation

Description

Stretch or shrink matrix x to m×n. When a dimension is not provided (empty), it is preserved. The new values are interpolated to the nearest neighbor when needed.

Example

x = {0,1,1,0; 0,1,1,0; 0,1,1,0; 0,1,1,0};m = {3}{0,1,1,0;0,1,1,0;0,1,1,0}
x = {1,0,0,0; 1,1,0,0; 0,1,1,0; 0,0,1,1; 0,0,0,1};n = {3}{1,0,0;1,0,0;0,1,0;0,1,1;0,0,1}

Resize (Bilinear Interpolation)

Summery

Resize and apply bilinear interpolation

Description

Stretch or shrink matrix x to m×n. When a dimension is not provided (empty), it is preserved. The new values are interpolated bilinearly when needed.

Example

x = {0,1,1,0; 0,1,1,0; 0,1,1,0; 0,1,1,0};m = {3}{0,1,1,0;0,1,1,0;0,1,1,0}
x = {1,0,0,0; 1,1,0,0; 0,1,1,0; 0,0,1,1; 0,0,0,1};n = {3}{1,0,0;1,0.5,0;0,1,0;0,0.5,1;0,0,1}

Resize (Bicubic Interpolation)

Summery

Resize and apply bicubic spline interpolation

Description

Stretch or shrink matrix x to m×n. When a dimension is not provided (empty), it is preserved. The new values are interpolated on a cubic spline when needed. Bilinear interpolation is applied for values next to the edges of the matrix.

Example

x = {0,1,1,0; 0,1,1,0; 0,1,1,0; 0,1,1,0};m = {3}{0,1,1,0;0,1,1,0;0,1,1,0}
x = {1,0,0,0; 1,1,0,0; 0,1,1,0; 0,0,1,1; 0,0,0,1};n = {3}{1,0,0;1,0.5,0;0,1.125,0;0,0.5,1;0,0,1}

Normalize Rows

Summery

Normalize rows to unit p-norm

Description

Normalize rows of matrix x to unit p-norm by dividing each x[i,j] by p-norm of the i-th row for each row i and column j.

Example

x = {1,1,0;0,-1,0;0,0,1};p = {2}⇒{0.70711,0.70711,0;0,-1,0;0,0,1}x = {1,0,4;1,1,6;-3,0,-10};p = {1}⇒{0.2,0,0.8;0.125,0.125,0.75;-0.23077,0,-0.76923}

Normalize Columns

Summery

Normalize columns to unit p-norm

Description

Normalize columns of matrix x to unit p-norm by dividing each x[i,j] by p-norm of the j-th column for each row i and column j.

Example

x = {1,1,0;0,-1,0;0,0,1};p = {2}⇒{1,0.70711,0;0,-0.70711,0;0,0,1}x = {1,0,4;1,1,6;-3,0,-10};p = {1}⇒{0.2,0,0.2;0.2,1,0.3;-0.6,0,-0.5}

Matrix Inverse

Summery

Inverse matrix

Description

Compute inverse of square matrix x.

Example

x = {1,0,0;0,-1,0;0,0,1}{1,0,0;0,-1,0;0,0,1}
x = {1,0,4;1,1,6;-3,0,-10}{-5,0,-2;-4,1,-1;1.5,0,0.5}

Matrix Power

Summery

Compute matrix power

Description

Compute k-th power of square matrix x where k is an integer.

Example

x = {1,1,1;0,1,1;0,0,1};k = {3}⇒{1,3,6;0,1,3;0,0,1}x = {1,0,4;1,1,6;-3,0,-10};k = {-1}⇒{-5,0,-2;-4,1,-1;1.5,0,0.5}

Matrix Polynomial

Summery

Compute matrix polynomial expression

Description

Compute the polynomial expression of square matrix x defined as a[0]I+a[1]x+a[2]x2+... . I is the identity matrix.

Example

x = {1,1,1;0,1,1;0,0,1};a = {-2,1,1}⇒{0,3,4;0,0,3;0,0,0}x = {1,0,4;1,1,6;-3,0,-10};a = {0,0,1}⇒{-11,0,-36;-16,1,-50;27,0,88}

Matrix Exponential

Summery

Compute matrix exponential

Description

Compute ex for square matrix x.

Example

x = {1,1,1;0,1,1;0,0,1}⇒{2.7183,2.7183,4.0774;0,2.7183,2.7183;0,0,2.7183}

Eigen Decomposition

Summery

Compute eigen decomposition

Description

Compute eigen decomposition of symmetric matrix x. The output matrix is in the form [d,p] where d is a column containing eigen values in ascending order and p is a matrix containing the corresponding normalized eigen vectors.

Example

x = {2,0,0;0,3,4;0,4,9}⇒{1,0,1,0;2,-0.89443,0,0.44721;11,0.44721,0,0.89443}

Cholesky Decomposition

Summery

Compute Cholesky decomposition

Description

Compute Cholesky decomposition of positive-definite matrix x. The output matrix, u, is an upper triangular matrix so that x = uT×u.

Example

x = {2,0,0;0,3,4;0,4,9}⇒{1.4142,0,0;0,1.7321,2.3094;0,0,1.9149}

Lower-Upper Decomposition

Summery

Compute lower-upper decomposition

Description

Compute lower-upper decomposition of square matrix x. The output matrix is in the form [l,u,p] where l is a lower triangular matrix, u is an upper triangular matrix, and p is a permutation matrix so that x = pT×l×u.

Example

x = {2,0,0;0,3,4;0,4,9}⇒{1,0,0,2,0,0,1,0,0; 0,1,0,0,4,9,0,0,1; 0,0.75,1,0,0,-2.75,0,1,0}

Singular Value Decomposition

Summery

Compute singular value decomposition

Description

Compute singular value decomposition of matrix x. The output matrix is in the form [s,u,v] where s is a column containing singular values, and u and v are unitary matrices so that x = u×diag(s)×vT. If x is not square, s,u, and v may be padded with 0's to fill the block matrix.

Example

x = {2,0,0;0,3,4;0,4,9}⇒{11,0,1,0,0,1,0; 2,-0.44721,0,-0.89443,-0.44721,0,-0.89443; 1,-0.89443,0,0.44721,-0.89443,0,0.44721}

Plans to Make Across Matrices


Replace Elements (Based on Another Matrix)

Summery

Conditionally replace element values

Description

Replace source elements when their corresponding reference element values are equal to from[k] with a[k] for each k or the last value in a when not available.

Example

source = {6,5,4;3,2,1;8,7,9};reference = {1,2,3;4,5,6;1,1,2};from = {1};a = {-1}{-1,5,4;3,2,1;-1,-1,9}
source = {6,5,4;3,2,1;8,7,9};reference = {1,2,3;4,5,6;1,1,2};from = {4,2,3};a = {-1,-2}{6,-2,-2;-1,2,1;8,7,-2}

Replace Element Ranges (Based on Another Matrix)

Summery

Conditionally replace ranges of element values

Description

Replace source elements when their corresponding reference element values are in ranges [from[k], to[k]] with a[k] for each k or the last value in a when not available.

Example

source = {6,5,4;3,2,1;8,7,9};reference = {1,2,3;4,5,6;1,1,2};from = {1,3.2};to = {1,10};a = {0}{0,5,4;0,0,0;0,0,9}
source = {6,5,4;3,2,1;8,7,9};reference = {1,2,3;4,5,6;1,1,2};from = {1,3.2};to = {1,10};a = {7,8,9}{7,5,4;8,8,8;7,7,9}

Replace High Elements (Based on Another Matrix)

Summery

Conditionally replace high element values

Description

Replace source elements with a when their corresponding reference element values are greater than or equal to b.

Example

source = {6,5,4;3,2,1;8,7,9};reference = {1,2,3;4,5,6;1,1,2};b = {3};a = {0}{6,5,0;0,0,0;8,7,9}

Replace Low Elements ((Based on Another Matrix)

Summery

Conditionally replace low element values

Description

Replace source elements with a when their corresponding reference element values are less than or equal to b.

Example

source = {6,5,4;3,2,1;8,7,9};reference = {1,2,3;4,5,6;1,1,2};b = {3};a = {0}{0,0,0;3,2,1;0,0,0}

Replace inf Elements (Based on Another Matrix)

Summery

Conditionally replace ±inf element values

Description

Replace source elements with a when their corresponding reference element values are equal to +/-inf with.

Example

source = {6,5,4;3,2,1;8,7,9};reference = {1,1/0;2,-2/0};a = {0}{6,0,4;3,0,1;8,7,9}

Replace nan Elements (Based on Another Matrix)

Summery

Conditionally replace nan element values

Description

Replace source elements with a when their corresponding reference element values are equal to nan.

Example

source = {6,5,4;3,2,1;8,7,9};reference = {1,nan;2,nan};a = {0}{6,0,4;3,0,1;8,7,9}

Replace Undefined Elements (Based on Another Matrix)

Summery

Conditionally replace non-finite element values

Description

Replace source elements with a when their corresponding reference element values are equal to +/-inf or nan.

Example

source = {6,5,4;3,2,1;8,7,9};x = {1,1/0;nan,-2/0};a = {0}{6,0,4;0,0,1;8,7,9}

Clean Elements (Based on Another Matrix)

Summery

Conditionally zero small element values

Description

Replace source elements when their corresponding reference element values have a magnitude less than or equal to a with 0.

Example

source = {6,5,4;3,2,1;8,7,9};reference = {0.1,0.2;1e-5,-0.4};a = {1e-3}{6,5,4;0,2,1;8,7,9}

Linear Element Expression

Summery

Compute linear combination of elements at the same position

Description

Compute linear combination of elements at the same row and column as a[0]+a[1]×x0[i,j]+a[2]×x1[i,j]+... for each row i and column j. The output matrix is as large as the largest provided matrix and the out-of-range elements are replaced with 0.

Example

a = {1,-1,1,-1};x0 = {1,0;-1,2};x1 = {0,0;-1,7};x2 = {5,3;-7,-2}{-5,-2;8,8}

Simple Element Expression

Summery

Compute simple expression at the same position

Description

Compute simple expression f(i,j,x0,x1,...,x20) for each row i and column j. The output matrix is as large as the largest provided matrix and the out-of-range elements are replaced with 0.

Expression parser supports the following:

  • Arithmetic operations: addition (+), subtraction/negation (-), multiplication (*), division (/), exponentiation (^) and modulus (%)
  • Numerical operations: sign, abs, ceil, floor, trunc, round, erf, sinc
  • Exponentiation operations: exp, pow, sqrt, logistic, logit
  • Combinatorial operations: fac, ncr, npr
  • Logarithmic operations: exp, ln (natural logarithm), log (base-10 logarithm), log10
  • Trigonometric functions: sin, cos, tan, cot, sec, csc, asin, acos, atan, atan2, acot, asec, acsc
  • Hyperbolic functions: sinh, cosh, tanh, coth, sech, csch, asinh, acosh, atanh, acoth, asech, acsch
  • Conditional operations: clamp, clean, disc, replace, replaceri, replacerx
  • Constants: pi, e

Example

f = {1+i+x0-2*x1+x2*(x3^2)};x0 = {1,-1;1,-1};x1 = {1,2;3,0};x2 = {-1,-2;-3,0};x3 = {0,2}{0,-12;-3,1}
f = {i-j};x0 = {0,0;0,0}{0,-1;1,0}

Advanced Element Expression

Summery

Compute general-form expression at the same position

Description

Compute general-form expression f = {f[0,0],f[0,1],...;f[1,0],...} where f[i,j] is a function of i,j,x,y,z,u,v,w1,x0_0,xp1_p1,xp1_n1,...,y0_0,yp1_p1,... . The output matrix is computed as f[i,j] for each row i and column j or the last function in f when filling column-by-column as column-major. x,y,z,u,v,w are the elements of matrices x,y,z,u,v,w at the same row and column. Fixed references are represented by x0_0=x[0,0], x1_2=x[1,2], and so on, and relative references by xp1_p1=x[i-1,j-1], xn1_n1=x[i+1,j+1], and so on. The output matrix is as large as the largest provided matrix and the out-of-range elements are replaced with 0.

Expression parser supports the following:

  • Arithmetic operations: addition (+), subtraction/negation (-), multiplication (*), division (/), exponentiation (^) and modulus (%)
  • Numerical operations: sign, abs, ceil, floor, trunc, round, erf, sinc
  • Exponentiation operations: exp, pow, sqrt, logistic, logit
  • Combinatorial operations: fac, ncr, npr
  • Logarithmic operations: exp, ln (natural logarithm), log (base-10 logarithm), log10
  • Trigonometric functions: sin, cos, tan, cot, sec, csc, asin, acos, atan, atan2, acot, asec, acsc
  • Hyperbolic functions: sinh, cosh, tanh, coth, sech, csch, asinh, acosh, atanh, acoth, asech, acsch
  • Conditional operations: clamp, clean, disc, replace, replaceri, replacerx
  • Constants: pi, e

Example

f = {i+x-y};x = {1,2;3,4};y = {1,-1;1,0}{0,3;3,5}
f = {x1_0+y1_0;x0_1-x-y0_1};x = {1,2;3,4};y = {1,-1;1,0}{4,1;0,-1}
f = {2*x-xp1_p1-xn1_p1+yn1_p0*yp0_n1};x = {1,2;3,4};y = {1,1;6,7}{1,1;0,5}

Element Product (Hadamard)

Summery

Compute element-wise product (Hadamard product) of matrices

Description

Compute element-wise product or Hadamard product of matrices x0,x1,... . When matrix dimensions are different, missing elements are replaced with identity.

Example

x0 = {1,0;-1,2};x1 = {-1,7};x2 = {5,3;-7,-2}{-5,0;7,-4}

Matrix Product

Summery

Compute matrix product

Description

Compute matrix multiplication x0×x1×... . The height of matrix xk+1 must be equal to the width of matrix xk for each k and the multiplication plan ignores matrices that do not follow this requirement.

Example

x0 = {1,0;-1,2};x1 = {-1;7};x2 = {5,3,2}{-5,-3,-2;75,45,30}

Matrix Solver

Summery

Solve matrix equation

Description

Solve matrix equation Ay = b where for A is a square matrix. b and the output matrix, y, are column matrices with the same height as A.

Example

A = {1,0,4;1,1,6;-3,0,-10};b = {-1;7;0}{5;11;-1.5}

2D Convolution (Full)

Summery

Compute full convolution of two matrices

Description

Compute full convolution of matrix x and (kernel) matrix y. The output matrix includes all partial convolutions with width/height equal to width/height(x)+width/height(y)-1.

Example

x = {0,1,1,0; 0,1,1,0; 0,1,1,0; 0,1,1,0; 0,1,1,0};y = {0,-1,0;-1,5,-1;0,-1,0}{0,0,-1,-1,0,0; 0,-1,3,3,-1,0; 0,-1,2,2,-1,0; 0,-1,2,2,-1,0; 0,-1,2,2,-1,0; 0,-1,3,3,-1,0; 0,0,-1,-1,0,0}

2D Convolution (Central)

Summery

Compute central convolution of two matrices

Description

Compute central convolution of matrix x and (kernel) matrix y. The output matrix is the same size as x.

Example

x = {0,1,1,0; 0,1,1,0; 0,1,1,0; 0,1,1,0; 0,1,1,0};y = {0,-1,0;-1,5,-1;0,-1,0}{-1,3,3,-1; -1,2,2,-1; -1,2,2,-1; -1,2,2,-1; -1,3,3,-1}

Plans to Derive From a Matrix


M - Count of Rows

Summery

Count matrix rows

Description

Count rows, that is m or the height, in matrix x.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9}{4}

N - Count of Columns

Summery

Count matrix columns

Description

Count columns, that is N or the width, in matrix x.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9}{3}

Copy Elements

Summery

Copy matrix elements

Description

Copy matrix elements at row i[k] and column j[k] for each k. If the sizes of arrays i and j are different, the last value in the smaller array is repeated.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9};i = {0,1};j = {0,1,2}{1,2,6}

Copy Rows

Summery

Copy matrix rows

Description

Copy matrix rows i[k] one row after another for each k.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9};i = {0,1,0}{1,0,-1,3,2,6,1,0,-1}

Copy Columns

Summery

Copy matrix columns

Description

Copy matrix columns j[k] one column after another for each k.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9};j = {0,1,0}{1,3,-1,7,0,2,1,8,1,3,-1,7}

Copy and Shuffle Rows

Summery

Copy matrix rows staggered

Description

Copy matrix rows i[k] along columns (staggered) for each k.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9};i = {0,1,0}{1,3,1,0,2,0,-1,6,-1}

Copy and Shuffle Columns

Summery

Copy matrix columns staggered

Description

Copy matrix columns j[k] along rows (staggered) for each k.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9};j = {0,1,0}{1,0,1,3,2,3,-1,1,-1,7,8,7}

Copy All Rows

Summery

Copy all matrix rows

Description

Copy matrix x row-by-row. This effectively converts a matrix to an array.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9}{1,0,-1,3,2,6,-1,1,4,7,8,9}

Copy All Columns

Summery

Copy all matrix columns

Description

Copy matrix x column-by-column. This effectively converts a matrix to an array.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9}{1,3,-1,7,0,2,1,8,-1,6,4,9}

Copy Main Diagonal

Summery

Copy matrix main diagonal

Description

Copy the main diagonal of matrix x starting from upper left corner.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9}{1,2,4}

Copy Super Diagonal

Summery

Copy matrix super diagonal

Description

Copy the super diagonal of matrix x starting from upper left side.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9}{0,6}

Copy Sub Diagonal

Summery

Copy matrix sub diagonal

Description

Copy the sub diagonal of matrix x starting from upper left side.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9}{3,1,9}

Copy Nth Diagonal

Summery

Copy an arbitrary matrix diagonal

Description

Copy the nth diagonal of matrix x starting from upper left side. Diagonals are counted from main diagonal at n=0 with positive n at upper right triangular portion and negative n at lower left triangular portion.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9};n = {2}{-1}
x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9};n = {-2}{-1,8}

Copy Main Skew Diagonal

Summery

Copy matrix main skew diagonal

Description

Copy the main skew diagonal of matrix x starting from upper right corner.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9}{-1,2,-1}

Copy Super Skew Diagonal

Summery

Copy matrix super skew diagonal

Description

Copy the super skew diagonal of matrix x starting from upper right side.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9}{0,3}

Copy Sub Skew Diagonal

Summery

Copy matrix sub skew diagonal

Description

Copy the sub skew diagonal of matrix x starting from upper right side.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9}{6,1,7}

Copy Nth Skew Diagonal

Summery

Copy an arbitrary matrix skew diagonal

Description

Copy the nth skew diagonal of matrix x starting from upper right side. Skew diagonals are counted from main skew diagonal at n=0 with positive n at upper left triangular portion and negative n at lower right triangular portion.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9};n = {2}{1}
x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9};n = {-2}{4,8}

Minimum in Rows

Summery

Find minimum element in rows

Description

Find minimum element in each row of matrix x from top.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9}{-1,2,-1,7}

Maximum in Rows

Summery

Find maximum element in rows

Description

Find maximum element in each row of matrix x from top.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9}{1,6,4,9}

Minimum in Columns

Summery

Find minimum element in columns

Description

Find minimum element in each column of matrix x from left.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9}{-1,0,-1}

Maximum in Columns

Summery

Find maximum element in columns

Description

Find maximum element in each column of matrix x from left.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9}{7,8,9}

Index of Minimum in Rows

Summery

Find column number of minimum element in rows

Description

Find column number of the minimum element in each row of matrix x from top.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9}{2,1,0,0}

Index of Maximum in Rows

Summery

Find column number of maximum element in rows

Description

Find column number of the maximum element in each row of matrix x from top.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9}{0,2,2,2}

Index of Minimum in Columns

Summery

Find row number of minimum element in columns

Description

Find row number of the minimum element in each column of matrix x from left.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9}{2,0,0}

Index of Maximum in Columns

Summery

Find row number of maximum element in columns

Description

Find row number of the maximum element in each column of matrix x from left.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9}{3,3,3}

Mean in Rows

Summery

Compute arithmetic mean of element values in rows

Description

Compute arithmetic mean in each row of matrix x from top as (x[i,0]+x[i,1]+...)/N for each row i. N is the width of matrix x.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9}{0,3.66667,1.33333,8}

Range in Rows

Summery

Compute range of element values in rows

Description

Compute range in each row of matrix x from top as the difference between the minimum and maximum of elements in each row.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9}{2,4,5,2}

Sum in Rows

Summery

Compute sum of element values in rows

Description

Compute sum in each row of matrix x from top as x[i,0]+x[i,1]+... for each row i.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9}{0,11,4,24}

Product in Rows

Summery

Compute product of element values in rows

Description

Compute product in each row of matrix x from top as x[i,0]×x[i,1]×... for each row i.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9}{0,36,-4,504}

Norm in Rows

Summery

Compute p-norm of element values in rows

Description

Compute p-norm in each row of matrix x from top as {|x[i,0]|p+|x[i,1]|p+...}1/p for each row i.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9};p = {1}{2,11,6,24}
x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9};p = {2}{1.41421,7,4.24264,13.9284}

Mean in Columns

Summery

Compute arithmetic mean of element values in columns

Description

Compute arithmetic mean in each column of matrix x from left as (x[0,j]+x[1,j]+...)/m for each column j. m is the height of matrix x.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9}{2.5,2.75,4.5}

Range in Columns

Summery

Compute range of element values in columns

Description

Compute range in each column of matrix x from left as the difference between the minimum and maximum of elements in each column.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9}{8,8,10}

Sum in Columns

Summery

Compute sum of element values in columns

Description

Compute sum in each column of matrix x from left as x[0,j]+x[1,j]+... for each column j.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9}{10,11,18}

Product in Columns

Summery

Compute product of element values in columns

Description

Compute product in each column of matrix x from left as x[0,j]×x[1,j]×... for each column j.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9}{-21,0,-216}

Norm in Columns

Summery

Compute p-norm of element values in columns

Description

Compute p-norm in each column of matrix x from left as {|x[0,j]|p+|x[1,j]|p+...}1/p for each column j.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9};p = {1}{12,11,20}
x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9};p = {2}{7.74597,8.30662,11.5758}

Sum in Diagonals

Summery

Compute sum of element values in diagonals

Description

Compute sum in each diagonal of matrix x from the lowest diagonal consisting the bottom left corner to the highest diagonal consisting the upper right corner.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9}{7,7,13,7,6,-1}

Sum in Skew Diagonals

Summery

Compute sum of element values in skew diagonals

Description

Compute sum in each skew diagonal of matrix x from the lowest skew diagonal consisting the bottom right corner to the highest skew diagonal consisting the upper left corner.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9}{9,12,14,0,3,1}

Sum Along a Formula

Summery

Compute sum of element values on a path

Description

Compute sum of elements x[i,j] with the same integer value for f(i,j) ordered from the lowest value of f(i,j) to the highest.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9};f = {i+2*j}{1,3,-1,9,0,14,4,9}

Trace

Summery

Compute trace of matrix

Description

Compute trace of matrix x.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9}{7}

Determinant

Summery

Compute determinant of matrix

Description

Compute determinant of square matrix x.

Example

x = {1,0,-1; 3,2,6; -1,1,4}{-3}

Rank

Summery

Compute rank of matrix

Description

Compute rank of matrix x.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9}{3}

Condition Number

Summery

Compute condition number of matrix

Description

Compute condition number or the ratio of the largest singular value to the smallest for matrix x.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9}{9.87909}

Matrix Norm

Summery

Compute p-norm of matrix

Description

Compute p-norm of matrix x.

Example

x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9};p = {1}{20}
x = {1,0,-1; 3,2,6; -1,1,4; 7,8,9};p = {2}{15.689}

Plans to Derive Across Matrices


Inner Product

Summery

Compute (Frobenius) inner product of matrices

Description

Compute inner product of matrices x0,x1,... defined as the sum of x0[i,j]×x1[i,j]×x2[i,j]x×... across all rows and columns. Missing elements are replaced with 0. This product reduces to real Frobenius inner product when x consists of two matrices of the same size and to dot product when x consists of two row/column matrices of the same size.

Example

x0 = {1,0.5;4,5};x1 = {4,-1;0,3};x2 = {-2,-3;12,-0.5}{-14}

Plans to Post a Matrix


Export to Text File

Summery

Export a matrix to text file

Description

Export matrix x to a text file at file name with values separated by delimiter. If append is nonempty, the matrix is appended to the end of the file. Floating-point format is set by width and precision parameters.

Example

file name = {tests\output_mat.txt};append = {};delimiter = {, };width = {};precision = {};x = {pi,2,3,4;-pi,10,25,38}
file name = {tests\output_mat_w.txt};append = {};delimiter = {, };width = {8};precision = {3};x = {pi,2,3,4;-pi,10,25,38}

Export to Armadillo Binary File

Summery

Export a matrix to Armadillo library binary file

Description

Export matrix x to an Armadillo library binary file at file name.

Example

file name = {tests\matrix.bin};x = {pi,2,3,4;-pi,10,25,38}

Export to Armadillo Text File

Summery

Export a matrix to Armadillo library text file

Description

Export matrix x to an Armadillo library text file at file name.

Example

file name = {tests\matrix.txt};x = {pi,2,3,4;-pi,10,25,38}

Export to Armadillo Raw Binary File

Summery

Export a matrix to Armadillo library raw binary file

Description

Export matrix x to an Armadillo library raw binary file at file name. In this file format, matrix dimensions are not preserved and the matrix is reduced to a column matrix with the underlying matrix data.

Example

file name = {tests\matrix.raw_bin};x = {pi,2,3,4;-pi,10,25,38}

Export to Armadillo Raw Text File

Summery

Export a matrix to Armadillo library raw text file

Description

Export matrix x to an Armadillo library raw text file at file name. In this file format, matrix dimensions are interpreted from the text structure.

Example

file name = {tests\matrix.raw_txt};x = {pi,2,3,4;-pi,10,25,38}

Export to CSV File

Summery

Export a matrix to CSV file

Description

Export matrix x to a Comma-Separated Values (CSV) file at file name.

Example

file name = {tests\matrix.csv};x = {pi,2,3,4;-pi,10,25,38}

Export to Coordinate List File

Summery

Export a matrix to coordinate list file

Description

Export matrix x to a coordinate list file at file name. In this file format, a line describes a non-zero element as "row column value" with row and column numbers counted from 0.

Example

file name = {tests\matrix.coord};x = {pi,2,3,4;-pi,10,25,38}

Export to PGM File

Summery

Export a matrix to PGM file

Description

Export matrix x to a Portable Gray Map (PGM) file at file name. In this file format, elements are stored as whole numbers between 0 and 255.

Example

file name = {tests\matrix.pgm};x = {pi,2,3,4;-pi,10,25,38}