comparison m-toolbox/test/test_ao_mrdivide.m @ 0:f0afece42f48

Import.
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 23 Nov 2011 19:22:13 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 mc
2
3
4 %% Some AOs
5
6 c1 = ao(1); c1.setName;
7 c2 = ao(2); c2.setName;
8 c3 = ao(3); c3.setName;
9 c4 = ao(randn(3,3)); c4.setName;
10 c5 = ao(randn(3,3)); c5.setName;
11 c6 = ao(randn(3,1)); c6.setName;
12 c7 = ao(randn(1,3)); c7.setName;
13
14
15 t1 = ao(plist('tsfcn', 't', 'fs', 10, 'nsecs', 10)); t1.'; t1.setName;
16 t2 = ao(plist('tsfcn', 'sqrt(t)', 'fs', 10, 'nsecs', 10)); t2.setName;
17 t3 = ao(plist('tsfcn', 't.^2', 'fs', 10, 'nsecs', 10)); t3.setName;
18 t4 = ao(plist('tsfcn', 't', 'fs', 10, 'nsecs', 10)); t4.'; t4.setName;
19 t5 = ao(plist('tsfcn', 't', 'fs', 10, 'nsecs', 10)); t5.'; t5.setName;
20
21 f1 = ao(plist('fsfcn', 'f', 'f', 'logspace(-4,1,100)')); f1.setName;
22 f2 = ao(plist('fsfcn', '1./f', 'f', 'logspace(-4,1,100)')); f2.'; f2.setName;
23 f3 = ao(plist('fsfcn', 'sqrt(f)', 'f', 'logspace(-4,1,100)')); f3.setName;
24
25 x1 = ao(plist('xyfcn', 'x', 'x', '1:100')); x1.setName;
26 x2 = ao(plist('xyfcn', '1./x', 'x', '1:100')); x2.'; x2.setName;
27 x3 = ao(plist('xyfcn', 'sqrt(x)', 'x', '1:100')); x3.setName;
28
29 %% Rule 1: [1x1] * [1x1]
30
31 %---------- CDATA
32 % cdata / cdata
33 r1 = mrdivide(c1,c3)
34 % cdata / tsdata
35 r2 = mrdivide(c2,t2)
36 % cdata / fsdata
37 r3 = mrdivide(c1,f2)
38 % cdata / xydata
39 r4 = mrdivide(c1,x2)
40
41 % tsdata / cdata
42 r8 = mrdivide(t1, c2)
43
44 %---------- FSDATA
45 % fsdata / tsdata
46 try
47 r9 = mrdivide(f1, t2)
48 error('Data types should be incompatible: booo!');
49 catch
50 lasterr
51 warning('Data types not compatible: fsdata+tsdata: hoorah!');
52 end
53 % fsdata / cdata
54 r12 = mrdivide(f1, c2)
55
56 % xydata / cdata
57 r16 = mrdivide(x1, c2)
58
59 %% Rule 2: [1xN] / a or [Nx1] / a
60
61 v1 = [t1 t3];
62 v2 = [t1; t3];
63
64 r1 = mrdivide(v1,c1)
65 r2 = mrdivide(v2,c1)
66
67 %% Rule 3: [1xN] / [Nx1]
68
69 v1 = [t1 t1];
70 v2 = [t3; t2];
71 try
72 r1 = mrdivide(v1,v2)
73 error('Matrix sizes should be incompatible: booo!');
74 catch
75 lasterr
76 warning('Data sizes not compatible: hoorah!');
77 end
78
79 %% Rule 4: [1xN] / [1xN]
80
81 v1 = [t1 t1];
82
83 try
84 r1 = mrdivide(v1,v1)
85 error('Sizes should be incompatible: booo!');
86 catch
87 lasterr
88 warning('Sizes not compatible: hoorah!');
89 end
90
91 %% Rule 5: [Nx1] / [1xM]
92
93 v1 = [t1;t4;t5];
94
95 r = mrdivide(v1,v1)
96
97 %% Rule 6: [Nx1] / [Nx1]
98
99 v1 = [t1;t4;t5];
100
101 r1 = mrdivide(v1,v1)
102
103 %% Rule 7: [NxP] / [Nx1]
104
105 m = [t1 t1;t4 t4;t5 t5];
106 v = [t1;t2;t3]
107
108 r1 = mrdivide(m,v)
109
110 %% Rule 8: [NxP] / [1xP]
111
112 m = [t1 t1;t4 t4;t5 t5];
113 v = [t2 t2]
114
115
116 r1 = mrdivide(m,v)
117
118 %% Rule 9: [NxP] / [NxP]
119
120 m = [t1 t1;t4 t4;t5 t5];
121
122
123 r1 = mrdivide(m,m)
124
125 %% Rule 10: [NxP] / [P*Q]
126
127 m1 = [t1 t1;t4 t4;t5 t5];
128 m2 = [c1 c2 c3; c3 c2 c3];
129
130 r1 = mrdivide(m1,m1)
131
132
133
134
135
136
137
138
139
140