Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /branches/charisee/src/include/Diderot/inline-matrix.h
ViewVC logotype

Diff of /branches/charisee/src/include/Diderot/inline-matrix.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2666, Wed Jun 4 01:59:49 2014 UTC revision 2667, Thu Jun 5 18:54:12 2014 UTC
# Line 32  Line 32 
32      dst[0].v = vec2(0.0, 0.0);      dst[0].v = vec2(0.0, 0.0);
33      dst[1].v = vec2(0.0, 0.0);      dst[1].v = vec2(0.0, 0.0);
34  }  }
35    /*
36  STATIC_INLINE void identity2x2 (Diderot_Mat2x2_t dst)  STATIC_INLINE void identity2x2 (Diderot_Mat2x2_t dst)
37  {  {
38      dst[0].v = vec2(1.0, 0.0);      dst[0].v = vec2(1.0, 0.0);
39      dst[1].v = vec2(0.0, 1.0);      dst[1].v = vec2(0.0, 1.0);
40  }  }
41    */
42    
43  STATIC_INLINE Diderot_vec2_t column2x2 (Diderot_Mat2x2_t m, int i)  STATIC_INLINE Diderot_vec2_t column2x2 (Diderot_Mat2x2_t m, int i)
44  {  {
# Line 49  Line 50 
50      dst[0].v = src[0].v;      dst[0].v = src[0].v;
51      dst[1].v = src[1].v;      dst[1].v = src[1].v;
52  }  }
53    /*
54  STATIC_INLINE void scale2x2 (Diderot_Mat2x2_t dst, Diderot_real_t s, Diderot_Mat2x2_t src)  STATIC_INLINE void scale2x2 (Diderot_Mat2x2_t dst, Diderot_real_t s, Diderot_Mat2x2_t src)
55  {  {
56      Diderot_vec2_t scale = vec2(s, s);      Diderot_vec2_t scale = vec2(s, s);
# Line 75  Line 76 
76          dot2(v, column2x2(m, 0)),          dot2(v, column2x2(m, 0)),
77          dot2(v, column2x2(m, 1)));          dot2(v, column2x2(m, 1)));
78  }  }
79    */
80  STATIC_INLINE Diderot_vec2_t mulMat2x2Vec2 (Diderot_Mat2x2_t m, Diderot_vec2_t v)  STATIC_INLINE Diderot_vec2_t mulMat2x2Vec2 (Diderot_Mat2x2_t m, Diderot_vec2_t v)
81  {  {
82      return vec2(dot2(m[0].v, v), dot2(m[1].v, v));      return vec2(dot2(m[0].v, v), dot2(m[1].v, v));
83  }  }
84    /*
85  STATIC_INLINE void mulMat2x2Mat2x2 (Diderot_Mat2x2_t dst, Diderot_Mat2x2_t m1, Diderot_Mat2x2_t m2)  STATIC_INLINE void mulMat2x2Mat2x2 (Diderot_Mat2x2_t dst, Diderot_Mat2x2_t m1, Diderot_Mat2x2_t m2)
86  {  {
87      dst[0].v = vec2(      dst[0].v = vec2(
# Line 90  Line 91 
91          dot2(m1[1].v, column2x2(m2, 0)),          dot2(m1[1].v, column2x2(m2, 0)),
92          dot2(m1[1].v, column2x2(m2, 1)));          dot2(m1[1].v, column2x2(m2, 1)));
93  }  }
94    //need it for /common/image
95     */
96  STATIC_INLINE void transpose2x2 (Diderot_Mat2x2_t dst, Diderot_Mat2x2_t src)  STATIC_INLINE void transpose2x2 (Diderot_Mat2x2_t dst, Diderot_Mat2x2_t src)
97  {  {
98      dst[0].v = column2x2(src, 0);      dst[0].v = column2x2(src, 0);
99      dst[1].v = column2x2(src, 1);      dst[1].v = column2x2(src, 1);
100  }  }
101    
102    
103  // The Frobenius norm of a matrix is the sqrt of the sum of the squares of the elements  // The Frobenius norm of a matrix is the sqrt of the sum of the squares of the elements
104  STATIC_INLINE Diderot_real_t norm2x2 (Diderot_Mat2x2_t m)  STATIC_INLINE Diderot_real_t norm2x2 (Diderot_Mat2x2_t m)
105  {  {
106      return SQRT(dot2(m[0].v,m[0].v) + dot2(m[1].v,m[1].v));      return SQRT(dot2(m[0].v,m[0].v) + dot2(m[1].v,m[1].v));
107  }  }
108    /*
109  // matrix time matrix ":" product  // matrix time matrix ":" product
110  STATIC_INLINE Diderot_real_t colonProdMat2x2Mat2x2 (Diderot_Mat2x2_t m1, Diderot_Mat2x2_t m2)  STATIC_INLINE Diderot_real_t colonProdMat2x2Mat2x2 (Diderot_Mat2x2_t m1, Diderot_Mat2x2_t m2)
111  {  {
112      return dot2(m1[0].v, m2[0].v) + dot2(m1[1].v, m2[1].v);      return dot2(m1[0].v, m2[0].v) + dot2(m1[1].v, m2[1].v);
113  }  }
114    */
115  /********** 3x3 matrix functions **********/  /********** 3x3 matrix functions **********/
116    
117  STATIC_INLINE void zero3x3 (Diderot_Mat3x3_t dst)  STATIC_INLINE void zero3x3 (Diderot_Mat3x3_t dst)
# Line 117  Line 120 
120      dst[1].v = vec3(0.0, 0.0, 0.0);      dst[1].v = vec3(0.0, 0.0, 0.0);
121      dst[2].v = vec3(0.0, 0.0, 0.0);      dst[2].v = vec3(0.0, 0.0, 0.0);
122  }  }
123    /*
124  STATIC_INLINE void identity3x3 (Diderot_Mat3x3_t dst)  STATIC_INLINE void identity3x3 (Diderot_Mat3x3_t dst)
125  {  {
126      dst[0].v = vec3(1.0, 0.0, 0.0);      dst[0].v = vec3(1.0, 0.0, 0.0);
127      dst[1].v = vec3(0.0, 1.0, 0.0);      dst[1].v = vec3(0.0, 1.0, 0.0);
128      dst[2].v = vec3(0.0, 0.0, 1.0);      dst[2].v = vec3(0.0, 0.0, 1.0);
129  }  }*/
130    
131  STATIC_INLINE Diderot_vec3_t column3x3 (Diderot_Mat3x3_t m, int i)  STATIC_INLINE Diderot_vec3_t column3x3 (Diderot_Mat3x3_t m, int i)
132  {  {
# Line 144  Line 147 
147      dst[1].v = scale * src[1].v;      dst[1].v = scale * src[1].v;
148      dst[2].v = scale * src[2].v;      dst[2].v = scale * src[2].v;
149  }  }
150    /*
151  STATIC_INLINE void add3x3 (Diderot_Mat3x3_t dst, Diderot_Mat3x3_t a, Diderot_Mat3x3_t b)  STATIC_INLINE void add3x3 (Diderot_Mat3x3_t dst, Diderot_Mat3x3_t a, Diderot_Mat3x3_t b)
152  {  {
153      dst[0].v = a[0].v + b[0].v;      dst[0].v = a[0].v + b[0].v;
# Line 166  Line 169 
169          dot3(v, column3x3(m, 1)),          dot3(v, column3x3(m, 1)),
170          dot3(v, column3x3(m, 2)));          dot3(v, column3x3(m, 2)));
171  }  }
172    */
173  STATIC_INLINE Diderot_vec3_t mulMat3x3Vec3 (Diderot_Mat3x3_t m, Diderot_vec3_t v)  STATIC_INLINE Diderot_vec3_t mulMat3x3Vec3 (Diderot_Mat3x3_t m, Diderot_vec3_t v)
174  {  {
175      return vec3(dot3(m[0].v, v), dot3(m[1].v, v), dot3(m[2].v, v));      return vec3(dot3(m[0].v, v), dot3(m[1].v, v), dot3(m[2].v, v));
176  }  }
177    /*
178  STATIC_INLINE void mulMat3x3Mat3x3 (Diderot_Mat3x3_t dst, Diderot_Mat3x3_t m1, Diderot_Mat3x3_t m2)  STATIC_INLINE void mulMat3x3Mat3x3 (Diderot_Mat3x3_t dst, Diderot_Mat3x3_t m1, Diderot_Mat3x3_t m2)
179  {  {
180      dst[0].v = vec3(      dst[0].v = vec3(
# Line 187  Line 190 
190          dot3(m1[2].v, column3x3(m2, 1)),          dot3(m1[2].v, column3x3(m2, 1)),
191          dot3(m1[2].v, column3x3(m2, 2)));          dot3(m1[2].v, column3x3(m2, 2)));
192  }  }
193    */
194  STATIC_INLINE void transpose3x3 (Diderot_Mat3x3_t dst, Diderot_Mat3x3_t src)  STATIC_INLINE void transpose3x3 (Diderot_Mat3x3_t dst, Diderot_Mat3x3_t src)
195  {  {
196      dst[0].v = column3x3(src, 0);      dst[0].v = column3x3(src, 0);
# Line 201  Line 204 
204      return SQRT(dot3(m[0].v,m[0].v) + dot3(m[1].v,m[1].v) + dot3(m[2].v,m[2].v));      return SQRT(dot3(m[0].v,m[0].v) + dot3(m[1].v,m[1].v) + dot3(m[2].v,m[2].v));
205  }  }
206    
207    /*
208  // matrix time matrix ":" product  // matrix time matrix ":" product
209  STATIC_INLINE Diderot_real_t colonProdMat3x3Mat3x3 (Diderot_Mat3x3_t m1, Diderot_Mat3x3_t m2)  STATIC_INLINE Diderot_real_t colonProdMat3x3Mat3x3 (Diderot_Mat3x3_t m1, Diderot_Mat3x3_t m2)
210  {  {
211      return dot3(m1[0].v,m2[0].v) + dot3(m1[1].v,m2[1].v) + dot3(m1[2].v,m2[2].v);      return dot3(m1[0].v,m2[0].v) + dot3(m1[1].v,m2[1].v) + dot3(m1[2].v,m2[2].v);
212  }  }
213    */
214    
215  /********** 4x4 matrix functions **********/  /********** 4x4 matrix functions **********/
216    
# Line 217  Line 221 
221      dst[2].v = vec4(0.0, 0.0, 0.0, 0.0);      dst[2].v = vec4(0.0, 0.0, 0.0, 0.0);
222      dst[3].v = vec4(0.0, 0.0, 0.0, 0.0);      dst[3].v = vec4(0.0, 0.0, 0.0, 0.0);
223  }  }
224    /*
225  STATIC_INLINE void identity4x4 (Diderot_Mat4x4_t dst)  STATIC_INLINE void identity4x4 (Diderot_Mat4x4_t dst)
226  {  {
227      dst[0].v = vec4(1.0, 0.0, 0.0, 0.0);      dst[0].v = vec4(1.0, 0.0, 0.0, 0.0);
228      dst[1].v = vec4(0.0, 1.0, 0.0, 0.0);      dst[1].v = vec4(0.0, 1.0, 0.0, 0.0);
229      dst[2].v = vec4(0.0, 0.0, 1.0, 0.0);      dst[2].v = vec4(0.0, 0.0, 1.0, 0.0);
230      dst[3].v = vec4(0.0, 0.0, 0.0, 1.0);      dst[3].v = vec4(0.0, 0.0, 0.0, 1.0);
231  }  }*/
232    
233  STATIC_INLINE Diderot_vec4_t column4x4 (Diderot_Mat4x4_t m, int i)  STATIC_INLINE Diderot_vec4_t column4x4 (Diderot_Mat4x4_t m, int i)
234  {  {
# Line 247  Line 251 
251      dst[2].v = scale * src[2].v;      dst[2].v = scale * src[2].v;
252      dst[3].v = scale * src[3].v;      dst[3].v = scale * src[3].v;
253  }  }
254    /*
255  STATIC_INLINE void add4x4 (Diderot_Mat4x4_t dst, Diderot_Mat4x4_t a, Diderot_Mat4x4_t b)  STATIC_INLINE void add4x4 (Diderot_Mat4x4_t dst, Diderot_Mat4x4_t a, Diderot_Mat4x4_t b)
256  {  {
257      dst[0].v = a[0].v + b[0].v;      dst[0].v = a[0].v + b[0].v;
# Line 277  Line 281 
281  {  {
282      return vec4(dot4(m[0].v, v), dot4(m[1].v, v), dot4(m[2].v, v), dot4(m[3].v, v));      return vec4(dot4(m[0].v, v), dot4(m[1].v, v), dot4(m[2].v, v), dot4(m[3].v, v));
283  }  }
284    */
285    /*
286  STATIC_INLINE void transpose4x4 (Diderot_Mat4x4_t dst, Diderot_Mat4x4_t src)  STATIC_INLINE void transpose4x4 (Diderot_Mat4x4_t dst, Diderot_Mat4x4_t src)
287  {  {
288      dst[0].v = column4x4(src, 0);      dst[0].v = column4x4(src, 0);
289      dst[1].v = column4x4(src, 1);      dst[1].v = column4x4(src, 1);
290      dst[2].v = column4x4(src, 2);      dst[2].v = column4x4(src, 2);
291      dst[3].v = column4x4(src, 3);      dst[3].v = column4x4(src, 3);
292  }  }*/
293    
294  // The Frobenius norm of a matrix is the sqrt of the sum of the squares of the elements  // The Frobenius norm of a matrix is the sqrt of the sum of the squares of the elements
295  STATIC_INLINE Diderot_real_t norm4x4 (Diderot_Mat4x4_t m)  STATIC_INLINE Diderot_real_t norm4x4 (Diderot_Mat4x4_t m)
296  {  {
297      return sqrt(dot4(m[0].v,m[0].v) + dot4(m[1].v,m[1].v) + dot4(m[2].v,m[2].v) + dot4(m[3].v,m[3].v));      return sqrt(dot4(m[0].v,m[0].v) + dot4(m[1].v,m[1].v) + dot4(m[2].v,m[2].v) + dot4(m[3].v,m[3].v));
298  }  }
299    /*
300  // matrix time matrix ":" product  // matrix time matrix ":" product
301  STATIC_INLINE Diderot_real_t colonProdMat4x4Mat4x4 (Diderot_Mat4x4_t m1, Diderot_Mat4x4_t m2)  STATIC_INLINE Diderot_real_t colonProdMat4x4Mat4x4 (Diderot_Mat4x4_t m1, Diderot_Mat4x4_t m2)
302  {  {
303      return dot4(m1[0].v,m2[0].v) + dot4(m1[1].v,m2[1].v) + dot4(m1[2].v,m2[2].v) + dot4(m1[3].v,m2[3].v);      return dot4(m1[0].v,m2[0].v) + dot4(m1[1].v,m2[1].v) + dot4(m1[2].v,m2[2].v) + dot4(m1[3].v,m2[3].v);
304  }  }
305    */
306  #endif /* !_DIDEROT_INLINE_MATRIX_H_ */  #endif /* !_DIDEROT_INLINE_MATRIX_H_ */

Legend:
Removed from v.2666  
changed lines
  Added in v.2667

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0