File: matfunc_test.ref

package info (click to toggle)
libitpp 4.3.1-14
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 9,952 kB
  • sloc: cpp: 73,628; makefile: 661; python: 548; sh: 261
file content (104 lines) | stat: -rw-r--r-- 3,599 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
=================================
    Test of matfunc routines     
=================================
a = [-0.284 1.364 0.906 1.249 1.558]
sum(a) = 4.794
cumsum(a) = [-0.284 1.081 1.987 3.236 4.794]
prod(a) = -0.683
sum_sqr(a) = 6.751

A = [[0.565 -1.075 -0.732 -0.869 -0.228]
 [-0.596 2.365 -2.106 -0.050 -1.837]
 [-1.197 2.365 -0.923 0.800 0.051]
 [-1.268 1.228 -1.892 1.028 1.441]
 [-0.300 0.234 -0.664 -0.900 -1.481]]

sum(A) = [-2.796 5.117 -6.318 0.008 -2.053]
sum(A,1) = [-2.796 5.117 -6.318 0.008 -2.053]
sum(A,2) = [-2.339 -2.225 1.095 0.538 -3.112]

cumsum(A) = [[0.565 -1.075 -0.732 -0.869 -0.228]
 [-0.031 1.290 -2.838 -0.920 -2.065]
 [-1.228 3.655 -3.761 -0.120 -2.014]
 [-2.496 4.883 -5.653 0.908 -0.572]
 [-2.796 5.117 -6.318 0.008 -2.053]]
cumsum(A,1) = [[0.565 -1.075 -0.732 -0.869 -0.228]
 [-0.031 1.290 -2.838 -0.920 -2.065]
 [-1.228 3.655 -3.761 -0.120 -2.014]
 [-2.496 4.883 -5.653 0.908 -0.572]
 [-2.796 5.117 -6.318 0.008 -2.053]]
cumsum(A,2) = [[0.565 -0.510 -1.242 -2.111 -2.339]
 [-0.596 1.769 -0.337 -0.387 -2.225]
 [-1.197 1.168 0.244 1.044 1.095]
 [-1.268 -0.040 -1.932 -0.903 0.538]
 [-0.300 -0.066 -0.731 -1.631 -3.112]]

prod(A) = [0.154 -1.728 -1.789 -0.033 -0.046]
prod(A,1) = [0.154 -1.728 -1.789 -0.033 -0.046]
prod(A,2) = [0.088 0.275 0.107 4.366 0.062]

sum_sqr(A) = [3.805 13.903 9.844 3.267 7.700]
sum_sqr(A,1) = [3.805 13.903 9.844 3.267 7.700]
sum_sqr(A,2) = [2.818 13.759 8.522 9.831 3.589]

repmat(a, 1, 3) = [[-0.284 -0.284 -0.284]
 [1.364 1.364 1.364]
 [0.906 0.906 0.906]
 [1.249 1.249 1.249]
 [1.558 1.558 1.558]]
repmat(a, 3, 1, true) = [[-0.284 1.364 0.906 1.249 1.558]
 [-0.284 1.364 0.906 1.249 1.558]
 [-0.284 1.364 0.906 1.249 1.558]]
repmat(A, 2, 2) = [[0.565 -1.075 -0.732 -0.869 -0.228 0.565 -1.075 -0.732 -0.869 -0.228]
 [-0.596 2.365 -2.106 -0.050 -1.837 -0.596 2.365 -2.106 -0.050 -1.837]
 [-1.197 2.365 -0.923 0.800 0.051 -1.197 2.365 -0.923 0.800 0.051]
 [-1.268 1.228 -1.892 1.028 1.441 -1.268 1.228 -1.892 1.028 1.441]
 [-0.300 0.234 -0.664 -0.900 -1.481 -0.300 0.234 -0.664 -0.900 -1.481]
 [0.565 -1.075 -0.732 -0.869 -0.228 0.565 -1.075 -0.732 -0.869 -0.228]
 [-0.596 2.365 -2.106 -0.050 -1.837 -0.596 2.365 -2.106 -0.050 -1.837]
 [-1.197 2.365 -0.923 0.800 0.051 -1.197 2.365 -0.923 0.800 0.051]
 [-1.268 1.228 -1.892 1.028 1.441 -1.268 1.228 -1.892 1.028 1.441]
 [-0.300 0.234 -0.664 -0.900 -1.481 -0.300 0.234 -0.664 -0.900 -1.481]]

Kronecker test
X = [[2.000 2.000]
 [3.000 1.000]]
Y = [[0.910 -0.270 0.495]
 [1.123 -1.005 0.722]
 [1.461 1.872 0.246]]
kron(X, Y) = [[1.820 -0.539 0.989 1.820 -0.539 0.989]
 [2.247 -2.011 1.444 2.247 -2.011 1.444]
 [2.921 3.744 0.493 2.921 3.744 0.493]
 [2.730 -0.809 1.484 0.910 -0.270 0.495]
 [3.370 -3.016 2.166 1.123 -1.005 0.722]
 [4.382 5.616 0.739 1.461 1.872 0.246]]

sqrtm of a real matrix
A = [[0.672 0.549 -0.454]
 [-1.001 -0.809 0.260]
 [-0.180 -2.297 -1.448]]
norm(sqrtm(A) * sqrtm(A) - A) = 0.000

sqrtm of a complex matrix
B = [[0.214-0.984i -0.885+0.466i -1.289+0.563i]
 [0.261+1.134i -0.608+0.053i -0.069-0.822i]
 [-0.226+1.077i -0.122-0.849i 0.953-0.128i]]
norm(sqrtm(B) * sqrtm(B) - B) = 0.000

Rank test
A = [[0.394 -0.184 -0.940]
 [0.847 0.110 0.462]
 [-0.270 -0.263 0.849]]
rank(A) = 3
A2 = [[0.394 -0.184 -0.940]
 [1.181 -0.553 -2.819]
 [-0.270 -0.263 0.849]]
rank(A2) = 2
B = [[-0.219-0.082i -0.298+0.296i -0.477-0.638i]
 [-0.352+0.221i 0.901-0.233i -1.249+0.340i]
 [0.635+0.087i 0.964+0.837i 0.023-0.182i]]
rank(B) = 3
B2 = [[-0.219-0.082i -0.219-0.082i -0.477-0.638i]
 [-0.352+0.221i -0.352+0.221i -1.249+0.340i]
 [0.635+0.087i 0.635+0.087i 0.023-0.182i]]
rank(B2) = 2