view m-toolbox/test/test_ao_mtimes.m @ 52:daf4eab1a51e database-connection-manager tip

Fix. Default password should be [] not an empty string
author Daniele Nicolodi <nicolodi@science.unitn.it>
date Wed, 07 Dec 2011 17:29:47 +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.'; 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;
t4 = ao(plist('tsfcn', 't', 'fs', 10, 'nsecs', 10)); t4.'; t4.setName; 
t5 = ao(plist('tsfcn', 't', 'fs', 10, 'nsecs', 10)); t5.'; t5.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.'; 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.'; x2.setName;
x3 = ao(plist('xyfcn', 'sqrt(x)', 'x', '1:100')); x3.setName;

%% Rule 1: [1x1] * [1x1]

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

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

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

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

%% Rule 2: [1xN] * a or [Nx1] * a

v1 = [t1 t3];
v2 = [t1; t3];

r1 = mtimes(v1,c1)
r2 = mtimes(v2,c1)

%% Rule 3: [1xN] * [Nx1]

v1 = [t1 t1];
v2 = [t3; t2];

r1 = mtimes(v1,v2)

%% Rule 4: [1xN] * [1xN]

v1 = [t1 t1];

try
  r1 = mtimes(v1,v1)
  error('Sizes should be incompatible: booo!');
catch
  lasterr
  warning('Sizes not compatible: hoorah!');
end

%% Rule 5: [Nx1] * [1xM]

v1 = [t1;t4;t5];
v2 = [t2 t3];

r = mtimes(v1,v2)

%% Rule 6:  [Nx1] * [Nx1]

v1 = [t1;t4;t5];

try
  r1 = mtimes(v1,v1)
  error('Sizes should be incompatible: booo!');
catch
  lasterr
  warning('Sizes not compatible: hoorah!');
end

%% Rule 7: [NxP] * [Nx1]

m = [t1 t1;t4 t4;t5 t5];
v = [t1;t2;t3]

try
  r1 = mtimes(m,v)
  error('Sizes should be incompatible: booo!');
catch
  lasterr
  warning('Sizes not compatible: hoorah!');
end

%% but [2x2] * [2 1] should work
m = [t1 t1; t4 t4];
v = [t2;t3];

r1 = mtimes(m,v);


%% Rule 8: [NxP] * [1xP]

m = [t1 t1;t4 t4;t5 t5];
v = [t2 t2]

  
try
  r1 = mtimes(m,v)
  error('Sizes should be incompatible: booo!');
catch
  lasterr
  warning('Sizes not compatible: hoorah!');
end

%% Rule 9: [NxP] * [NxP]

m = [t1 t1;t4 t4;t5 t5];

  
try
  r1 = mtimes(m,m)
  error('Sizes should be incompatible: booo!');
catch
  lasterr
  warning('Sizes not compatible: hoorah!');
end

%% Rule 10: [NxP] * [P*Q]

m1 = [t1 t1;t4 t4;t5 t5];
m2 = [t2 t2 t3; t3 t2 t3];

r1 = mtimes(m1,m2)