bug 10016 fixed - The damp function unit test failed under windows. 21/5021/3
Serge Steer [Mon, 26 Sep 2011 13:08:27 +0000 (15:08 +0200)]
Change-Id: I890cdfb7392d1058ac11e977dc9f01cfca674a28

scilab/CHANGES_5.4.X
scilab/modules/cacsd/macros/damp.sci
scilab/modules/cacsd/tests/unit_tests/damp.dia.ref
scilab/modules/cacsd/tests/unit_tests/damp.tst

index e46859b..b1d6e8d 100644 (file)
@@ -612,3 +612,5 @@ Bug fixes:
 * bug 9979 fixed - The who_user() function printed a wrong message.
 
 * bug 9980 fixed - Frozen console when one tryes to complete an empty string.
+
+* bug 10016 fixed - The damp function unit test failed under windows.
index 0baba91..b6b2fa4 100644 (file)
@@ -79,7 +79,7 @@ function [wn,z,p] = damp(R,dt1)
   z=-ones(p);
   im=ieee();ieee(2);//to allow inf and nan's
   if dt>0 then // Discrete  time case
-    ind=find(abs(p-1)>10*%eps)
+    ind=find(p<>1)
     s=p(ind);
     s=log(s)/dt;
   else //continuous time case
index 99be97b..83113be 100644 (file)
@@ -49,7 +49,8 @@ t2=log(2-3*%i)/dt;
 wnref=[0;log(2);abs(t1);abs(t1);abs(t2);abs(t2);%inf];
 zetaref=[-1;-1;-real(t1)/abs(t1);-real(t1)/abs(t1);-real(t2)/abs(t2);-real(t2)/abs(t2);%nan];
 assert_checkalmostequal (wn,wnref);
-assert_checkalmostequal (zeta,zetaref);
+assert_checkalmostequal (zeta(2:$),zetaref(2:$));
+assert_checktrue(abs(abs(zeta(1))-1)<100*%eps);
 dt=1;
 [wn,zeta]=damp(prod(P),dt);
 t1=log(1+%i)/dt;
@@ -57,13 +58,15 @@ t2=log(2-3*%i)/dt;
 wnref=[0;log(2);abs(t1);abs(t1);abs(t2);abs(t2);%inf];
 zetaref=[1;-1;-real(t1)/abs(t1);-real(t1)/abs(t1);-real(t2)/abs(t2);-real(t2)/abs(t2);%nan];
 assert_checkalmostequal (wn,wnref);
-assert_checkalmostequal (zeta,zetaref);
+assert_checkalmostequal (zeta(2:$),zetaref(2:$));
+assert_checktrue(abs(abs(zeta(1))-1)<100*%eps);
 //transfer function
 [wn,zeta]=damp(syslin('c',ones(1,3),P));
 wnref=[0;1;sqrt(2);sqrt(2);2;sqrt(13);sqrt(13)];
 zetaref=[-1;-1;-sqrt(2)/2;-sqrt(2)/2;-1;-2/sqrt(13);-2/sqrt(13)];
 assert_checkalmostequal (wn,wnref);
-assert_checkalmostequal (zeta,zetaref);
+assert_checkalmostequal (zeta(2:$),zetaref(2:$));
+assert_checktrue(abs(abs(zeta(1))-1)<100*%eps);
 dt=1;
 [wn,zeta]=damp(syslin(dt,ones(1,3),P));
 t1=log(1+%i)/dt;
@@ -71,13 +74,15 @@ t2=log(2-3*%i)/dt;
 wnref=[0;log(2);abs(t1);abs(t1);abs(t2);abs(t2);%inf];
 zetaref=[1;-1;-real(t1)/abs(t1);-real(t1)/abs(t1);-real(t2)/abs(t2);-real(t2)/abs(t2);%nan];
 assert_checkalmostequal (wn,wnref);
-assert_checkalmostequal (zeta,zetaref);
+assert_checkalmostequal (zeta(2:$),zetaref(2:$));
+assert_checktrue(abs(abs(zeta(1))-1)<100*%eps);
 //state-space
 [wn,zeta]=damp(tf2ss(syslin('c',1,prod(P))));
 wnref=[0;1;sqrt(2);sqrt(2);2;sqrt(13);sqrt(13)];
 zetaref=[-1;-1;-sqrt(2)/2;-sqrt(2)/2;-1;-2/sqrt(13);-2/sqrt(13)];
 assert_checkalmostequal (wn,wnref);
-assert_checkalmostequal (zeta,zetaref);
+assert_checkalmostequal (zeta(2:$),zetaref(2:$));
+assert_checktrue(abs(abs(zeta(1))-1)<100*%eps);
 dt=1;
 [wn,zeta]=damp(tf2ss(syslin(dt,1,prod(P))));
 t1=log(1+%i)/dt;
@@ -85,7 +90,8 @@ t2=log(2-3*%i)/dt;
 wnref=[0;log(2);abs(t1);abs(t1);abs(t2);abs(t2);%inf];
 zetaref=[1;-1;-real(t1)/abs(t1);-real(t1)/abs(t1);-real(t2)/abs(t2);-real(t2)/abs(t2);%nan];
 assert_checkalmostequal (wn,wnref) ;
-assert_checkalmostequal (zeta,zetaref) ;
+assert_checkalmostequal (zeta(2:$),zetaref(2:$)) ;
+assert_checktrue(abs(abs(zeta(1))-1)<100*%eps);
 //invalid calls
 assert_checkfalse(execstr("[wn,zeta]=damp()","errcatch")==0);
 assert_checkfalse(execstr("[wn,zeta]=damp(%t)","errcatch")==0);
index 20aa3a7..dcd8f4f 100644 (file)
@@ -58,7 +58,8 @@ t2=log(2-3*%i)/dt;
 wnref=[0;log(2);abs(t1);abs(t1);abs(t2);abs(t2);%inf];
 zetaref=[-1;-1;-real(t1)/abs(t1);-real(t1)/abs(t1);-real(t2)/abs(t2);-real(t2)/abs(t2);%nan];
 assert_checkalmostequal (wn,wnref);
-assert_checkalmostequal (zeta,zetaref);
+assert_checkalmostequal (zeta(2:$),zetaref(2:$));
+assert_checktrue(abs(abs(zeta(1))-1)<100*%eps);
 
 dt=1;
 [wn,zeta]=damp(prod(P),dt);
@@ -67,14 +68,18 @@ t2=log(2-3*%i)/dt;
 wnref=[0;log(2);abs(t1);abs(t1);abs(t2);abs(t2);%inf];
 zetaref=[1;-1;-real(t1)/abs(t1);-real(t1)/abs(t1);-real(t2)/abs(t2);-real(t2)/abs(t2);%nan];
 assert_checkalmostequal (wn,wnref);
-assert_checkalmostequal (zeta,zetaref);
+assert_checkalmostequal (zeta(2:$),zetaref(2:$));
+assert_checktrue(abs(abs(zeta(1))-1)<100*%eps);
+
 
 //transfer function
 [wn,zeta]=damp(syslin('c',ones(1,3),P));
 wnref=[0;1;sqrt(2);sqrt(2);2;sqrt(13);sqrt(13)];
 zetaref=[-1;-1;-sqrt(2)/2;-sqrt(2)/2;-1;-2/sqrt(13);-2/sqrt(13)];
 assert_checkalmostequal (wn,wnref);
-assert_checkalmostequal (zeta,zetaref);
+assert_checkalmostequal (zeta(2:$),zetaref(2:$));
+assert_checktrue(abs(abs(zeta(1))-1)<100*%eps);
+
 
 dt=1;
 [wn,zeta]=damp(syslin(dt,ones(1,3),P));
@@ -83,14 +88,16 @@ t2=log(2-3*%i)/dt;
 wnref=[0;log(2);abs(t1);abs(t1);abs(t2);abs(t2);%inf];
 zetaref=[1;-1;-real(t1)/abs(t1);-real(t1)/abs(t1);-real(t2)/abs(t2);-real(t2)/abs(t2);%nan];
 assert_checkalmostequal (wn,wnref);
-assert_checkalmostequal (zeta,zetaref);
+assert_checkalmostequal (zeta(2:$),zetaref(2:$));
+assert_checktrue(abs(abs(zeta(1))-1)<100*%eps);
 
 //state-space
 [wn,zeta]=damp(tf2ss(syslin('c',1,prod(P))));
 wnref=[0;1;sqrt(2);sqrt(2);2;sqrt(13);sqrt(13)];
 zetaref=[-1;-1;-sqrt(2)/2;-sqrt(2)/2;-1;-2/sqrt(13);-2/sqrt(13)];
 assert_checkalmostequal (wn,wnref);
-assert_checkalmostequal (zeta,zetaref);
+assert_checkalmostequal (zeta(2:$),zetaref(2:$));
+assert_checktrue(abs(abs(zeta(1))-1)<100*%eps);
 
 dt=1;
 [wn,zeta]=damp(tf2ss(syslin(dt,1,prod(P))));
@@ -99,7 +106,8 @@ t2=log(2-3*%i)/dt;
 wnref=[0;log(2);abs(t1);abs(t1);abs(t2);abs(t2);%inf];
 zetaref=[1;-1;-real(t1)/abs(t1);-real(t1)/abs(t1);-real(t2)/abs(t2);-real(t2)/abs(t2);%nan];
 assert_checkalmostequal (wn,wnref) ;
-assert_checkalmostequal (zeta,zetaref) ;
+assert_checkalmostequal (zeta(2:$),zetaref(2:$)) ;
+assert_checktrue(abs(abs(zeta(1))-1)<100*%eps);
 
 //invalid calls
 assert_checkfalse(execstr("[wn,zeta]=damp()","errcatch")==0);