summaryrefslogtreecommitdiffstats
path: root/scilab/modules/linear_algebra
diff options
context:
space:
mode:
authorMichaŽl Baudin <michael.baudin@scilab.org>2010-04-13 16:25:26 +0200
committerMichaŽl Baudin <michael.baudin@scilab.org>2010-04-13 16:25:26 +0200
commitf8306ff4bfe2f16e9b89a53135b9bd4a3c00f878 (patch)
tree5e3e181560a45e0d27286a0cf36d2f7b2cb77ba4 /scilab/modules/linear_algebra
parentaa7562c863b369ba7f9546da2cbc065ec2a50ab2 (diff)
downloadscilab-f8306ff4bfe2f16e9b89a53135b9bd4a3c00f878.zip
scilab-f8306ff4bfe2f16e9b89a53135b9bd4a3c00f878.tar.gz
Managed NaNs, but not done : still discrepancies
Diffstat (limited to 'scilab/modules/linear_algebra')
-rw-r--r--scilab/modules/linear_algebra/tests/nonreg_tests/bug_2775.tst74
1 files changed, 52 insertions, 22 deletions
diff --git a/scilab/modules/linear_algebra/tests/nonreg_tests/bug_2775.tst b/scilab/modules/linear_algebra/tests/nonreg_tests/bug_2775.tst
index 7d4a33d..9a46e52 100644
--- a/scilab/modules/linear_algebra/tests/nonreg_tests/bug_2775.tst
+++ b/scilab/modules/linear_algebra/tests/nonreg_tests/bug_2775.tst
@@ -2,27 +2,58 @@
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2008 - INRIA - Allan CORNET 3// Copyright (C) 2008 - INRIA - Allan CORNET
4// Copyright (C) 2009 - INRIA - Michael Baudin, Antoine Elias 4// Copyright (C) 2009 - INRIA - Michael Baudin, Antoine Elias
5// Copyright (C) 2010 - DIGITEO - Michael Baudin
5// 6//
6// This file is distributed under the same license as the Scilab package. 7// This file is distributed under the same license as the Scilab package.
7// ============================================================================= 8// =============================================================================
8
9// <-- Non-regression test for bug 2775 --> 9// <-- Non-regression test for bug 2775 -->
10// 10//
11// <-- JVM NOT MANDATORY -->
11// <-- Bugzilla URL --> 12// <-- Bugzilla URL -->
12// http://bugzilla.scilab.org/show_bug.cgi?id=2775 13// http://bugzilla.scilab.org/show_bug.cgi?id=2775
13// 14//
14res_1 = 0.0 * %nan;
15res_2 = %nan * 0.0;
16 15
17if ~isnan(res_1) then pause,end
18if ~isnan(res_2) then pause,end
19 16
20// Full tests after reading from 17//
18// assert_equal --
19// Returns 1 if the two real matrices computed and expected are equal.
20// Arguments
21// computed, expected : the two matrices to compare
22// epsilon : a small number
23//
24function flag = assert_equal ( computed , expected )
25 if ( type(computed) == 1 & type(expected) == 1 ) then
26 csize = size (computed,"*")
27 esize = size (expected,"*")
28 [cnonan , cnumb] = thrownan(computed)
29 [enonan , enumb] = thrownan(expected)
30 if ( and(enonan == cnonan) & and(enumb == cnumb) ) then
31 flag = 1;
32 else
33 flag = 0;
34 end
35 else
36 if computed==expected then
37 flag = 1;
38 else
39 flag = 0;
40 end
41 end
42 if flag <> 1 then pause,end
43endfunction
44
45// Bibliography :
21// "IEEE Standard for Floating-Point Arithmetic" 46// "IEEE Standard for Floating-Point Arithmetic"
22// IEEE Std 754?-2008 47// IEEE Std 754-2008
23// 29 August 2008 48// 29 August 2008
24// (Revision of IEEE Std 754-1985) 49// (Revision of IEEE Std 754-1985)
25 50
51res_1 = 0.0 * %nan;
52res_2 = %nan * 0.0;
53
54assert_equal ( res_1 , %nan );
55assert_equal ( res_2 , %nan );
56
26expectedadd = [ 57expectedadd = [
27-%inf -%inf -%inf -%inf -%inf %nan %nan 58-%inf -%inf -%inf -%inf -%inf %nan %nan
28-%inf -2 -1 -1 0 %inf %nan 59-%inf -2 -1 -1 0 %inf %nan
@@ -90,22 +121,21 @@ computedsqrt = zeros(n);
90computedmodulo = zeros(n,n); 121computedmodulo = zeros(n,n);
91ieee(2) 122ieee(2)
92for i=1:n 123for i=1:n
93for j=1:n
94 l=left(i); 124 l=left(i);
95 r=right(j);
96 computedadd (i,j)=l+r;
97 computedminus (i,j)=l-r;
98 computedmult (i,j)=l*r;
99 computeddiv (i,j)=l/r;
100 computedsqrt (i) = sqrt(l); 125 computedsqrt (i) = sqrt(l);
101 computedmodulo (i,j) = modulo(l , r); 126 for j=1:n
102end 127 r=right(j);
128 computedadd (i,j)=l+r;
129 computedminus (i,j)=l-r;
130 computedmult (i,j)=l*r;
131 computeddiv (i,j)=l/r;
132 computedmodulo (i,j) = modulo(l , r);
133 end
103end 134end
104 135
105if ~and(computedadd <> expectedadd) then pause,end 136assert_equal ( computedadd , expectedadd );
106if ~and(computedminus <> expectedminus) then pause,end 137assert_equal ( computedminus , expectedminus );
107if ~and(computedmult <> expectedmult) then pause,end 138assert_equal ( computedmult , expectedmult );
108if ~and(computeddiv <> expecteddiv) then pause,end 139assert_equal ( computeddiv , expecteddiv );
109if ~and(computedsqrt <> expectedsqrt) then pause,end 140assert_equal ( computedsqrt , expectedsqrt );
110if ~and(computedmodulo <> expectedmodulo) then pause,end 141assert_equal ( computedmodulo , expectedmodulo );
111