PyPO User Manual
Utils.h
Go to the documentation of this file.
1 #include <complex>
2 #include <array>
3 #include <cmath>
4 #include <limits>
5 
6 #define _USE_MATH_DEFINES
7 
8 #ifndef __Utils_h
9 #define __Utils_h
10 
11 /*! \file Utils.h
12  \brief Linear algebra functions for the CPU version of PyPO.
13 
14  Contains double/float overloaded functions for doing basic 3D vector operations.
15 */
16 
17 /**
18  * Class for basic 3D linear algebra functions.
19  *
20  * Note that no function returns. All values are stored inside a variable which is passed by reference to the function.
21  */
22 template <typename T> class Utils
23 {
24 public:
25  // Dot products
26  void dot(const std::array<T, 3> &v1, const std::array<T, 3> &v2, T &out);
27  void dot(const std::array<std::complex<T>, 3> &cv1, const std::array<std::complex<T>, 3> &cv2, std::complex<T> &out);
28  void dot(const std::array<std::complex<T>, 3> &cv1, const std::array<T, 3> &v2, std::complex<T> &out);
29  void dot(const std::array<T, 3> &v1, const std::array<std::complex<T>, 3> &cv2, std::complex<T> &out);
30 
31  // Overloaded cross products
32  void ext(const std::array<T, 3> &v1, const std::array<T, 3> &v2, std::array<T, 3> &out);
33  void ext(const std::array<std::complex<T>, 3> &cv1, const std::array<std::complex<T>, 3> &cv2, std::array<std::complex<T>, 3> &out);
34  void ext(const std::array<std::complex<T>, 3> &cv1, const std::array<T, 3> &v2, std::array<std::complex<T>, 3> &out);
35  void ext(const std::array<T, 3> &v1, const std::array<std::complex<T>, 3> &cv2, std::array<std::complex<T>, 3> &out);
36 
37  // Overloaded absolute value
38  void abs(const std::array<T, 3> &v, T &out);
39 
40  // Difference vectors
41  void diff(const std::array<T, 3> &v1, const std::array<T, 3> &v2, std::array<T, 3> &out);
42  void diff(const std::array<std::complex<T>, 3> &cv1, const std::array<std::complex<T>, 3> &cv2, std::array<std::complex<T>, 3> &out);
43 
44  // Normalization
45  void normalize(const std::array<T, 3> &v, std::array<T, 3> &out);
46 
47  // Addition
48  void add(const std::array<T, 3> &v1, const std::array<T, 3> &v2, std::array<T, 3> &out);
49 
50  // Scalar multiplication
51  void s_mult(const std::array<T, 3> &v, const T &s, std::array<T, 3> &out);
52  void s_mult(const std::array<std::complex<T>, 3> &cv, const std::complex<T> &cs, std::array<std::complex<T>, 3> &out);
53  void s_mult(const std::array<T, 3> &v, const std::complex<T> &cs, std::array<std::complex<T>, 3> &out);
54  void s_mult(const std::array<std::complex<T>, 3> &cv, const T &s, std::array<std::complex<T>, 3> &out);
55 
56  // Conjugation of complex vector
57  void conj(const std::array<std::complex<T>, 3> &cv, std::array<std::complex<T>, 3> &out);
58 
59  // Snell's function
60  void snell(const std::array<T, 3> &vin, const std::array<T, 3> &normal, std::array<T, 3> &out);
61  void snell_t(const std::array<T, 3> &vin, const std::array<T, 3> &normal, T mu, std::array<T, 3> &out);
62 
63  // Dyadic products
64  void dyad(const std::array<T, 3> &v1, const std::array<T, 3> &v2, std::array<std::array<T, 3>, 3> &out);
65 
66  // Real valued matrix-matrix subtraction
67  void matDiff(const std::array<std::array<T, 3>, 3> &m1, const std::array<std::array<T, 3>, 3> &m2, std::array<std::array<T, 3>, 3> &out);
68 
69  // Matrix-vector multiplication
70  void matVec(const std::array<std::array<T, 3>, 3> &m1, const std::array<T, 3> &v1, std::array<T, 3> &out);
71  void matVec(const std::array<std::array<T, 3>, 3> &m1, const std::array<std::complex<T>, 3> &cv1, std::array<std::complex<T>, 3> &out);
72 
73  // 4D-only need real-real method
74  void matVec4(const T *m1, const std::array<T, 3> &v1, std::array<T, 3> &out, bool vec=false);
75 
76  void invmatVec4(const T *m1, const std::array<T, 3> &v1, std::array<T, 3> &out, bool vec=false);
77  void matRot(const std::array<T, 3> &rot, const std::array<T, 3> &v1, const std::array<T, 3> &cRot, std::array<T, 3> &out);
78 };
79 
80 /**
81  * Dot product.
82  *
83  * Take the dot (inner) product of two real valued arrays of size 3.
84  *
85  * @param v1 Array of 3 double/float.
86  * @param v2 Array of 3 double/float.
87  * @param out Scalar double/float.
88  */
89 template <typename T> inline
90 void Utils<T>::dot(const std::array<T, 3> &v1, const std::array<T, 3> &v2, T &out)
91 {
92  out = 0;
93 
94  for(int n=0; n<3; n++)
95  {
96  out += v1[n] * v2[n];
97  }
98 }
99 
100 /**
101  * Dot product.
102  *
103  * Take the dot (inner) product of two complex valued double/float arrays of size 3.
104  *
105  * @param cv1 Array of 3 complex double/float.
106  * @param cv2 Array of 3 complex double/float.
107  * @param out Scalar complex double/float.
108  */
109 template <typename T> inline
110 void Utils<T>::dot(const std::array<std::complex<T>, 3> &cv1, const std::array<std::complex<T>, 3> &cv2, std::complex<T> &out)
111 {
112  out = (0, 0);
113 
114  for(int n=0; n<3; n++)
115  {
116  out += std::conj(cv1[n]) * cv2[n];
117  }
118 }
119 
120 /**
121  * Dot product.
122  *
123  * Take the dot (inner) product of one complex valued and one real valued double/float array of size 3.
124  *
125  * @param cv1 Array of 3 complex double/float.
126  * @param v2 Array of 3 double/float.
127  * @param out Scalar complex double/float.
128  */
129 template <typename T> inline
130 void Utils<T>::dot(const std::array<std::complex<T>, 3> &cv1, const std::array<T, 3> &v2, std::complex<T> &out)
131 {
132  out = (0, 0);
133 
134  for(int n=0; n<3; n++)
135  {
136  out += std::conj(cv1[n]) * v2[n];
137  }
138 }
139 
140 /**
141  * Dot product.
142  *
143  * Take the dot (inner) product of one real valued and one complex valued double/float array of size 3.
144  *
145  * @param v1 Array of 3 double/float.
146  * @param cv2 Array of 3 complex double/float.
147  * @param out Scalar complex double/float.
148  */
149 template <typename T> inline
150 void Utils<T>::dot(const std::array<T, 3> &v1, const std::array<std::complex<T>, 3> &cv2, std::complex<T> &out)
151 {
152  out = (0, 0);
153 
154  for(int n=0; n<3; n++)
155  {
156  out += v1[n] * cv2[n];
157  }
158 }
159 
160 /**
161  * Cross product.
162  *
163  * Take the cross (outer) product of two real valued double/float arrays of size 3.
164  *
165  * @param v1 Array of 3 double/float.
166  * @param v2 Array of 3 double/float.
167  * @param out Array of 3 double/float.
168  */
169 template <typename T> inline
170 void Utils<T>::ext(const std::array<T, 3> &v1, const std::array<T, 3> &v2, std::array<T, 3> &out)
171 {
172  out[0] = v1[1]*v2[2] - v1[2]*v2[1];
173  out[1] = v1[2]*v2[0] - v1[0]*v2[2];
174  out[2] = v1[0]*v2[1] - v1[1]*v2[0];
175 }
176 
177 /**
178  * Cross product.
179  *
180  * Take the cross (outer) product of two complex valued double/float arrays of size 3.
181  *
182  * @param cv1 Array of 3 complex double/float.
183  * @param cv2 Array of 3 complex double/float.
184  * @param out Array of 3 complex double/float.
185  */
186 template <typename T> inline
187 void Utils<T>::ext(const std::array<std::complex<T>, 3> &cv1, const std::array<std::complex<T>, 3> &cv2, std::array<std::complex<T>, 3> &out)
188 {
189  out[0] = cv1[1]*cv2[2] - cv1[2]*cv2[1];
190  out[1] = cv1[2]*cv2[0] - cv1[0]*cv2[2];
191  out[2] = cv1[0]*cv2[1] - cv1[1]*cv2[0];
192 }
193 
194 /**
195  * Cross product.
196  *
197  * Take the cross (outer) product of one complex valued and one real valued double/float array of size 3.
198  *
199  * @param cv1 Array of 3 complex double/float.
200  * @param v2 Array of 3 double/float.
201  * @param out Array of 3 complex double/float.
202  */
203 template <typename T> inline
204 void Utils<T>::ext(const std::array<std::complex<T>, 3> &cv1, const std::array<T, 3> &v2, std::array<std::complex<T>, 3> &out)
205 {
206  out[0] = cv1[1]*v2[2] - cv1[2]*v2[1];
207  out[1] = cv1[2]*v2[0] - cv1[0]*v2[2];
208  out[2] = cv1[0]*v2[1] - cv1[1]*v2[0];
209 }
210 
211 /**
212  * Cross product.
213  *
214  * Take the cross (outer) product of one real valued and one complex valued double/float array of size 3.
215  *
216  * @param v1 Array of 3 double/float.
217  * @param cv2 Array of 3 complex double/float.
218  * @param out Array of 3 complex double/float.
219  */
220 template <typename T> inline
221 void Utils<T>::ext(const std::array<T, 3> &v1, const std::array<std::complex<T>, 3> &cv2, std::array<std::complex<T>, 3> &out)
222 {
223  out[0] = v1[1]*cv2[2] - v1[2]*cv2[1];
224  out[1] = v1[2]*cv2[0] - v1[0]*cv2[2];
225  out[2] = v1[0]*cv2[1] - v1[1]*cv2[0];
226 }
227 
228 /**
229  * Component-wise vector difference.
230  *
231  * Subtract two real valued vectors of size 3, element-wise.
232  *
233  * @param v1 Array of 3 double/float.
234  * @param v2 Array of 3 double/float.
235  * @param out Array of 3 double/float.
236  */
237 template <typename T> inline
238 void Utils<T>::diff(const std::array<T, 3> &v1, const std::array<T, 3> &v2, std::array<T, 3> &out)
239 {
240  for(int n=0; n<3; n++)
241  {
242  out[n] = v1[n] - v2[n];
243  }
244 }
245 
246 /**
247  * Component-wise vector difference.
248  *
249  * Subtract two complex valued vectors of size 3, element-wise.
250  *
251  * @param cv1 Array of 3 complex double/float.
252  * @param cv2 Array of 3 complex double/float.
253  * @param out Array of 3 complex double/float.
254  */
255 template <typename T> inline
256 void Utils<T>::diff(const std::array<std::complex<T>, 3> &cv1, const std::array<std::complex<T>, 3> &cv2, std::array<std::complex<T>, 3> &out)
257 {
258  for(int n=0; n<3; n++)
259  {
260  out[n] = cv1[n] - cv2[n];
261  }
262 }
263 
264 /**
265  * Absolute value.
266  *
267  * Calculate absolute value of real valued vector of size 3.
268  *
269  * @param v Array of 3 double/float.
270  * @param out Scalar double/float.
271  */
272 template <typename T> inline
273 void Utils<T>::abs(const std::array<T, 3> &v, T &out)
274 {
275  dot(v, v, out);
276  out = std::sqrt(out);
277 }
278 
279 /**
280  * Normalize vector.
281  *
282  * Normalize real valued vector of size 3.
283  *
284  * @param v Array of 3 double/float.
285  * @param out Array of 3 double/float.
286  */
287 template <typename T> inline
288 void Utils<T>::normalize(const std::array<T, 3> &v, std::array<T, 3> &out)
289 {
290  T norm;
291  abs(v, norm);
292 
293  if (norm <= std::numeric_limits<T>::denorm_min())
294  {
295  norm = std::numeric_limits<T>::denorm_min();
296  }
297 
298  for( int n=0; n<3; n++)
299  {
300  out[n] = v[n] / norm;
301  }
302 }
303 
304 /**
305  * Vector addition.
306  *
307  * Add two real valued vectors of size 3 element-wise.
308  *
309  * @param v1 Array of 3 double/float.
310  * @param v2 Array of 3 double/float.
311  * @param out Array of 3 complex double/float.
312  */
313 template <typename T> inline
314 void Utils<T>::add(const std::array<T, 3> &v1, const std::array<T, 3> &v2, std::array<T, 3> &out)
315 {
316  for(int n=0; n<3; n++)
317  {
318  out[n] = v1[n] + v2[n];
319  }
320 }
321 
322 /**
323  * Scalar multiplication.
324  *
325  * Multiply real valued vector of size 3 by real scalar, element-wise.
326  *
327  * @param v Array of 3 double/float.
328  * @param s Scalar double/float.
329  * @param out Array of 3 double/float.
330  */
331 template <typename T> inline
332 void Utils<T>::s_mult(const std::array<T, 3> &v, const T &s, std::array<T, 3> &out)
333 {
334  for(int n=0; n<3; n++)
335  {
336  out[n] = s * v[n];
337  }
338 }
339 
340 /**
341  * Scalar multiplication.
342  *
343  * Multiply complex valued vector of size 3 by complex scalar, element-wise.
344  *
345  * @param cv Array of 3 complex double/float.
346  * @param cs Scalar complex double/float.
347  * @param out Array of 3 complex double/float.
348  */
349 template <typename T> inline
350 void Utils<T>::s_mult(const std::array<std::complex<T>, 3> &cv, const std::complex<T> &cs, std::array<std::complex<T>, 3> &out)
351 {
352  for(int n=0; n<3; n++)
353  {
354  out[n] = cs * cv[n];
355  }
356 }
357 
358 /**
359  * Scalar multiplication.
360  *
361  * Multiply real valued vector of size 3 by complex scalar, element-wise.
362  *
363  * @param v Array of 3 double/float.
364  * @param cs Scalar complex double/float.
365  * @param out Array of 3 complex double/float.
366  */
367 template <typename T> inline
368 void Utils<T>::s_mult(const std::array<T, 3> &v, const std::complex<T> &cs, std::array<std::complex<T>, 3> &out)
369 {
370  for(int n=0; n<3; n++)
371  {
372  out[n] = cs * v[n];
373  }
374 }
375 
376 /**
377  * Scalar multiplication.
378  *
379  * Multiply complex valued vector of size 3 by real scalar, element-wise.
380  *
381  * @param cv Array of 3 complex double/float.
382  * @param s Scalar double/float.
383  * @param out Array of 3 complex double/float.
384  */
385 template <typename T> inline
386 void Utils<T>::s_mult(const std::array<std::complex<T>, 3> &cv, const T &s, std::array<std::complex<T>, 3> &out)
387 {
388  for(int n=0; n<3; n++)
389  {
390  out[n] = s * cv[n];
391  }
392 }
393 
394 /**
395  * Conjugate.
396  *
397  * Conjugate complex valued vector of size 3.
398  *
399  * @param cv Array of 3 complex double/float.
400  * @param out Array of 3 complex double/float.
401  */
402 template <typename T> inline
403 void Utils<T>::conj(const std::array<std::complex<T>, 3> &cv, std::array<std::complex<T>, 3> &out)
404 {
405  for(int n=0; n<3; n++)
406  {
407  out[n] = std::conj(cv[n]);
408  }
409 }
410 
411 /**
412  * Snell's law for reflection.
413  *
414  * Calculate reflected direction vector from incoming direction and normal vector.
415  *
416  * @param vin Array of 3 double/float, incoming direction vector.
417  * @param normal Array of 3 double/float, normal vector of surface.
418  * @param out Array of 3 double/float.
419  */
420 template <typename T> inline
421 void Utils<T>::snell(const std::array<T, 3> &vin, const std::array<T, 3> &normal, std::array<T, 3> &out)
422 {
423  T factor;
424  dot(vin, normal, factor);
425 
426  factor = 2. * factor;
427 
428  std::array<T, 3> rhs;
429  s_mult(normal, factor, rhs);
430 
431  diff(vin, rhs, out);
432 }
433 
434 /**
435  * Snell's law refraction.
436  *
437  * Calculate refracted direction vector from incoming direction and normal vector.
438  *
439  * @param vin Array of 3 double/float, incoming direction vector.
440  * @param normal Array of 3 double/float, normal vector of surface.
441  * @param mu Ratio of n1 to n2.
442  * @param out Array of 3 double/float.
443  */
444 template <typename T> inline
445 void Utils<T>::snell_t(const std::array<T, 3> &vin, const std::array<T, 3> &normal, T mu, std::array<T, 3> &out)
446 {
447  T in_dot_n, factor1;
448  std::array<T, 3> term1, term2, temp1, temp2;
449 
450  dot(normal, vin, in_dot_n);
451 
452  factor1 = sqrt(1 - mu*mu * (1 - in_dot_n*in_dot_n));
453  s_mult(normal, factor1, term1);
454 
455  s_mult(normal, in_dot_n, temp1);
456  diff(vin, temp1, temp2);
457  s_mult(temp2, mu, term2);
458 
459  add(term1, term2, out);
460 }
461 
462 /**
463  * Dyadic product.
464  *
465  * Calculate dyadic product between two real valued double/float vectors of size 3.
466  *
467  * @param v1 Array of 3 double/float.
468  * @param v2 Array of 3 double/float.
469  * @param out Array of 3 double/float, nested inside array of size 3.
470  */
471 template <typename T> inline
472 void Utils<T>::dyad(const std::array<T, 3> &v1, const std::array<T, 3> &v2, std::array<std::array<T, 3>, 3> &out)
473 {
474  for(int n=0; n<3; n++)
475  {
476  out[n][0] = v1[n] * v2[0];
477  out[n][1] = v1[n] * v2[1];
478  out[n][2] = v1[n] * v2[2];
479  }
480 }
481 
482 /**
483  * Matrix difference, element wise.
484  *
485  * Subtract two 3x3 matrices, element wise.
486  *
487  * @param m1 Array of 3 double/float, nested inside array of size 3.
488  * @param m2 Array of 3 double/float, nested inside array of size 3.
489  * @param out Array of 3 double/float, nested inside array of size 3.
490  */
491 template <typename T> inline
492 void Utils<T>::matDiff(const std::array<std::array<T, 3>, 3> &m1, const std::array<std::array<T, 3>, 3> &m2, std::array<std::array<T, 3>, 3> &out)
493 {
494  for(int n=0; n<3; n++)
495  {
496  out[n][0] = m1[n][0] - m2[n][0];
497  out[n][1] = m1[n][1] - m2[n][1];
498  out[n][2] = m1[n][2] - m2[n][2];
499  }
500 }
501 
502 /**
503  * Matrix-vector product.
504  *
505  * Multiply a real valued 3x3 matrix and a real valued size 3 vector to generate a new real valued size 3 vector.
506  *
507  * @param m1 Array of 3 double/float, nested inside array of size 3.
508  * @param v1 Array of 3 double/float.
509  * @param out Array of 3 double/float.
510  */
511 template <typename T> inline
512 void Utils<T>::matVec(const std::array<std::array<T, 3>, 3> &m1, const std::array<T, 3> &v1, std::array<T, 3> &out)
513 {
514  for(int n=0; n<3; n++)
515  {
516  out[n] = m1[n][0] * v1[0] + m1[n][1] * v1[1] + m1[n][2] * v1[2];
517  }
518 }
519 
520 /**
521  * Matrix-vector product.
522  *
523  * Multiply a real valued 3x3 matrix and a complex valued size 3 vector to generate a new complex valued size 3 vector.
524  *
525  * @param m1 Array of 3 double/float, nested inside array of size 3.
526  * @param cv1 Array of 3 complex double/float.
527  * @param out Array of 3 complex double/float.
528  */
529 template <typename T> inline
530 void Utils<T>::matVec(const std::array<std::array<T, 3>, 3> &m1, const std::array<std::complex<T>, 3> &cv1, std::array<std::complex<T>, 3> &out)
531 {
532  for(int n=0; n<3; n++)
533  {
534  out[n] = m1[n][0] * cv1[0] + m1[n][1] * cv1[1] + m1[n][2] * cv1[2];
535  }
536 }
537 
538 /**
539  * Matrix-vector product.
540  *
541  * Multiply a real valued 4x4 matrix and a real valued size 3 vector to generate a new real valued size 3 vector.
542  * This function is only used for multiplying 3D vectors by a 4D transformation matrix.
543  *
544  * @param m1 Array of 4 double/float, nested inside array of size 4.
545  * @param v1 Array of 3 double/float.
546  * @param out Array of 3 double/float.
547  * @param vec Whether or not to transform v1 as a point or a vector.
548  */
549 template <typename T> inline
550 void Utils<T>::matVec4(const T *m1, const std::array<T, 3> &v1, std::array<T, 3> &out, bool vec)
551 {
552  if (vec)
553  {
554  for(int n=0; n<3; n++)
555  {
556  out[n] = m1[n*4] * v1[0] + m1[1+n*4] * v1[1] + m1[2+n*4] * v1[2];
557  }
558  }
559 
560  else
561  {
562  for(int n=0; n<3; n++)
563  {
564  out[n] = m1[n*4] * v1[0] + m1[1+n*4] * v1[1] + m1[2+n*4] * v1[2] + m1[3+n*4];
565  }
566  }
567 }
568 
569 /**
570  * Inverse matrix-vector product.
571  *
572  * Multiply the inverse of a real valued 4x4 matrix by a real valued size 3 vector to generate a new size 3 vector.
573  * This function is only used for multiplying 3D vectors by a 4D transformation matrix.
574  *
575  * @param m1 Array of 4 double/float, nested inside array of size 4.
576  * @param v1 Array of 3 double/float.
577  * @param out Array of 3 double/float.
578  * @param vec Whether or not to transform v1 as a point or a vector.
579  */
580 template <typename T> inline
581 void Utils<T>::invmatVec4(const T *m1, const std::array<T, 3> &v1, std::array<T, 3> &out, bool vec)
582 {
583  if (vec)
584  {
585  for(int n=0; n<3; n++)
586  {
587  out[n] = m1[n] * v1[0] + m1[n+4] * v1[1] + m1[n+8] * v1[2];
588  }
589  }
590 
591  else
592  {
593  T temp;
594  for(int n=0; n<3; n++)
595  {
596  temp = -m1[n]*m1[3] - m1[n+4]*m1[7] - m1[n+8]*m1[11];
597  out[n] = m1[n] * v1[0] + m1[n+4] * v1[1] + m1[n+8] * v1[2] + temp;
598  }
599  }
600 }
601 
602 /**
603  * Manual vector rotation.
604  *
605  * Rotate a real valued size 3 vector without defining a transformation matrix.
606  *
607  * @param rot Array of 3 double/float, containing rotation angles.
608  * @param v1 Array of 3 double/float.
609  * @param cRot Array of 3, center of rotation.
610  * @param out Array of 3 double/float.
611  */
612 template <typename T> inline
613 void Utils<T>::matRot(const std::array<T, 3> &rot, const std::array<T, 3> &v1, const std::array<T, 3> &cRot, std::array<T, 3> &out)
614 {
615  T cosx = cos(rot[0]);
616  T cosy = cos(rot[1]);
617  T cosz = cos(rot[2]);
618 
619  T sinx = sin(rot[0]);
620  T siny = sin(rot[1]);
621  T sinz = sin(rot[2]);
622 
623  T mu = cosz * siny;
624  T rho = sinz * siny;
625 
626  std::array<T, 3> to_rot;
627 
628  for(int n=0; n<3; n++) {to_rot[n] = v1[n] - cRot[n];}
629 
630  out[0] = cosz*cosy * to_rot[0] + (mu*sinx - sinz*cosx) * to_rot[1] + (mu*cosx + sinz*sinx) * to_rot[2];
631  out[1] = sinz*cosy * to_rot[0] + (rho*sinx + cosz*cosx) * to_rot[1] + (rho*cosx - cosz*sinx) * to_rot[2];
632  out[2] = -siny * to_rot[0] + cosy*sinx * to_rot[1] + cosy*cosx * to_rot[2];
633 
634  for(int n=0; n<3; n++) {out[n] = out[n] + cRot[n];}
635 }
636 
637 #endif
__device__ __inline__ void diff(float(&v1)[3], float(&v2)[3], float(&out)[3])
Definition: GUtils.h:162
__device__ __inline__ void abs(float(&v)[3], float &out)
Definition: GUtils.h:195
__device__ __inline__ void s_mult(float(&v)[3], float &s, float(&out)[3])
Definition: GUtils.h:268
__device__ __inline__ void add(float(&v1)[3], float(&v2)[3], float(&out)[3])
Definition: GUtils.h:251
__device__ __inline__ void dot(float(&v1)[3], float(&v2)[3], float &out)
Definition: GUtils.h:21
Definition: Utils.h:23
void ext(const std::array< T, 3 > &v1, const std::array< std::complex< T >, 3 > &cv2, std::array< std::complex< T >, 3 > &out)
Definition: Utils.h:221
void abs(const std::array< T, 3 > &v, T &out)
Definition: Utils.h:273
void dyad(const std::array< T, 3 > &v1, const std::array< T, 3 > &v2, std::array< std::array< T, 3 >, 3 > &out)
Definition: Utils.h:472
void s_mult(const std::array< std::complex< T >, 3 > &cv, const std::complex< T > &cs, std::array< std::complex< T >, 3 > &out)
Definition: Utils.h:350
void diff(const std::array< std::complex< T >, 3 > &cv1, const std::array< std::complex< T >, 3 > &cv2, std::array< std::complex< T >, 3 > &out)
Definition: Utils.h:256
void invmatVec4(const T *m1, const std::array< T, 3 > &v1, std::array< T, 3 > &out, bool vec=false)
Definition: Utils.h:581
void normalize(const std::array< T, 3 > &v, std::array< T, 3 > &out)
Definition: Utils.h:288
void ext(const std::array< T, 3 > &v1, const std::array< T, 3 > &v2, std::array< T, 3 > &out)
Definition: Utils.h:170
void dot(const std::array< std::complex< T >, 3 > &cv1, const std::array< std::complex< T >, 3 > &cv2, std::complex< T > &out)
Definition: Utils.h:110
void matVec(const std::array< std::array< T, 3 >, 3 > &m1, const std::array< T, 3 > &v1, std::array< T, 3 > &out)
Definition: Utils.h:512
void dot(const std::array< T, 3 > &v1, const std::array< std::complex< T >, 3 > &cv2, std::complex< T > &out)
Definition: Utils.h:150
void dot(const std::array< std::complex< T >, 3 > &cv1, const std::array< T, 3 > &v2, std::complex< T > &out)
Definition: Utils.h:130
void snell_t(const std::array< T, 3 > &vin, const std::array< T, 3 > &normal, T mu, std::array< T, 3 > &out)
Definition: Utils.h:445
void s_mult(const std::array< std::complex< T >, 3 > &cv, const T &s, std::array< std::complex< T >, 3 > &out)
Definition: Utils.h:386
void matVec(const std::array< std::array< T, 3 >, 3 > &m1, const std::array< std::complex< T >, 3 > &cv1, std::array< std::complex< T >, 3 > &out)
Definition: Utils.h:530
void add(const std::array< T, 3 > &v1, const std::array< T, 3 > &v2, std::array< T, 3 > &out)
Definition: Utils.h:314
void diff(const std::array< T, 3 > &v1, const std::array< T, 3 > &v2, std::array< T, 3 > &out)
Definition: Utils.h:238
void ext(const std::array< std::complex< T >, 3 > &cv1, const std::array< std::complex< T >, 3 > &cv2, std::array< std::complex< T >, 3 > &out)
Definition: Utils.h:187
void matDiff(const std::array< std::array< T, 3 >, 3 > &m1, const std::array< std::array< T, 3 >, 3 > &m2, std::array< std::array< T, 3 >, 3 > &out)
Definition: Utils.h:492
void s_mult(const std::array< T, 3 > &v, const std::complex< T > &cs, std::array< std::complex< T >, 3 > &out)
Definition: Utils.h:368
void matVec4(const T *m1, const std::array< T, 3 > &v1, std::array< T, 3 > &out, bool vec=false)
Definition: Utils.h:550
void s_mult(const std::array< T, 3 > &v, const T &s, std::array< T, 3 > &out)
Definition: Utils.h:332
void ext(const std::array< std::complex< T >, 3 > &cv1, const std::array< T, 3 > &v2, std::array< std::complex< T >, 3 > &out)
Definition: Utils.h:204
void dot(const std::array< T, 3 > &v1, const std::array< T, 3 > &v2, T &out)
Definition: Utils.h:90
void snell(const std::array< T, 3 > &vin, const std::array< T, 3 > &normal, std::array< T, 3 > &out)
Definition: Utils.h:421
void matRot(const std::array< T, 3 > &rot, const std::array< T, 3 > &v1, const std::array< T, 3 > &cRot, std::array< T, 3 > &out)
Definition: Utils.h:613
void conj(const std::array< std::complex< T >, 3 > &cv, std::array< std::complex< T >, 3 > &out)
Definition: Utils.h:403