Matrices: High Performance¶
CalcpadCE offers a parallel high-performance matrix mode for the larger linear-algebra workloads.
Wrap any matrix with hp([...]) (or use the hp creational helpers) and the engine switches to a packed numerical layout with SIMD-friendly element-wise operations, dropping per-element interpretation overhead — the gain scales with matrix size and is most visible on dense products, decompositions and reductions.
The six worksheets in this group are direct counterparts of the regular Matrices group, rewritten in HP form: literal construction and indexing, creational helpers, row- and column-wise data toolkit, linear-algebra primitives, structural plumbing, and the matrix and matrix–vector operators.
The semantics match the plain mode one-to-one, so you can drop hp(...) around an existing pipeline and trade only the storage layout.
Matrix Initialization and Indexing¶
HP foundations: literal matrices wrapped with \(hp(...)\), \(isHp\) checks, indexing, slicing and submatrix assignment on packed numerical storage.
'Direct:
A = hp([1|2; 3|4; 5; 6|7; 8])','isHp(A)
'Direct with vectors:
a = [1; 2; 4]
A = hp([a|2*a + 1|3*a + 2])','isHp(A)
'From a custom function (with vector arguments):
A(x) = transp(hp([x^0|x|x^2|x^3|x^4]))
x = hp([1; 2; 3; 4])
A = A(x)','isHp(A)
"Indexing
'<hr/>
A.(3; 2)'- simple dot operator (constant index)
i = 2', 'j = 3
A.(2*i - 1; j + 1)'- expressions with variables
A.(i; j) = 0' - assign a new value to an element:'A
'Initalize values in a block loop
x = hp([1; 2; 3; 4])
A = matrix_hp(len(x); 7)
#hide
#for i = 1 : n_rows(A)
#for j = 1 : n_cols(A)
A.(i; j) = x.i^(j - 1)
#loop
#loop
#show
A
'Inline loop
B = matrix_hp(len(x); 7)
$Repeat{$Repeat{B.(i; j) = x.i^(j - 1) @ j = 1 : n_cols(B)} @ i = 1 : n_rows(B)}
B
Direct:
A = hp ( [1 | 2; 3 | 4; 5; 6 | 7; 8] ) = 100 230 456 780 , isHp ( A ) = 1
Direct with vectors:
⃗a = [1; 2; 4] = [1 2 4]
A = hp ( [⃗a | 2 · ⃗a + 1 | 3 · ⃗a + 2] ) = 124 359 5814 , isHp ( A ) = 1
From a custom function (with vector arguments):
A ( x ) = transp ( hp ( [x0 | x | x2 | x3 | x4] ) )
⃗x = hp ( [1; 2; 3; 4] ) = [1 2 3 4]
A = A ( ⃗x ) = 11111 124816 1392781 141664256 , isHp ( A ) = 1
A3,2 = 3 - simple dot operator (constant index)
i = 2 , j = 3
A3,4 = 27 - expressions with variables
A2,3 = 0 - assign a new value to an element: A = 11111 120816 1392781 141664256
Initalize values in a block loop
⃗x = hp ( [1; 2; 3; 4] ) = [1 2 3 4]
A = matrixhp ( len ( ⃗x ) ; 7 ) = 0000000 0000000 0000000 0000000
A = 1111111 1248163264 1392781243729 14166425610244096
Inline loop
B = matrixhp ( len ( ⃗x ) ; 7 ) = 0000000 0000000 0000000 0000000
$Repeat{$Repeat{Bi,j = ⃗xij − 1 for j = 1...ncols ( B ) } for i = 1...nrows ( B ) } = 4096
B = 1111111 1248163264 1392781243729 14166425610244096
Matrix Creational Functions¶
HP variant of the creational helpers: \(matrix\), \(identity\), \(diagonal\), banded, random and Vandermonde constructors emitting packed storage.
'<style>em {font-family:"Times New Roman";}</style>
'<p><b>Matrix</b>(<em>m</em>; <em>n</em>)</p><hr/>
matrix_hp(3; 4)'- creates a 3x4 full (rectangular) matrix
'<p><b>Identity</b>(<em>n</em>)</p><hr/>
identity_hp(3)'- creates a 3x3 identity matrix (diagonal filled with ones)
'<p><b>Diagonal</b>(<em>n</em>, <em>value</em>)</p><hr/>
diagonal_hp(3; 2)'- creates a 3x3 diagonal matrix filled with 2
'<p><b>Column</b>(<em>m</em>, <em>value</em>)</p><hr/>
column_hp(3; 2)'- creates a 3x1 column matrix filled with 2
'<p><b>Utriang</b>(<em>n</em>, <em>value</em>)</p><hr/>
U = utriang_hp(3)'- creates a 3x3 upper triangular matrix
mfill(U; 1)'- fills the matrix with value of 1
'<p><b>Ltriang</b>(<em>n</em>, <em>value</em>)</p><hr/>
L = ltriang_hp(3)'- creates a 3x3 lower triangular matrix
mfill(L; 1)'- fills the matrix with value of 1
'<p><b>Symmetric</b>(<em>n</em>)</p><hr/>
A = symmetric_hp(4)'- creates a 4x4 empty symmetrix matrix
A.(1; 1) = 5', 'A.(1; 2) = 4'- assign some values
A.(2; 2) = 3', 'A.(2; 3) = 2
A.(4; 2) = 1', 'A.(4; 4) = 1
A'- symmetric values has also changed to preserve symmetry
'<p><b>Vec2diag</b>(<em>vector</em>)</p><hr/>
a = vec2diag(hp([1; 2; 3]))'- creates a 3x3 diagonal matrix from a vector
isHp(a)
'<p><b>Vec2col</b>(<em>vector</em>)</p><hr/>
a = vec2col(hp([1; 2; 3]))'- creates a 3x3 column matrix from a vector
isHp(a)
'<p><b>Join_Cols</b>(<em>list of vectors</em>)</p><hr/>
a = join_cols(hp([1]); hp([4; 5; 6]); hp([7; 8]); hp([10; 11; 12]))'- creates a general rectangular matrix by joining the input vectors into columns
isHp(a)
a = hp(join_cols([1]; [4; 5; 6]; [7; 8]; [10; 11; 12]))'- creates a general rectangular matrix by joining the input vectors into columns
isHp(a)
'<p><b>Join_Rows</b>(<em>list of vectors</em>)</p><hr/>
a = join_rows(hp([1; 2; 3; 4]); hp([6; 7; 8; 9; 10]))'- creates a general rectangular matrix by joining the input vectors into rows
isHp(a)
'<p><b>Join_Rows</b>(<em>list of vectors</em>)</p><hr/>
a = join_rows(hp([1; 2; 3; 4]); hp([6; 7; 8; 9; 10]))'- creates a general rectangular matrix by joining the input vectors into rows
isHp(a)
'<p><b>Augment</b>(<em>list of matrices</em>)</p><hr/>
A = hp([1; 2|3; 4])
B = hp([1; 2; 3|4; 5; 6|7; 8; 9])
c = hp([10; 11; 12; 13])
D = augment(A; B; c)'- creates a general rectangular matrix by joining the input matrices side to side
isHp(D)
'<p><b>Stack</b>(<em>list of matrices</em>)</p><hr/>
A = hp([1; 2|3; 4])
B = hp([1; 2; 3|4; 5; 6|7; 8; 9])
c = hp([10; 11])
D = stack(A; B; c)'- creates a general rectangular matrix by joining the input matrices one below the other
isHp(D)
Matrix(m; n)
matrixhp ( 3; 4 ) = 0000 0000 0000 - creates a 3x4 full (rectangular) matrix
Identity(n)
identityhp ( 3 ) = 100 010 001 - creates a 3x3 identity matrix (diagonal filled with ones)
Diagonal(n, value)
diagonalhp ( 3; 2 ) = 200 020 002 - creates a 3x3 diagonal matrix filled with 2
Column(m, value)
columnhp ( 3; 2 ) = 2 2 2 - creates a 3x1 column matrix filled with 2
Utriang(n, value)
U = utrianghp ( 3 ) = 000 000 000 - creates a 3x3 upper triangular matrix
mfill ( U; 1 ) = 111 011 001 - fills the matrix with value of 1
Ltriang(n, value)
L = ltrianghp ( 3 ) = 000 000 000 - creates a 3x3 lower triangular matrix
mfill ( L; 1 ) = 100 110 111 - fills the matrix with value of 1
Symmetric(n)
A = symmetrichp ( 4 ) = 0000 0000 0000 0000 - creates a 4x4 empty symmetrix matrix
A1,1 = 5 , A1,2 = 4 - assign some values
A2,2 = 3 , A2,3 = 2
A4,2 = 1 , A4,4 = 1
A = 5400 4321 0200 0101 - symmetric values has also changed to preserve symmetry
Vec2diag(vector)
a = vec2diag ( hp ( [1; 2; 3] ) ) = 100 020 003 - creates a 3x3 diagonal matrix from a vector
isHp ( a ) = 1
Vec2col(vector)
a = vec2col ( hp ( [1; 2; 3] ) ) = 1 2 3 - creates a 3x3 column matrix from a vector
isHp ( a ) = 1
Join_Cols(list of vectors)
a = joincols ( hp ( [1] ) ; hp ( [4; 5; 6] ) ; hp ( [7; 8] ) ; hp ( [10; 11; 12] ) ) = 14710 05811 06012 - creates a general rectangular matrix by joining the input vectors into columns
isHp ( a ) = 1
a = hp ( joincols ( [1]; [4; 5; 6]; [7; 8]; [10; 11; 12] ) ) = 14710 05811 06012 - creates a general rectangular matrix by joining the input vectors into columns
isHp ( a ) = 1
Join_Rows(list of vectors)
a = joinrows ( hp ( [1; 2; 3; 4] ) ; hp ( [6; 7; 8; 9; 10] ) ) = 12340 678910 - creates a general rectangular matrix by joining the input vectors into rows
isHp ( a ) = 1
Join_Rows(list of vectors)
a = joinrows ( hp ( [1; 2; 3; 4] ) ; hp ( [6; 7; 8; 9; 10] ) ) = 12340 678910 - creates a general rectangular matrix by joining the input vectors into rows
isHp ( a ) = 1
Augment(list of matrices)
A = hp ( [1; 2 | 3; 4] ) = 12 34
B = hp ( [1; 2; 3 | 4; 5; 6 | 7; 8; 9] ) = 123 456 789
⃗c = hp ( [10; 11; 12; 13] ) = [10 11 12 13]
D = augment ( A; B; ⃗c ) = 1212310 3445611 0078912 0000013 - creates a general rectangular matrix by joining the input matrices side to side
isHp ( D ) = 1
Stack(list of matrices)
A = hp ( [1; 2 | 3; 4] ) = 12 34
B = hp ( [1; 2; 3 | 4; 5; 6 | 7; 8; 9] ) = 123 456 789
⃗c = hp ( [10; 11] ) = [10 11]
D = stack ( A; B; ⃗c ) = 120 340 123 456 789 1000 1100 - creates a general rectangular matrix by joining the input matrices one below the other
isHp ( D ) = 1
Matrix Data Functions¶
HP variant of the data toolkit: row- and column-wise sorting, ordering, search and reductions, all on packed numerical storage.
'<style>em {font-family:"Times New Roman";}</style>
'<p><b>Sort_Cols</b>(<em>matrix</em>; <em>row index</em>) and <b>Rsort_Cols</b>(<em>matrix</em>; <em>row index</em>)</p><hr/>
A = hp([5; 2; 3|4; 9; 1|6; 8; 7])
B = sort_cols(A; 2)'- the matrix sorted by row 2 in ascending order
isHp(B)
C = rsort_cols(A; 2)'- the matrix sorted by row 2 in descending order
isHp(C)
A' - the original matrix remains unchanged
'<p><b>Sort_Rows</b>(<em>matrix</em>; <em>column index</em>) and <b>Rsort_Rows</b>(<em>matrix</em>; <em>column index</em>)</p><hr/>
A = hp([5; 2; 3|4; 9; 1|6; 8; 7])
B = sort_rows(A; 2)'- the matrix sorted by column 2 in ascending order
isHp(B)
C = rsort_rows(A; 2)'- the matrix sorted by column 2 in descending order
isHp(C)
A' - the original matrix remains unchanged
'<p><b>Order_Cols</b>(<em>matrix</em>; <em>row index</em>) and <b>Revorder_Cols</b>(<em>matrix</em>; <em>row index</em>)</p><hr/>
A = hp([5; 2; 3|4; 9; 1|6; 8; 7])
b = order_cols(A; 2)'- the indexes of matrix columns ordered by the values in row 2 in ascending order
isHp(b)
B = extract_cols(A; b)'- the matrix sorted by row 2 in ascending order
isHp(B)
c = revorder_cols(A; 2)'- the indexes of matrix columns ordered by the values in row 2 in descending order
isHp(c)
C = extract_cols(A; c)'- the matrix sorted by row 2 in descending order
isHp(C)
'<p><b>Order_Rows</b>(<em>matrix</em>; <em>column index</em>) and <b>Revorder_Rows</b>(<em>matrix</em>; <em>column index</em>)</p><hr/>
A = hp([5; 2; 3|4; 9; 1|6; 8; 7])
b = order_rows(A; 2)'- the indexes of matrix rows ordered by the values in column 2 in ascending order
isHp(b)
B = extract_rows(A; b)
isHp(B)
c = revorder_rows(A; 2)'- the matrix sorted by row 2 in descending order
isHp(c)
C = extract_rows(A; c)'- the indexes of matrix rows ordered by the values in column 2 in descending order
isHp(C)
'<p><b>Mcount</b>(<em>matrix</em>; <em>value</em>)</p><hr/>
A = hp([1; 0; 1|2; 1; 2|1; 3; 1])
n = mcount(A; 1)'- the number of occurances of value 1 in matrix A
'<p><b>Msearch</b>(<em>matrix</em>; <em>value</em>; <em>starting row index</em>; <em>starting column index</em>)</p><hr/>
A = hp([1; 2; 3|1; 5; 6|1; 8; 9])
b = msearch(A; 1; 1; 1)' - the row and column indexes of the first occurance of value 1 in A, starting from (1,1)
isHp(b)
c = msearch(A; 1; 2; 2)' - the same are previous, but starting from (2,2)
isHp(c)
d = msearch(A; 4; 1; 1)' - if the value is not found [0 0] is returned
isHp(d)
'<p><b>Mfind</b>(<em>matrix</em>; <em>value</em>)</p><hr/>
A = hp([1; 2; 3|4; 1; 6|1; 8; 9])
B = mfind(A; 1)' - the row and column indexes of all elements in A, that are equal to 1
isHp(B)
C = mfind_ne(A; 1)' - the row and column indexes of all elements in A, that are not equal to 1
isHp(C)
D = mfind_lt(A; 5)' - the row and column indexes of all elements in A, that are less than 5
isHp(D)
E = mfind(A; 5)'- if the value is not found
isHp(E)
'<p><b>Hlookup</b>(<em>matrix</em>; <em>value</em>; <em>reference row</em>; <em>return row</em>)</p><hr/>
A = hp([0; 1; 0; 1|1; 2; 3; 4; 5|6; 7; 8; 9; 10])
b = hlookup(A; 0; 1; 3)'- the values in row 3, where row 1 contains zeros
isHp(b)
c = hlookup_ne(A; 0; 1; 3)'- the values in row 3, where row 1 does not contain zeros
isHp(c)
d = hlookup_lt(A; 9; 3; 2)'- the values in row 2, where the respective values in row 3 are < 9
isHp(d)
e = hlookup_ge(A; 8; 3; 2)'- the values in row 2, where the respective values in row 3 are ≥ 8
isHp(e)
f = hlookup(A; 0; 1; 3)'- the values in row 3, where row 1 contains zeros
isHp(f)
g = hlookup(A; 2; 1; 3)'- since 2 is not found in row 1, an empty vector is returned
isHp(g)
'<p><b>Vlookup</b>(<em>matrix</em>; <em>value</em>; <em>reference column</em>; <em>return column</em>)</p><hr/>
A = hp([1; 2|3; 4; 1|5; 6|7; 8; 1|9; 10])
b = vlookup(A; 0; 3; 1)'- the values in column 1, where column 3 contains zeros
isHp(b)
c = vlookup_ne(A; 0; 3; 2)'- the values in column 2, where column 3 does not contain zeros
isHp(c)
d = vlookup_le(A; 5; 1; 2)'- the values in column 2, where the respective values in column 1 are ≤ 5
isHp(d)
e = vlookup_gt(A; 3; 1; 2)'- the values in column 2, where the respective values in column 1 are > 3
isHp(e)
f = vlookup(A; 2; 3; 1)'- since 2 is not found in column 3, an empty vector is returned
isHp(f)
Sort_Cols(matrix; row index) and Rsort_Cols(matrix; row index)
A = hp ( [5; 2; 3 | 4; 9; 1 | 6; 8; 7] ) = 523 491 687
B = sortcols ( A; 2 ) = 352 149 768 - the matrix sorted by row 2 in ascending order
isHp ( B ) = 1
C = rsortcols ( A; 2 ) = 253 941 867 - the matrix sorted by row 2 in descending order
isHp ( C ) = 1
A = 523 491 687 - the original matrix remains unchanged
Sort_Rows(matrix; column index) and Rsort_Rows(matrix; column index)
A = hp ( [5; 2; 3 | 4; 9; 1 | 6; 8; 7] ) = 523 491 687
B = sortrows ( A; 2 ) = 523 687 491 - the matrix sorted by column 2 in ascending order
isHp ( B ) = 1
C = rsortrows ( A; 2 ) = 491 687 523 - the matrix sorted by column 2 in descending order
isHp ( C ) = 1
A = 523 491 687 - the original matrix remains unchanged
Order_Cols(matrix; row index) and Revorder_Cols(matrix; row index)
A = hp ( [5; 2; 3 | 4; 9; 1 | 6; 8; 7] ) = 523 491 687
⃗b = ordercols ( A; 2 ) = [3 1 2] - the indexes of matrix columns ordered by the values in row 2 in ascending order
isHp ( ⃗b ) = 1
B = extractcols ( A; ⃗b ) = 352 149 768 - the matrix sorted by row 2 in ascending order
isHp ( B ) = 1
⃗c = revordercols ( A; 2 ) = [2 1 3] - the indexes of matrix columns ordered by the values in row 2 in descending order
isHp ( ⃗c ) = 1
C = extractcols ( A; ⃗c ) = 253 941 867 - the matrix sorted by row 2 in descending order
isHp ( C ) = 1
Order_Rows(matrix; column index) and Revorder_Rows(matrix; column index)
A = hp ( [5; 2; 3 | 4; 9; 1 | 6; 8; 7] ) = 523 491 687
⃗b = orderrows ( A; 2 ) = [1 3 2] - the indexes of matrix rows ordered by the values in column 2 in ascending order
isHp ( ⃗b ) = 1
B = extractrows ( A; ⃗b ) = 523 687 491
isHp ( B ) = 1
⃗c = revorderrows ( A; 2 ) = [2 3 1] - the matrix sorted by row 2 in descending order
isHp ( ⃗c ) = 1
C = extractrows ( A; ⃗c ) = 491 687 523 - the indexes of matrix rows ordered by the values in column 2 in descending order
isHp ( C ) = 1
Mcount(matrix; value)
A = hp ( [1; 0; 1 | 2; 1; 2 | 1; 3; 1] ) = 101 212 131
n = mcount ( A; 1 ) = 5 - the number of occurances of value 1 in matrix A
Msearch(matrix; value; starting row index; starting column index)
A = hp ( [1; 2; 3 | 1; 5; 6 | 1; 8; 9] ) = 123 156 189
⃗b = msearch ( A; 1; 1; 1 ) = [1 1] - the row and column indexes of the first occurance of value 1 in A, starting from (1,1)
isHp ( ⃗b ) = 1
⃗c = msearch ( A; 1; 2; 2 ) = [3 1] - the same are previous, but starting from (2,2)
isHp ( ⃗c ) = 1
⃗d = msearch ( A; 4; 1; 1 ) = [0 0] - if the value is not found [0 0] is returned
isHp ( ⃗d ) = 1
Mfind(matrix; value)
A = hp ( [1; 2; 3 | 4; 1; 6 | 1; 8; 9] ) = 123 416 189
B = mfind ( A; 1 ) = 123 121 - the row and column indexes of all elements in A, that are equal to 1
isHp ( B ) = 1
C = mfindne ( A; 1 ) = 112233 231323 - the row and column indexes of all elements in A, that are not equal to 1
isHp ( C ) = 1
D = mfindlt ( A; 5 ) = 111223 123121 - the row and column indexes of all elements in A, that are less than 5
isHp ( D ) = 1
E = mfind ( A; 5 ) = 0 0 - if the value is not found
isHp ( E ) = 1
Hlookup(matrix; value; reference row; return row)
A = hp ( [0; 1; 0; 1 | 1; 2; 3; 4; 5 | 6; 7; 8; 9; 10] ) = 01010 12345 678910
⃗b = hlookup ( A; 0; 1; 3 ) = [6 8 10] - the values in row 3, where row 1 contains zeros
isHp ( ⃗b ) = 1
⃗c = hlookupne ( A; 0; 1; 3 ) = [7 9] - the values in row 3, where row 1 does not contain zeros
isHp ( ⃗c ) = 1
⃗d = hlookuplt ( A; 9; 3; 2 ) = [1 2 3] - the values in row 2, where the respective values in row 3 are < 9
isHp ( ⃗d ) = 1
⃗e = hlookupge ( A; 8; 3; 2 ) = [3 4 5] - the values in row 2, where the respective values in row 3 are ≥ 8
isHp ( ⃗e ) = 1
⃗f = hlookup ( A; 0; 1; 3 ) = [6 8 10] - the values in row 3, where row 1 contains zeros
isHp ( ⃗f ) = 1
⃗g = hlookup ( A; 2; 1; 3 ) = [] - since 2 is not found in row 1, an empty vector is returned
isHp ( ⃗g ) = 1
Vlookup(matrix; value; reference column; return column)
A = hp ( [1; 2 | 3; 4; 1 | 5; 6 | 7; 8; 1 | 9; 10] ) = 120 341 560 781 9100
⃗b = vlookup ( A; 0; 3; 1 ) = [1 5 9] - the values in column 1, where column 3 contains zeros
isHp ( ⃗b ) = 1
⃗c = vlookupne ( A; 0; 3; 2 ) = [4 8] - the values in column 2, where column 3 does not contain zeros
isHp ( ⃗c ) = 1
⃗d = vlookuple ( A; 5; 1; 2 ) = [2 4 6] - the values in column 2, where the respective values in column 1 are ≤ 5
isHp ( ⃗d ) = 1
⃗e = vlookupgt ( A; 3; 1; 2 ) = [6 8 10] - the values in column 2, where the respective values in column 1 are > 3
isHp ( ⃗e ) = 1
⃗f = vlookup ( A; 2; 3; 1 ) = [] - since 2 is not found in column 3, an empty vector is returned
isHp ( ⃗f ) = 1
Matrix Math Functions¶
HP variant of the linear-algebra toolkit: Hadamard product, determinant, inverse, transpose, norms and decomposition helpers on packed numerical storage.
'<style>em {font-family:"Times New Roman";}</style>
'<p><b>Hprod</b>(<em>first matrix</em>; <em>second matrix</em>)</p><hr/>
A = hp([1; 2|3; 4|5; 6])'- first matrix
B = hp([9; 8|7; 6|5; 4])'- second matrix
C = hprod(A; B)'- The Hadamard product of matrices A and B
'<p><b>Fprod</b>(<em>first matrix</em>; <em>second matrix</em>)</p><hr/>
A = hp([1; 2|3; 4|5; 6])'- first matrix
B = hp([9; 8|7; 6|5; 4])'- second matrix
C = fprod(A; B)'- the Frobenius product of matrices A and B
'<p><b>Kprod</b>(<em>first matrix</em>; <em>second matrix</em>)</p><hr/>
A = hp([1; 2|3; 4])'- first matrix
B = hp([5; 6; 7|8; 9; 10])'- second matrix
C = kprod(A; B)'- the Kronecker product of matrices A and B
'<p><b>Mnorm_1</b>(<em>matrix</em>)</p><hr/>
A = hp([1; 2; 3|4; 5; 6|7; 8; 9])
mnorm_1(A)'- the L1 (Manhattan or taxicab) norm of matrix A
'<p><b>Mnorm</b>(<em>matrix</em>) or <b>Mnorm_2</b>(<em>matrix</em>)</p><hr/>
A = hp([1; 2; 3|4; 5; 6|7; 8; 9])
mnorm(A)' or
mnorm_2(A)'- the L2 (spectral) norm of matrix A
'<p><b>Mnorm_е</b>(<em>matrix</em>)</p><hr/>
A = hp([1; 2; 3|4; 5; 6|7; 8; 9])
mnorm_e(A)'- the Frobenius (a.k.a. Euclidean) norm of matrix A
'<p><b>Mnorm_i</b>(<em>matrix</em>)</p><hr/>
A = hp([1; 2; 3|4; 5; 6|7; 8; 9])
mnorm_i(A)'- the L∞ (infinity) norm of matrix A
'<p><b>Cond_1</b>(<em>matrix</em>)</p><hr/>
A = hp([1; 2; 3|4; 5; 6|7; 8; 9])
cond_1(A)'- condition number based on the L1 norm of matrix A
'<p><b>Cond</b>(<em>matrix</em>) or <b>Cond_2</b>(<em>matrix</em>)</p><hr/>
A = hp([1; 2; 3|4; 5; 6|7; 8; 9])
cond(A)' or
cond_2(A)'- condition number based on the L2 norm of matrix A
'<p><b>Cond_е</b>(<em>matrix</em>)</p><hr/>
A = hp([1; 2; 3|4; 5; 6|7; 8; 9])
cond_e(A)'- condition number based on the Frobenius norm of matrix A
'<p><b>Cond_i</b>(<em>matrix</em>)</p><hr/>
A = hp([1; 2; 3|4; 5; 6|7; 8; 9])
cond_i(A)'- condition number based on the L∞ norm of matrix A
'<p><b>Det</b>(<em>matrix</em>)</p><hr/>
A = hp([1; 2; 3|4; 5; 6|7; 8; 9])
det(A)'- the determinant of matrix A
'<p><b>Rank</b>(<em>matrix</em>)</p><hr/>
A = hp([1; 2; 3|4; 5; 6|7; 8; 9])
rank(A)'- the rank of matrix A
'<p><b>Trace</b>(<em>matrix</em>)</p><hr/>
A = hp([1; 2; 3|4; 5; 6|7; 8; 9])
trace(A)'- the trace of matrix A
'<p><b>Transp</b>(<em>matrix</em>)</p><hr/>
A = hp([1; 2; 3|4; 5; 6|7; 8; 9])
transp(A)'- the transpose of matrix A
'<p><b>Adj</b>(<em>matrix</em>)</p><hr/>
A = hp([1; 2|3; 4])
adj(A)'- the adjugate of matrix A
D = det(A)'- the determinant of matrix A
A_I = inverse(A)'- the inverse of matrix A
A_I*D'- the inverse multiplied by the determinant shoud give the adjugate
'<p><b>Cofactor</b>(<em>matrix</em>)</p><hr/>
A = hp([1; 2|3; 4])
C = cofactor(A)'- the cofactor of matrix A
transp(C)'- the transpose of the cofactor shoud give the adjugate'
adj(A)
'<p><b>Eigenvals</b>(<em>matrix</em>)</p><hr/>
A = copy( _
[4; 12; -16| _
12; 37; -43| _
- 16; -43; 98]; _
symmetric_hp(3); 1; 1)'- creates a symmetric matrix by copying a general initializer
eigenvals(A; 0)' - the eigenvalues of matrix A
'<p><b>Eigenvecs</b>(<em>matrix</em>)</p><hr/>
A = copy( _
[4; 12; -16| _
12; 37; -43| _
- 16; -43; 98]; _
symmetric_hp(3); 1; 1)'- creates a symmetric matrix by copying a general initializer
eigenvecs(A; 2)' - the eigenvectors of matrix A
'<p><b>Eigen</b>(<em>matrix</em>)</p><hr/>
A = copy( _
[4; 12; -16| _
12; 37; -43| _
- 16; -43; 98]; _
symmetric_hp(3); 1; 1)' creates symmetric matrix by copying a general initializer
eigen(A; 2)' - the eigenvalues (first column) and eigenvectors (other columns) of matrix A
'<p><b>Cholesky</b>(<em>matrix</em>)</p><hr/>
A = copy( _
[4; 12; -16| _
12; 37; -43| _
- 16; -43; 98]; _
symmetric_hp(3); 1; 1)'- creates a symmetric matrix by copying a general initi_hpalizer
LT = cholesky(A)'- the upper triangular matrix LT by Cholesky decomposition
L = transp(LT)'- the lower triangular matrix L
L*LT'- check: multiplying both matrices should give the original matrix
'<p><b>LU</b>(<em>matrix</em>)</p><hr/>
A = hp([4; 12; -16|12; 37; -43| - 16; -43; 98])'- creates general matrix
LU = lu(A)'- the combined matrix by LU decomposition
ind'- the index permutation vector
D = not(identity_hp(3))'- a helper matrix to remove the diagonal elements from L
L = hprod(mfill(ltriang_hp(3); 1); LU)^D'- extracts the lower triangular matrix
U = hprod(mfill(utriang_hp(3); 1); LU)'- extracts the upper triangular matrix
extract_rows(L*U; order(ind))'- check: multiplying both matrices and reordering by the permutation vector should give the original matrix
'<p><b>QR</b>(<em>matrix</em>)</p><hr/>
A = hp([4; 12; -16|12; 37; -43| - 16; -43; 98])'- creates a general matrix
QR = qr(A)'- the combined QR matrix
Q = submatrix(QR; 1; 3; 1; 3)'- extracts the Q matrix
R = submatrix(QR; 1; 3; 4; 6)'- extracts the R matrix
Q*R'- check: multiplying both matrices should give the original matrix
'<p><b>SVD</b>(<em>matrix</em>)</p><hr/>
A = hp([4; 12; -16|12; 37; -43| - 16; -43; 98])'- creates a general matrix
SVD = svd(A)'- the combined UΣV matrix, obtained by singular value decomposition
U = submatrix(SVD; 1; 3; 1; 3)'- extracts the U matrix
V = submatrix(SVD; 1; 3; 5; 7)'- extracts the V matrix
σ = col(SVD; 4)'- extracts the singular values
Σ = hp(vec2diag(σ))'- composes the singular value matrix
'Multiplying U,Σ and V may not give the original matrix A, due to the sign ambiguity problem
'<p><b>Inverse</b>(<em>matrix</em>)</p><hr/>
A = hp([4; 12; -16|12; 37; -43| - 16; -43; 98])'- creates a general matrix
B = inverse(A)'- the inverse of A
A*B'- check: multiplying both matrices should give the identity matrix
'Symmetric matrix inverse
A = copy([4; 12; -16|12; 37; -43| - 16; -43; 98]; _
symmetric_hp(3); 1; 1)'- creates a symmetric matrix
B = inverse(A)'- the inverse of A
A*B'- check: multiplying both matrices should give the identity matrix
'<p><b>Lsolve</b>(<em>matrix</em>, <em>vector</em>)</p><hr/>
A = hp([8; 6; -4|6; 12; -3| - 4; -3; 9])'- creates a general matrix
b = hp([10; 20; 30])'- the right hand side vector
x = lsolve(A; b)'- the solution vector obtained by LU (LDLT) decomposition
A*x'- check: multiplying the matrix by the solution vector should give the right hand side vector
'<p><b>Clsolve</b>(<em>matrix</em>, <em>vector</em>)</p><hr/>
A = copy([8; 6; -4|6; 12; -3| - 4; -3; 9]; _
symmetric_hp(3); 1; 1)'- creates a symmetric matrix
b = hp([10; 20; 30])'- the right hand side vector
x = clsolve(A; b)'- the solution vector obtained by Cholesky decomposition
x = slsolve(A; b)'- the solution vector obtained by PCG method
A*x'- check: multiplying the matrix by the solution vector should give the right hand side vector
'<p><b>Msolve</b>(<em>matrix</em>, <em>matrix</em>)</p><hr/>
A = hp([8; 6; -4|6; 12; -3| - 4; -3; 9])'- creates a general coefficients matrix
B = join_cols(hp([10; 20; 30]); hp([40; 50; 60]))'- the right hand side matrix
X = msolve(A; B)'- the solution matrix obtained by LU (LDLT) decomposition
A*X'- check: multiplying the coefficients matrix by the solution matrix should give the right hand side matrix
'<p><b>Cmsolve</b>(<em>matrix</em>, <em>matrix</em>)</p><hr/>
A = copy([8; 6; -4|6; 12; -3| - 4; -3; 9]; _
symmetric_hp(3); 1; 1)'- creates a symmetric coefficients matrix
B = join_cols(hp([10; 20; 30]); hp([40; 50; 60]))'- the right hand side matrix
X = cmsolve(A; B)'- the solution matrix obtained by Cholesky decomposition
X = smsolve(A; B)'- the solution matrix obtained by PCG method
A*X'- check: multiplying the coefficients matrix by the solution matrix should give the right hand side matrix
#rad
'Trigonometric:<hr/>
x = hp([0; 30; 45|60; 90; 180])*(π/180)
isHp(x)
sin(x)'- sine
cos(x)'- cosine
tan(x)'- tangent
csc(x)'- cosecant
sec(x)'- secant
cot(x)'- cotangent
'Hyperbolic:<hr/>
x = hp([-0.5; 0|0.5; 1])
sinh(x)'- hyperbolic sine
cosh(x)'- hyperbolic cosine
tanh(x)'- hyperbolic tangent
csch(x)'- hyperbolic cosecant
sech(x)'- hyperbolic secant
coth(x)'- hyperbolic cotangent
'Inverse trigonometric:<hr/>
x = hp([-0.5; 0; 0.5|sqrt(2)/2; sqrt(3)/2; 1])
y = hp([1; sqrt(3)/2; sqrt(2)/2|0.5; 0; -0.5])
asin(x)'- inverse sine
acos(x)'- inverse cosine
atan(x)'- inverse tangent
atan2(x; y)'- the angle whose tangent is the quotient of y and x
acsc(1/x)'- inverse cosecant
asec(1/x)'- inverse secant
acot(x)'- inverse cotangent
'Inverse hyperbolic:<hr/>
x = hp([1; 2|4; 8])
asinh(x)'- inverse hyperbolic sine
acosh(x)'- inverse hyperbolic cosine
atanh(x/5)'- inverse hyperbolic tangent
acsch(1/x)'- inverse hyperbolic cosecant
asech(1/x)'- inverse hyperbolic secant
acoth(5/x)'- inverse hyperbolic cotangent
'Logarithmic, exponential and roots:<hr/>
log(x)'- decimal logarithm
ln(x)'- natural logarithm
log_2(x)'- binary logarithm
exp(x)'- natural exponent = eˣ
sqr(x)'- square root
cbrt(x)'- cubic root
root(x; 3)'- n-th root
'Rounding:<hr/>
round(x)'- round to the nearest integer
floor(x)'- round to the smaller integer(towards - ∞)
ceiling(x)'- round to the greater integer(towards + ∞)
trunc(x)'- round to the smaller integer(towards zero)
'Integer:<hr/>
x
y = x + 2
mod(x; y)'- the remainder of an integer division
gcd(y)'- the greatest common divisor of several integers
lcm(y)'- the least common multiple of several integers
'Aggregate and interpolation:<hr />
A = hp([0; 2; 4|6; 8; 12])
b = hp([5; 3; 1])
min(A)'- minimum of multiple values
max(A)'- maximum of multiple values
sum(A)'- sum of multiple values
sumsq(A)'- sum of squares
srss(A)'- square root of sum of squares
average(A)'- average of multiple values
product(A)'- product of multiple values
mean(A)'- geometric mean
take(5; A)'- the 5-th element from the matrix, linearized to list by rows
line(5.5; A)'- linear interpolation along the linearized matrix
spline(5.5; A)'- Hermite spline interpolation along the linearized matrix
take(2; 2; A)'- the element on row 2 and column 2
line(1.5; 2.5; A)'- double linear interpolation
spline(1.5; 2.5; A)'- double Hermite spline interpolation
Hprod(first matrix; second matrix)
A = hp ( [1; 2 | 3; 4 | 5; 6] ) = 12 34 56 - first matrix
B = hp ( [9; 8 | 7; 6 | 5; 4] ) = 98 76 54 - second matrix
C = hprod ( A; B ) = 916 2124 2524 - The Hadamard product of matrices A and B
Fprod(first matrix; second matrix)
A = hp ( [1; 2 | 3; 4 | 5; 6] ) = 12 34 56 - first matrix
B = hp ( [9; 8 | 7; 6 | 5; 4] ) = 98 76 54 - second matrix
C = fprod ( A; B ) = 119 - the Frobenius product of matrices A and B
Kprod(first matrix; second matrix)
A = hp ( [1; 2 | 3; 4] ) = 12 34 - first matrix
B = hp ( [5; 6; 7 | 8; 9; 10] ) = 567 8910 - second matrix
C = kprod ( A; B ) = 567101214 8910161820 151821202428 242730323640 - the Kronecker product of matrices A and B
Mnorm_1(matrix)
A = hp ( [1; 2; 3 | 4; 5; 6 | 7; 8; 9] ) = 123 456 789
mnorm1 ( A ) = 18 - the L1 (Manhattan or taxicab) norm of matrix A
Mnorm(matrix) or Mnorm_2(matrix)
A = hp ( [1; 2; 3 | 4; 5; 6 | 7; 8; 9] ) = 123 456 789
mnorm ( A ) = 16.85 or
mnorm2 ( A ) = 16.85 - the L2 (spectral) norm of matrix A
Mnorm_е(matrix)
A = hp ( [1; 2; 3 | 4; 5; 6 | 7; 8; 9] ) = 123 456 789
mnorme ( A ) = 16.88 - the Frobenius (a.k.a. Euclidean) norm of matrix A
Mnorm_i(matrix)
A = hp ( [1; 2; 3 | 4; 5; 6 | 7; 8; 9] ) = 123 456 789
mnormi ( A ) = 24 - the L∞ (infinity) norm of matrix A
Cond_1(matrix)
A = hp ( [1; 2; 3 | 4; 5; 6 | 7; 8; 9] ) = 123 456 789
cond1 ( A ) = +∞ - condition number based on the L1 norm of matrix A
Cond(matrix) or Cond_2(matrix)
A = hp ( [1; 2; 3 | 4; 5; 6 | 7; 8; 9] ) = 123 456 789
cond ( A ) = 3.43×1017 or
cond2 ( A ) = 3.43×1017 - condition number based on the L2 norm of matrix A
Cond_е(matrix)
A = hp ( [1; 2; 3 | 4; 5; 6 | 7; 8; 9] ) = 123 456 789
conde ( A ) = +∞ - condition number based on the Frobenius norm of matrix A
Cond_i(matrix)
A = hp ( [1; 2; 3 | 4; 5; 6 | 7; 8; 9] ) = 123 456 789
condi ( A ) = +∞ - condition number based on the L∞ norm of matrix A
Det(matrix)
A = hp ( [1; 2; 3 | 4; 5; 6 | 7; 8; 9] ) = 123 456 789
det ( A ) = 0 - the determinant of matrix A
Rank(matrix)
A = hp ( [1; 2; 3 | 4; 5; 6 | 7; 8; 9] ) = 123 456 789
rank ( A ) = 2 - the rank of matrix A
Trace(matrix)
A = hp ( [1; 2; 3 | 4; 5; 6 | 7; 8; 9] ) = 123 456 789
trace ( A ) = 15 - the trace of matrix A
Transp(matrix)
A = hp ( [1; 2; 3 | 4; 5; 6 | 7; 8; 9] ) = 123 456 789
transp ( A ) = 147 258 369 - the transpose of matrix A
Adj(matrix)
A = hp ( [1; 2 | 3; 4] ) = 12 34
adj ( A ) = 4-2 -31 - the adjugate of matrix A
D = det ( A ) = -2 - the determinant of matrix A
AI = inverse ( A ) = -21 1.5-0.5 - the inverse of matrix A
AI · D = AI · ( -2 ) = 4-2 -31 - the inverse multiplied by the determinant shoud give the adjugate
Cofactor(matrix)
A = hp ( [1; 2 | 3; 4] ) = 12 34
C = cofactor ( A ) = 4-3 -21 - the cofactor of matrix A
transp ( C ) = 4-2 -31 - the transpose of the cofactor shoud give the adjugate
adj ( A ) = 4-2 -31
Eigenvals(matrix)
A = copy ( [4; 12; -16 | 12; 37; -43 | -16; -43; 98]; symmetrichp ( 3 ) ; 1; 1 ) = 412-16 1237-43 -16-4398 - creates a symmetric matrix by copying a general initializer
eigenvals ( A; 0 ) = [0.0188 15.5 123.48] - the eigenvalues of matrix A
Eigenvecs(matrix)
A = copy ( [4; 12; -16 | 12; 37; -43 | -16; -43; 98]; symmetrichp ( 3 ) ; 1; 1 ) = 412-16 1237-43 -16-4398 - creates a symmetric matrix by copying a general initializer
eigenvecs ( A; 2 ) = 0.963-0.2650.0411 -0.213-0.849-0.484 - the eigenvectors of matrix A
Eigen(matrix)
A = copy ( [4; 12; -16 | 12; 37; -43 | -16; -43; 98]; symmetrichp ( 3 ) ; 1; 1 ) = 412-16 1237-43 -16-4398 creates symmetric matrix by copying a general initializer
eigen ( A; 2 ) = 0.01880.963-0.2650.0411 15.5-0.213-0.849-0.484 - the eigenvalues (first column) and eigenvectors (other columns) of matrix A
Cholesky(matrix)
A = copy ( [4; 12; -16 | 12; 37; -43 | -16; -43; 98]; symmetrichp ( 3 ) ; 1; 1 ) = 412-16 1237-43 -16-4398 - creates a symmetric matrix by copying a general initi_hpalizer
LT = cholesky ( A ) = 26-8 015 003 - the upper triangular matrix LT by Cholesky decomposition
L = transp ( LT ) = 200 610 -853 - the lower triangular matrix L
L · LT = 412-16 1237-43 -16-4398 - check: multiplying both matrices should give the original matrix
LU(matrix)
A = hp ( [4; 12; -16 | 12; 37; -43 | -16; -43; 98] ) = 412-16 1237-43 -16-4398 - creates general matrix
LU = lu ( A ) = 1237-43 -1.336.3340.67 0.333-0.05260.474 - the combined matrix by LU decomposition
⃗ind = [1 2 0] - the index permutation vector
D = not ( identityhp ( 3 ) ) = 011 101 110 - a helper matrix to remove the diagonal elements from L
L = hprod ( mfill ( ltrianghp ( 3 ) ; 1 ) ; LU ) D = 100 -1.3310 0.333-0.05261 - extracts the lower triangular matrix
U = hprod ( mfill ( utrianghp ( 3 ) ; 1 ) ; LU ) = 1237-43 06.3340.67 000.474 - extracts the upper triangular matrix
extractrows ( L · U; order ( ⃗ind ) ) = 412-16 1237-43 -16-4398 - check: multiplying both matrices and reordering by the permutation vector should give the original matrix
QR(matrix)
A = hp ( [4; 12; -16 | 12; 37; -43 | -16; -43; 98] ) = 412-16 1237-43 -16-4398 - creates a general matrix
QR = qr ( A ) = -0.196-0.169-0.966-20.4-57.85105.31 -0.588-0.7680.2540-3.86-24.85 0.784-0.618-0.050800-0.457 - the combined QR matrix
Q = submatrix ( QR; 1; 3; 1; 3 ) = -0.196-0.169-0.966 -0.588-0.7680.254 0.784-0.618-0.0508 - extracts the Q matrix
R = submatrix ( QR; 1; 3; 4; 6 ) = -20.4-57.85105.31 0-3.86-24.85 00-0.457 - extracts the R matrix
Q · R = 412-16 1237-43 -16-4398 - check: multiplying both matrices should give the original matrix
SVD(matrix)
A = hp ( [4; 12; -16 | 12; 37; -43 | -16; -43; 98] ) = 412-16 1237-43 -16-4398 - creates a general matrix
SVD = svd ( A ) = -0.1630.213-0.963123.48-0.163-0.4570.874 -0.4570.8490.26515.50.2130.8490.484 0.8740.484-0.04110.0188-0.9630.265-0.0411 - the combined UΣV matrix, obtained by singular value decomposition
U = submatrix ( SVD; 1; 3; 1; 3 ) = -0.1630.213-0.963 -0.4570.8490.265 0.8740.484-0.0411 - extracts the U matrix
V = submatrix ( SVD; 1; 3; 5; 7 ) = -0.163-0.4570.874 0.2130.8490.484 -0.9630.265-0.0411 - extracts the V matrix
⃗σ = col ( SVD; 4 ) = [123.48 15.5 0.0188] - extracts the singular values
Σ = hp ( vec2diag ( ⃗σ ) ) = 123.4800 015.50 000.0188 - composes the singular value matrix
Multiplying U,Σ and V may not give the original matrix A, due to the sign ambiguity problem
Inverse(matrix)
A = hp ( [4; 12; -16 | 12; 37; -43 | -16; -43; 98] ) = 412-16 1237-43 -16-4398 - creates a general matrix
B = inverse ( A ) = 49.36-13.562.11 -13.563.78-0.556 2.11-0.5560.111 - the inverse of A
A · B = 100 -4.26×10-1410 01.42×10-141 - check: multiplying both matrices should give the identity matrix
Symmetric matrix inverse
A = copy ( [4; 12; -16 | 12; 37; -43 | -16; -43; 98]; symmetrichp ( 3 ) ; 1; 1 ) = 412-16 1237-43 -16-4398 - creates a symmetric matrix
B = inverse ( A ) = 49.36-13.562.11 -13.563.78-0.556 2.11-0.5560.111 - the inverse of A
A · B = 100 -1.14×10-1310 1.14×10-1301 - check: multiplying both matrices should give the identity matrix
Lsolve(matrix, vector)
A = hp ( [8; 6; -4 | 6; 12; -3 | -4; -3; 9] ) = 86-4 612-3 -4-39 - creates a general matrix
⃗b = hp ( [10; 20; 30] ) = [10 20 30] - the right hand side vector
⃗x = lsolve ( A; ⃗b ) = [2.5 1.67 5] - the solution vector obtained by LU (LDLT) decomposition
A · ⃗x = [10 20 30] - check: multiplying the matrix by the solution vector should give the right hand side vector
Clsolve(matrix, vector)
A = copy ( [8; 6; -4 | 6; 12; -3 | -4; -3; 9]; symmetrichp ( 3 ) ; 1; 1 ) = 86-4 612-3 -4-39 - creates a symmetric matrix
⃗b = hp ( [10; 20; 30] ) = [10 20 30] - the right hand side vector
⃗x = clsolve ( A; ⃗b ) = [2.5 1.67 5] - the solution vector obtained by Cholesky decomposition
⃗x = slsolve ( A; ⃗b ) = [2.5 1.67 5] - the solution vector obtained by PCG method
A · ⃗x = [10 20 30] - check: multiplying the matrix by the solution vector should give the right hand side vector
Msolve(matrix, matrix)
A = hp ( [8; 6; -4 | 6; 12; -3 | -4; -3; 9] ) = 86-4 612-3 -4-39 - creates a general coefficients matrix
B = joincols ( hp ( [10; 20; 30] ) ; hp ( [40; 50; 60] ) ) = 1040 2050 3060 - the right hand side matrix
X = msolve ( A; B ) = 2.58.71 1.672.67 511.43 - the solution matrix obtained by LU (LDLT) decomposition
A · X = 1040 2050 3060 - check: multiplying the coefficients matrix by the solution matrix should give the right hand side matrix
Cmsolve(matrix, matrix)
A = copy ( [8; 6; -4 | 6; 12; -3 | -4; -3; 9]; symmetrichp ( 3 ) ; 1; 1 ) = 86-4 612-3 -4-39 - creates a symmetric coefficients matrix
B = joincols ( hp ( [10; 20; 30] ) ; hp ( [40; 50; 60] ) ) = 1040 2050 3060 - the right hand side matrix
X = cmsolve ( A; B ) = 2.58.71 1.672.67 511.43 - the solution matrix obtained by Cholesky decomposition
X = smsolve ( A; B ) = 2.58.71 1.672.67 511.43 - the solution matrix obtained by PCG method
A · X = 1040 2050 3060 - check: multiplying the coefficients matrix by the solution matrix should give the right hand side matrix
Trigonometric:
x = hp ( [0; 30; 45 | 60; 90; 180] ) · π180 = hp ( [0; 30; 45 | 60; 90; 180] ) · 3.14180 = 00.5240.785 1.051.573.14
isHp ( x ) = 1
sin ( x ) = 00.50.707 0.86610 - sine
cos ( x ) = 10.8660.707 0.50-1 - cosine
tan ( x ) = 00.5771 1.731.63×10160 - tangent
csc ( x ) = +∞21.41 1.1518165619676597685 - cosecant
sec ( x ) = 11.151.41 21.63×1016-1 - secant
cot ( x ) = +∞1.731 0.5770-8165619676597685 - cotangent
Hyperbolic:
x = hp ( [-0.5; 0 | 0.5; 1] ) = -0.50 0.51
sinh ( x ) = -0.5210 0.5211.18 - hyperbolic sine
cosh ( x ) = 1.131 1.131.54 - hyperbolic cosine
tanh ( x ) = -0.4620 0.4620.762 - hyperbolic tangent
csch ( x ) = -1.92+∞ 1.920.851 - hyperbolic cosecant
sech ( x ) = 0.8871 0.8870.648 - hyperbolic secant
coth ( x ) = -2.16+∞ 2.161.31 - hyperbolic cotangent
Inverse trigonometric:
x = hp([-0.5; 0; 0.5 |   √ 22;   √ 32; 1]) = -0.500.5 0.7070.8661
y = hp([1;   √ 32;   √ 22 | 0.5; 0; -0.5]) = 10.8660.707 0.50-0.5
asin ( x ) = -0.52400.524 0.7851.051.57 - inverse sine
acos ( x ) = 2.091.571.05 0.7850.5240 - inverse cosine
atan ( x ) = -0.46400.464 0.6150.7140.785 - inverse tangent
atan2 ( x; y ) = 2.031.570.955 0.6150-0.464 - the angle whose tangent is the quotient of y and x
acsc(1x) = -0.52400.524 0.7851.051.57 - inverse cosecant
asec(1x) = 2.091.571.05 0.7850.5240 - inverse secant
acot ( x ) = -1.111.571.11 0.9550.8570.785 - inverse cotangent
Inverse hyperbolic:
x = hp ( [1; 2 | 4; 8] ) = 12 48
asinh ( x ) = 0.8811.44 2.092.78 - inverse hyperbolic sine
acosh ( x ) = 01.32 2.062.77 - inverse hyperbolic cosine
atanh(x5) = 0.2030.424 1.1 Undefined - inverse hyperbolic tangent
acsch(1x) = 0.8811.44 2.092.78 - inverse hyperbolic cosecant
asech(1x) = 01.32 2.062.77 - inverse hyperbolic secant
acoth(5x) = 0.2030.424 1.1 Undefined - inverse hyperbolic cotangent
Logarithmic, exponential and roots:
log ( x ) = 00.301 0.6020.903 - decimal logarithm
ln ( x ) = 00.693 1.392.08 - natural logarithm
log2 ( x ) = 01 23 - binary logarithm
exp ( x ) = 2.727.39 54.62980.96 - natural exponent = eˣ
  √ x = 11.41 22.83 - square root
 3  √ x = 11.26 1.592 - cubic root
 3  √ x = 11.26 1.592 - n-th root
Rounding:
round ( x ) = 12 48 - round to the nearest integer
floor ( x ) = 12 48 - round to the smaller integer(towards - ∞)
ceiling ( x ) = 12 48 - round to the greater integer(towards + ∞)
trunc ( x ) = 12 48 - round to the smaller integer(towards zero)
Integer:
x = 12 48
y = x + 2 = 34 610
mod ( x; y ) = 12 48 - the remainder of an integer division
gcd ( y ) = 1 - the greatest common divisor of several integers
lcm ( y ) = 60 - the least common multiple of several integers
Aggregate and interpolation:
A = hp ( [0; 2; 4 | 6; 8; 12] ) = 024 6812
⃗b = hp ( [5; 3; 1] ) = [5 3 1]
min ( A ) = 0 - minimum of multiple values
max ( A ) = 12 - maximum of multiple values
sum ( A ) = 32 - sum of multiple values
sumsq ( A ) = 264 - sum of squares
srss ( A ) = 16.25 - square root of sum of squares
average ( A ) = 5.33 - average of multiple values
product ( A ) = 0 - product of multiple values
mean ( A ) = 0 - geometric mean
take ( 5; A ) = 8 - the 5-th element from the matrix, linearized to list by rows
line ( 5.5; A ) = 10 - linear interpolation along the linearized matrix
spline ( 5.5; A ) = 9.81 - Hermite spline interpolation along the linearized matrix
take ( 2; 2; A ) = 8 - the element on row 2 and column 2
line ( 1.5; 2.5; A ) = 6.5 - double linear interpolation
spline ( 1.5; 2.5; A ) = 6.41 - double Hermite spline interpolation
Matrix Structural Functions¶
HP variant of the structural toolkit: \(n_{rows}\), \(n_{cols}\), resize, join, reshape and submatrix helpers on packed storage, with in-place semantics where possible.
'<style>em {font-family:"Times New Roman";}</style>
'<p><b>N_Rows</b>(<em>matrix</em>)</p><hr/>
A = hp([1; 2|3; 4|5; 6])
n_rows(A)'- the number of rows in A
'<p><b>N_Cols</b>(<em>matrix</em>)</p><hr/>
A = hp([1|2; 3|4; 5; 6])
n_cols(A)'- the number of columns in A
'<p><b>Mresize</b>(<em>matrix</em>; <em>m</em>; <em>n</em>)</p><hr/>
A = hp([1; 2; 3|4; 5; 6|7; 8; 9])'- creates a general type matrix
B = mresize(A; 2; 4)'- resizes to a general type as well 'isHp(B)
A'- the original matrix has changed
A = diagonal_hp(3; 5)'- creates a diagonal type matrix
B = mresize(A; 2; 4)'- resizes to a general type
A'- the original matrix remains unchanged
'<p><b>Mfill</b>(<em>matrix</em>; <em>value</em>)</p><hr/>
A = matrix_hp(2; 3)'- creates an empty matrix A
B = mfill(A; 1)'- fills A with ones and assigns the result to B
B.(1; 2) = 2'- changes a single value in B which references A
A'- A has also changed
L = mfill(ltriang_hp(4); 2)'- special matrices are filled only inside the designated area
'<p><b>Fill_Row</b>(<em>matrix</em>; <em>row index</em>; <em>value</em>)</p><hr/>
A = matrix_hp(3; 4)'- creates a general matrix
fill_row(A; 2; 1)'- fills the 2-nd row with value of 1
L = utriang_hp(4)' - creates an upper triangular matrix
$Repeat{fill_row(L; k; k) @ k = 1 : n_rows(L)}' - fills all rows
L' - only the designated area to the type (the upper triangle) is filled
'<p><b>Fill_Col</b>(<em>matrix</em>; <em>column index</em>; <em>value</em>)</p><hr/>
A = matrix_hp(3; 4)'- creates a general matrix
fill_col(A; 2; 1)'- fills the 2nd column with value of 1
B = symmetric_hp(4)'- creates a symmetric matrix
fill_col(B; 2; 1)' - the respective row is also filled to preserve symmetry
'<p><b>Copy</b>(<em>source matrix</em>; <em>target matrix</em>; <em>row index</em>; <em>column index</em>)</p><hr/>
A = hp([1; 2; 3|4; 5; 6])'- creates a 2x3 rectangular source matrix
B = mfill(matrix_hp(3; 4); -1)'- creates a 3x4 rectangular target matrix and fills it with -1
copy(A; B; 1; 1)'- copies A to B at indexes (1,1) of B
copy(A; B; 2; 2)'- copies A to B at indexes (2,2) of B
B'- the obtained target matrix
'<p><b>Add</b>(<em>source matrix</em>; <em>target matrix</em>; <em>row index</em>; <em>column index</em>)</p><hr/>
A = hp([1; 2; 3|4; 5; 6])'- creates a 2x3 rectangular source matrix
B = mfill(matrix_hp(3; 4); -1)'- creates a 3x4 rectangular target matrix and fills it with -1
add(A; B; 1; 1)'- adds A to B at indexes (1,1) of B
add(A; B; 2; 2)'- adds A to B at indexes (2,2) of B
B'- the obtained target matrix
'<p><b>Row</b>(<em>matrix</em>; <em>row index</em>)</p><hr/>
A = hp([1; 2; 3|4; 5; 6|7; 8; 9])'- creates a 3x3 general matrix
row(A; 3)'- extracts the 3-rd row into a new vector
'<p><b>Col</b>(<em>matrix</em>; <em>column index</em>)</p><hr/>
A = hp([1; 2; 3|4; 5; 6|7; 8; 9])'- creates a 3x3 general matrix
col(A; 2)'- extracts the 2-nd column into a new vector
'<p><b>Extract_Rows</b>(<em>matrix</em>; <em>row indexes vector</em>)</p><hr/>
A = hp([1; 2; 3|4; 5; 6|7; 8; 9])'- creates a 3x3 general matrix
extract_rows(A; [1; 2; 1])'- extracts rows 1, 2 and 1 into a new matrix
'<p><b>Extract_Cols</b>(<em>matrix</em>; <em>column index vector</em>)</p><hr/>
A = hp([1; 2; 3|4; 5; 6|7; 8; 9])'- creates a 3x3 general matrix
extract_cols(A; [3; 2; 1])'- extracts columns 3, 2 and 1 into a new matrix
'<p><b>Diag2vec</b>(<em>matrix</em>)</p><hr/>
A = hp([1; 2|3; 4|5; 6; 7|8; 9; 10])'- creates a 4x3 rectangular matrix
diag2vec(A)'- extracts the elements along the main diagonal into a new vector
'<p><b>Submatrix</b>(<em>matrix</em>; <em>start row</em>; <em>end row</em>; <em>start column</em>; <em>end column</em>)</p><hr/>
A = hp([1; 2; 3; 4| _
5; 6; 7; 8| _
9; 10; 11; 12| _
13; 14; 15; 16])'- creates a 4x4 general matrix
submatrix(A; 2; 3; 2; 4)'- extracts the values between rows 2 and 3 and between columns 2 and 4 into a new matrix
N_Rows(matrix)
A = hp ( [1; 2 | 3; 4 | 5; 6] ) = 12 34 56
nrows ( A ) = 3 - the number of rows in A
N_Cols(matrix)
A = hp ( [1 | 2; 3 | 4; 5; 6] ) = 100 230 456
ncols ( A ) = 3 - the number of columns in A
Mresize(matrix; m; n)
A = hp ( [1; 2; 3 | 4; 5; 6 | 7; 8; 9] ) = 123 456 789 - creates a general type matrix
B = mresize ( A; 2; 4 ) = 1230 4560 - resizes to a general type as well isHp ( B ) = 1
A = 1230 4560 - the original matrix has changed
A = diagonalhp ( 3; 5 ) = 500 050 005 - creates a diagonal type matrix
B = mresize ( A; 2; 4 ) = 500 050 005 - resizes to a general type
A = 500 050 005 - the original matrix remains unchanged
Mfill(matrix; value)
A = matrixhp ( 2; 3 ) = 000 000 - creates an empty matrix A
B = mfill ( A; 1 ) = 111 111 - fills A with ones and assigns the result to B
B1,2 = 2 - changes a single value in B which references A
A = 121 111 - A has also changed
L = mfill ( ltrianghp ( 4 ) ; 2 ) = 2000 2200 2220 2222 - special matrices are filled only inside the designated area
Fill_Row(matrix; row index; value)
A = matrixhp ( 3; 4 ) = 0000 0000 0000 - creates a general matrix
fillrow ( A; 2; 1 ) = 0000 1111 0000 - fills the 2-nd row with value of 1
L = utrianghp ( 4 ) = 0000 0000 0000 0000 - creates an upper triangular matrix
$Repeat{fillrow ( L; k; k ) for k = 1...nrows ( L ) } = 1111 0222 0033 0004 - fills all rows
L = 1111 0222 0033 0004 - only the designated area to the type (the upper triangle) is filled
Fill_Col(matrix; column index; value)
A = matrixhp ( 3; 4 ) = 0000 0000 0000 - creates a general matrix
fillcol ( A; 2; 1 ) = 0100 0100 0100 - fills the 2nd column with value of 1
B = symmetrichp ( 4 ) = 0000 0000 0000 0000 - creates a symmetric matrix
fillcol ( B; 2; 1 ) = 0000 0111 0100 0100 - the respective row is also filled to preserve symmetry
Copy(source matrix; target matrix; row index; column index)
A = hp ( [1; 2; 3 | 4; 5; 6] ) = 123 456 - creates a 2x3 rectangular source matrix
B = mfill ( matrixhp ( 3; 4 ) ; -1 ) = -1-1-1-1 -1-1-1-1 -1-1-1-1 - creates a 3x4 rectangular target matrix and fills it with -1
copy ( A; B; 1; 1 ) = 123-1 456-1 -1-1-1-1 - copies A to B at indexes (1,1) of B
copy ( A; B; 2; 2 ) = 123-1 4123 -1456 - copies A to B at indexes (2,2) of B
B = 123-1 4123 -1456 - the obtained target matrix
Add(source matrix; target matrix; row index; column index)
A = hp ( [1; 2; 3 | 4; 5; 6] ) = 123 456 - creates a 2x3 rectangular source matrix
B = mfill ( matrixhp ( 3; 4 ) ; -1 ) = -1-1-1-1 -1-1-1-1 -1-1-1-1 - creates a 3x4 rectangular target matrix and fills it with -1
add ( A; B; 1; 1 ) = 012-1 345-1 -1-1-1-1 - adds A to B at indexes (1,1) of B
add ( A; B; 2; 2 ) = 012-1 3572 -1345 - adds A to B at indexes (2,2) of B
B = 012-1 3572 -1345 - the obtained target matrix
Row(matrix; row index)
A = hp ( [1; 2; 3 | 4; 5; 6 | 7; 8; 9] ) = 123 456 789 - creates a 3x3 general matrix
row ( A; 3 ) = [7 8 9] - extracts the 3-rd row into a new vector
Col(matrix; column index)
A = hp ( [1; 2; 3 | 4; 5; 6 | 7; 8; 9] ) = 123 456 789 - creates a 3x3 general matrix
col ( A; 2 ) = [2 5 8] - extracts the 2-nd column into a new vector
Extract_Rows(matrix; row indexes vector)
A = hp ( [1; 2; 3 | 4; 5; 6 | 7; 8; 9] ) = 123 456 789 - creates a 3x3 general matrix
extractrows ( A; [1; 2; 1] ) = 123 456 123 - extracts rows 1, 2 and 1 into a new matrix
Extract_Cols(matrix; column index vector)
A = hp ( [1; 2; 3 | 4; 5; 6 | 7; 8; 9] ) = 123 456 789 - creates a 3x3 general matrix
extractcols ( A; [3; 2; 1] ) = 321 654 987 - extracts columns 3, 2 and 1 into a new matrix
Diag2vec(matrix)
A = hp ( [1; 2 | 3; 4 | 5; 6; 7 | 8; 9; 10] ) = 120 340 567 8910 - creates a 4x3 rectangular matrix
diag2vec ( A ) = [1 4 7] - extracts the elements along the main diagonal into a new vector
Submatrix(matrix; start row; end row; start column; end column)
A = hp ( [1; 2; 3; 4 | 5; 6; 7; 8 | 9; 10; 11; 12 | 13; 14; 15; 16] ) = 1234 5678 9101112 13141516 - creates a 4x4 general matrix
submatrix ( A; 2; 3; 2; 4 ) = 678 101112 - extracts the values between rows 2 and 3 and between columns 2 and 4 into a new matrix
Matrix Operators¶
HP variant of the matrix operators: element-wise vs. algebraic multiplication, comparison and logical operators broadcasting across packed storage.
'<h4>Matrix-matrix</h4>
A = hp([0; 1; 2|3; 4; 5])', 'B = hp([11; 10; 9|8; 7; 6])
'Arithmetic:
A!'- factorial
A^B'- exponentiation
A/B'- floating point division
A\B'- integer division
A÷B'- division bar
A⦼B'- modulo(⦼, remainder)
hprod(A; B)'- element-wise multiplication
A - B'- subtraction
A + B'- addition
'Relational (comparison):
A ≡ B'- equal to
A ≠ B'- unequal to
A < B'- less then
A > B'- greater than
A ≤ B'- less or equal
A ≥ B'- greater or equal
'Logical:
A ∧ B'- logical "and"
A ∨ B'- logical "or"
A ⊕ B'- logical "xor"
'Matrix multiplication
A = hp([1; 2; 3|4; 5; 6])
B = hp([6; 5|4; 3|2; 1])
A*B
'<h4>Matrix-vector</h4>
A = hp([0|1|2|3|4|5])', 'b = hp([11; 10; 9; 8; 7; 6])
'Arithmetic:
A^b'- exponentiation
A/b'- floating point division
A\b'- integer division
A÷b'- division bar
A⦼b'- modulo(⦼, remainder)
hprod(A; b)'- element-wise multiplication
A - b'- subtraction
A + b'- addition
'Relational (comparison):
A ≡ b'- equal to
A ≠ b'- unequal to
A < b'- less then
A > b'- greater than
A ≤ b'- less or equal
A ≥ b'- greater or equal
'Logical:
A ∧ b'- logical "and"
A ∨ b'- logical "or"
A ⊕ b'- logical "xor"
'Matrix multiplication
A*transp(b)
transp(A)*b
'<h4>Vector-matrix</h4>
a = hp([0; 1; 2; 3; 4; 5])', 'B = hp([11|10|9|8|7|6])
'Arithmetic:
a^B'- exponentiation
a/B'- floating point division
a\B'- integer division
a÷B'- division bar
a⦼B'- modulo(⦼, remainder)
hprod(a; b)'- element-wise multiplication
a - B'- subtraction
a + B'- addition
'Relational (comparison):
a ≡ B'- equal to
a ≠ B'- unequal to
a < B'- less then
a > B'- greater than
a ≤ B'- less or equal
a ≥ B'- greater or equal
'Logical:
a ∧ B'- logical "and"
a ∨ B'- logical "or"
a ⊕ B'- logical "xor"
'Matrix multiplication
a*transp(b)
transp(a)*b
'<h4>Matrix-scalar</h4>
A = hp([0; 1; 2|3; 4; 5])', 'b = 2
'Arithmetic:
A^2'- exponentiation
A/2'- floating point division
A\2'- integer division
A÷2'- division bar
A⦼2'- modulo(⦼, remainder)
A - 2'- subtraction
A + 2'- addition
'Relational (comparison):
A ≡ 2'- equal to
A ≠ 2'- unequal to
A < 2'- less then
A > 2'- greater than
A ≤ 2'- less or equal
A ≥ 2'- greater or equal
'Logical:
A ∧ 2'- logical "and"
A ∨ 2'- logical "or"
A ⊕ 2'- logical "xor"
'<h4>Scalar-matrix</h4>
a = 2', 'B = hp([11; 10; 9|8; 7; 6])
'Arithmetic:
2^B'-exponentiation
2/B'- floating point division
2\B'- integer division
2÷B'- division bar
2⦼B'- modulo(⦼, remainder)
2*B'- multiplication
2 - B'- subtraction
2 + B'- addition
'Relational (comparison):
2 ≡ B'- equal to
2 ≠ B'- unequal to
2 < B'- less then
2 > B'- greater than
2 ≤ B'- less or equal
2 ≥ B'- greater or equal
'Logical:
2 ∧ B'- logical "and"
2 ∨ B'- logical "or
2 ⊕ B'- logical "xor"
A = hp ( [0; 1; 2 | 3; 4; 5] ) = 012 345 , B = hp ( [11; 10; 9 | 8; 7; 6] ) = 11109 876
Arithmetic:
A! = 112 624120 - factorial
A⊙ B = 01512 65611638415625 - exponentiation
AB = 00.10.222 0.3750.5710.833 - floating point division
A\B = 000 000 - integer division
A / B = 00.10.222 0.3750.5710.833 - division bar
A mod B = 012 345 - modulo(⦼, remainder)
hprod ( A; B ) = 01018 242830 - element-wise multiplication
A − B = -11-9-7 -5-3-1 - subtraction
A + B = 111111 111111 - addition
Relational (comparison):
A ≡ B = 000 000 - equal to
A ≠ B = 111 111 - unequal to
A < B = 111 111 - less then
A > B = 000 000 - greater than
A ≤ B = 111 111 - less or equal
A ≥ B = 000 000 - greater or equal
Logical:
A and B = 011 111 - logical "and"
A or B = 111 111 - logical "or"
A xor B = 100 000 - logical "xor"
Matrix multiplication
A = hp ( [1; 2; 3 | 4; 5; 6] ) = 123 456
B = hp ( [6; 5 | 4; 3 | 2; 1] ) = 65 43 21
A · B = 2014 5641
A = hp ( [0 | 1 | 2 | 3 | 4 | 5] ) = 0 1 2 3 4 5 , ⃗b = hp ( [11; 10; 9; 8; 7; 6] ) = [11 10 9 8 7 6]
Arithmetic:
A⊙ ⃗b = 0 1 512 6561 16384 15625 - exponentiation
A⃗b = 0 0.1 0.222 0.375 0.571 0.833 - floating point division
A\⃗b = 0 0 0 0 0 0 - integer division
A / ⃗b = 0 0.1 0.222 0.375 0.571 0.833 - division bar
A mod ⃗b = 0 1 2 3 4 5 - modulo(⦼, remainder)
hprod ( A; ⃗b ) = 0 10 18 24 28 30 - element-wise multiplication
A − ⃗b = -11 -9 -7 -5 -3 -1 - subtraction
A + ⃗b = 11 11 11 11 11 11 - addition
Relational (comparison):
A ≡ ⃗b = 0 0 0 0 0 0 - equal to
A ≠ ⃗b = 1 1 1 1 1 1 - unequal to
A < ⃗b = 1 1 1 1 1 1 - less then
A > ⃗b = 0 0 0 0 0 0 - greater than
A ≤ ⃗b = 1 1 1 1 1 1 - less or equal
A ≥ ⃗b = 0 0 0 0 0 0 - greater or equal
Logical:
A and ⃗b = 0 1 1 1 1 1 - logical "and"
A or ⃗b = 1 1 1 1 1 1 - logical "or"
A xor ⃗b = 1 0 0 0 0 0 - logical "xor"
Matrix multiplication
A · transp ( ⃗b ) = 000000 11109876 222018161412 333027242118 444036322824 555045403530
transp ( A ) · ⃗b = 110
⃗a = hp ( [0; 1; 2; 3; 4; 5] ) = [0 1 2 3 4 5] , B = hp ( [11 | 10 | 9 | 8 | 7 | 6] ) = 11 10 9 8 7 6
Arithmetic:
⃗a⊙ B = 0 1 512 6561 16384 15625 - exponentiation
⃗aB = 0 0.1 0.222 0.375 0.571 0.833 - floating point division
⃗a\B = 0 0 0 0 0 0 - integer division
⃗a / B = 0 0.1 0.222 0.375 0.571 0.833 - division bar
⃗a mod B = 0 1 2 3 4 5 - modulo(⦼, remainder)
hprod ( ⃗a; ⃗b ) = 0 10 18 24 28 30 - element-wise multiplication
⃗a − B = -11 -9 -7 -5 -3 -1 - subtraction
⃗a + B = 11 11 11 11 11 11 - addition
Relational (comparison):
⃗a ≡ B = 0 0 0 0 0 0 - equal to
⃗a ≠ B = 1 1 1 1 1 1 - unequal to
⃗a < B = 1 1 1 1 1 1 - less then
⃗a > B = 0 0 0 0 0 0 - greater than
⃗a ≤ B = 1 1 1 1 1 1 - less or equal
⃗a ≥ B = 0 0 0 0 0 0 - greater or equal
Logical:
⃗a and B = 0 1 1 1 1 1 - logical "and"
⃗a or B = 1 1 1 1 1 1 - logical "or"
⃗a xor B = 1 0 0 0 0 0 - logical "xor"
Matrix multiplication
⃗a · transp ( ⃗b ) = 000000 11109876 222018161412 333027242118 444036322824 555045403530
transp ( ⃗a ) · ⃗b = 110
A = hp ( [0; 1; 2 | 3; 4; 5] ) = 012 345 , b = 2
Arithmetic:
A⊙ 2 = 014 91625 - exponentiation
A2 = 00.51 1.522.5 - floating point division
A\2 = 001 122 - integer division
A / 2 = 00.51 1.522.5 - division bar
A mod 2 = 010 101 - modulo(⦼, remainder)
A − 2 = -2-10 123 - subtraction
A + 2 = 234 567 - addition
Relational (comparison):
A ≡ 2 = 001 000 - equal to
A ≠ 2 = 110 111 - unequal to
A < 2 = 110 000 - less then
A > 2 = 000 111 - greater than
A ≤ 2 = 111 000 - less or equal
A ≥ 2 = 001 111 - greater or equal
Logical:
A and 2 = 011 111 - logical "and"
A or 2 = 111 111 - logical "or"
A xor 2 = 100 000 - logical "xor"
a = 2 , B = hp ( [11; 10; 9 | 8; 7; 6] ) = 11109 876
Arithmetic:
2B = 20481024512 25612864 -exponentiation
2B = 0.1820.20.222 0.250.2860.333 - floating point division
2\B = 000 000 - integer division
2 / B = 0.1820.20.222 0.250.2860.333 - division bar
2 mod B = 222 222 - modulo(⦼, remainder)
2 · B = 222018 161412 - multiplication
2 − B = -9-8-7 -6-5-4 - subtraction
2 + B = 131211 1098 - addition
Relational (comparison):
2 ≡ B = 000 000 - equal to
2 ≠ B = 111 111 - unequal to
2 < B = 111 111 - less then
2 > B = 000 000 - greater than
2 ≤ B = 111 111 - less or equal
2 ≥ B = 000 000 - greater or equal
Logical:
2 and B = 111 111 - logical "and"
2 or B = 111 111 - logical "or
2 xor B = 000 000 - logical "xor"
Spotted an error? Edit these examples.