fix divide Sparse by Double
[scilab.git] / scilab / modules / ast / tests / unit_tests / divide.dia.ref
1 // ============================================================================
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) 2012 - DIGITEO - Antoine ELIAS
4 //
5 //  This file is distributed under the same license as the Scilab package.
6 // ============================================================================
7 // <-- JVM NOT MANDATORY -->
8 r = 2;
9 R = [1,2;3,4];
10 R3(:,:,1) = R;
11 R3(:,:,2) = R';
12 c = 1 + 2*%i;
13 C = [1+2*%i,2+4*%i;3+6*%i,4+8*%i];
14 C3(:,:,1) = C;
15 C3(:,:,2) = C';
16 SP = sparse([1,2;4,5;3,10],[1,2,3]);
17 SPC = sparse([1,2;4,5;3,10],[1,2,3]) * ( 1 + 4*%i);
18 //double / double
19 //r / r
20 assert_checkalmostequal(r / r, 1);
21 //r / c
22 assert_checkalmostequal(r / c, 0.4-0.8*%i);
23 //c / r
24 assert_checkalmostequal(c / r, 0.5+%i);
25 //c / c
26 assert_checkalmostequal(c / c, 1);
27 //double / DOUBLE
28 //r / R
29 assert_checkalmostequal(r / R, [-4,2;3,-1]);
30 //r / C
31 assert_checkalmostequal(r / C, [-0.8+1.6*%i,0.4-0.8*%i;0.6-1.2*%i,-0.2+0.4*%i]);
32 //c / R
33 assert_checkalmostequal(c / R, [-2-4*%i,1+2*%i;1.5+3*%i,-0.5-1*%i]);
34 //c / C
35 assert_checkalmostequal(c / C, [-2,1;1.5,-0.5]);
36 //DOUBLE / double
37 //R / r
38 assert_checkalmostequal(R / r, [0.5,1;1.5,2]);
39 R3rref(:,:,1) = [0.5,1;1.5,2];
40 R3rref(:,:,2) = [0.5,1.5;1,2];
41 assert_checkalmostequal(R3 / r, R3rref);
42 //R / c
43 assert_checkalmostequal(R / c, [0.2-0.4*%i,0.4-0.8*%i;0.6-1.2*%i,0.8-1.6*%i]);
44 R3cref(:,:,1) = [0.2-0.4*%i,0.4-0.8*%i;0.6-1.2*%i,0.8-1.6*%i];
45 R3cref(:,:,2) = [0.2-0.4*%i,0.6-1.2*%i;0.4-0.8*%i,0.8-1.6*%i];
46 assert_checkalmostequal(R3 / c, R3cref);
47 //C / r
48 assert_checkalmostequal(C / r, [0.5+1*%i,1+2*%i;1.5+3*%i,2+4*%i]);
49 C3rref(:,:,1) = [0.5+1*%i,1+2*%i;1.5+3*%i,2+4*%i];
50 C3rref(:,:,2) = [0.5-1*%i,1.5-3*%i;1-2*%i,2-4*%i];
51 assert_checkalmostequal(C3 / r, C3rref);
52 //C / c
53 assert_checkalmostequal(C / c, [1,2;3,4]);
54 C3cref(:,:,1) = [1,2;3,4];
55 C3cref(:,:,2) = [-0.6-0.8*%i,-1.8-2.4*%i;-1.2-1.6*%i,-2.4-3.2*%i];
56 assert_checkalmostequal(C3 / c, C3cref);
57 //DOUBLE / DOUBLE
58 //R / R
59 assert_checkalmostequal(R / R, [1,0;0,1]);
60 //R / C
61 assert_checkalmostequal(R / C, [0.2-0.4*%i,0;0,0.2-0.4*%i]);
62 //C / R
63 assert_checkalmostequal(C / R, [1+2*%i,0;0,1+2*%i]);
64 //C / C
65 assert_checkalmostequal(C / C, [1,0;0,1]);
66 //SPARSE / double
67 //SP / r
68 assert_checkalmostequal(SP/ r, sparse([1,2;4,5;3,10],[0.5,1,1.5]));
69 //SP / c
70 assert_checkalmostequal(SP/ c, sparse([1,2;4,5;3,10],[0.2-0.4*%i,0.4-0.8*%i,0.6-1.2*%i]));
71 //SPC /r
72 assert_checkalmostequal(SPC/ r, sparse([1,2;4,5;3,10],[0.5+2*%i,1+4*%i,1.5+6*%i]));
73 //SPC /c
74 assert_checkalmostequal(SPC/ c, sparse([1,2;4,5;3,10],[1.8+0.4*%i,3.6+0.8*%i,5.4+1.2*%i]));