Home My Page Projects Code Snippets Project Openings diderot

# SCM Repository

[diderot] View of /branches/pure-cfg/test/bug-matrix.diderot
 [diderot] / branches / pure-cfg / test / bug-matrix.diderot

# View of /branches/pure-cfg/test/bug-matrix.diderot

Wed May 4 08:05:53 2011 UTC (8 years, 8 months ago) by glk
File size: 1053 byte(s)
`3x3 matrix subtraction is addition`
```/*

If 3x3 matrix subtraction works, mip.txt will be:

0.928571 -0.142857 0.214286
-0.142857 0.714286 0.428571
0.214286 0.428571 0.357143
0.928571 -0.142857 0.214286
-0.142857 0.714286 0.428571
0.214286 0.428571 0.357143

That is, the same three lines, repeated twice.

*/

strand subtract (int bugvali) {
output vec3 out = [0.0, 0.0, 0.0];
int vali = bugvali;

update {
vec3 norm = normalize([1.0, 2.0, -3.0]);
tensor[3,3] sub0 = identity[3] + (norm⊗norm*(-1.0));
tensor[3,3] sub1 = identity[3] - norm⊗norm;

if (0 == vali) {
out = sub0•[1.0, 0.0, 0.0];
} else if (1 == vali) {
out = sub0•[0.0, 1.0, 0.0];
} else if (2 == vali) {
out = sub0•[0.0, 0.0, 1.0];
}
else if (3 == vali) {
out = sub1•[1.0, 0.0, 0.0];
} else if (4 == vali) {
out = sub1•[0.0, 1.0, 0.0];
} else if (5 == vali) {
out = sub1•[0.0, 0.0, 1.0];
}

stabilize;
}
}

initially [ subtract(vali) | vali in 0..5 ];
```