tcal_rs 0.1.1

Number theory functions library - Rust port of libqalculate number theory module
(1,)
	[1  0]
1,
	[1  0]
[,,,]
	[0  0  0  0]
(,,,-2)
	[0  0  0  -2]
(1;;2)
	[1  0  2]
(1,1)
	[1  1]
((1, 2), (4, 5))
	[1  2; 4  5]
((1; 2; 3); (4; 5; 6))
	[1  2  3; 4  5  6]
[[1, 2], [4, 5]]
	[1  2; 4  5]
( 1; 2; 3, 4, 5, 6 ); (4; 5)
	([1  2  3  4  5  6], [4  5])
[-0.1, 1.23, ], [.1, , -.2], [,,]
	[-0.1  1.23  0; 0.1  0  -0.2; 0  0  0]

(1; 2; 3) * 2 - 2
	[0  2  4]

adj([1 2; 4 5])
	[5  -2; -4  1]
adj([1, 2, 3; 4, 5, 6; 1, 0, 9])
	[45  -18  -3; -30  6  6; -5  2  -3]
adj([3 4 7 9; 5 4 -1 4; 8 7 8 5; 4 3 0 9])
	[240  264  -177  -259; -284  -436  194  370; 16  100  -53  -31; -12  28  14  -54]

cofactor([1 2; 4 5], 1, 1)
	5
cofactor([1 2 3; 4 5 6; 1 0 9], 1, 2)
	-30
cofactor([3 4 7 9; 5 4 -1 4; 8 7 8 5; 4 3 0 9], 4, 4)
	-54

columns([])
	0
columns([1])
	1
columns([1 2; 4 5])
	2
#columns([1; 4 5 6; 1 9])
#	3
columns([[,,,]])
	4

matrix(1, 1, [2])
	2
matrix(1, 3, 2)
	[2  0  0]
matrix(3, 1, [1 2])
	[1; 2; 0]
matrix(3, 3, [])
	[0  0  0; 0  0  0; 0  0  0]
matrix(3, 3, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
	[1  2  3; 4  5  6; 7  8  9]

vector()
	[]
vector(,)
	[0  0]
vector(1, 2, 3)
	[1  2  3]

matrix2vector([[0]])
	0
matrix2vector([1 2; 4 5])
	[1  2  4  5]
matrix2vector([1 2 3; 4 5 6; 7 8 9])
	[1  2  3  4  5  6  7  8  9]

horzcat([1], [2 3], [4 5 6 7])
	[1  2  3  4  5  6  7]
horzcat([1; 2], [3 4; 5 6], [7 8 9; 10 11 12])
	[1  3  4  7  8  9; 2  5  6  10  11  12]
vertcat([1 2], [3 4], [5 6])
	[1  2; 3  4; 5  6]

((1; 2; 3); (4; 5; 6)) * ((7; 8); (9; 10); (11; 12))
	[58  64; 139  154]

cross((1; 2; 3); (4; 5; 6))
	[-3  6  -3]

det([[1]])
	1
det([1 2; 4 5])
	-3
det([1 2 3; 4 5 6; 1 0 9])
	-30
det([3 4 7 9; 5 4 -1 4; 8 7 8 5; 4 3 0 9])
	-412

dimension([])
	0
dimension([0])
	1
dimension([1 2 3 4])
	4

dot((2); (3))
	6
dot((1; 2); (3, 4))
	11
dot((1; 2; 3); (4; 5; 6))
	32
(1; 2; 3).(4; 5; 6)
	32
(1; 2; 3, 4) . (5; 6; 7, 8)
	70

element([1 2; 3 4], 1)
	[1  2]
element([1 2 3; 4 5 6; 1 0 9], 1, 3)
	3
element([1 2 3; 4 5 6], 2, 1)
	4

multiply(1)
	1
multiply([1 2; 4 5], 2)
	[2  4; 8  10]
[1 2; 4 5] * 2
	[2  4; 8  10]
multiply([1 2], 3, 4)
	[12  24]
[1 2] times 3 times 4
	[12  24]
[1 2].*[3 4]
	[3  8]
[1; 2].*[3 4]
	[3  4; 6  8]
[1 2; 3 4].*[1 2; 3 4]
	[1  4; 9  16]

pow([1 2; 3 4], 2)
	[1  4; 9  16]
[1 2; 3 4].^2
	[1  4; 9  16]
[2 4; 3 4].^[-1; 2]
	[0.5  0.25; 9  16]
[2; 3].^[3 4]
	[8  16; 27  81]

[2 4 12] / 2
	[1  2  6]
divide([2 4 12], 2)
	[1  2  6]
[2 4 12]./2
	[1  2  6]
[[2, 4], [6, 12]] / 2
	[1  2; 3  6]
[2 4; 6 12]./[1 2; 3 4]
	[2  2; 2  3]

elements([])
	0
elements([1 2])
	2
elements([1 2; 3 4])
	4

entrywise(x, [4 10 12], x)
	[4  10  12]
entrywise(x / y, [4 10 12], x, [2 2 4], y)
	[2  5  3]
entrywise(x / y + z, [4 10 12], x, [2 2 4], y, [1 2 3], z)
	[3  7  6]

column([1], 1)
	1
column([1, 2], 1)
	1
column([1 2; 3 4], 2)
	[2  4]

row([1], 1)
	1
row([1 2], 1)
	[1  2]
row([1 2; 3 4], 2)
	[3  4]

genvector(x+10, 1, 2, 2)
	[11  12]
genvector(x+10, 1, 2, 3)
	[11  11.5  12]
genvector(x+10, -1, 2, 5)
	[9  9.75  10.5  11.25  12]
genvector(x+10, -1, 2, 7, x, 0)
	[9  9.5  10  10.5  11  11.5  12]
genvector(x+100, -3, 5, 2, x, 1)
	[97  99  101  103  105]
genvector(x+100, 1, 2, 1, y, 1)
	[(x + 100)  (x + 100)]

hadamard([2], [3], [4])
	24
hadamard([1 2 3; 4 5 6]; [7 8 9; 10 11 12])
	[7  16  27; 40  55  72]

identity(1)
	1
identity(3)
	[1  0  0; 0  1  0; 0  0  1]
identity([1 2; 4 5])
	[1  0; 0  1]

magnitude(-2)
	2
magnitude([-2])
	2
magnitude([-2, 3, 4])
	5.385164807

part([1], 1, 1, 1, 1)
	1
part([1 2 3; 4 5 6; 7 8 9; 10 11 12], 2, 2, 2, 2)
	5
part([1 2 3; 4 5 6; 7 8 9; 10 11 12], 1, 3, 2, 3)
	[3; 6]
part([1 2 3; 4 5 6; 7 8 9; 10 11 12], 1, 2, 4, 3)
	[2  3; 5  6; 8  9; 11  12]

((1; 2); (3; 4))^-1
	[-2  1; 1.5  -0.5]
inverse([1 2; 3 5])
	[-5  2; 3  -1]
inverse([1  2  3; 4  5  6; 1  0  9])
	[-1.5  0.6  0.1; 1  -0.2  -0.2; 0.1666666667  -0.06666666667  0.1]
inverse([1 1 1 1; 2 4 -1 4; 2 4 3 4; 4 3 0 2])
	[2  0.125  -0.625  0; -6  -0.75  1.75  1; 0  -0.25  0.25  0; 5  0.875  -1.375  -1]

rk([1 2 3; 3 6 9])
	1
rk([1 2 3; 0 2 2; 1 4 5])
	2
rk([1 2 3; 0 2 2; 1 -2 -1])
	2
rk(identity(3))
	3

combine([1, 2])
	[1  2]
combine([1, 2], [3], [4, 5, 6])
	[1  2  3  4  5  6]

norm([2])
	2
norm([3, 4])
	5
norm([2, 3, 6])
	7

permanent([1])
	1
permanent([1 2; 4 5])
	13
permanent([1 2 3; 4 5 6; 1 0 9])
	144
permanent([3 4 7 9; 5 4 -1 4; 8 7 8 5; 4 3 0 9])
	11028

rank([6, 7, 1, 4])
	[3  4  1  2]
rank([-1, 2, 5, 10], 1)
	[1  2  3  4]
rank([-1, 2, 5, 10], 0)
	[4  3  2  1]

rref([1 3 1 9; 1 1 -1 1; 3 11 5 35])
	[1  0  -2  -3; 0  1  1  4; 0  0  0  0]

rows([1])
	1
rows([1 2; 3 4])
	2

sort([5, 2, 0, 1, 3, -4, 0])
	[-4  0  0  1  2  3  5]
sort([5, 2, 0, 1, 3, -4, 0], 1)
	[-4  0  0  1  2  3  5]
sort([5, 2, 0, 1, 3, -4, 0], 0)
	[5  3  2  1  0  0  -4]

transpose([1 2; 3 4])
	[1  3; 2  4]
[1 2 3; 4 5 6].'
	[1  4; 2  5; 3  6]

slice([5], 1, 1)
	5
slice([5, 6, 7, 8, 9], 2, 4)
	[6  7  8]