view m-toolbox/test/test_ao_multiply.m @ 1:2014ba5b353a database-connection-manager

Remove old code
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Sat, 03 Dec 2011 18:13:55 +0100
parents f0afece42f48
children
line wrap: on
line source

mc

%% Some AOs

c1 = ao(1); c1.setName;
c2 = ao(2); c2.setName;
c3 = ao(3); c3.setName;
c4 = ao(randn(3,3)); c4.setName;
c5 = ao(randn(3,3)); c5.setName;
c6 = ao(randn(3,1)); c6.setName;
c7 = ao(randn(1,3)); c7.setName;


t1 = ao(plist('tsfcn', 't', 'fs', 10, 'nsecs', 10)); t1.setName;
t2 = ao(plist('tsfcn', 'sqrt(t)', 'fs', 10, 'nsecs', 10)); t2.setName;
t3 = ao(plist('tsfcn', 't.^2', 'fs', 10, 'nsecs', 10)); t3.setName;

f1 = ao(plist('fsfcn', 'f', 'f', 'logspace(-4,1,100)')); f1.setName;
f2 = ao(plist('fsfcn', '1./f', 'f', 'logspace(-4,1,100)')); f2.setName;
f3 = ao(plist('fsfcn', 'sqrt(f)', 'f', 'logspace(-4,1,100)')); f3.setName;

x1 = ao(plist('xyfcn', 'x', 'x', '1:100')); x1.setName;
x2 = ao(plist('xyfcn', '1./x', 'x', '1:100')); x2.setName;
x3 = ao(plist('xyfcn', 'sqrt(x)', 'x', '1:100')); x3.setName;


%% Rule 1

%---------- CDATA
% cdata  .* cdata
r1 = times(c1,c3);
% cdata  .* tsdata
r2 = times(c1,t1);
% cdata  .* fsdata
r3 = times(c1,f1);
% cdata  .* xydata
r4 = times(c1,x1);

%---------- TSDATA
% tsdata .* tsdata
r5 = times(t1, t2);
% tsdata .* fsdata
try
  r6 = times(t1, f2);
  error('Data types should be incompatible: booo!');
catch
  lasterr
  warning('Data types not compatible: fsdata.*tsdata: hoorah!');
end
% tsdata .* xydata
r7 = times(t1, x2);
% tsdata .* cdata
r8 = times(t1, c2);

%---------- FSDATA
% fsdata .* tsdata
try
  r9 = times(f1, t2);
  error('Data types should be incompatible: booo!');
catch
  lasterr
  warning('Data types not compatible: fsdata.*tsdata: hoorah!');
end
% fsdata .* fsdata
r10 = times(f1, f2);
% fsdata .* xydata
r11 = times(f1, x2);
% fsdata .* cdata
r12 = times(f1, c2);

%---------- XYDATA
% xydata .* tsdata
r13 = times(x1, t2);
% xydata .* fsdata
r14 = times(x1, f2);
% xydata .* xydata
r15 = times(x1, x2);
% xydata .* cdata
r16 = times(x1, c2);




%% Rule 2: vector .* single

v = [t1 t2];
s = c2;

% one output
r1 = times(v,s)
r2 = times(s,v)

% multiple outputs
[r1 r2] = times(v,s)


%% Rule 3: V_N .* V_M

v1 = [t1 t2];
v2 = [c1 c2 c3];

try
  r = times(v1,v2);
  error('Rule 3 should fail: booo!');
catch
  lasterr
  warning('Rule 3 fails: hoorah!');
end

%% Rule 4: V_N .* U_N

v1 = [t1 t2 t3];
v2 = [x1 x2 x3];

r = times(v1,v2);
[r1 r2 r3] = times(v1,v2);

%% Rule 5: matrix .* single

m = [t1 t2 t3; x1 x2 x3];
s = c2;

r1 = times(m,s);
r2 = times(s,m);

%% Rule 6: matrix .* column vector

m = [t1 t2 t3; x1 x2 x3];
v = [c1; c2];

r1 = times(m,v)
r2 = times(v,m)

%% Rule 7: matrix .* row vector

m = [t1 t2 t3; x1 x2 x3];
v = [c1 c2 c3];

r1 = times(m,v)
r2 = times(v,m)

%% Rule 8: M_NP .* V_1Q (or V_Q1)


m = [t1 t2 t3; x1 x2 x3];
v = [c1 c2];
try
  r = times(m,v)
  error('Rule 8 should fail: booo!');
catch
  lasterr
  warning('Rule 8 fails: hoorah!');
end
try
  r = times(v,m)
  error('Rule 8 should fail: booo!');
catch
  lasterr
  warning('Rule 8 fails: hoorah!');
end

m = [t1 t2 t3; x1 x2 x3];
v = [c1; c2; c3];
try
  r = times(m,v)
  error('Rule 8 should fail: booo!');
catch
  lasterr
  warning('Rule 8 fails: hoorah!');
end
try
  r = times(v,m)
  error('Rule 8 should fail: booo!');
catch
  lasterr
  warning('Rule 8 fails: hoorah!');
end

%% Rule 9: M_NP .* H_PQ

m = [t1 t2; x1 x2];
h = [c1 c2 c3; c1 c2 c3];

try
  r = times(m,h)
  error('Rule 9 should fail: booo!');
catch
  lasterr
  warning('Rule 9 fails: hoorah!');
end

%% Rule 10: matrix .* matrix

m = [t1 t2 t3; x1 x2 x3];
h = [c1 c2 c3; c1 c2 c3];

r = times(m,h)

%% Rule 11: more than two inputs

m = [t1 t2 t3; x1 x2 x3];
v = [c1; c2];

r = times(m,v, c3, v, m)

%% Check units


% empty .* m = m
t1.setYunits('m');
t2.setYunits('');
r = times(t1,t2)

% V .* m = mV
t2.setYunits('V');
r = times(t1,t2)