File: matfunc_test.ref

package info (click to toggle)
libitpp 4.0.4-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 7,520 kB
  • ctags: 6,341
  • sloc: cpp: 51,608; sh: 9,248; makefile: 636; fortran: 8
file content (86 lines) | stat: -rw-r--r-- 3,093 bytes parent folder | download | duplicates (2)
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
=================================
    Test of matfunc routines     
=================================
a = [0.765 -1.131 0.452 -0.452 1.365]
sum(a) = 0.999
cumsum(a) = [0.765 -0.366 0.086 -0.365 0.999]
prod(a) = 0.241
sum_sqr(a) = 4.135

A = [[0.355 -0.946 -0.049 1.021 0.612]
 [-0.557 0.404 -0.236 1.255 -0.080]
 [1.010 -0.129 -0.269 1.000 -0.102]
 [0.252 0.280 -1.538 -1.125 1.029]
 [-0.902 -0.440 1.679 0.369 -1.379]]

sum(A) = [0.158 -0.832 -0.413 2.520 0.080]
sum(A,1) = [0.158 -0.832 -0.413 2.520 0.080]
sum(A,2) = [0.992 0.786 1.510 -1.102 -0.674]

cumsum(A) = [[0.355 -0.946 -0.049 1.021 0.612]
 [-0.201 -0.542 -0.285 2.276 0.532]
 [0.808 -0.672 -0.554 3.276 0.430]
 [1.060 -0.392 -2.092 2.151 1.459]
 [0.158 -0.832 -0.413 2.520 0.080]]
cumsum(A,1) = [[0.355 -0.946 -0.049 1.021 0.612]
 [-0.201 -0.542 -0.285 2.276 0.532]
 [0.808 -0.672 -0.554 3.276 0.430]
 [1.060 -0.392 -2.092 2.151 1.459]
 [0.158 -0.832 -0.413 2.520 0.080]]
cumsum(A,2) = [[0.355 -0.591 -0.640 0.381 0.992]
 [-0.557 -0.153 -0.389 0.866 0.786]
 [1.010 0.880 0.611 1.612 1.510]
 [0.252 0.532 -1.006 -2.131 -1.102]
 [-0.902 -1.342 0.337 0.706 -0.674]]

prod(A) = [0.045 -0.006 0.008 -0.532 -0.007]
prod(A,1) = [0.045 -0.006 0.008 -0.532 -0.007]
prod(A,2) = [0.010 -0.005 -0.004 0.126 -0.339]

sum_sqr(A) = [2.334 1.347 5.314 5.018 3.353]
sum_sqr(A,1) = [2.334 1.347 5.314 5.018 3.353]
sum_sqr(A,2) = [2.441 2.109 2.120 4.831 5.865]

repmat(a, 1, 3) = [[0.765 0.765 0.765]
 [-1.131 -1.131 -1.131]
 [0.452 0.452 0.452]
 [-0.452 -0.452 -0.452]
 [1.365 1.365 1.365]]
repmat(a, 3, 1, true) = [[0.765 -1.131 0.452 -0.452 1.365]
 [0.765 -1.131 0.452 -0.452 1.365]
 [0.765 -1.131 0.452 -0.452 1.365]]
repmat(A, 2, 2) = [[0.355 -0.946 -0.049 1.021 0.612 0.355 -0.946 -0.049 1.021 0.612]
 [-0.557 0.404 -0.236 1.255 -0.080 -0.557 0.404 -0.236 1.255 -0.080]
 [1.010 -0.129 -0.269 1.000 -0.102 1.010 -0.129 -0.269 1.000 -0.102]
 [0.252 0.280 -1.538 -1.125 1.029 0.252 0.280 -1.538 -1.125 1.029]
 [-0.902 -0.440 1.679 0.369 -1.379 -0.902 -0.440 1.679 0.369 -1.379]
 [0.355 -0.946 -0.049 1.021 0.612 0.355 -0.946 -0.049 1.021 0.612]
 [-0.557 0.404 -0.236 1.255 -0.080 -0.557 0.404 -0.236 1.255 -0.080]
 [1.010 -0.129 -0.269 1.000 -0.102 1.010 -0.129 -0.269 1.000 -0.102]
 [0.252 0.280 -1.538 -1.125 1.029 0.252 0.280 -1.538 -1.125 1.029]
 [-0.902 -0.440 1.679 0.369 -1.379 -0.902 -0.440 1.679 0.369 -1.379]]

Kronecker test
X = [[3.000 3.000]
 [1.000 3.000]]
Y = [[-0.106 -0.421 0.147]
 [0.103 0.298 -1.174]
 [-0.862 -0.286 0.114]]
kron(X, Y) = [[-0.318 -1.262 0.442 -0.318 -1.262 0.442]
 [0.309 0.893 -3.521 0.309 0.893 -3.521]
 [-2.586 -0.859 0.342 -2.586 -0.859 0.342]
 [-0.106 -0.421 0.147 -0.318 -1.262 0.442]
 [0.103 0.298 -1.174 0.309 0.893 -3.521]
 [-0.862 -0.286 0.114 -2.586 -0.859 0.342]]

sqrtm of a real matrix
A = [[0.523 0.445 0.485]
 [-0.557 0.362 0.252]
 [-0.166 -0.742 0.996]]
norm(sqrtm(A) * sqrtm(A) - A) = 0.000

sqrtm of a complex matrix
B = [[-0.061-0.284i -0.397+0.110i -0.726+0.056i]
 [0.669-0.108i 0.743-0.443i 0.215-0.161i]
 [0.131+0.775i -1.163+1.000i 0.557-0.667i]]
norm(sqrtm(B) * sqrtm(B) - B) = 0.000