HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ImathMatrix.h
Go to the documentation of this file.
1 //
2 // SPDX-License-Identifier: BSD-3-Clause
3 // Copyright Contributors to the OpenEXR Project.
4 //
5 
6 //
7 // 2x2, 3x3, and 4x4 transformation matrix templates
8 //
9 
10 #ifndef INCLUDED_IMATHMATRIX_H
11 #define INCLUDED_IMATHMATRIX_H
12 
13 #include "ImathExport.h"
14 #include "ImathNamespace.h"
15 
16 #include "ImathFun.h"
17 #include "ImathPlatform.h"
18 #include "ImathShear.h"
19 #include "ImathVec.h"
20 
21 #include <cstring>
22 #include <iomanip>
23 #include <iostream>
24 #include <limits>
25 #include <string.h>
26 
27 #if (defined _WIN32 || defined _WIN64) && defined _MSC_VER
28 // suppress exception specification warnings
29 # pragma warning(disable : 4290)
30 #endif
31 
32 IMATH_INTERNAL_NAMESPACE_HEADER_ENTER
33 
34 /// Enum used to indicate uninitialized construction of Matrix22,
35 /// Matrix33, Matrix44
37 {
39 };
40 
41 ///
42 /// 2x2 transformation matrix
43 ///
44 
45 template <class T> class IMATH_EXPORT_TEMPLATE_TYPE Matrix22
46 {
47 public:
48  /// @{
49  /// @name Direct access to elements
50 
51  /// Matrix elements
52  T x[2][2];
53 
54  /// @}
55 
56  /// Row access
57  IMATH_HOSTDEVICE T* operator[] (int i) IMATH_NOEXCEPT;
58 
59  /// Row access
60  IMATH_HOSTDEVICE const T* operator[] (int i) const IMATH_NOEXCEPT;
61 
62  /// @{
63  /// @name Constructors and Assignment
64 
65  /// Uninitialized
67 
68  /// Default constructor: initialize to identity
69  ///
70  /// 1 0
71  /// 0 1
72  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix22 () IMATH_NOEXCEPT;
73 
74  /// Initialize to scalar constant:
75  ///
76  /// a a
77  /// a a
78  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix22 (T a) IMATH_NOEXCEPT;
79 
80  /// Construct from 2x2 array:
81  ///
82  /// a[0][0] a[0][1]
83  /// a[1][0] a[1][1]
84  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix22 (const T a[2][2]) IMATH_NOEXCEPT;
85  /// Construct from given scalar values:
86  ///
87  /// a b
88  /// c d
89  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix22 (T a, T b, T c, T d)
90  IMATH_NOEXCEPT;
91 
92  /// Copy constructor
93  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix22 (const Matrix22& v)
94  IMATH_NOEXCEPT;
95 
96  /// Construct from Matrix22 of another base type
97  template <class S>
98  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 explicit Matrix22 (const Matrix22<S>& v)
99  IMATH_NOEXCEPT;
100 
101  /// Assignment
102  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix22&
103  operator= (const Matrix22& v) IMATH_NOEXCEPT;
104 
105  /// Assignment from scalar
106  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix22&
107  operator= (T a) IMATH_NOEXCEPT;
108 
109  /// Destructor
110  ~Matrix22 () IMATH_NOEXCEPT = default;
111 
112  /// @}
113 
114 #if IMATH_FOREIGN_VECTOR_INTEROP
115  /// @{
116  /// @name Interoperability with other matrix types
117  ///
118  /// Construction and assignment are allowed from other classes that
119  /// appear to be equivalent matrix types, provided that they support
120  /// double-subscript (i.e., `m[j][i]`) giving the same type as the
121  /// elements of this matrix, and their total size appears to be the
122  /// right number of matrix elements.
123  ///
124  /// This functionality is disabled for gcc 4.x, which seems to have a
125  /// compiler bug that results in spurious errors. It can also be
126  /// disabled by defining IMATH_FOREIGN_VECTOR_INTEROP to be 0 prior to
127  /// including any Imath header files.
128  ///
129  template <
130  typename M,
132  IMATH_HOSTDEVICE explicit Matrix22 (const M& m)
133  : Matrix22 (T (m[0][0]), T (m[0][1]), T (m[1][0]), T (m[1][1]))
134  {}
135 
136  template <
137  typename M,
140  {
141  *this = Matrix22 (T (m[0][0]), T (m[0][1]), T (m[1][0]), T (m[1][1]));
142  return *this;
143  }
144  /// @}
145 #endif
146 
147  /// @{
148  /// @name Compatibility with Sb
149 
150  /// Return a raw pointer to the array of values
151  IMATH_HOSTDEVICE T* getValue () IMATH_NOEXCEPT;
152 
153  /// Return a raw pointer to the array of values
154  IMATH_HOSTDEVICE const T* getValue () const IMATH_NOEXCEPT;
155 
156  /// Return the value in `v`
157  template <class S>
158  IMATH_HOSTDEVICE void getValue (Matrix22<S>& v) const IMATH_NOEXCEPT;
159 
160  /// Set the value
161  template <class S>
162  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix22&
163  setValue (const Matrix22<S>& v) IMATH_NOEXCEPT;
164 
165  /// Set the value
166  template <class S>
167  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix22&
168  setTheMatrix (const Matrix22<S>& v) IMATH_NOEXCEPT;
169 
170  /// @}
171 
172  /// @{
173  /// @name Arithmetic and Comparison
174 
175  /// Equality
176  IMATH_HOSTDEVICE constexpr bool
177  operator== (const Matrix22& v) const IMATH_NOEXCEPT;
178 
179  /// Inequality
180  IMATH_HOSTDEVICE constexpr bool
181  operator!= (const Matrix22& v) const IMATH_NOEXCEPT;
182 
183  /// Compare two matrices and test if they are "approximately equal":
184  /// @return True if the coefficients of this and `m` are the same
185  /// with an absolute error of no more than e, i.e., for all i, j:
186  ///
187  /// abs (this[i][j] - m[i][j]) <= e
188  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 bool
189  equalWithAbsError (const Matrix22<T>& v, T e) const IMATH_NOEXCEPT;
190 
191  /// Compare two matrices and test if they are "approximately equal":
192  /// @return True if the coefficients of this and m are the same with
193  /// a relative error of no more than e, i.e., for all i, j:
194  ///
195  /// abs (this[i] - v[i][j]) <= e * abs (this[i][j])
196  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 bool
197  equalWithRelError (const Matrix22<T>& v, T e) const IMATH_NOEXCEPT;
198 
199  /// Component-wise addition
200  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix22&
201  operator+= (const Matrix22& v) IMATH_NOEXCEPT;
202 
203  /// Component-wise addition
204  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix22&
205  operator+= (T a) IMATH_NOEXCEPT;
206 
207  /// Component-wise addition
208  IMATH_HOSTDEVICE constexpr Matrix22
209  operator+ (const Matrix22& v) const IMATH_NOEXCEPT;
210 
211  /// Component-wise subtraction
212  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix22&
213  operator-= (const Matrix22& v) IMATH_NOEXCEPT;
214 
215  /// Component-wise subtraction
216  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix22&
217  operator-= (T a) IMATH_NOEXCEPT;
218 
219  /// Component-wise subtraction
220  IMATH_HOSTDEVICE constexpr Matrix22
221  operator- (const Matrix22& v) const IMATH_NOEXCEPT;
222 
223  /// Component-wise multiplication by -1
224  IMATH_HOSTDEVICE constexpr Matrix22 operator- () const IMATH_NOEXCEPT;
225 
226  /// Component-wise multiplication by -1
227  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix22& negate () IMATH_NOEXCEPT;
228 
229  /// Component-wise multiplication
230  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix22&
231  operator*= (T a) IMATH_NOEXCEPT;
232 
233  /// Component-wise multiplication
234  IMATH_HOSTDEVICE constexpr Matrix22 operator* (T a) const IMATH_NOEXCEPT;
235 
236  /// Component-wise division
237  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix22&
238  operator/= (T a) IMATH_NOEXCEPT;
239 
240  /// Component-wise division
241  IMATH_HOSTDEVICE constexpr Matrix22 operator/ (T a) const IMATH_NOEXCEPT;
242 
243  /// Matrix-matrix multiplication
244  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix22&
245  operator*= (const Matrix22& v) IMATH_NOEXCEPT;
246 
247  /// Matrix-matrix multiplication
248  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix22
249  operator* (const Matrix22& v) const IMATH_NOEXCEPT;
250 
251  /// Vector * matrix multiplication
252  /// @param[in] src Input vector
253  /// @param[out] dst transformed vector
254  template <class S>
255  IMATH_HOSTDEVICE void
256  multDirMatrix (const Vec2<S>& src, Vec2<S>& dst) const IMATH_NOEXCEPT;
257 
258  /// @}
259 
260  /// @{
261  /// @name Maniplation
262 
263  /// Set to the identity
264  IMATH_HOSTDEVICE void makeIdentity () IMATH_NOEXCEPT;
265 
266  /// Transpose
267  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix22&
268  transpose () IMATH_NOEXCEPT;
269 
270  /// Return the transpose
271  IMATH_HOSTDEVICE constexpr Matrix22 transposed () const IMATH_NOEXCEPT;
272 
273  /// Invert in place
274  /// @param singExc If true, throw an exception if the matrix cannot be inverted.
275  /// @return const reference to this
276  IMATH_CONSTEXPR14 const Matrix22& invert (bool singExc);
277 
278  /// Invert in place
279  /// @return const reference to this
280  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix22& invert () IMATH_NOEXCEPT;
281 
282  /// Return the inverse, leaving this unmodified.
283  /// @param singExc If true, throw an exception if the matrix cannot be inverted.
284  IMATH_CONSTEXPR14 Matrix22<T> inverse (bool singExc) const;
285 
286  /// Return the inverse, leaving this unmodified.
287  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix22<T>
288  inverse () const IMATH_NOEXCEPT;
289 
290  /// Determinant
291  IMATH_HOSTDEVICE constexpr T determinant () const IMATH_NOEXCEPT;
292 
293  /// Trace
294  IMATH_HOSTDEVICE constexpr T trace() const IMATH_NOEXCEPT;
295 
296  /// Set matrix to rotation by r (in radians)
297  /// @return const referenced to this
298  template <class S>
299  IMATH_HOSTDEVICE const Matrix22& setRotation (S r) IMATH_NOEXCEPT;
300 
301  /// Rotate the given matrix by r (in radians)
302  /// @return const referenced to this
303  template <class S>
304  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix22&
305  rotate (S r) IMATH_NOEXCEPT;
306 
307  /// Set matrix to scale by given uniform factor
308  /// @return const referenced to this
309  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix22&
310  setScale (T s) IMATH_NOEXCEPT;
311 
312  /// Set matrix to scale by given vector
313  /// @return const referenced to this
314  template <class S>
315  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix22&
316  setScale (const Vec2<S>& s) IMATH_NOEXCEPT;
317 
318  // Scale the matrix by s
319  /// @return const referenced to this
320  template <class S>
321  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix22&
322  scale (const Vec2<S>& s) IMATH_NOEXCEPT;
323 
324  /// @}
325 
326  /// @{
327  /// @name Numeric Limits
328 
329  /// Largest possible negative value
330  IMATH_HOSTDEVICE constexpr static T baseTypeLowest () IMATH_NOEXCEPT
331  {
332  return std::numeric_limits<T>::lowest ();
333  }
334 
335  /// Largest possible positive value
336  IMATH_HOSTDEVICE constexpr static T baseTypeMax () IMATH_NOEXCEPT
337  {
338  return std::numeric_limits<T>::max ();
339  }
340 
341  /// Smallest possible positive value
342  IMATH_HOSTDEVICE constexpr static T baseTypeSmallest () IMATH_NOEXCEPT
343  {
344  return std::numeric_limits<T>::min ();
345  }
346 
347  /// Smallest possible e for which 1+e != 1
348  IMATH_HOSTDEVICE constexpr static T baseTypeEpsilon () IMATH_NOEXCEPT
349  {
350  return std::numeric_limits<T>::epsilon ();
351  }
352 
353  /// @}
354 
355  /// Return the number of the row and column dimensions, i.e. 2.
356  IMATH_HOSTDEVICE constexpr static unsigned int dimensions () IMATH_NOEXCEPT
357  {
358  return 2;
359  }
360 
361  /// The base type: In templates that accept a parameter `V`, you
362  /// can refer to `T` as `V::BaseType`
363  typedef T BaseType;
364 
365  /// The base vector type
367 };
368 
369 ///
370 /// 3x3 transformation matrix
371 ///
372 
373 template <class T> class IMATH_EXPORT_TEMPLATE_TYPE Matrix33
374 {
375 public:
376  /// @{
377  /// @name Direct access to elements
378 
379  /// Matrix elements
380  T x[3][3];
381 
382  /// @}
383 
384  /// Row access
385  IMATH_HOSTDEVICE T* operator[] (int i) IMATH_NOEXCEPT;
386 
387  /// Row access
388  IMATH_HOSTDEVICE const T* operator[] (int i) const IMATH_NOEXCEPT;
389 
390  /// @{
391  /// @name Constructors and Assignment
392 
393  /// Uninitialized
395 
396  /// Default constructor: initialize to identity
397  /// 1 0 0
398  /// 0 1 0
399  /// 0 0 1
400  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix33 () IMATH_NOEXCEPT;
401 
402  /// Initialize to scalar constant
403  /// a a a
404  /// a a a
405  /// a a a
406  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix33 (T a) IMATH_NOEXCEPT;
407 
408  /// Construct from 3x3 array
409  /// a[0][0] a[0][1] a[0][2]
410  /// a[1][0] a[1][1] a[1][2]
411  /// a[2][0] a[2][1] a[2][2]
412  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix33 (const T a[3][3]) IMATH_NOEXCEPT;
413  /// Construct from given scalar values
414  /// a b c
415  /// d e f
416  /// g h i
417  IMATH_HOSTDEVICE IMATH_CONSTEXPR14
418  Matrix33 (T a, T b, T c, T d, T e, T f, T g, T h, T i) IMATH_NOEXCEPT;
419 
420  /// Copy constructor
421  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix33 (const Matrix33& v)
422  IMATH_NOEXCEPT;
423 
424  /// Construct from Matrix33 of another base type
425  template <class S>
426  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 explicit Matrix33 (const Matrix33<S>& v)
427  IMATH_NOEXCEPT;
428 
429  /// Assignment operator
430  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33&
431  operator= (const Matrix33& v) IMATH_NOEXCEPT;
432 
433  /// Assignment from scalar
434  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33&
435  operator= (T a) IMATH_NOEXCEPT;
436 
437  /// Destructor
438  ~Matrix33 () IMATH_NOEXCEPT = default;
439 
440  /// @}
441 
442 #if IMATH_FOREIGN_VECTOR_INTEROP
443  /// @{
444  /// @name Interoperability with other matrix types
445  ///
446  /// Construction and assignment are allowed from other classes that
447  /// appear to be equivalent matrix types, provided that they support
448  /// double-subscript (i.e., `m[j][i]`) giving the same type as the
449  /// elements of this matrix, and their total size appears to be the
450  /// right number of matrix elements.
451  ///
452  /// This functionality is disabled for gcc 4.x, which seems to have a
453  /// compiler bug that results in spurious errors. It can also be
454  /// disabled by defining IMATH_FOREIGN_VECTOR_INTEROP to be 0 prior to
455  /// including any Imath header files.
456  ///
457  template <
458  typename M,
460  IMATH_HOSTDEVICE explicit Matrix33 (const M& m)
461  : Matrix33 (
462  T (m[0][0]),
463  T (m[0][1]),
464  T (m[0][2]),
465  T (m[1][0]),
466  T (m[1][1]),
467  T (m[1][2]),
468  T (m[2][0]),
469  T (m[2][1]),
470  T (m[2][2]))
471  {}
472 
473  /// Interoperability assignment from another type that behaves as if it
474  /// were an equivalent matrix.
475  template <
476  typename M,
479  {
480  *this = Matrix33 (
481  T (m[0][0]),
482  T (m[0][1]),
483  T (m[0][2]),
484  T (m[1][0]),
485  T (m[1][1]),
486  T (m[1][2]),
487  T (m[2][0]),
488  T (m[2][1]),
489  T (m[2][2]));
490  return *this;
491  }
492  /// @}
493 #endif
494 
495  /// @{
496  /// @name Compatibility with Sb
497 
498  /// Return a raw pointer to the array of values
499  IMATH_HOSTDEVICE T* getValue () IMATH_NOEXCEPT;
500 
501  /// Return a raw pointer to the array of values
502  IMATH_HOSTDEVICE const T* getValue () const IMATH_NOEXCEPT;
503 
504  /// Return the value in `v`
505  template <class S>
506  IMATH_HOSTDEVICE void getValue (Matrix33<S>& v) const IMATH_NOEXCEPT;
507 
508  /// Set the value
509  template <class S>
510  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix33&
511  setValue (const Matrix33<S>& v) IMATH_NOEXCEPT;
512 
513  /// Set the value
514  template <class S>
515  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix33&
516  setTheMatrix (const Matrix33<S>& v) IMATH_NOEXCEPT;
517 
518  /// @}
519 
520  /// @{
521  /// @name Arithmetic and Comparison
522 
523  /// Equality
524  IMATH_HOSTDEVICE constexpr bool
525  operator== (const Matrix33& v) const IMATH_NOEXCEPT;
526 
527  /// Inequality
528  IMATH_HOSTDEVICE constexpr bool
529  operator!= (const Matrix33& v) const IMATH_NOEXCEPT;
530 
531  /// Compare two matrices and test if they are "approximately equal":
532  /// @return True if the coefficients of this and `m` are the same
533  /// with an absolute error of no more than e, i.e., for all i, j:
534  ///
535  /// abs (this[i][j] - m[i][j]) <= e
536  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 bool
537  equalWithAbsError (const Matrix33<T>& v, T e) const IMATH_NOEXCEPT;
538 
539  /// Compare two matrices and test if they are "approximately equal":
540  /// @return True if the coefficients of this and m are the same with
541  /// a relative error of no more than e, i.e., for all i, j:
542  ///
543  /// abs (this[i] - v[i][j]) <= e * abs (this[i][j])
544  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 bool
545  equalWithRelError (const Matrix33<T>& v, T e) const IMATH_NOEXCEPT;
546 
547  /// Component-wise addition
548  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33&
549  operator+= (const Matrix33& v) IMATH_NOEXCEPT;
550 
551  /// Component-wise addition
552  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33&
553  operator+= (T a) IMATH_NOEXCEPT;
554 
555  /// Component-wise addition
556  IMATH_HOSTDEVICE constexpr Matrix33
557  operator+ (const Matrix33& v) const IMATH_NOEXCEPT;
558 
559  /// Component-wise subtraction
560  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33&
561  operator-= (const Matrix33& v) IMATH_NOEXCEPT;
562 
563  /// Component-wise subtraction
564  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33&
565  operator-= (T a) IMATH_NOEXCEPT;
566 
567  /// Component-wise subtraction
568  IMATH_HOSTDEVICE constexpr Matrix33
569  operator- (const Matrix33& v) const IMATH_NOEXCEPT;
570 
571  /// Component-wise multiplication by -1
572  IMATH_HOSTDEVICE constexpr Matrix33 operator- () const IMATH_NOEXCEPT;
573 
574  /// Component-wise multiplication by -1
575  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33& negate () IMATH_NOEXCEPT;
576 
577  /// Component-wise multiplication
578  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33&
579  operator*= (T a) IMATH_NOEXCEPT;
580 
581  /// Component-wise multiplication
582  IMATH_HOSTDEVICE constexpr Matrix33 operator* (T a) const IMATH_NOEXCEPT;
583 
584  /// Component-wise division
585  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33&
586  operator/= (T a) IMATH_NOEXCEPT;
587 
588  /// Component-wise division
589  IMATH_HOSTDEVICE constexpr Matrix33 operator/ (T a) const IMATH_NOEXCEPT;
590 
591  /// Matrix-matrix multiplication
592  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33&
593  operator*= (const Matrix33& v) IMATH_NOEXCEPT;
594 
595  /// Matrix-matrix multiplication
596  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix33
597  operator* (const Matrix33& v) const IMATH_NOEXCEPT;
598 
599  /// Vector-matrix multiplication: a homogeneous transformation
600  /// by computing Vec3 (src.x, src.y, 1) * m and dividing by the
601  /// result's third element.
602  /// @param[in] src The input vector
603  /// @param[out] dst The output vector
604  template <class S>
605  IMATH_HOSTDEVICE void
606  multVecMatrix (const Vec2<S>& src, Vec2<S>& dst) const IMATH_NOEXCEPT;
607 
608  /// Vector-matrix multiplication: multiply `src` by the upper left 2x2
609  /// submatrix, ignoring the rest of matrix.
610  /// @param[in] src The input vector
611  /// @param[out] dst The output vector
612  template <class S>
613  IMATH_HOSTDEVICE void
614  multDirMatrix (const Vec2<S>& src, Vec2<S>& dst) const IMATH_NOEXCEPT;
615 
616  /// @}
617 
618  /// @{
619  /// @name Maniplation
620 
621  /// Set to the identity matrix
622  IMATH_HOSTDEVICE void makeIdentity () IMATH_NOEXCEPT;
623 
624  /// Transpose
625  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33&
626  transpose () IMATH_NOEXCEPT;
627 
628  /// Return the transpose
629  IMATH_HOSTDEVICE constexpr Matrix33 transposed () const IMATH_NOEXCEPT;
630 
631  /// Invert in place using the determinant.
632  /// @param singExc If true, throw an exception if the matrix cannot be inverted.
633  /// @return const reference to this
634  IMATH_CONSTEXPR14 const Matrix33& invert (bool singExc);
635 
636  /// Invert in place using the determinant.
637  /// @return const reference to this
638  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33& invert () IMATH_NOEXCEPT;
639 
640  /// Return the inverse using the determinant, leaving this unmodified.
641  /// @param singExc If true, throw an exception if the matrix cannot be inverted.
642  IMATH_CONSTEXPR14 Matrix33<T> inverse (bool singExc) const;
643 
644  /// Return the inverse using the determinant, leaving this unmodified.
645  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix33<T>
646  inverse () const IMATH_NOEXCEPT;
647 
648  /// Invert in place using the Gauss-Jordan method. Significantly slower
649  /// but more accurate than invert().
650  /// @param singExc If true, throw an exception if the matrix cannot be inverted.
651  /// @return const reference to this
652  const Matrix33& gjInvert (bool singExc);
653 
654  /// Invert in place using the Gauss-Jordan method. Significantly slower
655  /// but more accurate than invert().
656  /// @return const reference to this
657  IMATH_HOSTDEVICE const Matrix33& gjInvert () IMATH_NOEXCEPT;
658 
659  /// Return the inverse using the Gauss-Jordan method, leaving this
660  /// unmodified. Significantly slower but more accurate than inverse().
661  Matrix33<T> gjInverse (bool singExc) const;
662 
663  /// Return the inverse using the Gauss-Jordan method. Significantly slower,
664  /// leaving this unmodified. Slower but more accurate than inverse().
665  IMATH_HOSTDEVICE Matrix33<T> gjInverse () const IMATH_NOEXCEPT;
666 
667  /// Calculate the matrix minor of the (r,c) element
668  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 T
669  minorOf (const int r, const int c) const IMATH_NOEXCEPT;
670 
671  /// Build a minor using the specified rows and columns
673  constexpr T
674  fastMinor (const int r0, const int r1, const int c0, const int c1) const
675  IMATH_NOEXCEPT;
676 
677  /// Determinant
678  IMATH_HOSTDEVICE constexpr T determinant () const IMATH_NOEXCEPT;
679 
680  /// Trace
681  IMATH_HOSTDEVICE constexpr T trace() const IMATH_NOEXCEPT;
682 
683  /// Set matrix to rotation by r (in radians, assumed to be a scalar) around (0, 0, 1)
684  /// @return const referenced to this
685  template <class S>
686  IMATH_HOSTDEVICE const Matrix33& setRotation (S r) IMATH_NOEXCEPT;
687 
688  // Rotate the given matrix by r (in radians)
689  /// @return const referenced to this
690  template <class S>
691  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33&
692  rotate (S r) IMATH_NOEXCEPT;
693 
694  /// Set matrix to scale by given uniform factor
695  /// @return const referenced to this
696  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33&
697  setScale (T s) IMATH_NOEXCEPT;
698 
699  /// Set matrix to scale by given vector
700  /// @return const referenced to this
701  template <class S>
702  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33&
703  setScale (const Vec2<S>& s) IMATH_NOEXCEPT;
704 
705  /// Scale the matrix by s
706  /// @return const referenced to this
707  template <class S>
708  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33&
709  scale (const Vec2<S>& s) IMATH_NOEXCEPT;
710 
711  /// Set matrix to translation by given vector
712  /// @return const referenced to this
713  template <class S>
714  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33&
715  setTranslation (const Vec2<S>& t) IMATH_NOEXCEPT;
716 
717  /// Return the translation component
718  IMATH_HOSTDEVICE constexpr Vec2<T> translation () const IMATH_NOEXCEPT;
719 
720  /// Translate the matrix by t
721  /// @return const referenced to this
722  template <class S>
723  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33&
724  translate (const Vec2<S>& t) IMATH_NOEXCEPT;
725 
726  /// Set matrix to shear x for each y coord. by given factor xy
727  /// @return const referenced to this
728  template <class S>
729  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33&
730  setShear (const S& h) IMATH_NOEXCEPT;
731 
732  /// Set matrix to shear x for each y coord. by given factor h.x
733  /// and to shear y for each x coord. by given factor h.y
734  /// @return const referenced to this
735  template <class S>
736  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33&
737  setShear (const Vec2<S>& h) IMATH_NOEXCEPT;
738 
739  /// Shear the matrix in x for each y coord. by given factor xy
740  /// @return const referenced to this
741  template <class S>
742  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33&
743  shear (const S& xy) IMATH_NOEXCEPT;
744 
745  /// Shear the matrix in x for each y coord. by given factor xy
746  /// and shear y for each x coord. by given factor yx
747  /// @return const referenced to this
748  template <class S>
749  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33&
750  shear (const Vec2<S>& h) IMATH_NOEXCEPT;
751 
752  /// @}
753 
754  /// @{
755  /// @name Numeric Limits
756 
757  /// Largest possible negative value
758  IMATH_HOSTDEVICE constexpr static T baseTypeLowest () IMATH_NOEXCEPT
759  {
760  return std::numeric_limits<T>::lowest ();
761  }
762 
763  /// Largest possible positive value
764  IMATH_HOSTDEVICE constexpr static T baseTypeMax () IMATH_NOEXCEPT
765  {
766  return std::numeric_limits<T>::max ();
767  }
768 
769  /// Smallest possible positive value
770  IMATH_HOSTDEVICE constexpr static T baseTypeSmallest () IMATH_NOEXCEPT
771  {
772  return std::numeric_limits<T>::min ();
773  }
774 
775  /// Smallest possible e for which 1+e != 1
776  IMATH_HOSTDEVICE constexpr static T baseTypeEpsilon () IMATH_NOEXCEPT
777  {
778  return std::numeric_limits<T>::epsilon ();
779  }
780 
781  /// @}
782 
783  /// Return the number of the row and column dimensions, i.e. 3.
784  IMATH_HOSTDEVICE constexpr static unsigned int dimensions () IMATH_NOEXCEPT
785  {
786  return 3;
787  }
788 
789  /// The base type: In templates that accept a parameter `V` (could be a Color4), you can refer to `T` as `V::BaseType`
790  typedef T BaseType;
791 
792  /// The base vector type
794 };
795 
796 ///
797 /// 4x4 transformation matrix
798 ///
799 
800 template <class T> class IMATH_EXPORT_TEMPLATE_TYPE Matrix44
801 {
802 public:
803  using value_type = T;
804 
805  /// @{
806  /// @name Direct access to elements
807 
808  /// Matrix elements
809  T x[4][4];
810 
811  /// @}
812 
813  /// Row access
814  IMATH_HOSTDEVICE T* operator[] (int i) IMATH_NOEXCEPT;
815 
816  /// Row access
817  IMATH_HOSTDEVICE const T* operator[] (int i) const IMATH_NOEXCEPT;
818 
819  /// @{
820  /// @name Constructors and Assignment
821 
822  /// Uninitialized
824 
825  /// Default constructor: initialize to identity
826  /// 1 0 0 0
827  /// 0 1 0 0
828  /// 0 0 1 0
829  /// 0 0 0 1
830  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix44 () IMATH_NOEXCEPT;
831 
832  /// Initialize to scalar constant
833  /// a a a a
834  /// a a a a
835  /// a a a a
836  /// a a a a
837  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix44 (T a) IMATH_NOEXCEPT;
838 
839  /// Construct from 4x4 array
840  /// a[0][0] a[0][1] a[0][2] a[0][3]
841  /// a[1][0] a[1][1] a[1][2] a[1][3]
842  /// a[2][0] a[2][1] a[2][2] a[2][3]
843  /// a[3][0] a[3][1] a[3][2] a[3][3]
844  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix44 (const T a[4][4]) IMATH_NOEXCEPT;
845  /// Construct from given scalar values
846  /// a b c d
847  /// e f g h
848  /// i j k l
849  /// m n o p
850  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix44 (
851  T a,
852  T b,
853  T c,
854  T d,
855  T e,
856  T f,
857  T g,
858  T h,
859  T i,
860  T j,
861  T k,
862  T l,
863  T m,
864  T n,
865  T o,
866  T p) IMATH_NOEXCEPT;
867 
868  /// Construct from a 3x3 rotation matrix and a translation vector
869  /// r r r 0
870  /// r r r 0
871  /// r r r 0
872  /// t t t 1
873  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix44 (Matrix33<T> r, Vec3<T> t)
874  IMATH_NOEXCEPT;
875 
876  /// Copy constructor
877  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix44 (const Matrix44& v)
878  IMATH_NOEXCEPT;
879 
880  /// Construct from Matrix44 of another base type
881  template <class S>
882  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 explicit Matrix44 (const Matrix44<S>& v)
883  IMATH_NOEXCEPT;
884 
885  /// Assignment operator
886  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44&
887  operator= (const Matrix44& v) IMATH_NOEXCEPT;
888 
889  /// Assignment from scalar
890  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44&
891  operator= (T a) IMATH_NOEXCEPT;
892 
893  /// Destructor
894  ~Matrix44 () IMATH_NOEXCEPT = default;
895 
896  /// @}
897 
898 #if IMATH_FOREIGN_VECTOR_INTEROP
899  /// @{
900  /// @name Interoperability with other matrix types
901  ///
902  /// Construction and assignment are allowed from other classes that
903  /// appear to be equivalent matrix types, provided that they support
904  /// double-subscript (i.e., `m[j][i]`) giving the same type as the
905  /// elements of this matrix, and their total size appears to be the
906  /// right number of matrix elements.
907  ///
908  /// This functionality is disabled for gcc 4.x, which seems to have a
909  /// compiler bug that results in spurious errors. It can also be
910  /// disabled by defining IMATH_FOREIGN_VECTOR_INTEROP to be 0 prior to
911  /// including any Imath header files.
912  ///
913  template <
914  typename M,
916  IMATH_HOSTDEVICE explicit Matrix44 (const M& m)
917  : Matrix44 (
918  T (m[0][0]),
919  T (m[0][1]),
920  T (m[0][2]),
921  T (m[0][3]),
922  T (m[1][0]),
923  T (m[1][1]),
924  T (m[1][2]),
925  T (m[1][3]),
926  T (m[2][0]),
927  T (m[2][1]),
928  T (m[2][2]),
929  T (m[2][3]),
930  T (m[3][0]),
931  T (m[3][1]),
932  T (m[3][2]),
933  T (m[3][3]))
934  {}
935 
936  /// Interoperability assignment from another type that behaves as if it
937  /// were an equivalent matrix.
938  template <
939  typename M,
942  {
943  *this = Matrix44 (
944  T (m[0][0]),
945  T (m[0][1]),
946  T (m[0][2]),
947  T (m[0][3]),
948  T (m[1][0]),
949  T (m[1][1]),
950  T (m[1][2]),
951  T (m[1][3]),
952  T (m[2][0]),
953  T (m[2][1]),
954  T (m[2][2]),
955  T (m[2][3]),
956  T (m[3][0]),
957  T (m[3][1]),
958  T (m[3][2]),
959  T (m[3][3]));
960  return *this;
961  }
962  /// @}
963 #endif
964 
965  /// @{
966  /// @name Compatibility with Sb
967 
968  /// Return a raw pointer to the array of values
969  IMATH_HOSTDEVICE T* getValue () IMATH_NOEXCEPT;
970 
971  /// Return a raw pointer to the array of values
972  IMATH_HOSTDEVICE const T* getValue () const IMATH_NOEXCEPT;
973 
974  /// Return the value in `v`
975  template <class S>
976  IMATH_HOSTDEVICE void getValue (Matrix44<S>& v) const IMATH_NOEXCEPT;
977 
978  /// Set the value
979  template <class S>
980  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix44&
981  setValue (const Matrix44<S>& v) IMATH_NOEXCEPT;
982 
983  /// Set the value
984  template <class S>
985  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix44&
986  setTheMatrix (const Matrix44<S>& v) IMATH_NOEXCEPT;
987 
988  /// @}
989 
990  /// @{
991  /// @name Arithmetic and Comparison
992 
993  /// Equality
994  IMATH_HOSTDEVICE constexpr bool
995  operator== (const Matrix44& v) const IMATH_NOEXCEPT;
996 
997  /// Inequality
998  IMATH_HOSTDEVICE constexpr bool
999  operator!= (const Matrix44& v) const IMATH_NOEXCEPT;
1000 
1001  /// Compare two matrices and test if they are "approximately equal":
1002  /// @return True if the coefficients of this and `m` are the same
1003  /// with an absolute error of no more than e, i.e., for all i, j:
1004  ///
1005  /// abs (this[i][j] - m[i][j]) <= e
1006  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 bool
1007  equalWithAbsError (const Matrix44<T>& v, T e) const IMATH_NOEXCEPT;
1008 
1009  /// Compare two matrices and test if they are "approximately equal":
1010  /// @return True if the coefficients of this and m are the same with
1011  /// a relative error of no more than e, i.e., for all i, j:
1012  ///
1013  /// abs (this[i] - v[i][j]) <= e * abs (this[i][j])
1014  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 bool
1015  equalWithRelError (const Matrix44<T>& v, T e) const IMATH_NOEXCEPT;
1016 
1017  /// Component-wise addition
1018  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44&
1019  operator+= (const Matrix44& v) IMATH_NOEXCEPT;
1020 
1021  /// Component-wise addition
1022  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44&
1023  operator+= (T a) IMATH_NOEXCEPT;
1024 
1025  /// Component-wise addition
1026  IMATH_HOSTDEVICE constexpr Matrix44
1027  operator+ (const Matrix44& v) const IMATH_NOEXCEPT;
1028 
1029  /// Component-wise subtraction
1030  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44&
1031  operator-= (const Matrix44& v) IMATH_NOEXCEPT;
1032 
1033  /// Component-wise subtraction
1034  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44&
1035  operator-= (T a) IMATH_NOEXCEPT;
1036 
1037  /// Component-wise subtraction
1038  IMATH_HOSTDEVICE constexpr Matrix44
1039  operator- (const Matrix44& v) const IMATH_NOEXCEPT;
1040 
1041  /// Component-wise multiplication by -1
1042  IMATH_HOSTDEVICE constexpr Matrix44 operator- () const IMATH_NOEXCEPT;
1043 
1044  /// Component-wise multiplication by -1
1045  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44& negate () IMATH_NOEXCEPT;
1046 
1047  /// Component-wise multiplication
1048  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44&
1049  operator*= (T a) IMATH_NOEXCEPT;
1050 
1051  /// Component-wise multiplication
1052  IMATH_HOSTDEVICE constexpr Matrix44 operator* (T a) const IMATH_NOEXCEPT;
1053 
1054  /// Component-wise division
1055  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44&
1056  operator/= (T a) IMATH_NOEXCEPT;
1057 
1058  /// Component-wise division
1059  IMATH_HOSTDEVICE constexpr Matrix44 operator/ (T a) const IMATH_NOEXCEPT;
1060 
1061  /// Matrix-matrix multiplication
1062  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44&
1063  operator*= (const Matrix44& v) IMATH_NOEXCEPT;
1064 
1065  /// Matrix-matrix multiplication
1066  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix44
1067  operator* (const Matrix44& v) const IMATH_NOEXCEPT;
1068 
1069  /// Matrix-matrix multiplication: compute c = a * b
1071  static void multiply (
1072  const Matrix44& a, // assumes that
1073  const Matrix44& b, // &a != &c and
1074  Matrix44& c) IMATH_NOEXCEPT; // &b != &c.
1075 
1076  /// Matrix-matrix multiplication returning a result.
1078  static IMATH_CONSTEXPR14 Matrix44
1079  multiply (const Matrix44& a, const Matrix44& b) IMATH_NOEXCEPT;
1080 
1081  /// Vector-matrix multiplication: a homogeneous transformation
1082  /// by computing Vec3 (src.x, src.y, src.z, 1) * m and dividing by the
1083  /// result's third element.
1084  /// @param[in] src The input vector
1085  /// @param[out] dst The output vector
1086  template <class S>
1087  IMATH_HOSTDEVICE void
1088  multVecMatrix (const Vec3<S>& src, Vec3<S>& dst) const IMATH_NOEXCEPT;
1089 
1090  /// Vector-matrix multiplication: multiply `src` by the upper left 2x2
1091  /// submatrix, ignoring the rest of matrix.
1092  /// @param[in] src The input vector
1093  /// @param[out] dst The output vector
1094  template <class S>
1095  IMATH_HOSTDEVICE void
1096  multDirMatrix (const Vec3<S>& src, Vec3<S>& dst) const IMATH_NOEXCEPT;
1097 
1098  /// @}
1099 
1100  /// @{
1101  /// @name Maniplation
1102 
1103  /// Set to the identity matrix
1104  IMATH_HOSTDEVICE void makeIdentity () IMATH_NOEXCEPT;
1105 
1106  /// Transpose
1107  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44&
1108  transpose () IMATH_NOEXCEPT;
1109 
1110  /// Return the transpose
1111  IMATH_HOSTDEVICE constexpr Matrix44 transposed () const IMATH_NOEXCEPT;
1112 
1113  /// Invert in place using the determinant.
1114  /// @param singExc If true, throw an exception if the matrix cannot be inverted.
1115  /// @return const reference to this
1116  IMATH_CONSTEXPR14 const Matrix44& invert (bool singExc);
1117 
1118  /// Invert in place using the determinant.
1119  /// @return const reference to this
1120  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44& invert () IMATH_NOEXCEPT;
1121 
1122  /// Return the inverse using the determinant, leaving this unmodified.
1123  /// @param singExc If true, throw an exception if the matrix cannot be inverted.
1124  IMATH_CONSTEXPR14 Matrix44<T> inverse (bool singExc) const;
1125 
1126  /// Return the inverse using the determinant, leaving this unmodified.
1127  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix44<T>
1128  inverse () const IMATH_NOEXCEPT;
1129 
1130  /// Invert in place using the Gauss-Jordan method. Significantly slower
1131  /// but more accurate than invert().
1132  /// @param singExc If true, throw an exception if the matrix cannot be inverted.
1133  /// @return const reference to this
1134  IMATH_CONSTEXPR14 const Matrix44& gjInvert (bool singExc);
1135 
1136  /// Invert in place using the Gauss-Jordan method. Significantly slower
1137  /// but more accurate than invert().
1138  /// @return const reference to this
1139  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44&
1140  gjInvert () IMATH_NOEXCEPT;
1141 
1142  /// Return the inverse using the Gauss-Jordan method, leaving this
1143  /// unmodified. Significantly slower but more accurate than inverse().
1144  Matrix44<T> gjInverse (bool singExc) const;
1145 
1146  /// Return the inverse using the Gauss-Jordan method, leaving this
1147  /// unmodified Significantly slower but more accurate than inverse().
1148  IMATH_HOSTDEVICE Matrix44<T> gjInverse () const IMATH_NOEXCEPT;
1149 
1150  /// Calculate the matrix minor of the (r,c) element
1151  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 T
1152  minorOf (const int r, const int c) const IMATH_NOEXCEPT;
1153 
1154  /// Build a minor using the specified rows and columns
1156  constexpr T fastMinor (
1157  const int r0,
1158  const int r1,
1159  const int r2,
1160  const int c0,
1161  const int c1,
1162  const int c2) const IMATH_NOEXCEPT;
1163 
1164  /// Determinant
1165  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 T determinant () const IMATH_NOEXCEPT;
1166 
1167  /// Trace
1168  IMATH_HOSTDEVICE constexpr T trace() const IMATH_NOEXCEPT;
1169 
1170  /// Set matrix to rotation by XYZ euler angles (in radians)
1171  /// @return const referenced to this
1172  template <class S>
1173  IMATH_HOSTDEVICE const Matrix44&
1174  setEulerAngles (const Vec3<S>& r) IMATH_NOEXCEPT;
1175 
1176  /// Set matrix to rotation around given axis by given angle (in radians)
1177  /// @return const referenced to this
1178  template <class S>
1179  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44&
1180  setAxisAngle (const Vec3<S>& ax, S ang) IMATH_NOEXCEPT;
1181 
1182  /// Rotate the matrix by XYZ euler angles in r (in radians)
1183  /// @return const referenced to this
1184  template <class S>
1185  IMATH_HOSTDEVICE const Matrix44& rotate (const Vec3<S>& r) IMATH_NOEXCEPT;
1186 
1187  /// Set matrix to scale by given uniform factor
1188  /// @return const referenced to this
1189  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44&
1190  setScale (T s) IMATH_NOEXCEPT;
1191 
1192  /// Set matrix to scale by given vector
1193  /// @return const referenced to this
1194  template <class S>
1195  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44&
1196  setScale (const Vec3<S>& s) IMATH_NOEXCEPT;
1197 
1198  /// Scale the matrix by s
1199  /// @return const referenced to this
1200  template <class S>
1201  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44&
1202  scale (const Vec3<S>& s) IMATH_NOEXCEPT;
1203 
1204  /// Set matrix to translation by given vector
1205  /// @return const referenced to this
1206  template <class S>
1207  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44&
1208  setTranslation (const Vec3<S>& t) IMATH_NOEXCEPT;
1209 
1210  /// Return translation component
1211  IMATH_HOSTDEVICE constexpr const Vec3<T>
1212  translation () const IMATH_NOEXCEPT;
1213 
1214  /// Translate the matrix by t
1215  /// @return const referenced to this
1216  template <class S>
1217  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44&
1218  translate (const Vec3<S>& t) IMATH_NOEXCEPT;
1219 
1220  /// Set matrix to shear by given vector h. The resulting matrix
1221  /// - will shear x for each y coord. by a factor of h[0] ;
1222  /// - will shear x for each z coord. by a factor of h[1] ;
1223  /// - will shear y for each z coord. by a factor of h[2] .
1224  /// @return const referenced to this
1225  template <class S>
1226  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44&
1227  setShear (const Vec3<S>& h) IMATH_NOEXCEPT;
1228 
1229  /// Set matrix to shear by given factors. The resulting matrix
1230  /// - will shear x for each y coord. by a factor of h.xy ;
1231  /// - will shear x for each z coord. by a factor of h.xz ;
1232  /// - will shear y for each z coord. by a factor of h.yz ;
1233  /// - will shear y for each x coord. by a factor of h.yx ;
1234  /// - will shear z for each x coord. by a factor of h.zx ;
1235  /// - will shear z for each y coord. by a factor of h.zy .
1236  /// @return const referenced to this
1237  template <class S>
1238  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44&
1239  setShear (const Shear6<S>& h) IMATH_NOEXCEPT;
1240 
1241  /// Shear the matrix by given vector. The composed matrix
1242  /// will be `shear` * `this`, where the shear matrix ...
1243  /// - will shear x for each y coord. by a factor of h[0] ;
1244  /// - will shear x for each z coord. by a factor of h[1] ;
1245  /// - will shear y for each z coord. by a factor of h[2] .
1246  /// @return const referenced to this
1247  template <class S>
1248  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44&
1249  shear (const Vec3<S>& h) IMATH_NOEXCEPT;
1250 
1251  /// Shear the matrix by the given factors. The composed matrix
1252  /// will be `shear` * `this`, where the shear matrix ...
1253  /// - will shear x for each y coord. by a factor of h.xy ;
1254  /// - will shear x for each z coord. by a factor of h.xz ;
1255  /// - will shear y for each z coord. by a factor of h.yz ;
1256  /// - will shear y for each x coord. by a factor of h.yx ;
1257  /// - will shear z for each x coord. by a factor of h.zx ;
1258  /// - will shear z for each y coord. by a factor of h.zy .
1259  /// @return const referenced to this
1260  template <class S>
1261  IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44&
1262  shear (const Shear6<S>& h) IMATH_NOEXCEPT;
1263 
1264  /// @}
1265 
1266  /// @{
1267  /// @name Numeric Limits
1268 
1269  /// Largest possible negative value
1270  IMATH_HOSTDEVICE constexpr static T baseTypeLowest () IMATH_NOEXCEPT
1271  {
1272  return std::numeric_limits<T>::lowest ();
1273  }
1274 
1275  /// Largest possible positive value
1276  IMATH_HOSTDEVICE constexpr static T baseTypeMax () IMATH_NOEXCEPT
1277  {
1278  return std::numeric_limits<T>::max ();
1279  }
1280 
1281  /// Smallest possible positive value
1282  IMATH_HOSTDEVICE constexpr static T baseTypeSmallest () IMATH_NOEXCEPT
1283  {
1284  return std::numeric_limits<T>::min ();
1285  }
1286 
1287  /// Smallest possible e for which 1+e != 1
1288  IMATH_HOSTDEVICE constexpr static T baseTypeEpsilon () IMATH_NOEXCEPT
1289  {
1290  return std::numeric_limits<T>::epsilon ();
1291  }
1292 
1293  /// @}
1294 
1295  /// Return the number of the row and column dimensions, i.e. 4
1296  IMATH_HOSTDEVICE constexpr static unsigned int dimensions () IMATH_NOEXCEPT
1297  {
1298  return 4;
1299  }
1300 
1301  /// The base type: In templates that accept a parameter `V` (could be a Color4), you can refer to `T` as `V::BaseType`
1302  typedef T BaseType;
1303 
1304  /// The base vector type
1306 };
1307 
1308 /// Stream output, as:
1309 /// (m00 m01
1310 /// m10 m11)
1311 template <class T>
1312 std::ostream& operator<< (std::ostream& s, const Matrix22<T>& m);
1313 
1314 /// Stream output, as:
1315 /// (m00 m01 m02
1316 /// m10 m11 m12
1317 /// m20 m21 m22)
1318 template <class T>
1319 std::ostream& operator<< (std::ostream& s, const Matrix33<T>& m);
1320 
1321 /// Stream output, as:
1322 ///
1323 /// (m00 m01 m02 m03
1324 /// m10 m11 m12 m13
1325 /// m20 m21 m22 m23
1326 /// m30 m31 m32 m33)
1327 template <class T>
1328 std::ostream& operator<< (std::ostream& s, const Matrix44<T>& m);
1329 
1330 //---------------------------------------------
1331 // Vector-times-matrix multiplication operators
1332 //---------------------------------------------
1333 
1334 /// Vector-matrix multiplication: v *= m
1335 template <class S, class T>
1336 IMATH_HOSTDEVICE inline const Vec2<S>&
1338 
1339 /// Vector-matrix multiplication: r = v * m
1340 template <class S, class T>
1342 operator* (const Vec2<S>& v, const Matrix22<T>& m) IMATH_NOEXCEPT;
1343 
1344 /// Vector-matrix multiplication: v *= m
1345 template <class S, class T>
1346 IMATH_HOSTDEVICE inline const Vec2<S>&
1348 
1349 /// Vector-matrix multiplication: r = v * m
1350 template <class S, class T>
1352 operator* (const Vec2<S>& v, const Matrix33<T>& m) IMATH_NOEXCEPT;
1353 
1354 /// Vector-matrix multiplication: v *= m
1355 template <class S, class T>
1356 IMATH_HOSTDEVICE inline const Vec3<S>&
1358 
1359 /// Vector-matrix multiplication: r = v * m
1360 template <class S, class T>
1362 operator* (const Vec3<S>& v, const Matrix33<T>& m) IMATH_NOEXCEPT;
1363 
1364 /// Vector-matrix multiplication: v *= m
1365 template <class S, class T>
1366 IMATH_HOSTDEVICE inline const Vec3<S>&
1368 
1369 /// Vector-matrix multiplication: r = v * m
1370 template <class S, class T>
1372 operator* (const Vec3<S>& v, const Matrix44<T>& m) IMATH_NOEXCEPT;
1373 
1374 /// Vector-matrix multiplication: v *= m
1375 template <class S, class T>
1376 IMATH_HOSTDEVICE inline const Vec4<S>&
1378 
1379 /// Vector-matrix multiplication: r = v * m
1380 template <class S, class T>
1382 operator* (const Vec4<S>& v, const Matrix44<T>& m) IMATH_NOEXCEPT;
1383 
1384 //-------------------------
1385 // Typedefs for convenience
1386 //-------------------------
1387 
1388 /// 2x2 matrix of float
1390 
1391 /// 2x2 matrix of double
1393 
1394 /// 3x3 matrix of float
1396 
1397 /// 3x3 matrix of double
1399 
1400 /// 4x4 matrix of float
1402 
1403 /// 4x4 matrix of double
1405 
1406 //---------------------------
1407 // Implementation of Matrix22
1408 //---------------------------
1409 
1410 template <class T>
1411 IMATH_HOSTDEVICE inline T*
1412 Matrix22<T>::operator[] (int i) IMATH_NOEXCEPT
1413 {
1414  return x[i];
1415 }
1416 
1417 template <class T>
1418 IMATH_HOSTDEVICE inline const T*
1419 Matrix22<T>::operator[] (int i) const IMATH_NOEXCEPT
1420 {
1421  return x[i];
1422 }
1423 
1424 template <class T>
1426  IMATH_CONSTEXPR14 inline Matrix22<T>::Matrix22 () IMATH_NOEXCEPT
1427 {
1428  x[0][0] = 1;
1429  x[0][1] = 0;
1430  x[1][0] = 0;
1431  x[1][1] = 1;
1432 }
1433 
1434 template <class T>
1436  IMATH_CONSTEXPR14 inline Matrix22<T>::Matrix22 (T a) IMATH_NOEXCEPT
1437 {
1438  x[0][0] = a;
1439  x[0][1] = a;
1440  x[1][0] = a;
1441  x[1][1] = a;
1442 }
1443 
1444 template <class T>
1445 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline Matrix22<T>::Matrix22 (
1446  const T a[2][2]) IMATH_NOEXCEPT
1447 {
1448  // Function calls and aliasing issues can inhibit vectorization versus
1449  // straight assignment of data members, so instead of this:
1450  // memcpy (x, a, sizeof (x));
1451  // we do this:
1452  x[0][0] = a[0][0];
1453  x[0][1] = a[0][1];
1454  x[1][0] = a[1][0];
1455  x[1][1] = a[1][1];
1456 }
1457 
1458 template <class T>
1459 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline Matrix22<T>::Matrix22 (
1460  T a, T b, T c, T d) IMATH_NOEXCEPT
1461 {
1462  x[0][0] = a;
1463  x[0][1] = b;
1464  x[1][0] = c;
1465  x[1][1] = d;
1466 }
1467 
1468 template <class T>
1469 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline Matrix22<T>::Matrix22 (
1470  const Matrix22& v) IMATH_NOEXCEPT
1471 {
1472  // Function calls and aliasing issues can inhibit vectorization versus
1473  // straight assignment of data members, so we don't do this:
1474  // memcpy (x, v.x, sizeof (x));
1475  // we do this:
1476  x[0][0] = v.x[0][0];
1477  x[0][1] = v.x[0][1];
1478  x[1][0] = v.x[1][0];
1479  x[1][1] = v.x[1][1];
1480 }
1481 
1482 template <class T>
1483 template <class S>
1484 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline Matrix22<T>::Matrix22 (
1485  const Matrix22<S>& v) IMATH_NOEXCEPT
1486 {
1487  x[0][0] = T (v.x[0][0]);
1488  x[0][1] = T (v.x[0][1]);
1489  x[1][0] = T (v.x[1][0]);
1490  x[1][1] = T (v.x[1][1]);
1491 }
1492 
1493 template <class T>
1494 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix22<T>&
1495 Matrix22<T>::operator= (const Matrix22& v) IMATH_NOEXCEPT
1496 {
1497  // Function calls and aliasing issues can inhibit vectorization versus
1498  // straight assignment of data members, so we don't do this:
1499  // memcpy (x, v.x, sizeof (x));
1500  // we do this:
1501  x[0][0] = v.x[0][0];
1502  x[0][1] = v.x[0][1];
1503  x[1][0] = v.x[1][0];
1504  x[1][1] = v.x[1][1];
1505  return *this;
1506 }
1507 
1508 template <class T>
1509 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix22<T>&
1510 Matrix22<T>::operator= (T a) IMATH_NOEXCEPT
1511 {
1512  x[0][0] = a;
1513  x[0][1] = a;
1514  x[1][0] = a;
1515  x[1][1] = a;
1516  return *this;
1517 }
1518 
1519 template <class T>
1520 IMATH_HOSTDEVICE inline T*
1521 Matrix22<T>::getValue () IMATH_NOEXCEPT
1522 {
1523  return reinterpret_cast<T*> (this);
1524 }
1525 
1526 template <class T>
1527 IMATH_HOSTDEVICE inline const T*
1528 Matrix22<T>::getValue () const IMATH_NOEXCEPT
1529 {
1530  return reinterpret_cast<const T*> (this);
1531 }
1532 
1533 template <class T>
1534 template <class S>
1535 IMATH_HOSTDEVICE inline void
1536 Matrix22<T>::getValue (Matrix22<S>& v) const IMATH_NOEXCEPT
1537 {
1538  v.x[0][0] = x[0][0];
1539  v.x[0][1] = x[0][1];
1540  v.x[1][0] = x[1][0];
1541  v.x[1][1] = x[1][1];
1542 }
1543 
1544 template <class T>
1545 template <class S>
1546 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline Matrix22<T>&
1547  Matrix22<T>::setValue (const Matrix22<S>& v) IMATH_NOEXCEPT
1548 {
1549  x[0][0] = v.x[0][0];
1550  x[0][1] = v.x[0][1];
1551  x[1][0] = v.x[1][0];
1552  x[1][1] = v.x[1][1];
1553  return *this;
1554 }
1555 
1556 template <class T>
1557 template <class S>
1558 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline Matrix22<T>&
1559  Matrix22<T>::setTheMatrix (const Matrix22<S>& v) IMATH_NOEXCEPT
1560 {
1561  x[0][0] = v.x[0][0];
1562  x[0][1] = v.x[0][1];
1563  x[1][0] = v.x[1][0];
1564  x[1][1] = v.x[1][1];
1565  return *this;
1566 }
1567 
1568 template <class T>
1569 IMATH_HOSTDEVICE inline void
1570 Matrix22<T>::makeIdentity () IMATH_NOEXCEPT
1571 {
1572  x[0][0] = 1;
1573  x[0][1] = 0;
1574  x[1][0] = 0;
1575  x[1][1] = 1;
1576 }
1577 
1578 template <class T>
1579 IMATH_HOSTDEVICE constexpr inline bool
1580 Matrix22<T>::operator== (const Matrix22& v) const IMATH_NOEXCEPT
1581 {
1582  return x[0][0] == v.x[0][0] && x[0][1] == v.x[0][1] &&
1583  x[1][0] == v.x[1][0] && x[1][1] == v.x[1][1];
1584 }
1585 
1586 template <class T>
1587 IMATH_HOSTDEVICE constexpr inline bool
1588 Matrix22<T>::operator!= (const Matrix22& v) const IMATH_NOEXCEPT
1589 {
1590  return x[0][0] != v.x[0][0] || x[0][1] != v.x[0][1] ||
1591  x[1][0] != v.x[1][0] || x[1][1] != v.x[1][1];
1592 }
1593 
1594 template <class T>
1595 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline bool
1596 Matrix22<T>::equalWithAbsError (const Matrix22<T>& m, T e) const IMATH_NOEXCEPT
1597 {
1598  for (int i = 0; i < 2; i++)
1599  for (int j = 0; j < 2; j++)
1601  (*this).x[i][j], m.x[i][j], e))
1602  return false;
1603 
1604  return true;
1605 }
1606 
1607 template <class T>
1608 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline bool
1609 Matrix22<T>::equalWithRelError (const Matrix22<T>& m, T e) const IMATH_NOEXCEPT
1610 {
1611  for (int i = 0; i < 2; i++)
1612  for (int j = 0; j < 2; j++)
1614  (*this).x[i][j], m.x[i][j], e))
1615  return false;
1616 
1617  return true;
1618 }
1619 
1620 template <class T>
1621 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix22<T>&
1623 {
1624  x[0][0] += v.x[0][0];
1625  x[0][1] += v.x[0][1];
1626  x[1][0] += v.x[1][0];
1627  x[1][1] += v.x[1][1];
1628 
1629  return *this;
1630 }
1631 
1632 template <class T>
1633 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix22<T>&
1634 Matrix22<T>::operator+= (T a) IMATH_NOEXCEPT
1635 {
1636  x[0][0] += a;
1637  x[0][1] += a;
1638  x[1][0] += a;
1639  x[1][1] += a;
1640 
1641  return *this;
1642 }
1643 
1644 template <class T>
1645 IMATH_HOSTDEVICE constexpr inline Matrix22<T>
1646 Matrix22<T>::operator+ (const Matrix22<T>& v) const IMATH_NOEXCEPT
1647 {
1648  return Matrix22 (
1649  x[0][0] + v.x[0][0],
1650  x[0][1] + v.x[0][1],
1651  x[1][0] + v.x[1][0],
1652  x[1][1] + v.x[1][1]);
1653 }
1654 
1655 template <class T>
1656 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix22<T>&
1658 {
1659  x[0][0] -= v.x[0][0];
1660  x[0][1] -= v.x[0][1];
1661  x[1][0] -= v.x[1][0];
1662  x[1][1] -= v.x[1][1];
1663 
1664  return *this;
1665 }
1666 
1667 template <class T>
1668 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix22<T>&
1669 Matrix22<T>::operator-= (T a) IMATH_NOEXCEPT
1670 {
1671  x[0][0] -= a;
1672  x[0][1] -= a;
1673  x[1][0] -= a;
1674  x[1][1] -= a;
1675 
1676  return *this;
1677 }
1678 
1679 template <class T>
1680 IMATH_HOSTDEVICE constexpr inline Matrix22<T>
1681 Matrix22<T>::operator- (const Matrix22<T>& v) const IMATH_NOEXCEPT
1682 {
1683  return Matrix22 (
1684  x[0][0] - v.x[0][0],
1685  x[0][1] - v.x[0][1],
1686  x[1][0] - v.x[1][0],
1687  x[1][1] - v.x[1][1]);
1688 }
1689 
1690 template <class T>
1691 IMATH_HOSTDEVICE constexpr inline Matrix22<T>
1692 Matrix22<T>::operator- () const IMATH_NOEXCEPT
1693 {
1694  return Matrix22 (-x[0][0], -x[0][1], -x[1][0], -x[1][1]);
1695 }
1696 
1697 template <class T>
1698 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix22<T>&
1699  Matrix22<T>::negate () IMATH_NOEXCEPT
1700 {
1701  x[0][0] = -x[0][0];
1702  x[0][1] = -x[0][1];
1703  x[1][0] = -x[1][0];
1704  x[1][1] = -x[1][1];
1705 
1706  return *this;
1707 }
1708 
1709 template <class T>
1710 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix22<T>&
1711 Matrix22<T>::operator*= (T a) IMATH_NOEXCEPT
1712 {
1713  x[0][0] *= a;
1714  x[0][1] *= a;
1715  x[1][0] *= a;
1716  x[1][1] *= a;
1717 
1718  return *this;
1719 }
1720 
1721 template <class T>
1722 IMATH_HOSTDEVICE constexpr inline Matrix22<T>
1723 Matrix22<T>::operator* (T a) const IMATH_NOEXCEPT
1724 {
1725  return Matrix22 (x[0][0] * a, x[0][1] * a, x[1][0] * a, x[1][1] * a);
1726 }
1727 
1728 /// Matrix-scalar multiplication
1729 template <class T>
1731 operator* (T a, const Matrix22<T>& v) IMATH_NOEXCEPT
1732 {
1733  return v * a;
1734 }
1735 
1736 template <class T>
1737 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix22<T>&
1739 {
1740  Matrix22 tmp (T (0));
1741 
1742  for (int i = 0; i < 2; i++)
1743  for (int j = 0; j < 2; j++)
1744  for (int k = 0; k < 2; k++)
1745  tmp.x[i][j] += x[i][k] * v.x[k][j];
1746 
1747  *this = tmp;
1748  return *this;
1749 }
1750 
1751 template <class T>
1752 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline Matrix22<T>
1753 Matrix22<T>::operator* (const Matrix22<T>& v) const IMATH_NOEXCEPT
1754 {
1755  Matrix22 tmp (T (0));
1756 
1757  for (int i = 0; i < 2; i++)
1758  for (int j = 0; j < 2; j++)
1759  for (int k = 0; k < 2; k++)
1760  tmp.x[i][j] += x[i][k] * v.x[k][j];
1761 
1762  return tmp;
1763 }
1764 
1765 template <class T>
1766 template <class S>
1767 IMATH_HOSTDEVICE inline void
1769  IMATH_NOEXCEPT
1770 {
1771  S a, b;
1772 
1773  a = src.x * x[0][0] + src.y * x[1][0];
1774  b = src.x * x[0][1] + src.y * x[1][1];
1775 
1776  dst.x = a;
1777  dst.y = b;
1778 }
1779 
1780 template <class T>
1781 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix22<T>&
1782 Matrix22<T>::operator/= (T a) IMATH_NOEXCEPT
1783 {
1784  x[0][0] /= a;
1785  x[0][1] /= a;
1786  x[1][0] /= a;
1787  x[1][1] /= a;
1788 
1789  return *this;
1790 }
1791 
1792 template <class T>
1793 IMATH_HOSTDEVICE constexpr inline Matrix22<T>
1794 Matrix22<T>::operator/ (T a) const IMATH_NOEXCEPT
1795 {
1796  return Matrix22 (x[0][0] / a, x[0][1] / a, x[1][0] / a, x[1][1] / a);
1797 }
1798 
1799 template <class T>
1800 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix22<T>&
1801  Matrix22<T>::transpose () IMATH_NOEXCEPT
1802 {
1803  Matrix22 tmp (x[0][0], x[1][0], x[0][1], x[1][1]);
1804  *this = tmp;
1805  return *this;
1806 }
1807 
1808 template <class T>
1809 IMATH_HOSTDEVICE constexpr inline Matrix22<T>
1810 Matrix22<T>::transposed () const IMATH_NOEXCEPT
1811 {
1812  return Matrix22 (x[0][0], x[1][0], x[0][1], x[1][1]);
1813 }
1814 
1815 template <class T>
1816 IMATH_CONSTEXPR14 inline const Matrix22<T>&
1817 Matrix22<T>::invert (bool singExc)
1818 {
1819  *this = inverse (singExc);
1820  return *this;
1821 }
1822 
1823 template <class T>
1824 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix22<T>&
1825  Matrix22<T>::invert () IMATH_NOEXCEPT
1826 {
1827  *this = inverse ();
1828  return *this;
1829 }
1830 
1831 template <class T>
1832 IMATH_CONSTEXPR14 inline Matrix22<T>
1833 Matrix22<T>::inverse (bool singExc) const
1834 {
1835  Matrix22 s (x[1][1], -x[0][1], -x[1][0], x[0][0]);
1836 
1837  T r = x[0][0] * x[1][1] - x[1][0] * x[0][1];
1838 
1839  if (IMATH_INTERNAL_NAMESPACE::abs (r) >= 1)
1840  {
1841  for (int i = 0; i < 2; ++i)
1842  {
1843  for (int j = 0; j < 2; ++j)
1844  {
1845  s[i][j] /= r;
1846  }
1847  }
1848  }
1849  else
1850  {
1851  T mr =
1853 
1854  for (int i = 0; i < 2; ++i)
1855  {
1856  for (int j = 0; j < 2; ++j)
1857  {
1858  if (mr > IMATH_INTERNAL_NAMESPACE::abs (s[i][j]))
1859  {
1860  s[i][j] /= r;
1861  }
1862  else
1863  {
1864  if (singExc)
1865  throw std::invalid_argument ("Cannot invert "
1866  "singular matrix.");
1867  return Matrix22 ();
1868  }
1869  }
1870  }
1871  }
1872  return s;
1873 }
1874 
1875 template <class T>
1876 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline Matrix22<T>
1877  Matrix22<T>::inverse () const IMATH_NOEXCEPT
1878 {
1879  Matrix22 s (x[1][1], -x[0][1], -x[1][0], x[0][0]);
1880 
1881  T r = x[0][0] * x[1][1] - x[1][0] * x[0][1];
1882 
1883  if (IMATH_INTERNAL_NAMESPACE::abs (r) >= 1)
1884  {
1885  for (int i = 0; i < 2; ++i)
1886  {
1887  for (int j = 0; j < 2; ++j)
1888  {
1889  s[i][j] /= r;
1890  }
1891  }
1892  }
1893  else
1894  {
1895  T mr =
1897 
1898  for (int i = 0; i < 2; ++i)
1899  {
1900  for (int j = 0; j < 2; ++j)
1901  {
1902  if (mr > IMATH_INTERNAL_NAMESPACE::abs (s[i][j]))
1903  {
1904  s[i][j] /= r;
1905  }
1906  else
1907  {
1908  return Matrix22 ();
1909  }
1910  }
1911  }
1912  }
1913  return s;
1914 }
1915 
1916 template <class T>
1917 IMATH_HOSTDEVICE constexpr inline T
1918 Matrix22<T>::determinant () const IMATH_NOEXCEPT
1919 {
1920  return x[0][0] * x[1][1] - x[1][0] * x[0][1];
1921 }
1922 
1923 template <class T>
1924 IMATH_HOSTDEVICE constexpr inline T
1925 Matrix22<T>::trace () const IMATH_NOEXCEPT
1926 {
1927  return x[0][0] + x[1][1];
1928 }
1929 
1930 template <class T>
1931 template <class S>
1932 IMATH_HOSTDEVICE inline const Matrix22<T>&
1933 Matrix22<T>::setRotation (S r) IMATH_NOEXCEPT
1934 {
1935  S cos_r, sin_r;
1936 
1937  cos_r = cos ((T) r);
1938  sin_r = sin ((T) r);
1939 
1940  x[0][0] = cos_r;
1941  x[0][1] = sin_r;
1942 
1943  x[1][0] = -sin_r;
1944  x[1][1] = cos_r;
1945 
1946  return *this;
1947 }
1948 
1949 template <class T>
1950 template <class S>
1951 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix22<T>&
1952  Matrix22<T>::rotate (S r) IMATH_NOEXCEPT
1953 {
1954  *this *= Matrix22<T> ().setRotation (r);
1955  return *this;
1956 }
1957 
1958 template <class T>
1959 IMATH_CONSTEXPR14 inline const Matrix22<T>&
1960 Matrix22<T>::setScale (T s) IMATH_NOEXCEPT
1961 {
1962  //
1963  // Set the matrix to:
1964  // | s 0 |
1965  // | 0 s |
1966  //
1967 
1968  x[0][0] = s;
1969  x[0][1] = static_cast<T> (0);
1970  x[1][0] = static_cast<T> (0);
1971  x[1][1] = s;
1972 
1973  return *this;
1974 }
1975 
1976 template <class T>
1977 template <class S>
1978 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix22<T>&
1979  Matrix22<T>::setScale (const Vec2<S>& s) IMATH_NOEXCEPT
1980 {
1981  //
1982  // Set the matrix to:
1983  // | s.x 0 |
1984  // | 0 s.y |
1985  //
1986 
1987  x[0][0] = s.x;
1988  x[0][1] = static_cast<T> (0);
1989  x[1][0] = static_cast<T> (0);
1990  x[1][1] = s.y;
1991 
1992  return *this;
1993 }
1994 
1995 template <class T>
1996 template <class S>
1997 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix22<T>&
1998  Matrix22<T>::scale (const Vec2<S>& s) IMATH_NOEXCEPT
1999 {
2000  x[0][0] *= s.x;
2001  x[0][1] *= s.x;
2002 
2003  x[1][0] *= s.y;
2004  x[1][1] *= s.y;
2005 
2006  return *this;
2007 }
2008 
2009 //---------------------------
2010 // Implementation of Matrix33
2011 //---------------------------
2012 
2013 template <class T>
2014 IMATH_HOSTDEVICE inline T*
2015 Matrix33<T>::operator[] (int i) IMATH_NOEXCEPT
2016 {
2017  return x[i];
2018 }
2019 
2020 template <class T>
2021 IMATH_HOSTDEVICE inline const T*
2022 Matrix33<T>::operator[] (int i) const IMATH_NOEXCEPT
2023 {
2024  return x[i];
2025 }
2026 
2027 template <class T>
2028 IMATH_HOSTDEVICE inline IMATH_CONSTEXPR14
2029 Matrix33<T>::Matrix33 () IMATH_NOEXCEPT
2030 {
2031  x[0][0] = 1;
2032  x[0][1] = 0;
2033  x[0][2] = 0;
2034  x[1][0] = 0;
2035  x[1][1] = 1;
2036  x[1][2] = 0;
2037  x[2][0] = 0;
2038  x[2][1] = 0;
2039  x[2][2] = 1;
2040 }
2041 
2042 template <class T>
2044  IMATH_CONSTEXPR14 inline Matrix33<T>::Matrix33 (T a) IMATH_NOEXCEPT
2045 {
2046  x[0][0] = a;
2047  x[0][1] = a;
2048  x[0][2] = a;
2049  x[1][0] = a;
2050  x[1][1] = a;
2051  x[1][2] = a;
2052  x[2][0] = a;
2053  x[2][1] = a;
2054  x[2][2] = a;
2055 }
2056 
2057 template <class T>
2058 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline Matrix33<T>::Matrix33 (
2059  const T a[3][3]) IMATH_NOEXCEPT
2060 {
2061  // Function calls and aliasing issues can inhibit vectorization versus
2062  // straight assignment of data members, so instead of this:
2063  // memcpy (x, a, sizeof (x));
2064  // we do this:
2065  x[0][0] = a[0][0];
2066  x[0][1] = a[0][1];
2067  x[0][2] = a[0][2];
2068  x[1][0] = a[1][0];
2069  x[1][1] = a[1][1];
2070  x[1][2] = a[1][2];
2071  x[2][0] = a[2][0];
2072  x[2][1] = a[2][1];
2073  x[2][2] = a[2][2];
2074 }
2075 
2076 template <class T>
2077 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline Matrix33<T>::Matrix33 (
2078  T a, T b, T c, T d, T e, T f, T g, T h, T i) IMATH_NOEXCEPT
2079 {
2080  x[0][0] = a;
2081  x[0][1] = b;
2082  x[0][2] = c;
2083  x[1][0] = d;
2084  x[1][1] = e;
2085  x[1][2] = f;
2086  x[2][0] = g;
2087  x[2][1] = h;
2088  x[2][2] = i;
2089 }
2090 
2091 template <class T>
2092 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline Matrix33<T>::Matrix33 (
2093  const Matrix33& v) IMATH_NOEXCEPT
2094 {
2095  // Function calls and aliasing issues can inhibit vectorization versus
2096  // straight assignment of data members, so instead of this:
2097  // memcpy (x, v.x, sizeof (x));
2098  // we do this:
2099  x[0][0] = v.x[0][0];
2100  x[0][1] = v.x[0][1];
2101  x[0][2] = v.x[0][2];
2102  x[1][0] = v.x[1][0];
2103  x[1][1] = v.x[1][1];
2104  x[1][2] = v.x[1][2];
2105  x[2][0] = v.x[2][0];
2106  x[2][1] = v.x[2][1];
2107  x[2][2] = v.x[2][2];
2108 }
2109 
2110 template <class T>
2111 template <class S>
2112 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline Matrix33<T>::Matrix33 (
2113  const Matrix33<S>& v) IMATH_NOEXCEPT
2114 {
2115  x[0][0] = T (v.x[0][0]);
2116  x[0][1] = T (v.x[0][1]);
2117  x[0][2] = T (v.x[0][2]);
2118  x[1][0] = T (v.x[1][0]);
2119  x[1][1] = T (v.x[1][1]);
2120  x[1][2] = T (v.x[1][2]);
2121  x[2][0] = T (v.x[2][0]);
2122  x[2][1] = T (v.x[2][1]);
2123  x[2][2] = T (v.x[2][2]);
2124 }
2125 
2126 template <class T>
2127 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix33<T>&
2128 Matrix33<T>::operator= (const Matrix33& v) IMATH_NOEXCEPT
2129 {
2130  // Function calls and aliasing issues can inhibit vectorization versus
2131  // straight assignment of data members, so instead of this:
2132  // memcpy (x, v.x, sizeof (x));
2133  // we do this:
2134  x[0][0] = v.x[0][0];
2135  x[0][1] = v.x[0][1];
2136  x[0][2] = v.x[0][2];
2137  x[1][0] = v.x[1][0];
2138  x[1][1] = v.x[1][1];
2139  x[1][2] = v.x[1][2];
2140  x[2][0] = v.x[2][0];
2141  x[2][1] = v.x[2][1];
2142  x[2][2] = v.x[2][2];
2143  return *this;
2144 }
2145 
2146 template <class T>
2147 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix33<T>&
2148 Matrix33<T>::operator= (T a) IMATH_NOEXCEPT
2149 {
2150  x[0][0] = a;
2151  x[0][1] = a;
2152  x[0][2] = a;
2153  x[1][0] = a;
2154  x[1][1] = a;
2155  x[1][2] = a;
2156  x[2][0] = a;
2157  x[2][1] = a;
2158  x[2][2] = a;
2159  return *this;
2160 }
2161 
2162 template <class T>
2163 IMATH_HOSTDEVICE inline T*
2164 Matrix33<T>::getValue () IMATH_NOEXCEPT
2165 {
2166  return reinterpret_cast<T*> (this);
2167 }
2168 
2169 template <class T>
2170 IMATH_HOSTDEVICE inline const T*
2171 Matrix33<T>::getValue () const IMATH_NOEXCEPT
2172 {
2173  return reinterpret_cast<const T*> (this);
2174 }
2175 
2176 template <class T>
2177 template <class S>
2178 IMATH_HOSTDEVICE inline void
2179 Matrix33<T>::getValue (Matrix33<S>& v) const IMATH_NOEXCEPT
2180 {
2181  v.x[0][0] = x[0][0];
2182  v.x[0][1] = x[0][1];
2183  v.x[0][2] = x[0][2];
2184  v.x[1][0] = x[1][0];
2185  v.x[1][1] = x[1][1];
2186  v.x[1][2] = x[1][2];
2187  v.x[2][0] = x[2][0];
2188  v.x[2][1] = x[2][1];
2189  v.x[2][2] = x[2][2];
2190 }
2191 
2192 template <class T>
2193 template <class S>
2194 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline Matrix33<T>&
2195  Matrix33<T>::setValue (const Matrix33<S>& v) IMATH_NOEXCEPT
2196 {
2197  x[0][0] = v.x[0][0];
2198  x[0][1] = v.x[0][1];
2199  x[0][2] = v.x[0][2];
2200  x[1][0] = v.x[1][0];
2201  x[1][1] = v.x[1][1];
2202  x[1][2] = v.x[1][2];
2203  x[2][0] = v.x[2][0];
2204  x[2][1] = v.x[2][1];
2205  x[2][2] = v.x[2][2];
2206  return *this;
2207 }
2208 
2209 template <class T>
2210 template <class S>
2211 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline Matrix33<T>&
2212  Matrix33<T>::setTheMatrix (const Matrix33<S>& v) IMATH_NOEXCEPT
2213 {
2214  x[0][0] = v.x[0][0];
2215  x[0][1] = v.x[0][1];
2216  x[0][2] = v.x[0][2];
2217  x[1][0] = v.x[1][0];
2218  x[1][1] = v.x[1][1];
2219  x[1][2] = v.x[1][2];
2220  x[2][0] = v.x[2][0];
2221  x[2][1] = v.x[2][1];
2222  x[2][2] = v.x[2][2];
2223  return *this;
2224 }
2225 
2226 template <class T>
2227 IMATH_HOSTDEVICE inline void
2228 Matrix33<T>::makeIdentity () IMATH_NOEXCEPT
2229 {
2230  x[0][0] = 1;
2231  x[0][1] = 0;
2232  x[0][2] = 0;
2233  x[1][0] = 0;
2234  x[1][1] = 1;
2235  x[1][2] = 0;
2236  x[2][0] = 0;
2237  x[2][1] = 0;
2238  x[2][2] = 1;
2239 }
2240 
2241 template <class T>
2242 IMATH_HOSTDEVICE constexpr inline bool
2243 Matrix33<T>::operator== (const Matrix33& v) const IMATH_NOEXCEPT
2244 {
2245  return x[0][0] == v.x[0][0] && x[0][1] == v.x[0][1] &&
2246  x[0][2] == v.x[0][2] && x[1][0] == v.x[1][0] &&
2247  x[1][1] == v.x[1][1] && x[1][2] == v.x[1][2] &&
2248  x[2][0] == v.x[2][0] && x[2][1] == v.x[2][1] && x[2][2] == v.x[2][2];
2249 }
2250 
2251 template <class T>
2252 IMATH_HOSTDEVICE constexpr inline bool
2253 Matrix33<T>::operator!= (const Matrix33& v) const IMATH_NOEXCEPT
2254 {
2255  return x[0][0] != v.x[0][0] || x[0][1] != v.x[0][1] ||
2256  x[0][2] != v.x[0][2] || x[1][0] != v.x[1][0] ||
2257  x[1][1] != v.x[1][1] || x[1][2] != v.x[1][2] ||
2258  x[2][0] != v.x[2][0] || x[2][1] != v.x[2][1] || x[2][2] != v.x[2][2];
2259 }
2260 
2261 template <class T>
2262 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline bool
2263 Matrix33<T>::equalWithAbsError (const Matrix33<T>& m, T e) const IMATH_NOEXCEPT
2264 {
2265  for (int i = 0; i < 3; i++)
2266  for (int j = 0; j < 3; j++)
2268  (*this)[i][j], m[i][j], e))
2269  return false;
2270 
2271  return true;
2272 }
2273 
2274 template <class T>
2275 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline bool
2276 Matrix33<T>::equalWithRelError (const Matrix33<T>& m, T e) const IMATH_NOEXCEPT
2277 {
2278  for (int i = 0; i < 3; i++)
2279  for (int j = 0; j < 3; j++)
2281  (*this)[i][j], m[i][j], e))
2282  return false;
2283 
2284  return true;
2285 }
2286 
2287 template <class T>
2288 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix33<T>&
2290 {
2291  x[0][0] += v.x[0][0];
2292  x[0][1] += v.x[0][1];
2293  x[0][2] += v.x[0][2];
2294  x[1][0] += v.x[1][0];
2295  x[1][1] += v.x[1][1];
2296  x[1][2] += v.x[1][2];
2297  x[2][0] += v.x[2][0];
2298  x[2][1] += v.x[2][1];
2299  x[2][2] += v.x[2][2];
2300 
2301  return *this;
2302 }
2303 
2304 template <class T>
2305 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix33<T>&
2306 Matrix33<T>::operator+= (T a) IMATH_NOEXCEPT
2307 {
2308  x[0][0] += a;
2309  x[0][1] += a;
2310  x[0][2] += a;
2311  x[1][0] += a;
2312  x[1][1] += a;
2313  x[1][2] += a;
2314  x[2][0] += a;
2315  x[2][1] += a;
2316  x[2][2] += a;
2317 
2318  return *this;
2319 }
2320 
2321 template <class T>
2322 IMATH_HOSTDEVICE constexpr inline Matrix33<T>
2323 Matrix33<T>::operator+ (const Matrix33<T>& v) const IMATH_NOEXCEPT
2324 {
2325  return Matrix33 (
2326  x[0][0] + v.x[0][0],
2327  x[0][1] + v.x[0][1],
2328  x[0][2] + v.x[0][2],
2329  x[1][0] + v.x[1][0],
2330  x[1][1] + v.x[1][1],
2331  x[1][2] + v.x[1][2],
2332  x[2][0] + v.x[2][0],
2333  x[2][1] + v.x[2][1],
2334  x[2][2] + v.x[2][2]);
2335 }
2336 
2337 template <class T>
2338 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix33<T>&
2340 {
2341  x[0][0] -= v.x[0][0];
2342  x[0][1] -= v.x[0][1];
2343  x[0][2] -= v.x[0][2];
2344  x[1][0] -= v.x[1][0];
2345  x[1][1] -= v.x[1][1];
2346  x[1][2] -= v.x[1][2];
2347  x[2][0] -= v.x[2][0];
2348  x[2][1] -= v.x[2][1];
2349  x[2][2] -= v.x[2][2];
2350 
2351  return *this;
2352 }
2353 
2354 template <class T>
2355 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix33<T>&
2356 Matrix33<T>::operator-= (T a) IMATH_NOEXCEPT
2357 {
2358  x[0][0] -= a;
2359  x[0][1] -= a;
2360  x[0][2] -= a;
2361  x[1][0] -= a;
2362  x[1][1] -= a;
2363  x[1][2] -= a;
2364  x[2][0] -= a;
2365  x[2][1] -= a;
2366  x[2][2] -= a;
2367 
2368  return *this;
2369 }
2370 
2371 template <class T>
2372 IMATH_HOSTDEVICE constexpr inline Matrix33<T>
2373 Matrix33<T>::operator- (const Matrix33<T>& v) const IMATH_NOEXCEPT
2374 {
2375  return Matrix33 (
2376  x[0][0] - v.x[0][0],
2377  x[0][1] - v.x[0][1],
2378  x[0][2] - v.x[0][2],
2379  x[1][0] - v.x[1][0],
2380  x[1][1] - v.x[1][1],
2381  x[1][2] - v.x[1][2],
2382  x[2][0] - v.x[2][0],
2383  x[2][1] - v.x[2][1],
2384  x[2][2] - v.x[2][2]);
2385 }
2386 
2387 template <class T>
2388 IMATH_HOSTDEVICE constexpr inline Matrix33<T>
2389 Matrix33<T>::operator- () const IMATH_NOEXCEPT
2390 {
2391  return Matrix33 (
2392  -x[0][0],
2393  -x[0][1],
2394  -x[0][2],
2395  -x[1][0],
2396  -x[1][1],
2397  -x[1][2],
2398  -x[2][0],
2399  -x[2][1],
2400  -x[2][2]);
2401 }
2402 
2403 template <class T>
2404 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix33<T>&
2405  Matrix33<T>::negate () IMATH_NOEXCEPT
2406 {
2407  x[0][0] = -x[0][0];
2408  x[0][1] = -x[0][1];
2409  x[0][2] = -x[0][2];
2410  x[1][0] = -x[1][0];
2411  x[1][1] = -x[1][1];
2412  x[1][2] = -x[1][2];
2413  x[2][0] = -x[2][0];
2414  x[2][1] = -x[2][1];
2415  x[2][2] = -x[2][2];
2416 
2417  return *this;
2418 }
2419 
2420 template <class T>
2421 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix33<T>&
2422 Matrix33<T>::operator*= (T a) IMATH_NOEXCEPT
2423 {
2424  x[0][0] *= a;
2425  x[0][1] *= a;
2426  x[0][2] *= a;
2427  x[1][0] *= a;
2428  x[1][1] *= a;
2429  x[1][2] *= a;
2430  x[2][0] *= a;
2431  x[2][1] *= a;
2432  x[2][2] *= a;
2433 
2434  return *this;
2435 }
2436 
2437 template <class T>
2438 IMATH_HOSTDEVICE constexpr inline Matrix33<T>
2439 Matrix33<T>::operator* (T a) const IMATH_NOEXCEPT
2440 {
2441  return Matrix33 (
2442  x[0][0] * a,
2443  x[0][1] * a,
2444  x[0][2] * a,
2445  x[1][0] * a,
2446  x[1][1] * a,
2447  x[1][2] * a,
2448  x[2][0] * a,
2449  x[2][1] * a,
2450  x[2][2] * a);
2451 }
2452 
2453 /// Matrix-scalar multiplication
2454 template <class T>
2455 IMATH_HOSTDEVICE inline Matrix33<T> constexpr
2456 operator* (T a, const Matrix33<T>& v) IMATH_NOEXCEPT
2457 {
2458  return v * a;
2459 }
2460 
2461 template <class T>
2462 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix33<T>&
2464 {
2465  // Avoid initializing with 0 values before immediately overwriting them,
2466  // and unroll all loops for the best autovectorization.
2468 
2469  tmp.x[0][0] =
2470  x[0][0] * v.x[0][0] + x[0][1] * v.x[1][0] + x[0][2] * v.x[2][0];
2471  tmp.x[0][1] =
2472  x[0][0] * v.x[0][1] + x[0][1] * v.x[1][1] + x[0][2] * v.x[2][1];
2473  tmp.x[0][2] =
2474  x[0][0] * v.x[0][2] + x[0][1] * v.x[1][2] + x[0][2] * v.x[2][2];
2475 
2476  tmp.x[1][0] =
2477  x[1][0] * v.x[0][0] + x[1][1] * v.x[1][0] + x[1][2] * v.x[2][0];
2478  tmp.x[1][1] =
2479  x[1][0] * v.x[0][1] + x[1][1] * v.x[1][1] + x[1][2] * v.x[2][1];
2480  tmp.x[1][2] =
2481  x[1][0] * v.x[0][2] + x[1][1] * v.x[1][2] + x[1][2] * v.x[2][2];
2482 
2483  tmp.x[2][0] =
2484  x[2][0] * v.x[0][0] + x[2][1] * v.x[1][0] + x[2][2] * v.x[2][0];
2485  tmp.x[2][1] =
2486  x[2][0] * v.x[0][1] + x[2][1] * v.x[1][1] + x[2][2] * v.x[2][1];
2487  tmp.x[2][2] =
2488  x[2][0] * v.x[0][2] + x[2][1] * v.x[1][2] + x[2][2] * v.x[2][2];
2489 
2490  *this = tmp;
2491  return *this;
2492 }
2493 
2494 template <class T>
2495 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline Matrix33<T>
2496 Matrix33<T>::operator* (const Matrix33<T>& v) const IMATH_NOEXCEPT
2497 {
2498  // Avoid initializing with 0 values before immediately overwriting them,
2499  // and unroll all loops for the best autovectorization.
2501 
2502  tmp.x[0][0] =
2503  x[0][0] * v.x[0][0] + x[0][1] * v.x[1][0] + x[0][2] * v.x[2][0];
2504  tmp.x[0][1] =
2505  x[0][0] * v.x[0][1] + x[0][1] * v.x[1][1] + x[0][2] * v.x[2][1];
2506  tmp.x[0][2] =
2507  x[0][0] * v.x[0][2] + x[0][1] * v.x[1][2] + x[0][2] * v.x[2][2];
2508 
2509  tmp.x[1][0] =
2510  x[1][0] * v.x[0][0] + x[1][1] * v.x[1][0] + x[1][2] * v.x[2][0];
2511  tmp.x[1][1] =
2512  x[1][0] * v.x[0][1] + x[1][1] * v.x[1][1] + x[1][2] * v.x[2][1];
2513  tmp.x[1][2] =
2514  x[1][0] * v.x[0][2] + x[1][1] * v.x[1][2] + x[1][2] * v.x[2][2];
2515 
2516  tmp.x[2][0] =
2517  x[2][0] * v.x[0][0] + x[2][1] * v.x[1][0] + x[2][2] * v.x[2][0];
2518  tmp.x[2][1] =
2519  x[2][0] * v.x[0][1] + x[2][1] * v.x[1][1] + x[2][2] * v.x[2][1];
2520  tmp.x[2][2] =
2521  x[2][0] * v.x[0][2] + x[2][1] * v.x[1][2] + x[2][2] * v.x[2][2];
2522 
2523  return tmp;
2524 }
2525 
2526 template <class T>
2527 template <class S>
2528 IMATH_HOSTDEVICE inline void
2530  IMATH_NOEXCEPT
2531 {
2532  S a, b, w;
2533 
2534  a = src.x * x[0][0] + src.y * x[1][0] + x[2][0];
2535  b = src.x * x[0][1] + src.y * x[1][1] + x[2][1];
2536  w = src.x * x[0][2] + src.y * x[1][2] + x[2][2];
2537 
2538  dst.x = a / w;
2539  dst.y = b / w;
2540 }
2541 
2542 template <class T>
2543 template <class S>
2544 IMATH_HOSTDEVICE inline void
2546  IMATH_NOEXCEPT
2547 {
2548  S a, b;
2549 
2550  a = src.x * x[0][0] + src.y * x[1][0];
2551  b = src.x * x[0][1] + src.y * x[1][1];
2552 
2553  dst.x = a;
2554  dst.y = b;
2555 }
2556 
2557 template <class T>
2558 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix33<T>&
2559 Matrix33<T>::operator/= (T a) IMATH_NOEXCEPT
2560 {
2561  x[0][0] /= a;
2562  x[0][1] /= a;
2563  x[0][2] /= a;
2564  x[1][0] /= a;
2565  x[1][1] /= a;
2566  x[1][2] /= a;
2567  x[2][0] /= a;
2568  x[2][1] /= a;
2569  x[2][2] /= a;
2570 
2571  return *this;
2572 }
2573 
2574 template <class T>
2575 IMATH_HOSTDEVICE constexpr inline Matrix33<T>
2576 Matrix33<T>::operator/ (T a) const IMATH_NOEXCEPT
2577 {
2578  return Matrix33 (
2579  x[0][0] / a,
2580  x[0][1] / a,
2581  x[0][2] / a,
2582  x[1][0] / a,
2583  x[1][1] / a,
2584  x[1][2] / a,
2585  x[2][0] / a,
2586  x[2][1] / a,
2587  x[2][2] / a);
2588 }
2589 
2590 template <class T>
2591 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix33<T>&
2592  Matrix33<T>::transpose () IMATH_NOEXCEPT
2593 {
2594  Matrix33 tmp (
2595  x[0][0],
2596  x[1][0],
2597  x[2][0],
2598  x[0][1],
2599  x[1][1],
2600  x[2][1],
2601  x[0][2],
2602  x[1][2],
2603  x[2][2]);
2604  *this = tmp;
2605  return *this;
2606 }
2607 
2608 template <class T>
2609 IMATH_HOSTDEVICE constexpr inline Matrix33<T>
2610 Matrix33<T>::transposed () const IMATH_NOEXCEPT
2611 {
2612  return Matrix33 (
2613  x[0][0],
2614  x[1][0],
2615  x[2][0],
2616  x[0][1],
2617  x[1][1],
2618  x[2][1],
2619  x[0][2],
2620  x[1][2],
2621  x[2][2]);
2622 }
2623 
2624 template <class T>
2625 const inline Matrix33<T>&
2627 {
2628  *this = gjInverse (singExc);
2629  return *this;
2630 }
2631 
2632 template <class T>
2633 IMATH_HOSTDEVICE const inline Matrix33<T>&
2634 Matrix33<T>::gjInvert () IMATH_NOEXCEPT
2635 {
2636  *this = gjInverse ();
2637  return *this;
2638 }
2639 
2640 template <class T>
2641 inline Matrix33<T>
2642 Matrix33<T>::gjInverse (bool singExc) const
2643 {
2644  int i, j, k;
2645  Matrix33 s;
2646  Matrix33 t (*this);
2647 
2648  // Forward elimination
2649 
2650  for (i = 0; i < 2; i++)
2651  {
2652  int pivot = i;
2653 
2654  T pivotsize = t.x[i][i];
2655 
2656  if (pivotsize < 0) pivotsize = -pivotsize;
2657 
2658  for (j = i + 1; j < 3; j++)
2659  {
2660  T tmp = t.x[j][i];
2661 
2662  if (tmp < 0) tmp = -tmp;
2663 
2664  if (tmp > pivotsize)
2665  {
2666  pivot = j;
2667  pivotsize = tmp;
2668  }
2669  }
2670 
2671  if (pivotsize == 0)
2672  {
2673  if (singExc)
2674  throw std::invalid_argument ("Cannot invert singular matrix.");
2675 
2676  return Matrix33 ();
2677  }
2678 
2679  if (pivot != i)
2680  {
2681  for (j = 0; j < 3; j++)
2682  {
2683  T tmp;
2684 
2685  tmp = t.x[i][j];
2686  t.x[i][j] = t.x[pivot][j];
2687  t.x[pivot][j] = tmp;
2688 
2689  tmp = s.x[i][j];
2690  s.x[i][j] = s.x[pivot][j];
2691  s.x[pivot][j] = tmp;
2692  }
2693  }
2694 
2695  for (j = i + 1; j < 3; j++)
2696  {
2697  T f = t.x[j][i] / t.x[i][i];
2698 
2699  for (k = 0; k < 3; k++)
2700  {
2701  t.x[j][k] -= f * t.x[i][k];
2702  s.x[j][k] -= f * s.x[i][k];
2703  }
2704  }
2705  }
2706 
2707  // Backward substitution
2708 
2709  for (i = 2; i >= 0; --i)
2710  {
2711  T f;
2712 
2713  if ((f = t[i][i]) == 0)
2714  {
2715  if (singExc)
2716  throw std::invalid_argument ("Cannot invert singular matrix.");
2717 
2718  return Matrix33 ();
2719  }
2720 
2721  for (j = 0; j < 3; j++)
2722  {
2723  t.x[i][j] /= f;
2724  s.x[i][j] /= f;
2725  }
2726 
2727  for (j = 0; j < i; j++)
2728  {
2729  f = t.x[j][i];
2730 
2731  for (k = 0; k < 3; k++)
2732  {
2733  t.x[j][k] -= f * t.x[i][k];
2734  s.x[j][k] -= f * s.x[i][k];
2735  }
2736  }
2737  }
2738 
2739  return s;
2740 }
2741 
2742 template <class T>
2744 Matrix33<T>::gjInverse () const IMATH_NOEXCEPT
2745 {
2746  int i, j, k;
2747  Matrix33 s;
2748  Matrix33 t (*this);
2749 
2750  // Forward elimination
2751 
2752  for (i = 0; i < 2; i++)
2753  {
2754  int pivot = i;
2755 
2756  T pivotsize = t.x[i][i];
2757 
2758  if (pivotsize < 0) pivotsize = -pivotsize;
2759 
2760  for (j = i + 1; j < 3; j++)
2761  {
2762  T tmp = t.x[j][i];
2763 
2764  if (tmp < 0) tmp = -tmp;
2765 
2766  if (tmp > pivotsize)
2767  {
2768  pivot = j;
2769  pivotsize = tmp;
2770  }
2771  }
2772 
2773  if (pivotsize == 0) { return Matrix33 (); }
2774 
2775  if (pivot != i)
2776  {
2777  for (j = 0; j < 3; j++)
2778  {
2779  T tmp;
2780 
2781  tmp = t.x[i][j];
2782  t.x[i][j] = t.x[pivot][j];
2783  t.x[pivot][j] = tmp;
2784 
2785  tmp = s.x[i][j];
2786  s.x[i][j] = s.x[pivot][j];
2787  s.x[pivot][j] = tmp;
2788  }
2789  }
2790 
2791  for (j = i + 1; j < 3; j++)
2792  {
2793  T f = t.x[j][i] / t.x[i][i];
2794 
2795  for (k = 0; k < 3; k++)
2796  {
2797  t.x[j][k] -= f * t.x[i][k];
2798  s.x[j][k] -= f * s.x[i][k];
2799  }
2800  }
2801  }
2802 
2803  // Backward substitution
2804 
2805  for (i = 2; i >= 0; --i)
2806  {
2807  T f;
2808 
2809  if ((f = t.x[i][i]) == 0) { return Matrix33 (); }
2810 
2811  for (j = 0; j < 3; j++)
2812  {
2813  t.x[i][j] /= f;
2814  s.x[i][j] /= f;
2815  }
2816 
2817  for (j = 0; j < i; j++)
2818  {
2819  f = t.x[j][i];
2820 
2821  for (k = 0; k < 3; k++)
2822  {
2823  t.x[j][k] -= f * t.x[i][k];
2824  s.x[j][k] -= f * s.x[i][k];
2825  }
2826  }
2827  }
2828 
2829  return s;
2830 }
2831 
2832 template <class T>
2833 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix33<T>&
2834 Matrix33<T>::invert (bool singExc)
2835 {
2836  *this = inverse (singExc);
2837  return *this;
2838 }
2839 
2840 template <class T>
2841 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix33<T>&
2842  Matrix33<T>::invert () IMATH_NOEXCEPT
2843 {
2844  *this = inverse ();
2845  return *this;
2846 }
2847 
2848 template <class T>
2849 IMATH_CONSTEXPR14 inline Matrix33<T>
2850 Matrix33<T>::inverse (bool singExc) const
2851 {
2852  if (x[0][2] != 0 || x[1][2] != 0 || x[2][2] != 1)
2853  {
2854  Matrix33 s (
2855  x[1][1] * x[2][2] - x[2][1] * x[1][2],
2856  x[2][1] * x[0][2] - x[0][1] * x[2][2],
2857  x[0][1] * x[1][2] - x[1][1] * x[0][2],
2858 
2859  x[2][0] * x[1][2] - x[1][0] * x[2][2],
2860  x[0][0] * x[2][2] - x[2][0] * x[0][2],
2861  x[1][0] * x[0][2] - x[0][0] * x[1][2],
2862 
2863  x[1][0] * x[2][1] - x[2][0] * x[1][1],
2864  x[2][0] * x[0][1] - x[0][0] * x[2][1],
2865  x[0][0] * x[1][1] - x[1][0] * x[0][1]);
2866 
2867  T r = x[0][0] * s[0][0] + x[0][1] * s[1][0] + x[0][2] * s[2][0];
2868 
2869  if (IMATH_INTERNAL_NAMESPACE::abs (r) >= 1)
2870  {
2871  for (int i = 0; i < 3; ++i)
2872  {
2873  for (int j = 0; j < 3; ++j)
2874  {
2875  s.x[i][j] /= r;
2876  }
2877  }
2878  }
2879  else
2880  {
2881  T mr = IMATH_INTERNAL_NAMESPACE::abs (r) /
2883 
2884  for (int i = 0; i < 3; ++i)
2885  {
2886  for (int j = 0; j < 3; ++j)
2887  {
2888  if (mr > IMATH_INTERNAL_NAMESPACE::abs (s.x[i][j]))
2889  {
2890  s.x[i][j] /= r;
2891  }
2892  else
2893  {
2894  if (singExc)
2895  throw std::invalid_argument ("Cannot invert "
2896  "singular matrix.");
2897  return Matrix33 ();
2898  }
2899  }
2900  }
2901  }
2902 
2903  return s;
2904  }
2905  else
2906  {
2907  Matrix33 s (
2908  x[1][1],
2909  -x[0][1],
2910  0,
2911 
2912  -x[1][0],
2913  x[0][0],
2914  0,
2915 
2916  0,
2917  0,
2918  1);
2919 
2920  T r = x[0][0] * x[1][1] - x[1][0] * x[0][1];
2921 
2922  if (IMATH_INTERNAL_NAMESPACE::abs (r) >= 1)
2923  {
2924  for (int i = 0; i < 2; ++i)
2925  {
2926  for (int j = 0; j < 2; ++j)
2927  {
2928  s.x[i][j] /= r;
2929  }
2930  }
2931  }
2932  else
2933  {
2934  T mr = IMATH_INTERNAL_NAMESPACE::abs (r) /
2936 
2937  for (int i = 0; i < 2; ++i)
2938  {
2939  for (int j = 0; j < 2; ++j)
2940  {
2941  if (mr > IMATH_INTERNAL_NAMESPACE::abs (s.x[i][j]))
2942  {
2943  s.x[i][j] /= r;
2944  }
2945  else
2946  {
2947  if (singExc)
2948  throw std::invalid_argument ("Cannot invert "
2949  "singular matrix.");
2950  return Matrix33 ();
2951  }
2952  }
2953  }
2954  }
2955 
2956  s.x[2][0] = -x[2][0] * s.x[0][0] - x[2][1] * s.x[1][0];
2957  s.x[2][1] = -x[2][0] * s.x[0][1] - x[2][1] * s.x[1][1];
2958 
2959  return s;
2960  }
2961 }
2962 
2963 template <class T>
2964 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline Matrix33<T>
2965 Matrix33<T>::inverse () const IMATH_NOEXCEPT
2966 {
2967  if (x[0][2] != 0 || x[1][2] != 0 || x[2][2] != 1)
2968  {
2969  Matrix33 s (
2970  x[1][1] * x[2][2] - x[2][1] * x[1][2],
2971  x[2][1] * x[0][2] - x[0][1] * x[2][2],
2972  x[0][1] * x[1][2] - x[1][1] * x[0][2],
2973 
2974  x[2][0] * x[1][2] - x[1][0] * x[2][2],
2975  x[0][0] * x[2][2] - x[2][0] * x[0][2],
2976  x[1][0] * x[0][2] - x[0][0] * x[1][2],
2977 
2978  x[1][0] * x[2][1] - x[2][0] * x[1][1],
2979  x[2][0] * x[0][1] - x[0][0] * x[2][1],
2980  x[0][0] * x[1][1] - x[1][0] * x[0][1]);
2981 
2982  T r = x[0][0] * s.x[0][0] + x[0][1] * s.x[1][0] + x[0][2] * s.x[2][0];
2983 
2984  if (IMATH_INTERNAL_NAMESPACE::abs (r) >= 1)
2985  {
2986  for (int i = 0; i < 3; ++i)
2987  {
2988  for (int j = 0; j < 3; ++j)
2989  {
2990  s.x[i][j] /= r;
2991  }
2992  }
2993  }
2994  else
2995  {
2996  T mr = IMATH_INTERNAL_NAMESPACE::abs (r) /
2998 
2999  for (int i = 0; i < 3; ++i)
3000  {
3001  for (int j = 0; j < 3; ++j)
3002  {
3003  if (mr > IMATH_INTERNAL_NAMESPACE::abs (s.x[i][j]))
3004  {
3005  s.x[i][j] /= r;
3006  }
3007  else
3008  {
3009  return Matrix33 ();
3010  }
3011  }
3012  }
3013  }
3014 
3015  return s;
3016  }
3017  else
3018  {
3019  Matrix33 s (
3020  x[1][1],
3021  -x[0][1],
3022  0,
3023 
3024  -x[1][0],
3025  x[0][0],
3026  0,
3027 
3028  0,
3029  0,
3030  1);
3031 
3032  T r = x[0][0] * x[1][1] - x[1][0] * x[0][1];
3033 
3034  if (IMATH_INTERNAL_NAMESPACE::abs (r) >= 1)
3035  {
3036  for (int i = 0; i < 2; ++i)
3037  {
3038  for (int j = 0; j < 2; ++j)
3039  {
3040  s.x[i][j] /= r;
3041  }
3042  }
3043  }
3044  else
3045  {
3046  T mr = IMATH_INTERNAL_NAMESPACE::abs (r) /
3048 
3049  for (int i = 0; i < 2; ++i)
3050  {
3051  for (int j = 0; j < 2; ++j)
3052  {
3053  if (mr > IMATH_INTERNAL_NAMESPACE::abs (s.x[i][j]))
3054  {
3055  s.x[i][j] /= r;
3056  }
3057  else
3058  {
3059  return Matrix33 ();
3060  }
3061  }
3062  }
3063  }
3064 
3065  s.x[2][0] = -x[2][0] * s.x[0][0] - x[2][1] * s.x[1][0];
3066  s.x[2][1] = -x[2][0] * s.x[0][1] - x[2][1] * s.x[1][1];
3067 
3068  return s;
3069  }
3070 }
3071 
3072 template <class T>
3073 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline T
3074 Matrix33<T>::minorOf (const int r, const int c) const IMATH_NOEXCEPT
3075 {
3076  int r0 = 0 + (r < 1 ? 1 : 0);
3077  int r1 = 1 + (r < 2 ? 1 : 0);
3078  int c0 = 0 + (c < 1 ? 1 : 0);
3079  int c1 = 1 + (c < 2 ? 1 : 0);
3080 
3081  return x[r0][c0] * x[r1][c1] - x[r1][c0] * x[r0][c1];
3082 }
3083 
3084 template <class T>
3085 IMATH_HOSTDEVICE constexpr inline T
3087  const int r0, const int r1, const int c0, const int c1) const IMATH_NOEXCEPT
3088 {
3089  return x[r0][c0] * x[r1][c1] - x[r0][c1] * x[r1][c0];
3090 }
3091 
3092 template <class T>
3093 IMATH_HOSTDEVICE constexpr inline T
3094 Matrix33<T>::determinant () const IMATH_NOEXCEPT
3095 {
3096  return x[0][0] * (x[1][1] * x[2][2] - x[1][2] * x[2][1]) +
3097  x[0][1] * (x[1][2] * x[2][0] - x[1][0] * x[2][2]) +
3098  x[0][2] * (x[1][0] * x[2][1] - x[1][1] * x[2][0]);
3099 }
3100 
3101 template <class T>
3102 IMATH_HOSTDEVICE constexpr inline T
3103 Matrix33<T>::trace () const IMATH_NOEXCEPT
3104 {
3105  return x[0][0] + x[1][1] + x[2][2];
3106 }
3107 
3108 template <class T>
3109 template <class S>
3110 IMATH_HOSTDEVICE inline const Matrix33<T>&
3111 Matrix33<T>::setRotation (S r) IMATH_NOEXCEPT
3112 {
3113  S cos_r, sin_r;
3114 
3115  cos_r = cos ((T) r);
3116  sin_r = sin ((T) r);
3117 
3118  x[0][0] = cos_r;
3119  x[0][1] = sin_r;
3120  x[0][2] = 0;
3121 
3122  x[1][0] = -sin_r;
3123  x[1][1] = cos_r;
3124  x[1][2] = 0;
3125 
3126  x[2][0] = 0;
3127  x[2][1] = 0;
3128  x[2][2] = 1;
3129 
3130  return *this;
3131 }
3132 
3133 template <class T>
3134 template <class S>
3135 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix33<T>&
3136  Matrix33<T>::rotate (S r) IMATH_NOEXCEPT
3137 {
3138  *this *= Matrix33<T> ().setRotation (r);
3139  return *this;
3140 }
3141 
3142 template <class T>
3143 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix33<T>&
3144  Matrix33<T>::setScale (T s) IMATH_NOEXCEPT
3145 {
3146  //
3147  // Set the matrix to a 2D homogeneous transform scale:
3148  // | s 0 0 |
3149  // | 0 s 0 |
3150  // | 0 0 1 |
3151  //
3152 
3153  x[0][0] = s;
3154  x[0][1] = 0;
3155  x[0][2] = 0;
3156  x[1][0] = 0;
3157  x[1][1] = s;
3158  x[1][2] = 0;
3159  x[2][0] = 0;
3160  x[2][1] = 0;
3161  x[2][2] = 1;
3162  return *this;
3163 }
3164 
3165 template <class T>
3166 template <class S>
3167 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix33<T>&
3168  Matrix33<T>::setScale (const Vec2<S>& s) IMATH_NOEXCEPT
3169 {
3170  //
3171  // Set the matrix to a 2D homogeneous transform scale:
3172  // | s.x 0 0 |
3173  // | 0 s.y 0 |
3174  // | 0 0 1 |
3175  //
3176 
3177  x[0][0] = s.x;
3178  x[0][1] = 0;
3179  x[0][2] = 0;
3180  x[1][0] = 0;
3181  x[1][1] = s.y;
3182  x[1][2] = 0;
3183  x[2][0] = 0;
3184  x[2][1] = 0;
3185  x[2][2] = 1;
3186  return *this;
3187 }
3188 
3189 template <class T>
3190 template <class S>
3191 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix33<T>&
3192  Matrix33<T>::scale (const Vec2<S>& s) IMATH_NOEXCEPT
3193 {
3194  x[0][0] *= s.x;
3195  x[0][1] *= s.x;
3196  x[0][2] *= s.x;
3197 
3198  x[1][0] *= s.y;
3199  x[1][1] *= s.y;
3200  x[1][2] *= s.y;
3201 
3202  return *this;
3203 }
3204 
3205 template <class T>
3206 template <class S>
3207 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix33<T>&
3208  Matrix33<T>::setTranslation (const Vec2<S>& t) IMATH_NOEXCEPT
3209 {
3210  x[0][0] = 1;
3211  x[0][1] = 0;
3212  x[0][2] = 0;
3213 
3214  x[1][0] = 0;
3215  x[1][1] = 1;
3216  x[1][2] = 0;
3217 
3218  x[2][0] = t.x;
3219  x[2][1] = t.y;
3220  x[2][2] = 1;
3221 
3222  return *this;
3223 }
3224 
3225 template <class T>
3226 IMATH_HOSTDEVICE constexpr inline Vec2<T>
3227 Matrix33<T>::translation () const IMATH_NOEXCEPT
3228 {
3229  return Vec2<T> (x[2][0], x[2][1]);
3230 }
3231 
3232 template <class T>
3233 template <class S>
3234 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix33<T>&
3235  Matrix33<T>::translate (const Vec2<S>& t) IMATH_NOEXCEPT
3236 {
3237  x[2][0] += t.x * x[0][0] + t.y * x[1][0];
3238  x[2][1] += t.x * x[0][1] + t.y * x[1][1];
3239  x[2][2] += t.x * x[0][2] + t.y * x[1][2];
3240 
3241  return *this;
3242 }
3243 
3244 template <class T>
3245 template <class S>
3246 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix33<T>&
3247  Matrix33<T>::setShear (const S& xy) IMATH_NOEXCEPT
3248 {
3249  x[0][0] = 1;
3250  x[0][1] = 0;
3251  x[0][2] = 0;
3252 
3253  x[1][0] = xy;
3254  x[1][1] = 1;
3255  x[1][2] = 0;
3256 
3257  x[2][0] = 0;
3258  x[2][1] = 0;
3259  x[2][2] = 1;
3260 
3261  return *this;
3262 }
3263 
3264 template <class T>
3265 template <class S>
3266 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix33<T>&
3267  Matrix33<T>::setShear (const Vec2<S>& h) IMATH_NOEXCEPT
3268 {
3269  x[0][0] = 1;
3270  x[0][1] = h.y;
3271  x[0][2] = 0;
3272 
3273  x[1][0] = h.x;
3274  x[1][1] = 1;
3275  x[1][2] = 0;
3276 
3277  x[2][0] = 0;
3278  x[2][1] = 0;
3279  x[2][2] = 1;
3280 
3281  return *this;
3282 }
3283 
3284 template <class T>
3285 template <class S>
3286 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix33<T>&
3287  Matrix33<T>::shear (const S& xy) IMATH_NOEXCEPT
3288 {
3289  //
3290  // In this case, we don't need a temp. copy of the matrix
3291  // because we never use a value on the RHS after we've
3292  // changed it on the LHS.
3293  //
3294 
3295  x[1][0] += xy * x[0][0];
3296  x[1][1] += xy * x[0][1];
3297  x[1][2] += xy * x[0][2];
3298 
3299  return *this;
3300 }
3301 
3302 template <class T>
3303 template <class S>
3304 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix33<T>&
3305  Matrix33<T>::shear (const Vec2<S>& h) IMATH_NOEXCEPT
3306 {
3307  Matrix33<T> P (*this);
3308 
3309  x[0][0] = P.x[0][0] + h.y * P.x[1][0];
3310  x[0][1] = P.x[0][1] + h.y * P.x[1][1];
3311  x[0][2] = P.x[0][2] + h.y * P.x[1][2];
3312 
3313  x[1][0] = P.x[1][0] + h.x * P.x[0][0];
3314  x[1][1] = P.x[1][1] + h.x * P.x[0][1];
3315  x[1][2] = P.x[1][2] + h.x * P.x[0][2];
3316 
3317  return *this;
3318 }
3319 
3320 //---------------------------
3321 // Implementation of Matrix44
3322 //---------------------------
3323 
3324 template <class T>
3325 IMATH_HOSTDEVICE inline T*
3326 Matrix44<T>::operator[] (int i) IMATH_NOEXCEPT
3327 {
3328  return x[i];
3329 }
3330 
3331 template <class T>
3332 IMATH_HOSTDEVICE inline const T*
3333 Matrix44<T>::operator[] (int i) const IMATH_NOEXCEPT
3334 {
3335  return x[i];
3336 }
3337 
3338 template <class T>
3340  IMATH_CONSTEXPR14 inline Matrix44<T>::Matrix44 () IMATH_NOEXCEPT
3341 {
3342  x[0][0] = 1;
3343  x[0][1] = 0;
3344  x[0][2] = 0;
3345  x[0][3] = 0;
3346  x[1][0] = 0;
3347  x[1][1] = 1;
3348  x[1][2] = 0;
3349  x[1][3] = 0;
3350  x[2][0] = 0;
3351  x[2][1] = 0;
3352  x[2][2] = 1;
3353  x[2][3] = 0;
3354  x[3][0] = 0;
3355  x[3][1] = 0;
3356  x[3][2] = 0;
3357  x[3][3] = 1;
3358 }
3359 
3360 template <class T>
3362  IMATH_CONSTEXPR14 inline Matrix44<T>::Matrix44 (T a) IMATH_NOEXCEPT
3363 {
3364  x[0][0] = a;
3365  x[0][1] = a;
3366  x[0][2] = a;
3367  x[0][3] = a;
3368  x[1][0] = a;
3369  x[1][1] = a;
3370  x[1][2] = a;
3371  x[1][3] = a;
3372  x[2][0] = a;
3373  x[2][1] = a;
3374  x[2][2] = a;
3375  x[2][3] = a;
3376  x[3][0] = a;
3377  x[3][1] = a;
3378  x[3][2] = a;
3379  x[3][3] = a;
3380 }
3381 
3382 template <class T>
3383 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline Matrix44<T>::Matrix44 (
3384  const T a[4][4]) IMATH_NOEXCEPT
3385 {
3386  x[0][0] = a[0][0];
3387  x[0][1] = a[0][1];
3388  x[0][2] = a[0][2];
3389  x[0][3] = a[0][3];
3390  x[1][0] = a[1][0];
3391  x[1][1] = a[1][1];
3392  x[1][2] = a[1][2];
3393  x[1][3] = a[1][3];
3394  x[2][0] = a[2][0];
3395  x[2][1] = a[2][1];
3396  x[2][2] = a[2][2];
3397  x[2][3] = a[2][3];
3398  x[3][0] = a[3][0];
3399  x[3][1] = a[3][1];
3400  x[3][2] = a[3][2];
3401  x[3][3] = a[3][3];
3402 }
3403 
3404 template <class T>
3405 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline Matrix44<T>::Matrix44 (
3406  T a,
3407  T b,
3408  T c,
3409  T d,
3410  T e,
3411  T f,
3412  T g,
3413  T h,
3414  T i,
3415  T j,
3416  T k,
3417  T l,
3418  T m,
3419  T n,
3420  T o,
3421  T p) IMATH_NOEXCEPT
3422 {
3423  x[0][0] = a;
3424  x[0][1] = b;
3425  x[0][2] = c;
3426  x[0][3] = d;
3427  x[1][0] = e;
3428  x[1][1] = f;
3429  x[1][2] = g;
3430  x[1][3] = h;
3431  x[2][0] = i;
3432  x[2][1] = j;
3433  x[2][2] = k;
3434  x[2][3] = l;
3435  x[3][0] = m;
3436  x[3][1] = n;
3437  x[3][2] = o;
3438  x[3][3] = p;
3439 }
3440 
3441 template <class T>
3442 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline Matrix44<T>::Matrix44 (
3443  Matrix33<T> r, Vec3<T> t) IMATH_NOEXCEPT
3444 {
3445  x[0][0] = r.x[0][0];
3446  x[0][1] = r.x[0][1];
3447  x[0][2] = r.x[0][2];
3448  x[0][3] = 0;
3449  x[1][0] = r.x[1][0];
3450  x[1][1] = r.x[1][1];
3451  x[1][2] = r.x[1][2];
3452  x[1][3] = 0;
3453  x[2][0] = r.x[2][0];
3454  x[2][1] = r.x[2][1];
3455  x[2][2] = r.x[2][2];
3456  x[2][3] = 0;
3457  x[3][0] = t.x;
3458  x[3][1] = t.y;
3459  x[3][2] = t.z;
3460  x[3][3] = 1;
3461 }
3462 
3463 template <class T>
3464 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline Matrix44<T>::Matrix44 (
3465  const Matrix44& v) IMATH_NOEXCEPT
3466 {
3467  x[0][0] = v.x[0][0];
3468  x[0][1] = v.x[0][1];
3469  x[0][2] = v.x[0][2];
3470  x[0][3] = v.x[0][3];
3471  x[1][0] = v.x[1][0];
3472  x[1][1] = v.x[1][1];
3473  x[1][2] = v.x[1][2];
3474  x[1][3] = v.x[1][3];
3475  x[2][0] = v.x[2][0];
3476  x[2][1] = v.x[2][1];
3477  x[2][2] = v.x[2][2];
3478  x[2][3] = v.x[2][3];
3479  x[3][0] = v.x[3][0];
3480  x[3][1] = v.x[3][1];
3481  x[3][2] = v.x[3][2];
3482  x[3][3] = v.x[3][3];
3483 }
3484 
3485 template <class T>
3486 template <class S>
3487 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline Matrix44<T>::Matrix44 (
3488  const Matrix44<S>& v) IMATH_NOEXCEPT
3489 {
3490  x[0][0] = T (v.x[0][0]);
3491  x[0][1] = T (v.x[0][1]);
3492  x[0][2] = T (v.x[0][2]);
3493  x[0][3] = T (v.x[0][3]);
3494  x[1][0] = T (v.x[1][0]);
3495  x[1][1] = T (v.x[1][1]);
3496  x[1][2] = T (v.x[1][2]);
3497  x[1][3] = T (v.x[1][3]);
3498  x[2][0] = T (v.x[2][0]);
3499  x[2][1] = T (v.x[2][1]);
3500  x[2][2] = T (v.x[2][2]);
3501  x[2][3] = T (v.x[2][3]);
3502  x[3][0] = T (v.x[3][0]);
3503  x[3][1] = T (v.x[3][1]);
3504  x[3][2] = T (v.x[3][2]);
3505  x[3][3] = T (v.x[3][3]);
3506 }
3507 
3508 template <class T>
3509 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix44<T>&
3510 Matrix44<T>::operator= (const Matrix44& v) IMATH_NOEXCEPT
3511 {
3512  x[0][0] = v.x[0][0];
3513  x[0][1] = v.x[0][1];
3514  x[0][2] = v.x[0][2];
3515  x[0][3] = v.x[0][3];
3516  x[1][0] = v.x[1][0];
3517  x[1][1] = v.x[1][1];
3518  x[1][2] = v.x[1][2];
3519  x[1][3] = v.x[1][3];
3520  x[2][0] = v.x[2][0];
3521  x[2][1] = v.x[2][1];
3522  x[2][2] = v.x[2][2];
3523  x[2][3] = v.x[2][3];
3524  x[3][0] = v.x[3][0];
3525  x[3][1] = v.x[3][1];
3526  x[3][2] = v.x[3][2];
3527  x[3][3] = v.x[3][3];
3528  return *this;
3529 }
3530 
3531 template <class T>
3532 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix44<T>&
3533 Matrix44<T>::operator= (T a) IMATH_NOEXCEPT
3534 {
3535  x[0][0] = a;
3536  x[0][1] = a;
3537  x[0][2] = a;
3538  x[0][3] = a;
3539  x[1][0] = a;
3540  x[1][1] = a;
3541  x[1][2] = a;
3542  x[1][3] = a;
3543  x[2][0] = a;
3544  x[2][1] = a;
3545  x[2][2] = a;
3546  x[2][3] = a;
3547  x[3][0] = a;
3548  x[3][1] = a;
3549  x[3][2] = a;
3550  x[3][3] = a;
3551  return *this;
3552 }
3553 
3554 template <class T>
3555 IMATH_HOSTDEVICE inline T*
3556 Matrix44<T>::getValue () IMATH_NOEXCEPT
3557 {
3558  return reinterpret_cast<T*> (this);
3559 }
3560 
3561 template <class T>
3562 IMATH_HOSTDEVICE inline const T*
3563 Matrix44<T>::getValue () const IMATH_NOEXCEPT
3564 {
3565  return reinterpret_cast<const T*> (this);
3566 }
3567 
3568 template <class T>
3569 template <class S>
3570 IMATH_HOSTDEVICE inline void
3571 Matrix44<T>::getValue (Matrix44<S>& v) const IMATH_NOEXCEPT
3572 {
3573  v.x[0][0] = x[0][0];
3574  v.x[0][1] = x[0][1];
3575  v.x[0][2] = x[0][2];
3576  v.x[0][3] = x[0][3];
3577  v.x[1][0] = x[1][0];
3578  v.x[1][1] = x[1][1];
3579  v.x[1][2] = x[1][2];
3580  v.x[1][3] = x[1][3];
3581  v.x[2][0] = x[2][0];
3582  v.x[2][1] = x[2][1];
3583  v.x[2][2] = x[2][2];
3584  v.x[2][3] = x[2][3];
3585  v.x[3][0] = x[3][0];
3586  v.x[3][1] = x[3][1];
3587  v.x[3][2] = x[3][2];
3588  v.x[3][3] = x[3][3];
3589 }
3590 
3591 template <class T>
3592 template <class S>
3593 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline Matrix44<T>&
3594  Matrix44<T>::setValue (const Matrix44<S>& v) IMATH_NOEXCEPT
3595 {
3596  x[0][0] = T(v.x[0][0]);
3597  x[0][1] = T(v.x[0][1]);
3598  x[0][2] = T(v.x[0][2]);
3599  x[0][3] = T(v.x[0][3]);
3600  x[1][0] = T(v.x[1][0]);
3601  x[1][1] = T(v.x[1][1]);
3602  x[1][2] = T(v.x[1][2]);
3603  x[1][3] = T(v.x[1][3]);
3604  x[2][0] = T(v.x[2][0]);
3605  x[2][1] = T(v.x[2][1]);
3606  x[2][2] = T(v.x[2][2]);
3607  x[2][3] = T(v.x[2][3]);
3608  x[3][0] = T(v.x[3][0]);
3609  x[3][1] = T(v.x[3][1]);
3610  x[3][2] = T(v.x[3][2]);
3611  x[3][3] = T(v.x[3][3]);
3612  return *this;
3613 }
3614 
3615 template <class T>
3616 template <class S>
3617 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline Matrix44<T>&
3618  Matrix44<T>::setTheMatrix (const Matrix44<S>& v) IMATH_NOEXCEPT
3619 {
3620  x[0][0] = v.x[0][0];
3621  x[0][1] = v.x[0][1];
3622  x[0][2] = v.x[0][2];
3623  x[0][3] = v.x[0][3];
3624  x[1][0] = v.x[1][0];
3625  x[1][1] = v.x[1][1];
3626  x[1][2] = v.x[1][2];
3627  x[1][3] = v.x[1][3];
3628  x[2][0] = v.x[2][0];
3629  x[2][1] = v.x[2][1];
3630  x[2][2] = v.x[2][2];
3631  x[2][3] = v.x[2][3];
3632  x[3][0] = v.x[3][0];
3633  x[3][1] = v.x[3][1];
3634  x[3][2] = v.x[3][2];
3635  x[3][3] = v.x[3][3];
3636  return *this;
3637 }
3638 
3639 template <class T>
3640 IMATH_HOSTDEVICE inline void
3641 Matrix44<T>::makeIdentity () IMATH_NOEXCEPT
3642 {
3643  x[0][0] = 1;
3644  x[0][1] = 0;
3645  x[0][2] = 0;
3646  x[0][3] = 0;
3647  x[1][0] = 0;
3648  x[1][1] = 1;
3649  x[1][2] = 0;
3650  x[1][3] = 0;
3651  x[2][0] = 0;
3652  x[2][1] = 0;
3653  x[2][2] = 1;
3654  x[2][3] = 0;
3655  x[3][0] = 0;
3656  x[3][1] = 0;
3657  x[3][2] = 0;
3658  x[3][3] = 1;
3659 }
3660 
3661 template <class T>
3662 IMATH_HOSTDEVICE constexpr inline bool
3663 Matrix44<T>::operator== (const Matrix44& v) const IMATH_NOEXCEPT
3664 {
3665  return x[0][0] == v.x[0][0] && x[0][1] == v.x[0][1] &&
3666  x[0][2] == v.x[0][2] && x[0][3] == v.x[0][3] &&
3667  x[1][0] == v.x[1][0] && x[1][1] == v.x[1][1] &&
3668  x[1][2] == v.x[1][2] && x[1][3] == v.x[1][3] &&
3669  x[2][0] == v.x[2][0] && x[2][1] == v.x[2][1] &&
3670  x[2][2] == v.x[2][2] && x[2][3] == v.x[2][3] &&
3671  x[3][0] == v.x[3][0] && x[3][1] == v.x[3][1] &&
3672  x[3][2] == v.x[3][2] && x[3][3] == v.x[3][3];
3673 }
3674 
3675 template <class T>
3676 IMATH_HOSTDEVICE constexpr inline bool
3677 Matrix44<T>::operator!= (const Matrix44& v) const IMATH_NOEXCEPT
3678 {
3679  return x[0][0] != v.x[0][0] || x[0][1] != v.x[0][1] ||
3680  x[0][2] != v.x[0][2] || x[0][3] != v.x[0][3] ||
3681  x[1][0] != v.x[1][0] || x[1][1] != v.x[1][1] ||
3682  x[1][2] != v.x[1][2] || x[1][3] != v.x[1][3] ||
3683  x[2][0] != v.x[2][0] || x[2][1] != v.x[2][1] ||
3684  x[2][2] != v.x[2][2] || x[2][3] != v.x[2][3] ||
3685  x[3][0] != v.x[3][0] || x[3][1] != v.x[3][1] ||
3686  x[3][2] != v.x[3][2] || x[3][3] != v.x[3][3];
3687 }
3688 
3689 template <class T>
3690 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline bool
3691 Matrix44<T>::equalWithAbsError (const Matrix44<T>& m, T e) const IMATH_NOEXCEPT
3692 {
3693  for (int i = 0; i < 4; i++)
3694  for (int j = 0; j < 4; j++)
3696  (*this).x[i][j], m.x[i][j], e))
3697  return false;
3698 
3699  return true;
3700 }
3701 
3702 template <class T>
3703 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline bool
3704 Matrix44<T>::equalWithRelError (const Matrix44<T>& m, T e) const IMATH_NOEXCEPT
3705 {
3706  for (int i = 0; i < 4; i++)
3707  for (int j = 0; j < 4; j++)
3709  (*this).x[i][j], m.x[i][j], e))
3710  return false;
3711 
3712  return true;
3713 }
3714 
3715 template <class T>
3716 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix44<T>&
3718 {
3719  x[0][0] += v.x[0][0];
3720  x[0][1] += v.x[0][1];
3721  x[0][2] += v.x[0][2];
3722  x[0][3] += v.x[0][3];
3723  x[1][0] += v.x[1][0];
3724  x[1][1] += v.x[1][1];
3725  x[1][2] += v.x[1][2];
3726  x[1][3] += v.x[1][3];
3727  x[2][0] += v.x[2][0];
3728  x[2][1] += v.x[2][1];
3729  x[2][2] += v.x[2][2];
3730  x[2][3] += v.x[2][3];
3731  x[3][0] += v.x[3][0];
3732  x[3][1] += v.x[3][1];
3733  x[3][2] += v.x[3][2];
3734  x[3][3] += v.x[3][3];
3735 
3736  return *this;
3737 }
3738 
3739 template <class T>
3740 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix44<T>&
3741 Matrix44<T>::operator+= (T a) IMATH_NOEXCEPT
3742 {
3743  x[0][0] += a;
3744  x[0][1] += a;
3745  x[0][2] += a;
3746  x[0][3] += a;
3747  x[1][0] += a;
3748  x[1][1] += a;
3749  x[1][2] += a;
3750  x[1][3] += a;
3751  x[2][0] += a;
3752  x[2][1] += a;
3753  x[2][2] += a;
3754  x[2][3] += a;
3755  x[3][0] += a;
3756  x[3][1] += a;
3757  x[3][2] += a;
3758  x[3][3] += a;
3759 
3760  return *this;
3761 }
3762 
3763 template <class T>
3764 IMATH_HOSTDEVICE constexpr inline Matrix44<T>
3765 Matrix44<T>::operator+ (const Matrix44<T>& v) const IMATH_NOEXCEPT
3766 {
3767  return Matrix44 (
3768  x[0][0] + v.x[0][0],
3769  x[0][1] + v.x[0][1],
3770  x[0][2] + v.x[0][2],
3771  x[0][3] + v.x[0][3],
3772  x[1][0] + v.x[1][0],
3773  x[1][1] + v.x[1][1],
3774  x[1][2] + v.x[1][2],
3775  x[1][3] + v.x[1][3],
3776  x[2][0] + v.x[2][0],
3777  x[2][1] + v.x[2][1],
3778  x[2][2] + v.x[2][2],
3779  x[2][3] + v.x[2][3],
3780  x[3][0] + v.x[3][0],
3781  x[3][1] + v.x[3][1],
3782  x[3][2] + v.x[3][2],
3783  x[3][3] + v.x[3][3]);
3784 }
3785 
3786 template <class T>
3787 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix44<T>&
3789 {
3790  x[0][0] -= v.x[0][0];
3791  x[0][1] -= v.x[0][1];
3792  x[0][2] -= v.x[0][2];
3793  x[0][3] -= v.x[0][3];
3794  x[1][0] -= v.x[1][0];
3795  x[1][1] -= v.x[1][1];
3796  x[1][2] -= v.x[1][2];
3797  x[1][3] -= v.x[1][3];
3798  x[2][0] -= v.x[2][0];
3799  x[2][1] -= v.x[2][1];
3800  x[2][2] -= v.x[2][2];
3801  x[2][3] -= v.x[2][3];
3802  x[3][0] -= v.x[3][0];
3803  x[3][1] -= v.x[3][1];
3804  x[3][2] -= v.x[3][2];
3805  x[3][3] -= v.x[3][3];
3806 
3807  return *this;
3808 }
3809 
3810 template <class T>
3811 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix44<T>&
3812 Matrix44<T>::operator-= (T a) IMATH_NOEXCEPT
3813 {
3814  x[0][0] -= a;
3815  x[0][1] -= a;
3816  x[0][2] -= a;
3817  x[0][3] -= a;
3818  x[1][0] -= a;
3819  x[1][1] -= a;
3820  x[1][2] -= a;
3821  x[1][3] -= a;
3822  x[2][0] -= a;
3823  x[2][1] -= a;
3824  x[2][2] -= a;
3825  x[2][3] -= a;
3826  x[3][0] -= a;
3827  x[3][1] -= a;
3828  x[3][2] -= a;
3829  x[3][3] -= a;
3830 
3831  return *this;
3832 }
3833 
3834 template <class T>
3835 IMATH_HOSTDEVICE constexpr inline Matrix44<T>
3836 Matrix44<T>::operator- (const Matrix44<T>& v) const IMATH_NOEXCEPT
3837 {
3838  return Matrix44 (
3839  x[0][0] - v.x[0][0],
3840  x[0][1] - v.x[0][1],
3841  x[0][2] - v.x[0][2],
3842  x[0][3] - v.x[0][3],
3843  x[1][0] - v.x[1][0],
3844  x[1][1] - v.x[1][1],
3845  x[1][2] - v.x[1][2],
3846  x[1][3] - v.x[1][3],
3847  x[2][0] - v.x[2][0],
3848  x[2][1] - v.x[2][1],
3849  x[2][2] - v.x[2][2],
3850  x[2][3] - v.x[2][3],
3851  x[3][0] - v.x[3][0],
3852  x[3][1] - v.x[3][1],
3853  x[3][2] - v.x[3][2],
3854  x[3][3] - v.x[3][3]);
3855 }
3856 
3857 template <class T>
3858 IMATH_HOSTDEVICE constexpr inline Matrix44<T>
3859 Matrix44<T>::operator- () const IMATH_NOEXCEPT
3860 {
3861  return Matrix44 (
3862  -x[0][0],
3863  -x[0][1],
3864  -x[0][2],
3865  -x[0][3],
3866  -x[1][0],
3867  -x[1][1],
3868  -x[1][2],
3869  -x[1][3],
3870  -x[2][0],
3871  -x[2][1],
3872  -x[2][2],
3873  -x[2][3],
3874  -x[3][0],
3875  -x[3][1],
3876  -x[3][2],
3877  -x[3][3]);
3878 }
3879 
3880 template <class T>
3881 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix44<T>&
3882  Matrix44<T>::negate () IMATH_NOEXCEPT
3883 {
3884  x[0][0] = -x[0][0];
3885  x[0][1] = -x[0][1];
3886  x[0][2] = -x[0][2];
3887  x[0][3] = -x[0][3];
3888  x[1][0] = -x[1][0];
3889  x[1][1] = -x[1][1];
3890  x[1][2] = -x[1][2];
3891  x[1][3] = -x[1][3];
3892  x[2][0] = -x[2][0];
3893  x[2][1] = -x[2][1];
3894  x[2][2] = -x[2][2];
3895  x[2][3] = -x[2][3];
3896  x[3][0] = -x[3][0];
3897  x[3][1] = -x[3][1];
3898  x[3][2] = -x[3][2];
3899  x[3][3] = -x[3][3];
3900 
3901  return *this;
3902 }
3903 
3904 template <class T>
3905 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix44<T>&
3906 Matrix44<T>::operator*= (T a) IMATH_NOEXCEPT
3907 {
3908  x[0][0] *= a;
3909  x[0][1] *= a;
3910  x[0][2] *= a;
3911  x[0][3] *= a;
3912  x[1][0] *= a;
3913  x[1][1] *= a;
3914  x[1][2] *= a;
3915  x[1][3] *= a;
3916  x[2][0] *= a;
3917  x[2][1] *= a;
3918  x[2][2] *= a;
3919  x[2][3] *= a;
3920  x[3][0] *= a;
3921  x[3][1] *= a;
3922  x[3][2] *= a;
3923  x[3][3] *= a;
3924 
3925  return *this;
3926 }
3927 
3928 template <class T>
3929 IMATH_HOSTDEVICE constexpr inline Matrix44<T>
3930 Matrix44<T>::operator* (T a) const IMATH_NOEXCEPT
3931 {
3932  return Matrix44 (
3933  x[0][0] * a,
3934  x[0][1] * a,
3935  x[0][2] * a,
3936  x[0][3] * a,
3937  x[1][0] * a,
3938  x[1][1] * a,
3939  x[1][2] * a,
3940  x[1][3] * a,
3941  x[2][0] * a,
3942  x[2][1] * a,
3943  x[2][2] * a,
3944  x[2][3] * a,
3945  x[3][0] * a,
3946  x[3][1] * a,
3947  x[3][2] * a,
3948  x[3][3] * a);
3949 }
3950 
3951 /// Matrix-scalar multiplication
3952 template <class T>
3954 operator* (T a, const Matrix44<T>& v) IMATH_NOEXCEPT
3955 {
3956  return v * a;
3957 }
3958 
3959 template <class T>
3960 IMATH_HOSTDEVICE inline IMATH_CONSTEXPR14 Matrix44<T>
3961 Matrix44<T>::multiply (const Matrix44& a, const Matrix44& b) IMATH_NOEXCEPT
3962 {
3963  const auto a00 = a.x[0][0];
3964  const auto a01 = a.x[0][1];
3965  const auto a02 = a.x[0][2];
3966  const auto a03 = a.x[0][3];
3967 
3968  const auto c00 =
3969  a00 * b.x[0][0] + a01 * b.x[1][0] + a02 * b.x[2][0] + a03 * b.x[3][0];
3970  const auto c01 =
3971  a00 * b.x[0][1] + a01 * b.x[1][1] + a02 * b.x[2][1] + a03 * b.x[3][1];
3972  const auto c02 =
3973  a00 * b.x[0][2] + a01 * b.x[1][2] + a02 * b.x[2][2] + a03 * b.x[3][2];
3974  const auto c03 =
3975  a00 * b.x[0][3] + a01 * b.x[1][3] + a02 * b.x[2][3] + a03 * b.x[3][3];
3976 
3977  const auto a10 = a.x[1][0];
3978  const auto a11 = a.x[1][1];
3979  const auto a12 = a.x[1][2];
3980  const auto a13 = a.x[1][3];
3981 
3982  const auto c10 =
3983  a10 * b.x[0][0] + a11 * b.x[1][0] + a12 * b.x[2][0] + a13 * b.x[3][0];
3984  const auto c11 =
3985  a10 * b.x[0][1] + a11 * b.x[1][1] + a12 * b.x[2][1] + a13 * b.x[3][1];
3986  const auto c12 =
3987  a10 * b.x[0][2] + a11 * b.x[1][2] + a12 * b.x[2][2] + a13 * b.x[3][2];
3988  const auto c13 =
3989  a10 * b.x[0][3] + a11 * b.x[1][3] + a12 * b.x[2][3] + a13 * b.x[3][3];
3990 
3991  const auto a20 = a.x[2][0];
3992  const auto a21 = a.x[2][1];
3993  const auto a22 = a.x[2][2];
3994  const auto a23 = a.x[2][3];
3995 
3996  const auto c20 =
3997  a20 * b.x[0][0] + a21 * b.x[1][0] + a22 * b.x[2][0] + a23 * b.x[3][0];
3998  const auto c21 =
3999  a20 * b.x[0][1] + a21 * b.x[1][1] + a22 * b.x[2][1] + a23 * b.x[3][1];
4000  const auto c22 =
4001  a20 * b.x[0][2] + a21 * b.x[1][2] + a22 * b.x[2][2] + a23 * b.x[3][2];
4002  const auto c23 =
4003  a20 * b.x[0][3] + a21 * b.x[1][3] + a22 * b.x[2][3] + a23 * b.x[3][3];
4004 
4005  const auto a30 = a.x[3][0];
4006  const auto a31 = a.x[3][1];
4007  const auto a32 = a.x[3][2];
4008  const auto a33 = a.x[3][3];
4009 
4010  const auto c30 =
4011  a30 * b.x[0][0] + a31 * b.x[1][0] + a32 * b.x[2][0] + a33 * b.x[3][0];
4012  const auto c31 =
4013  a30 * b.x[0][1] + a31 * b.x[1][1] + a32 * b.x[2][1] + a33 * b.x[3][1];
4014  const auto c32 =
4015  a30 * b.x[0][2] + a31 * b.x[1][2] + a32 * b.x[2][2] + a33 * b.x[3][2];
4016  const auto c33 =
4017  a30 * b.x[0][3] + a31 * b.x[1][3] + a32 * b.x[2][3] + a33 * b.x[3][3];
4018  return Matrix44 (
4019  c00,
4020  c01,
4021  c02,
4022  c03,
4023  c10,
4024  c11,
4025  c12,
4026  c13,
4027  c20,
4028  c21,
4029  c22,
4030  c23,
4031  c30,
4032  c31,
4033  c32,
4034  c33);
4035 }
4036 
4037 template <class T>
4038 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix44<T>&
4040 {
4041  *this = multiply (*this, v);
4042  return *this;
4043 }
4044 
4045 template <class T>
4046 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline Matrix44<T>
4047 Matrix44<T>::operator* (const Matrix44<T>& v) const IMATH_NOEXCEPT
4048 {
4049  return multiply (*this, v);
4050 }
4051 
4052 template <class T>
4053 IMATH_HOSTDEVICE inline void
4055  const Matrix44<T>& a, const Matrix44<T>& b, Matrix44<T>& c) IMATH_NOEXCEPT
4056 {
4057  c = multiply (a, b);
4058 }
4059 
4060 template <class T>
4061 template <class S>
4062 IMATH_HOSTDEVICE inline void
4064  IMATH_NOEXCEPT
4065 {
4066  S a, b, c, w;
4067 
4068  a = src.x * x[0][0] + src.y * x[1][0] + src.z * x[2][0] + x[3][0];
4069  b = src.x * x[0][1] + src.y * x[1][1] + src.z * x[2][1] + x[3][1];
4070  c = src.x * x[0][2] + src.y * x[1][2] + src.z * x[2][2] + x[3][2];
4071  w = src.x * x[0][3] + src.y * x[1][3] + src.z * x[2][3] + x[3][3];
4072 
4073  dst.x = a / w;
4074  dst.y = b / w;
4075  dst.z = c / w;
4076 }
4077 
4078 template <class T>
4079 template <class S>
4080 IMATH_HOSTDEVICE inline void
4082  IMATH_NOEXCEPT
4083 {
4084  S a, b, c;
4085 
4086  a = src.x * x[0][0] + src.y * x[1][0] + src.z * x[2][0];
4087  b = src.x * x[0][1] + src.y * x[1][1] + src.z * x[2][1];
4088  c = src.x * x[0][2] + src.y * x[1][2] + src.z * x[2][2];
4089 
4090  dst.x = a;
4091  dst.y = b;
4092  dst.z = c;
4093 }
4094 
4095 template <class T>
4096 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix44<T>&
4097 Matrix44<T>::operator/= (T a) IMATH_NOEXCEPT
4098 {
4099  x[0][0] /= a;
4100  x[0][1] /= a;
4101  x[0][2] /= a;
4102  x[0][3] /= a;
4103  x[1][0] /= a;
4104  x[1][1] /= a;
4105  x[1][2] /= a;
4106  x[1][3] /= a;
4107  x[2][0] /= a;
4108  x[2][1] /= a;
4109  x[2][2] /= a;
4110  x[2][3] /= a;
4111  x[3][0] /= a;
4112  x[3][1] /= a;
4113  x[3][2] /= a;
4114  x[3][3] /= a;
4115 
4116  return *this;
4117 }
4118 
4119 template <class T>
4120 IMATH_HOSTDEVICE constexpr inline Matrix44<T>
4121 Matrix44<T>::operator/ (T a) const IMATH_NOEXCEPT
4122 {
4123  return Matrix44 (
4124  x[0][0] / a,
4125  x[0][1] / a,
4126  x[0][2] / a,
4127  x[0][3] / a,
4128  x[1][0] / a,
4129  x[1][1] / a,
4130  x[1][2] / a,
4131  x[1][3] / a,
4132  x[2][0] / a,
4133  x[2][1] / a,
4134  x[2][2] / a,
4135  x[2][3] / a,
4136  x[3][0] / a,
4137  x[3][1] / a,
4138  x[3][2] / a,
4139  x[3][3] / a);
4140 }
4141 
4142 template <class T>
4143 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix44<T>&
4144  Matrix44<T>::transpose () IMATH_NOEXCEPT
4145 {
4146  Matrix44 tmp (
4147  x[0][0],
4148  x[1][0],
4149  x[2][0],
4150  x[3][0],
4151  x[0][1],
4152  x[1][1],
4153  x[2][1],
4154  x[3][1],
4155  x[0][2],
4156  x[1][2],
4157  x[2][2],
4158  x[3][2],
4159  x[0][3],
4160  x[1][3],
4161  x[2][3],
4162  x[3][3]);
4163  *this = tmp;
4164  return *this;
4165 }
4166 
4167 template <class T>
4168 IMATH_HOSTDEVICE constexpr inline Matrix44<T>
4169 Matrix44<T>::transposed () const IMATH_NOEXCEPT
4170 {
4171  return Matrix44 (
4172  x[0][0],
4173  x[1][0],
4174  x[2][0],
4175  x[3][0],
4176  x[0][1],
4177  x[1][1],
4178  x[2][1],
4179  x[3][1],
4180  x[0][2],
4181  x[1][2],
4182  x[2][2],
4183  x[3][2],
4184  x[0][3],
4185  x[1][3],
4186  x[2][3],
4187  x[3][3]);
4188 }
4189 
4190 template <class T>
4191 IMATH_CONSTEXPR14 inline const Matrix44<T>&
4193 {
4194  *this = gjInverse (singExc);
4195  return *this;
4196 }
4197 
4198 template <class T>
4199 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix44<T>&
4200  Matrix44<T>::gjInvert () IMATH_NOEXCEPT
4201 {
4202  *this = gjInverse ();
4203  return *this;
4204 }
4205 
4206 template <class T>
4207 inline Matrix44<T>
4208 Matrix44<T>::gjInverse (bool singExc) const
4209 {
4210  int i, j, k;
4211  Matrix44 s;
4212  Matrix44 t (*this);
4213 
4214  // Forward elimination
4215 
4216  for (i = 0; i < 3; i++)
4217  {
4218  int pivot = i;
4219 
4220  T pivotsize = t.x[i][i];
4221 
4222  if (pivotsize < 0) pivotsize = -pivotsize;
4223 
4224  for (j = i + 1; j < 4; j++)
4225  {
4226  T tmp = t.x[j][i];
4227 
4228  if (tmp < 0) tmp = -tmp;
4229 
4230  if (tmp > pivotsize)
4231  {
4232  pivot = j;
4233  pivotsize = tmp;
4234  }
4235  }
4236 
4237  if (pivotsize == 0)
4238  {
4239  if (singExc)
4240  throw std::invalid_argument ("Cannot invert singular matrix.");
4241 
4242  return Matrix44 ();
4243  }
4244 
4245  if (pivot != i)
4246  {
4247  for (j = 0; j < 4; j++)
4248  {
4249  T tmp;
4250 
4251  tmp = t.x[i][j];
4252  t.x[i][j] = t.x[pivot][j];
4253  t.x[pivot][j] = tmp;
4254 
4255  tmp = s.x[i][j];
4256  s.x[i][j] = s.x[pivot][j];
4257  s.x[pivot][j] = tmp;
4258  }
4259  }
4260 
4261  for (j = i + 1; j < 4; j++)
4262  {
4263  T f = t.x[j][i] / t.x[i][i];
4264 
4265  for (k = 0; k < 4; k++)
4266  {
4267  t.x[j][k] -= f * t.x[i][k];
4268  s.x[j][k] -= f * s.x[i][k];
4269  }
4270  }
4271  }
4272 
4273  // Backward substitution
4274 
4275  for (i = 3; i >= 0; --i)
4276  {
4277  T f;
4278 
4279  if ((f = t.x[i][i]) == 0)
4280  {
4281  if (singExc)
4282  throw std::invalid_argument ("Cannot invert singular matrix.");
4283 
4284  return Matrix44 ();
4285  }
4286 
4287  for (j = 0; j < 4; j++)
4288  {
4289  t.x[i][j] /= f;
4290  s.x[i][j] /= f;
4291  }
4292 
4293  for (j = 0; j < i; j++)
4294  {
4295  f = t.x[j][i];
4296 
4297  for (k = 0; k < 4; k++)
4298  {
4299  t.x[j][k] -= f * t.x[i][k];
4300  s.x[j][k] -= f * s.x[i][k];
4301  }
4302  }
4303  }
4304 
4305  return s;
4306 }
4307 
4308 template <class T>
4310 Matrix44<T>::gjInverse () const IMATH_NOEXCEPT
4311 {
4312  int i, j, k;
4313  Matrix44 s;
4314  Matrix44 t (*this);
4315 
4316  // Forward elimination
4317 
4318  for (i = 0; i < 3; i++)
4319  {
4320  int pivot = i;
4321 
4322  T pivotsize = t.x[i][i];
4323 
4324  if (pivotsize < 0) pivotsize = -pivotsize;
4325 
4326  for (j = i + 1; j < 4; j++)
4327  {
4328  T tmp = t.x[j][i];
4329 
4330  if (tmp < 0) tmp = -tmp;
4331 
4332  if (tmp > pivotsize)
4333  {
4334  pivot = j;
4335  pivotsize = tmp;
4336  }
4337  }
4338 
4339  if (pivotsize == 0) { return Matrix44 (); }
4340 
4341  if (pivot != i)
4342  {
4343  for (j = 0; j < 4; j++)
4344  {
4345  T tmp;
4346 
4347  tmp = t.x[i][j];
4348  t.x[i][j] = t.x[pivot][j];
4349  t.x[pivot][j] = tmp;
4350 
4351  tmp = s.x[i][j];
4352  s.x[i][j] = s.x[pivot][j];
4353  s.x[pivot][j] = tmp;
4354  }
4355  }
4356 
4357  for (j = i + 1; j < 4; j++)
4358  {
4359  T f = t.x[j][i] / t.x[i][i];
4360 
4361  for (k = 0; k < 4; k++)
4362  {
4363  t.x[j][k] -= f * t.x[i][k];
4364  s.x[j][k] -= f * s.x[i][k];
4365  }
4366  }
4367  }
4368 
4369  // Backward substitution
4370 
4371  for (i = 3; i >= 0; --i)
4372  {
4373  T f;
4374 
4375  if ((f = t.x[i][i]) == 0) { return Matrix44 (); }
4376 
4377  for (j = 0; j < 4; j++)
4378  {
4379  t.x[i][j] /= f;
4380  s.x[i][j] /= f;
4381  }
4382 
4383  for (j = 0; j < i; j++)
4384  {
4385  f = t.x[j][i];
4386 
4387  for (k = 0; k < 4; k++)
4388  {
4389  t.x[j][k] -= f * t.x[i][k];
4390  s.x[j][k] -= f * s.x[i][k];
4391  }
4392  }
4393  }
4394 
4395  return s;
4396 }
4397 
4398 template <class T>
4399 IMATH_CONSTEXPR14 inline const Matrix44<T>&
4400 Matrix44<T>::invert (bool singExc)
4401 {
4402  *this = inverse (singExc);
4403  return *this;
4404 }
4405 
4406 template <class T>
4407 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix44<T>&
4408  Matrix44<T>::invert () IMATH_NOEXCEPT
4409 {
4410  *this = inverse ();
4411  return *this;
4412 }
4413 
4414 template <class T>
4415 IMATH_CONSTEXPR14 inline Matrix44<T>
4416 Matrix44<T>::inverse (bool singExc) const
4417 {
4418  if (x[0][3] != 0 || x[1][3] != 0 || x[2][3] != 0 || x[3][3] != 1)
4419  return gjInverse (singExc);
4420 
4421  Matrix44 s (
4422  x[1][1] * x[2][2] - x[2][1] * x[1][2],
4423  x[2][1] * x[0][2] - x[0][1] * x[2][2],
4424  x[0][1] * x[1][2] - x[1][1] * x[0][2],
4425  0,
4426 
4427  x[2][0] * x[1][2] - x[1][0] * x[2][2],
4428  x[0][0] * x[2][2] - x[2][0] * x[0][2],
4429  x[1][0] * x[0][2] - x[0][0] * x[1][2],
4430  0,
4431 
4432  x[1][0] * x[2][1] - x[2][0] * x[1][1],
4433  x[2][0] * x[0][1] - x[0][0] * x[2][1],
4434  x[0][0] * x[1][1] - x[1][0] * x[0][1],
4435  0,
4436 
4437  0,
4438  0,
4439  0,
4440  1);
4441 
4442  T r = x[0][0] * s.x[0][0] + x[0][1] * s.x[1][0] + x[0][2] * s.x[2][0];
4443 
4444  if (IMATH_INTERNAL_NAMESPACE::abs (r) >= 1)
4445  {
4446  for (int i = 0; i < 3; ++i)
4447  {
4448  for (int j = 0; j < 3; ++j)
4449  {
4450  s.x[i][j] /= r;
4451  }
4452  }
4453  }
4454  else
4455  {
4456  T mr =
4458 
4459  for (int i = 0; i < 3; ++i)
4460  {
4461  for (int j = 0; j < 3; ++j)
4462  {
4463  if (mr > IMATH_INTERNAL_NAMESPACE::abs (s.x[i][j]))
4464  {
4465  s.x[i][j] /= r;
4466  }
4467  else
4468  {
4469  if (singExc)
4470  throw std::invalid_argument (
4471  "Cannot invert singular matrix.");
4472 
4473  return Matrix44 ();
4474  }
4475  }
4476  }
4477  }
4478 
4479  s.x[3][0] =
4480  -x[3][0] * s.x[0][0] - x[3][1] * s.x[1][0] - x[3][2] * s.x[2][0];
4481  s.x[3][1] =
4482  -x[3][0] * s.x[0][1] - x[3][1] * s.x[1][1] - x[3][2] * s.x[2][1];
4483  s.x[3][2] =
4484  -x[3][0] * s.x[0][2] - x[3][1] * s.x[1][2] - x[3][2] * s.x[2][2];
4485 
4486  return s;
4487 }
4488 
4489 template <class T>
4490 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline Matrix44<T>
4491  Matrix44<T>::inverse () const IMATH_NOEXCEPT
4492 {
4493  if (x[0][3] != 0 || x[1][3] != 0 || x[2][3] != 0 || x[3][3] != 1)
4494  return gjInverse ();
4495 
4496  Matrix44 s (
4497  x[1][1] * x[2][2] - x[2][1] * x[1][2],
4498  x[2][1] * x[0][2] - x[0][1] * x[2][2],
4499  x[0][1] * x[1][2] - x[1][1] * x[0][2],
4500  0,
4501 
4502  x[2][0] * x[1][2] - x[1][0] * x[2][2],
4503  x[0][0] * x[2][2] - x[2][0] * x[0][2],
4504  x[1][0] * x[0][2] - x[0][0] * x[1][2],
4505  0,
4506 
4507  x[1][0] * x[2][1] - x[2][0] * x[1][1],
4508  x[2][0] * x[0][1] - x[0][0] * x[2][1],
4509  x[0][0] * x[1][1] - x[1][0] * x[0][1],
4510  0,
4511 
4512  0,
4513  0,
4514  0,
4515  1);
4516 
4517  T r = x[0][0] * s.x[0][0] + x[0][1] * s.x[1][0] + x[0][2] * s.x[2][0];
4518 
4519  if (IMATH_INTERNAL_NAMESPACE::abs (r) >= 1)
4520  {
4521  for (int i = 0; i < 3; ++i)
4522  {
4523  for (int j = 0; j < 3; ++j)
4524  {
4525  s.x[i][j] /= r;
4526  }
4527  }
4528  }
4529  else
4530  {
4531  T mr =
4533 
4534  for (int i = 0; i < 3; ++i)
4535  {
4536  for (int j = 0; j < 3; ++j)
4537  {
4538  if (mr > IMATH_INTERNAL_NAMESPACE::abs (s.x[i][j]))
4539  {
4540  s.x[i][j] /= r;
4541  }
4542  else
4543  {
4544  return Matrix44 ();
4545  }
4546  }
4547  }
4548  }
4549 
4550  s.x[3][0] =
4551  -x[3][0] * s.x[0][0] - x[3][1] * s.x[1][0] - x[3][2] * s.x[2][0];
4552  s.x[3][1] =
4553  -x[3][0] * s.x[0][1] - x[3][1] * s.x[1][1] - x[3][2] * s.x[2][1];
4554  s.x[3][2] =
4555  -x[3][0] * s.x[0][2] - x[3][1] * s.x[1][2] - x[3][2] * s.x[2][2];
4556 
4557  return s;
4558 }
4559 
4560 template <class T>
4561 IMATH_HOSTDEVICE constexpr inline T
4563  const int r0,
4564  const int r1,
4565  const int r2,
4566  const int c0,
4567  const int c1,
4568  const int c2) const IMATH_NOEXCEPT
4569 {
4570  return x[r0][c0] * (x[r1][c1] * x[r2][c2] - x[r1][c2] * x[r2][c1]) +
4571  x[r0][c1] * (x[r1][c2] * x[r2][c0] - x[r1][c0] * x[r2][c2]) +
4572  x[r0][c2] * (x[r1][c0] * x[r2][c1] - x[r1][c1] * x[r2][c0]);
4573 }
4574 
4575 template <class T>
4576 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline T
4577 Matrix44<T>::minorOf (const int r, const int c) const IMATH_NOEXCEPT
4578 {
4579  int r0 = 0 + (r < 1 ? 1 : 0);
4580  int r1 = 1 + (r < 2 ? 1 : 0);
4581  int r2 = 2 + (r < 3 ? 1 : 0);
4582  int c0 = 0 + (c < 1 ? 1 : 0);
4583  int c1 = 1 + (c < 2 ? 1 : 0);
4584  int c2 = 2 + (c < 3 ? 1 : 0);
4585 
4586  Matrix33<T> working (
4587  x[r0][c0],
4588  x[r1][c0],
4589  x[r2][c0],
4590  x[r0][c1],
4591  x[r1][c1],
4592  x[r2][c1],
4593  x[r0][c2],
4594  x[r1][c2],
4595  x[r2][c2]);
4596 
4597  return working.determinant ();
4598 }
4599 
4600 template <class T>
4601 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline T
4602 Matrix44<T>::determinant () const IMATH_NOEXCEPT
4603 {
4604  T sum = (T) 0;
4605 
4606  if (x[0][3] != 0.) sum -= x[0][3] * fastMinor (1, 2, 3, 0, 1, 2);
4607  if (x[1][3] != 0.) sum += x[1][3] * fastMinor (0, 2, 3, 0, 1, 2);
4608  if (x[2][3] != 0.) sum -= x[2][3] * fastMinor (0, 1, 3, 0, 1, 2);
4609  if (x[3][3] != 0.) sum += x[3][3] * fastMinor (0, 1, 2, 0, 1, 2);
4610 
4611  return sum;
4612 }
4613 
4614 template <class T>
4615 IMATH_HOSTDEVICE constexpr inline T
4616 Matrix44<T>::trace () const IMATH_NOEXCEPT
4617 {
4618  return x[0][0] + x[1][1] + x[2][2] + x[3][3];
4619 }
4620 
4621 template <class T>
4622 template <class S>
4623 IMATH_HOSTDEVICE inline const Matrix44<T>&
4624 Matrix44<T>::setEulerAngles (const Vec3<S>& r) IMATH_NOEXCEPT
4625 {
4626  S cos_rz, sin_rz, cos_ry, sin_ry, cos_rx, sin_rx;
4627 
4628  cos_rz = cos ((T) r.z);
4629  cos_ry = cos ((T) r.y);
4630  cos_rx = cos ((T) r.x);
4631 
4632  sin_rz = sin ((T) r.z);
4633  sin_ry = sin ((T) r.y);
4634  sin_rx = sin ((T) r.x);
4635 
4636  x[0][0] = cos_rz * cos_ry;
4637  x[0][1] = sin_rz * cos_ry;
4638  x[0][2] = -sin_ry;
4639  x[0][3] = 0;
4640 
4641  x[1][0] = -sin_rz * cos_rx + cos_rz * sin_ry * sin_rx;
4642  x[1][1] = cos_rz * cos_rx + sin_rz * sin_ry * sin_rx;
4643  x[1][2] = cos_ry * sin_rx;
4644  x[1][3] = 0;
4645 
4646  x[2][0] = sin_rz * sin_rx + cos_rz * sin_ry * cos_rx;
4647  x[2][1] = -cos_rz * sin_rx + sin_rz * sin_ry * cos_rx;
4648  x[2][2] = cos_ry * cos_rx;
4649  x[2][3] = 0;
4650 
4651  x[3][0] = 0;
4652  x[3][1] = 0;
4653  x[3][2] = 0;
4654  x[3][3] = 1;
4655 
4656  return *this;
4657 }
4658 
4659 template <class T>
4660 template <class S>
4661 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix44<T>&
4662 Matrix44<T>::setAxisAngle (const Vec3<S>& axis, S angle) IMATH_NOEXCEPT
4663 {
4664  Vec3<S> unit (axis.normalized ());
4665  S sine = std::sin (angle);
4666  S cosine = std::cos (angle);
4667 
4668  x[0][0] = unit.x * unit.x * (1 - cosine) + cosine;
4669  x[0][1] = unit.x * unit.y * (1 - cosine) + unit.z * sine;
4670  x[0][2] = unit.x * unit.z * (1 - cosine) - unit.y * sine;
4671  x[0][3] = 0;
4672 
4673  x[1][0] = unit.x * unit.y * (1 - cosine) - unit.z * sine;
4674  x[1][1] = unit.y * unit.y * (1 - cosine) + cosine;
4675  x[1][2] = unit.y * unit.z * (1 - cosine) + unit.x * sine;
4676  x[1][3] = 0;
4677 
4678  x[2][0] = unit.x * unit.z * (1 - cosine) + unit.y * sine;
4679  x[2][1] = unit.y * unit.z * (1 - cosine) - unit.x * sine;
4680  x[2][2] = unit.z * unit.z * (1 - cosine) + cosine;
4681  x[2][3] = 0;
4682 
4683  x[3][0] = 0;
4684  x[3][1] = 0;
4685  x[3][2] = 0;
4686  x[3][3] = 1;
4687 
4688  return *this;
4689 }
4690 
4691 template <class T>
4692 template <class S>
4693 IMATH_HOSTDEVICE inline const Matrix44<T>&
4694 Matrix44<T>::rotate (const Vec3<S>& r) IMATH_NOEXCEPT
4695 {
4696  S cos_rz, sin_rz, cos_ry, sin_ry, cos_rx, sin_rx;
4697  S m00, m01, m02;
4698  S m10, m11, m12;
4699  S m20, m21, m22;
4700 
4701  cos_rz = cos ((S) r.z);
4702  cos_ry = cos ((S) r.y);
4703  cos_rx = cos ((S) r.x);
4704 
4705  sin_rz = sin ((S) r.z);
4706  sin_ry = sin ((S) r.y);
4707  sin_rx = sin ((S) r.x);
4708 
4709  m00 = cos_rz * cos_ry;
4710  m01 = sin_rz * cos_ry;
4711  m02 = -sin_ry;
4712  m10 = -sin_rz * cos_rx + cos_rz * sin_ry * sin_rx;
4713  m11 = cos_rz * cos_rx + sin_rz * sin_ry * sin_rx;
4714  m12 = cos_ry * sin_rx;
4715  m20 = -sin_rz * -sin_rx + cos_rz * sin_ry * cos_rx;
4716  m21 = cos_rz * -sin_rx + sin_rz * sin_ry * cos_rx;
4717  m22 = cos_ry * cos_rx;
4718 
4719  Matrix44<T> P (*this);
4720 
4721  x[0][0] = P.x[0][0] * m00 + P.x[1][0] * m01 + P.x[2][0] * m02;
4722  x[0][1] = P.x[0][1] * m00 + P.x[1][1] * m01 + P.x[2][1] * m02;
4723  x[0][2] = P.x[0][2] * m00 + P.x[1][2] * m01 + P.x[2][2] * m02;
4724  x[0][3] = P.x[0][3] * m00 + P.x[1][3] * m01 + P.x[2][3] * m02;
4725 
4726  x[1][0] = P.x[0][0] * m10 + P.x[1][0] * m11 + P.x[2][0] * m12;
4727  x[1][1] = P.x[0][1] * m10 + P.x[1][1] * m11 + P.x[2][1] * m12;
4728  x[1][2] = P.x[0][2] * m10 + P.x[1][2] * m11 + P.x[2][2] * m12;
4729  x[1][3] = P.x[0][3] * m10 + P.x[1][3] * m11 + P.x[2][3] * m12;
4730 
4731  x[2][0] = P.x[0][0] * m20 + P.x[1][0] * m21 + P.x[2][0] * m22;
4732  x[2][1] = P.x[0][1] * m20 + P.x[1][1] * m21 + P.x[2][1] * m22;
4733  x[2][2] = P.x[0][2] * m20 + P.x[1][2] * m21 + P.x[2][2] * m22;
4734  x[2][3] = P.x[0][3] * m20 + P.x[1][3] * m21 + P.x[2][3] * m22;
4735 
4736  return *this;
4737 }
4738 
4739 template <class T>
4740 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix44<T>&
4741  Matrix44<T>::setScale (T s) IMATH_NOEXCEPT
4742 {
4743  //
4744  // Set the matrix to a 3D homogeneous transform scale:
4745  // | s 0 0 0 |
4746  // | 0 s 0 0 |
4747  // | 0 0 s 0 |
4748  // | 0 0 0 1 |
4749  //
4750 
4751  x[0][0] = s;
4752  x[0][1] = 0;
4753  x[0][2] = 0;
4754  x[0][3] = 0;
4755  x[1][0] = 0;
4756  x[1][1] = s;
4757  x[1][2] = 0;
4758  x[1][3] = 0;
4759  x[2][0] = 0;
4760  x[2][1] = 0;
4761  x[2][2] = s;
4762  x[2][3] = 0;
4763  x[3][0] = 0;
4764  x[3][1] = 0;
4765  x[3][2] = 0;
4766  x[3][3] = 1;
4767  return *this;
4768 }
4769 
4770 template <class T>
4771 template <class S>
4772 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix44<T>&
4773  Matrix44<T>::setScale (const Vec3<S>& s) IMATH_NOEXCEPT
4774 {
4775  //
4776  // Set the matrix to a 3D homogeneous transform scale:
4777  // | s.x 0 0 0 |
4778  // | 0 s.y 0 0 |
4779  // | 0 0 s.z 0 |
4780  // | 0 0 0 1 |
4781  //
4782 
4783  x[0][0] = s.x;
4784  x[0][1] = 0;
4785  x[0][2] = 0;
4786  x[0][3] = 0;
4787  x[1][0] = 0;
4788  x[1][1] = s.y;
4789  x[1][2] = 0;
4790  x[1][3] = 0;
4791  x[2][0] = 0;
4792  x[2][1] = 0;
4793  x[2][2] = s.z;
4794  x[2][3] = 0;
4795  x[3][0] = 0;
4796  x[3][1] = 0;
4797  x[3][2] = 0;
4798  x[3][3] = 1;
4799  return *this;
4800 }
4801 
4802 template <class T>
4803 template <class S>
4804 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix44<T>&
4805  Matrix44<T>::scale (const Vec3<S>& s) IMATH_NOEXCEPT
4806 {
4807  x[0][0] *= s.x;
4808  x[0][1] *= s.x;
4809  x[0][2] *= s.x;
4810  x[0][3] *= s.x;
4811 
4812  x[1][0] *= s.y;
4813  x[1][1] *= s.y;
4814  x[1][2] *= s.y;
4815  x[1][3] *= s.y;
4816 
4817  x[2][0] *= s.z;
4818  x[2][1] *= s.z;
4819  x[2][2] *= s.z;
4820  x[2][3] *= s.z;
4821 
4822  return *this;
4823 }
4824 
4825 template <class T>
4826 template <class S>
4827 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix44<T>&
4828  Matrix44<T>::setTranslation (const Vec3<S>& t) IMATH_NOEXCEPT
4829 {
4830  x[0][0] = 1;
4831  x[0][1] = 0;
4832  x[0][2] = 0;
4833  x[0][3] = 0;
4834 
4835  x[1][0] = 0;
4836  x[1][1] = 1;
4837  x[1][2] = 0;
4838  x[1][3] = 0;
4839 
4840  x[2][0] = 0;
4841  x[2][1] = 0;
4842  x[2][2] = 1;
4843  x[2][3] = 0;
4844 
4845  x[3][0] = t.x;
4846  x[3][1] = t.y;
4847  x[3][2] = t.z;
4848  x[3][3] = 1;
4849 
4850  return *this;
4851 }
4852 
4853 template <class T>
4854 IMATH_HOSTDEVICE constexpr inline const Vec3<T>
4855 Matrix44<T>::translation () const IMATH_NOEXCEPT
4856 {
4857  return Vec3<T> (x[3][0], x[3][1], x[3][2]);
4858 }
4859 
4860 template <class T>
4861 template <class S>
4862 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix44<T>&
4863  Matrix44<T>::translate (const Vec3<S>& t) IMATH_NOEXCEPT
4864 {
4865  x[3][0] += t.x * x[0][0] + t.y * x[1][0] + t.z * x[2][0];
4866  x[3][1] += t.x * x[0][1] + t.y * x[1][1] + t.z * x[2][1];
4867  x[3][2] += t.x * x[0][2] + t.y * x[1][2] + t.z * x[2][2];
4868  x[3][3] += t.x * x[0][3] + t.y * x[1][3] + t.z * x[2][3];
4869 
4870  return *this;
4871 }
4872 
4873 template <class T>
4874 template <class S>
4875 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix44<T>&
4876  Matrix44<T>::setShear (const Vec3<S>& h) IMATH_NOEXCEPT
4877 {
4878  x[0][0] = 1;
4879  x[0][1] = 0;
4880  x[0][2] = 0;
4881  x[0][3] = 0;
4882 
4883  x[1][0] = h.x;
4884  x[1][1] = 1;
4885  x[1][2] = 0;
4886  x[1][3] = 0;
4887 
4888  x[2][0] = h.y;
4889  x[2][1] = h.z;
4890  x[2][2] = 1;
4891  x[2][3] = 0;
4892 
4893  x[3][0] = 0;
4894  x[3][1] = 0;
4895  x[3][2] = 0;
4896  x[3][3] = 1;
4897 
4898  return *this;
4899 }
4900 
4901 template <class T>
4902 template <class S>
4903 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix44<T>&
4904  Matrix44<T>::setShear (const Shear6<S>& h) IMATH_NOEXCEPT
4905 {
4906  x[0][0] = 1;
4907  x[0][1] = h.yx;
4908  x[0][2] = h.zx;
4909  x[0][3] = 0;
4910 
4911  x[1][0] = h.xy;
4912  x[1][1] = 1;
4913  x[1][2] = h.zy;
4914  x[1][3] = 0;
4915 
4916  x[2][0] = h.xz;
4917  x[2][1] = h.yz;
4918  x[2][2] = 1;
4919  x[2][3] = 0;
4920 
4921  x[3][0] = 0;
4922  x[3][1] = 0;
4923  x[3][2] = 0;
4924  x[3][3] = 1;
4925 
4926  return *this;
4927 }
4928 
4929 template <class T>
4930 template <class S>
4931 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix44<T>&
4932  Matrix44<T>::shear (const Vec3<S>& h) IMATH_NOEXCEPT
4933 {
4934  //
4935  // In this case, we don't need a temp. copy of the matrix
4936  // because we never use a value on the RHS after we've
4937  // changed it on the LHS.
4938  //
4939 
4940  for (int i = 0; i < 4; i++)
4941  {
4942  x[2][i] += h.y * x[0][i] + h.z * x[1][i];
4943  x[1][i] += h.x * x[0][i];
4944  }
4945 
4946  return *this;
4947 }
4948 
4949 template <class T>
4950 template <class S>
4951 IMATH_HOSTDEVICE IMATH_CONSTEXPR14 inline const Matrix44<T>&
4952  Matrix44<T>::shear (const Shear6<S>& h) IMATH_NOEXCEPT
4953 {
4954  Matrix44<T> P (*this);
4955 
4956  for (int i = 0; i < 4; i++)
4957  {
4958  x[0][i] = P.x[0][i] + h.yx * P.x[1][i] + h.zx * P.x[2][i];
4959  x[1][i] = h.xy * P.x[0][i] + P.x[1][i] + h.zy * P.x[2][i];
4960  x[2][i] = h.xz * P.x[0][i] + h.yz * P.x[1][i] + P.x[2][i];
4961  }
4962 
4963  return *this;
4964 }
4965 
4966 //--------------------------------
4967 // Implementation of stream output
4968 //--------------------------------
4969 
4970 template <class T>
4971 std::ostream&
4972 operator<< (std::ostream& s, const Matrix22<T>& m)
4973 {
4974  std::ios_base::fmtflags oldFlags = s.flags ();
4975  int width;
4976 
4977  if (s.flags () & std::ios_base::fixed)
4978  {
4979  s.setf (std::ios_base::showpoint);
4980  width = static_cast<int> (s.precision ()) + 5;
4981  }
4982  else
4983  {
4984  s.setf (std::ios_base::scientific);
4985  s.setf (std::ios_base::showpoint);
4986  width = static_cast<int> (s.precision ()) + 8;
4987  }
4988 
4989  s << "(" << std::setw (width) << m[0][0] << " " << std::setw (width)
4990  << m[0][1] << "\n"
4991  <<
4992 
4993  " " << std::setw (width) << m[1][0] << " " << std::setw (width)
4994  << m[1][1] << ")\n";
4995 
4996  s.flags (oldFlags);
4997  return s;
4998 }
4999 
5000 template <class T>
5001 std::ostream&
5002 operator<< (std::ostream& s, const Matrix33<T>& m)
5003 {
5004  std::ios_base::fmtflags oldFlags = s.flags ();
5005  int width;
5006 
5007  if (s.flags () & std::ios_base::fixed)
5008  {
5009  s.setf (std::ios_base::showpoint);
5010  width = static_cast<int> (s.precision ()) + 5;
5011  }
5012  else
5013  {
5014  s.setf (std::ios_base::scientific);
5015  s.setf (std::ios_base::showpoint);
5016  width = static_cast<int> (s.precision ()) + 8;
5017  }
5018 
5019  s << "(" << std::setw (width) << m[0][0] << " " << std::setw (width)
5020  << m[0][1] << " " << std::setw (width) << m[0][2] << "\n"
5021  <<
5022 
5023  " " << std::setw (width) << m[1][0] << " " << std::setw (width)
5024  << m[1][1] << " " << std::setw (width) << m[1][2] << "\n"
5025  <<
5026 
5027  " " << std::setw (width) << m[2][0] << " " << std::setw (width)
5028  << m[2][1] << " " << std::setw (width) << m[2][2] << ")\n";
5029 
5030  s.flags (oldFlags);
5031  return s;
5032 }
5033 
5034 template <class T>
5035 std::ostream&
5036 operator<< (std::ostream& s, const Matrix44<T>& m)
5037 {
5038  std::ios_base::fmtflags oldFlags = s.flags ();
5039  int width;
5040 
5041  if (s.flags () & std::ios_base::fixed)
5042  {
5043  s.setf (std::ios_base::showpoint);
5044  width = static_cast<int> (s.precision ()) + 5;
5045  }
5046  else
5047  {
5048  s.setf (std::ios_base::scientific);
5049  s.setf (std::ios_base::showpoint);
5050  width = static_cast<int> (s.precision ()) + 8;
5051  }
5052 
5053  s << "(" << std::setw (width) << m[0][0] << " " << std::setw (width)
5054  << m[0][1] << " " << std::setw (width) << m[0][2] << " "
5055  << std::setw (width) << m[0][3] << "\n"
5056  <<
5057 
5058  " " << std::setw (width) << m[1][0] << " " << std::setw (width)
5059  << m[1][1] << " " << std::setw (width) << m[1][2] << " "
5060  << std::setw (width) << m[1][3] << "\n"
5061  <<
5062 
5063  " " << std::setw (width) << m[2][0] << " " << std::setw (width)
5064  << m[2][1] << " " << std::setw (width) << m[2][2] << " "
5065  << std::setw (width) << m[2][3] << "\n"
5066  <<
5067 
5068  " " << std::setw (width) << m[3][0] << " " << std::setw (width)
5069  << m[3][1] << " " << std::setw (width) << m[3][2] << " "
5070  << std::setw (width) << m[3][3] << ")\n";
5071 
5072  s.flags (oldFlags);
5073  return s;
5074 }
5075 
5076 //---------------------------------------------------------------
5077 // Implementation of vector-times-matrix multiplication operators
5078 //---------------------------------------------------------------
5079 
5080 template <class S, class T>
5081 IMATH_HOSTDEVICE inline const Vec2<S>&
5082 operator*= (Vec2<S>& v, const Matrix22<T>& m) IMATH_NOEXCEPT
5083 {
5084  S x = S (v.x * m.x[0][0] + v.y * m.x[1][0]);
5085  S y = S (v.x * m.x[0][1] + v.y * m.x[1][1]);
5086 
5087  v.x = x;
5088  v.y = y;
5089 
5090  return v;
5091 }
5092 
5093 template <class S, class T>
5095 operator* (const Vec2<S>& v, const Matrix22<T>& m) IMATH_NOEXCEPT
5096 {
5097  S x = S (v.x * m.x[0][0] + v.y * m.x[1][0]);
5098  S y = S (v.x * m.x[0][1] + v.y * m.x[1][1]);
5099 
5100  return Vec2<S> (x, y);
5101 }
5102 
5103 template <class S, class T>
5104 IMATH_HOSTDEVICE inline const Vec2<S>&
5105 operator*= (Vec2<S>& v, const Matrix33<T>& m) IMATH_NOEXCEPT
5106 {
5107  S x = S (v.x * m.x[0][0] + v.y * m.x[1][0] + m.x[2][0]);
5108  S y = S (v.x * m.x[0][1] + v.y * m.x[1][1] + m.x[2][1]);
5109  S w = S (v.x * m.x[0][2] + v.y * m.x[1][2] + m.x[2][2]);
5110 
5111  v.x = x / w;
5112  v.y = y / w;
5113 
5114  return v;
5115 }
5116 
5117 template <class S, class T>
5119 operator* (const Vec2<S>& v, const Matrix33<T>& m) IMATH_NOEXCEPT
5120 {
5121  S x = S (v.x * m.x[0][0] + v.y * m.x[1][0] + m.x[2][0]);
5122  S y = S (v.x * m.x[0][1] + v.y * m.x[1][1] + m.x[2][1]);
5123  S w = S (v.x * m.x[0][2] + v.y * m.x[1][2] + m.x[2][2]);
5124 
5125  return Vec2<S> (x / w, y / w);
5126 }
5127 
5128 template <class S, class T>
5129 IMATH_HOSTDEVICE inline const Vec3<S>&
5130 operator*= (Vec3<S>& v, const Matrix33<T>& m) IMATH_NOEXCEPT
5131 {
5132  S x = S (v.x * m.x[0][0] + v.y * m.x[1][0] + v.z * m.x[2][0]);
5133  S y = S (v.x * m.x[0][1] + v.y * m.x[1][1] + v.z * m.x[2][1]);
5134  S z = S (v.x * m.x[0][2] + v.y * m.x[1][2] + v.z * m.x[2][2]);
5135 
5136  v.x = x;
5137  v.y = y;
5138  v.z = z;
5139 
5140  return v;
5141 }
5142 
5143 template <class S, class T>
5145 operator* (const Vec3<S>& v, const Matrix33<T>& m) IMATH_NOEXCEPT
5146 {
5147  S x = S (v.x * m.x[0][0] + v.y * m.x[1][0] + v.z * m.x[2][0]);
5148  S y = S (v.x * m.x[0][1] + v.y * m.x[1][1] + v.z * m.x[2][1]);
5149  S z = S (v.x * m.x[0][2] + v.y * m.x[1][2] + v.z * m.x[2][2]);
5150 
5151  return Vec3<S> (x, y, z);
5152 }
5153 
5154 template <class S, class T>
5155 IMATH_HOSTDEVICE inline const Vec3<S>&
5156 operator*= (Vec3<S>& v, const Matrix44<T>& m) IMATH_NOEXCEPT
5157 {
5158  S x = S (v.x * m.x[0][0] + v.y * m.x[1][0] + v.z * m.x[2][0] + m.x[3][0]);
5159  S y = S (v.x * m.x[0][1] + v.y * m.x[1][1] + v.z * m.x[2][1] + m.x[3][1]);
5160  S z = S (v.x * m.x[0][2] + v.y * m.x[1][2] + v.z * m.x[2][2] + m.x[3][2]);
5161  S w = S (v.x * m.x[0][3] + v.y * m.x[1][3] + v.z * m.x[2][3] + m.x[3][3]);
5162 
5163  v.x = x / w;
5164  v.y = y / w;
5165  v.z = z / w;
5166 
5167  return v;
5168 }
5169 
5170 template <class S, class T>
5172 operator* (const Vec3<S>& v, const Matrix44<T>& m) IMATH_NOEXCEPT
5173 {
5174  S x = S (v.x * m.x[0][0] + v.y * m.x[1][0] + v.z * m.x[2][0] + m.x[3][0]);
5175  S y = S (v.x * m.x[0][1] + v.y * m.x[1][1] + v.z * m.x[2][1] + m.x[3][1]);
5176  S z = S (v.x * m.x[0][2] + v.y * m.x[1][2] + v.z * m.x[2][2] + m.x[3][2]);
5177  S w = S (v.x * m.x[0][3] + v.y * m.x[1][3] + v.z * m.x[2][3] + m.x[3][3]);
5178 
5179  return Vec3<S> (x / w, y / w, z / w);
5180 }
5181 
5182 template <class S, class T>
5183 IMATH_HOSTDEVICE inline const Vec4<S>&
5184 operator*= (Vec4<S>& v, const Matrix44<T>& m) IMATH_NOEXCEPT
5185 {
5186  S x = S (
5187  v.x * m.x[0][0] + v.y * m.x[1][0] + v.z * m.x[2][0] + v.w * m.x[3][0]);
5188  S y = S (
5189  v.x * m.x[0][1] + v.y * m.x[1][1] + v.z * m.x[2][1] + v.w * m.x[3][1]);
5190  S z = S (
5191  v.x * m.x[0][2] + v.y * m.x[1][2] + v.z * m.x[2][2] + v.w * m.x[3][2]);
5192  S w = S (
5193  v.x * m.x[0][3] + v.y * m.x[1][3] + v.z * m.x[2][3] + v.w * m.x[3][3]);
5194 
5195  v.x = x;
5196  v.y = y;
5197  v.z = z;
5198  v.w = w;
5199 
5200  return v;
5201 }
5202 
5203 template <class S, class T>
5205 operator* (const Vec4<S>& v, const Matrix44<T>& m) IMATH_NOEXCEPT
5206 {
5207  S x = S (
5208  v.x * m.x[0][0] + v.y * m.x[1][0] + v.z * m.x[2][0] + v.w * m.x[3][0]);
5209  S y = S (
5210  v.x * m.x[0][1] + v.y * m.x[1][1] + v.z * m.x[2][1] + v.w * m.x[3][1]);
5211  S z = S (
5212  v.x * m.x[0][2] + v.y * m.x[1][2] + v.z * m.x[2][2] + v.w * m.x[3][2]);
5213  S w = S (
5214  v.x * m.x[0][3] + v.y * m.x[1][3] + v.z * m.x[2][3] + v.w * m.x[3][3]);
5215 
5216  return Vec4<S> (x, y, z, w);
5217 }
5218 
5219 IMATH_INTERNAL_NAMESPACE_HEADER_EXIT
5220 
5221 #endif // INCLUDED_IMATHMATRIX_H
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix33 & setTheMatrix(const Matrix33< S > &v) IMATH_NOEXCEPT
Set the value.
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 bool equalWithAbsError(T x1, T x2, T e) IMATH_NOEXCEPT
Definition: ImathMath.h:151
IMATH_HOSTDEVICE Matrix44(const M &m)
Definition: ImathMatrix.h:916
Matrix33 operator+() const
Unary plus of a matrix.
Definition: Types.h:564
Definition: format.h:3268
Mat3< typename promote< S, T >::type > operator*(S scalar, const Mat3< T > &m)
Multiply each element of the given matrix by scalar and return the result.
Definition: Mat3.h:561
IMATH_HOSTDEVICE constexpr Vec2< T > translation() const IMATH_NOEXCEPT
Return the translation component.
Definition: ImathMatrix.h:3227
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44 & gjInvert() IMATH_NOEXCEPT
Definition: ImathMatrix.h:4200
IMATH_HOSTDEVICE static constexpr unsigned int dimensions() IMATH_NOEXCEPT
Return the number of the row and column dimensions, i.e. 4.
Definition: ImathMatrix.h:1296
IMATH_INTERNAL_NAMESPACE_HEADER_ENTER enum IMATH_EXPORT_ENUM Uninitialized
Definition: ImathMatrix.h:36
IMATH_HOSTDEVICE constexpr Matrix22 operator*(T a) const IMATH_NOEXCEPT
Component-wise multiplication.
Definition: ImathMatrix.h:1723
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 bool equalWithAbsError(const Matrix44< T > &v, T e) const IMATH_NOEXCEPT
Definition: ImathMatrix.h:3691
Matrix44< float > M44f
4x4 matrix of float
Definition: ImathMatrix.h:1401
IMATH_HOSTDEVICE constexpr bool operator==(const Matrix33 &v) const IMATH_NOEXCEPT
Equality.
Definition: ImathMatrix.h:2243
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33 & transpose() IMATH_NOEXCEPT
Transpose.
Definition: ImathMatrix.h:2592
#define IMATH_NOEXCEPT
Definition: ImathConfig.h:78
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44 & operator-=(const Matrix44 &v) IMATH_NOEXCEPT
Component-wise subtraction.
Definition: ImathMatrix.h:3788
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 bool equalWithAbsError(const Matrix22< T > &v, T e) const IMATH_NOEXCEPT
Definition: ImathMatrix.h:1596
Definition: ImathVec.h:40
IMATH_HOSTDEVICE constexpr bool operator!=(const Matrix33 &v) const IMATH_NOEXCEPT
Inequality.
Definition: ImathMatrix.h:2253
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix22 & invert() IMATH_NOEXCEPT
Definition: ImathMatrix.h:1825
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44 & operator+=(const Matrix44 &v) IMATH_NOEXCEPT
Component-wise addition.
Definition: ImathMatrix.h:3717
*get result *(waiting if necessary)*A common idiom is to fire a bunch of sub tasks at the and then *wait for them to all complete We provide a helper class
Definition: thread.h:632
IMATH_HOSTDEVICE constexpr Matrix44 operator/(T a) const IMATH_NOEXCEPT
Component-wise division.
Definition: ImathMatrix.h:4121
static IMATH_HOSTDEVICE void multiply(const Matrix44 &a, const Matrix44 &b, Matrix44 &c) IMATH_NOEXCEPT
Matrix-matrix multiplication: compute c = a * b.
Definition: ImathMatrix.h:4054
SIM_API const UT_StringHolder angle
MatType shear(Axis axis0, Axis axis1, typename MatType::value_type shear)
Set the matrix to a shear along axis0 by a fraction of axis1.
Definition: Mat.h:688
GLboolean invert
Definition: glcorearb.h:549
IMATH_HOSTDEVICE constexpr Matrix33 operator-() const IMATH_NOEXCEPT
Component-wise multiplication by -1.
Definition: ImathMatrix.h:2389
IMATH_HOSTDEVICE constexpr Matrix33 operator*(T a) const IMATH_NOEXCEPT
Component-wise multiplication.
Definition: ImathMatrix.h:2439
IMATH_HOSTDEVICE constexpr Matrix44(Uninitialized) IMATH_NOEXCEPT
Uninitialized.
Definition: ImathMatrix.h:823
const GLdouble * v
Definition: glcorearb.h:837
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44 & setShear(const Vec3< S > &h) IMATH_NOEXCEPT
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 bool equalWithRelError(T x1, T x2, T e) IMATH_NOEXCEPT
Definition: ImathMath.h:164
Vec2< T > BaseVecType
The base vector type.
Definition: ImathMatrix.h:366
IMATH_HOSTDEVICE constexpr T fastMinor(const int r0, const int r1, const int r2, const int c0, const int c1, const int c2) const IMATH_NOEXCEPT
Build a minor using the specified rows and columns.
Definition: ImathMatrix.h:4562
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44 & operator*=(T a) IMATH_NOEXCEPT
Component-wise multiplication.
Definition: ImathMatrix.h:3906
GLsizei const GLfloat * value
Definition: glcorearb.h:824
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix22 & setValue(const Matrix22< S > &v) IMATH_NOEXCEPT
Set the value.
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 T minorOf(const int r, const int c) const IMATH_NOEXCEPT
Calculate the matrix minor of the (r,c) element.
Definition: ImathMatrix.h:3074
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix44 & setTheMatrix(const Matrix44< S > &v) IMATH_NOEXCEPT
Set the value.
GLdouble GLdouble GLdouble z
Definition: glcorearb.h:848
GLboolean GLboolean g
Definition: glcorearb.h:1222
IMATH_HOSTDEVICE constexpr bool operator==(const Matrix22 &v) const IMATH_NOEXCEPT
Equality.
Definition: ImathMatrix.h:1580
IMATH_HOSTDEVICE const Matrix33 & gjInvert() IMATH_NOEXCEPT
Definition: ImathMatrix.h:2634
T x[2][2]
Matrix elements.
Definition: ImathMatrix.h:52
GLboolean GLboolean GLboolean GLboolean a
Definition: glcorearb.h:1222
GLdouble s
Definition: glad.h:3009
IMATH_HOSTDEVICE T * operator[](int i) IMATH_NOEXCEPT
Row access.
Definition: ImathMatrix.h:1412
Matrix22< double > M22d
2x2 matrix of double
Definition: ImathMatrix.h:1392
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix22< T > inverse() const IMATH_NOEXCEPT
Return the inverse, leaving this unmodified.
Definition: ImathMatrix.h:1877
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix22 & operator*=(T a) IMATH_NOEXCEPT
Component-wise multiplication.
Definition: ImathMatrix.h:1711
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
GLint y
Definition: glcorearb.h:103
IMATH_HOSTDEVICE void multVecMatrix(const Vec2< S > &src, Vec2< S > &dst) const IMATH_NOEXCEPT
Definition: ImathMatrix.h:2529
IMATH_HOSTDEVICE static constexpr unsigned int dimensions() IMATH_NOEXCEPT
Return the number of the row and column dimensions, i.e. 2.
Definition: ImathMatrix.h:356
T x[4][4]
Matrix elements.
Definition: ImathMatrix.h:809
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix33() IMATH_NOEXCEPT
Definition: ImathMatrix.h:2029
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix22 & rotate(S r) IMATH_NOEXCEPT
IMATH_HOSTDEVICE static constexpr unsigned int dimensions() IMATH_NOEXCEPT
Return the number of the row and column dimensions, i.e. 3.
Definition: ImathMatrix.h:784
IMATH_HOSTDEVICE T * operator[](int i) IMATH_NOEXCEPT
Row access.
Definition: ImathMatrix.h:2015
#define IMATH_HOSTDEVICE
Definition: ImathConfig.h:108
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33 & shear(const S &xy) IMATH_NOEXCEPT
IMATH_HOSTDEVICE constexpr const Vec3< T > translation() const IMATH_NOEXCEPT
Return translation component.
Definition: ImathMatrix.h:4855
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 bool equalWithRelError(const Matrix44< T > &v, T e) const IMATH_NOEXCEPT
Definition: ImathMatrix.h:3704
Matrix33< float > M33f
3x3 matrix of float
Definition: ImathMatrix.h:1395
T BaseType
The base type: In templates that accept a parameter V (could be a Color4), you can refer to T as V::B...
Definition: ImathMatrix.h:1302
IMATH_HOSTDEVICE constexpr T trace() const IMATH_NOEXCEPT
Trace.
Definition: ImathMatrix.h:3103
Matrix44< double > M44d
4x4 matrix of double
Definition: ImathMatrix.h:1404
IMATH_HOSTDEVICE static constexpr T baseTypeMax() IMATH_NOEXCEPT
Largest possible positive value.
Definition: ImathMatrix.h:336
__hostdev__ float getValue(uint32_t i) const
Definition: NanoVDB.h:5578
Matrix33< double > M33d
3x3 matrix of double
Definition: ImathMatrix.h:1398
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 bool equalWithAbsError(const Matrix33< T > &v, T e) const IMATH_NOEXCEPT
Definition: ImathMatrix.h:2263
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33 & operator*=(T a) IMATH_NOEXCEPT
Component-wise multiplication.
Definition: ImathMatrix.h:2422
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44 & invert() IMATH_NOEXCEPT
Definition: ImathMatrix.h:4408
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix22 & setTheMatrix(const Matrix22< S > &v) IMATH_NOEXCEPT
Set the value.
IMATH_HOSTDEVICE Matrix44< T > gjInverse() const IMATH_NOEXCEPT
Definition: ImathMatrix.h:4310
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix22 & operator+=(const Matrix22 &v) IMATH_NOEXCEPT
Component-wise addition.
Definition: ImathMatrix.h:1622
FMT_CONSTEXPR uint64_t multiply(uint64_t lhs, uint64_t rhs)
Definition: format.h:1718
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix44< T > inverse() const IMATH_NOEXCEPT
Return the inverse using the determinant, leaving this unmodified.
Definition: ImathMatrix.h:4491
IMATH_HOSTDEVICE const Matrix22 & setRotation(S r) IMATH_NOEXCEPT
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33 & setScale(T s) IMATH_NOEXCEPT
Definition: ImathMatrix.h:3144
GLsizei GLboolean transpose
Definition: glcorearb.h:832
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix22 & setScale(T s) IMATH_NOEXCEPT
Definition: ImathMatrix.h:1960
IMATH_HOSTDEVICE void multVecMatrix(const Vec3< S > &src, Vec3< S > &dst) const IMATH_NOEXCEPT
Definition: ImathMatrix.h:4063
GA_API const UT_StringHolder scale
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 bool equalWithRelError(const Matrix33< T > &v, T e) const IMATH_NOEXCEPT
Definition: ImathMatrix.h:2276
GLdouble n
Definition: glcorearb.h:2008
GLfloat f
Definition: glcorearb.h:1926
IMATH_HOSTDEVICE constexpr Matrix22 transposed() const IMATH_NOEXCEPT
Return the transpose.
Definition: ImathMatrix.h:1810
IMATH_HOSTDEVICE constexpr T determinant() const IMATH_NOEXCEPT
Determinant.
Definition: ImathMatrix.h:3094
IMATH_HOSTDEVICE constexpr T fastMinor(const int r0, const int r1, const int c0, const int c1) const IMATH_NOEXCEPT
Build a minor using the specified rows and columns.
Definition: ImathMatrix.h:3086
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33 & operator-=(const Matrix33 &v) IMATH_NOEXCEPT
Component-wise subtraction.
Definition: ImathMatrix.h:2339
Vec3< T > & operator*=(Vec3< T > &_v, const Mat3< MT > &_m)
Multiply _v by _m and replace _v with the resulting vector.
Definition: Mat3.h:633
IMATH_HOSTDEVICE constexpr bool operator==(const Matrix44 &v) const IMATH_NOEXCEPT
Equality.
Definition: ImathMatrix.h:3663
IMATH_HOSTDEVICE constexpr Matrix33 operator/(T a) const IMATH_NOEXCEPT
Component-wise division.
Definition: ImathMatrix.h:2576
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44 & shear(const Vec3< S > &h) IMATH_NOEXCEPT
IMATH_HOSTDEVICE constexpr bool operator!=(const Matrix22 &v) const IMATH_NOEXCEPT
Inequality.
Definition: ImathMatrix.h:1588
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33 & invert() IMATH_NOEXCEPT
Definition: ImathMatrix.h:2842
IMATH_HOSTDEVICE T * operator[](int i) IMATH_NOEXCEPT
Row access.
Definition: ImathMatrix.h:3326
IMATH_HOSTDEVICE void makeIdentity() IMATH_NOEXCEPT
Set to the identity.
Definition: ImathMatrix.h:1570
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix44() IMATH_NOEXCEPT
Definition: ImathMatrix.h:3340
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44 & transpose() IMATH_NOEXCEPT
Transpose.
Definition: ImathMatrix.h:4144
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix22 & transpose() IMATH_NOEXCEPT
Transpose.
Definition: ImathMatrix.h:1801
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33 & setTranslation(const Vec2< S > &t) IMATH_NOEXCEPT
IMATH_HOSTDEVICE static constexpr T baseTypeSmallest() IMATH_NOEXCEPT
Smallest possible positive value.
Definition: ImathMatrix.h:342
IMATH_HOSTDEVICE constexpr Matrix22 operator/(T a) const IMATH_NOEXCEPT
Component-wise division.
Definition: ImathMatrix.h:1794
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix33 & setValue(const Matrix33< S > &v) IMATH_NOEXCEPT
Set the value.
IMATH_HOSTDEVICE constexpr T determinant() const IMATH_NOEXCEPT
Determinant.
Definition: ImathMatrix.h:1918
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33 & translate(const Vec2< S > &t) IMATH_NOEXCEPT
IMATH_HOSTDEVICE static constexpr T baseTypeEpsilon() IMATH_NOEXCEPT
Smallest possible e for which 1+e != 1.
Definition: ImathMatrix.h:1288
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix44 & setValue(const Matrix44< S > &v) IMATH_NOEXCEPT
Set the value.
#define IMATH_EXPORT_ENUM
Definition: ImathExport.h:60
IMATH_HOSTDEVICE Matrix33< T > gjInverse() const IMATH_NOEXCEPT
Definition: ImathMatrix.h:2744
png_const_structrp png_const_inforp int * unit
Definition: png.h:2161
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix22 & negate() IMATH_NOEXCEPT
Component-wise multiplication by -1.
Definition: ImathMatrix.h:1699
T BaseType
The base type: In templates that accept a parameter V (could be a Color4), you can refer to T as V::B...
Definition: ImathMatrix.h:790
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33 & setShear(const S &h) IMATH_NOEXCEPT
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44 & translate(const Vec3< S > &t) IMATH_NOEXCEPT
IMATH_HOSTDEVICE T * getValue() IMATH_NOEXCEPT
Return a raw pointer to the array of values.
Definition: ImathMatrix.h:3556
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
IMATH_HOSTDEVICE static constexpr T baseTypeEpsilon() IMATH_NOEXCEPT
Smallest possible e for which 1+e != 1.
Definition: ImathMatrix.h:348
GLint GLenum GLint x
Definition: glcorearb.h:409
#define IMATH_ENABLE_IF(...)
ImageBuf OIIO_API rotate(const ImageBuf &src, float angle, string_view filtername=string_view(), float filterwidth=0.0f, bool recompute_roi=false, ROI roi={}, int nthreads=0)
IMATH_HOSTDEVICE constexpr bool operator!=(const Matrix44 &v) const IMATH_NOEXCEPT
Inequality.
Definition: ImathMatrix.h:3677
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 bool equalWithRelError(const Matrix22< T > &v, T e) const IMATH_NOEXCEPT
Definition: ImathMatrix.h:1609
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44 & negate() IMATH_NOEXCEPT
Component-wise multiplication by -1.
Definition: ImathMatrix.h:3882
GLdouble t
Definition: glad.h:2397
IMATH_HOSTDEVICE constexpr Matrix22 operator+(const Matrix22 &v) const IMATH_NOEXCEPT
Component-wise addition.
Definition: ImathMatrix.h:1646
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix22 & scale(const Vec2< S > &s) IMATH_NOEXCEPT
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44 & scale(const Vec3< S > &s) IMATH_NOEXCEPT
IMATH_HOSTDEVICE constexpr Matrix33 transposed() const IMATH_NOEXCEPT
Return the transpose.
Definition: ImathMatrix.h:2610
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44 & setTranslation(const Vec3< S > &t) IMATH_NOEXCEPT
IMATH_HOSTDEVICE void makeIdentity() IMATH_NOEXCEPT
Set to the identity matrix.
Definition: ImathMatrix.h:2228
GLint j
Definition: glad.h:2733
Vec3< T > BaseVecType
The base vector type.
Definition: ImathMatrix.h:793
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
GLenum GLenum dst
Definition: glcorearb.h:1793
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 T determinant() const IMATH_NOEXCEPT
Determinant.
Definition: ImathMatrix.h:4602
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33 & operator=(const Matrix33 &v) IMATH_NOEXCEPT
Assignment operator.
Definition: ImathMatrix.h:2128
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33 & operator+=(const Matrix33 &v) IMATH_NOEXCEPT
Component-wise addition.
Definition: ImathMatrix.h:2289
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix22 & operator=(const Matrix22 &v) IMATH_NOEXCEPT
Assignment.
Definition: ImathMatrix.h:1495
IMATH_HOSTDEVICE static constexpr T baseTypeEpsilon() IMATH_NOEXCEPT
Smallest possible e for which 1+e != 1.
Definition: ImathMatrix.h:776
Matrix22< float > M22f
2x2 matrix of float
Definition: ImathMatrix.h:1389
IMATH_HOSTDEVICE constexpr Matrix44 operator-() const IMATH_NOEXCEPT
Component-wise multiplication by -1.
Definition: ImathMatrix.h:3859
IMATH_HOSTDEVICE constexpr Matrix44 transposed() const IMATH_NOEXCEPT
Return the transpose.
Definition: ImathMatrix.h:4169
Definition: ImathVec.h:39
IMATH_HOSTDEVICE Matrix22(const M &m)
Definition: ImathMatrix.h:132
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33 & scale(const Vec2< S > &s) IMATH_NOEXCEPT
IMATH_HOSTDEVICE Matrix33(Uninitialized) IMATH_NOEXCEPT
Uninitialized.
Definition: ImathMatrix.h:394
IMATH_HOSTDEVICE Matrix22(Uninitialized) IMATH_NOEXCEPT
Uninitialized.
Definition: ImathMatrix.h:66
IMATH_HOSTDEVICE static constexpr T baseTypeMax() IMATH_NOEXCEPT
Largest possible positive value.
Definition: ImathMatrix.h:1276
LeafData & operator=(const LeafData &)=delete
IMATH_HOSTDEVICE Matrix33(const M &m)
Definition: ImathMatrix.h:460
#define IMATH_EXPORT_TEMPLATE_TYPE
Definition: ImathExport.h:61
IMATH_HOSTDEVICE void multDirMatrix(const Vec2< S > &src, Vec2< S > &dst) const IMATH_NOEXCEPT
Definition: ImathMatrix.h:1768
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33 & operator/=(T a) IMATH_NOEXCEPT
Component-wise division.
Definition: ImathMatrix.h:2559
IMATH_HOSTDEVICE const Matrix44 & rotate(const Vec3< S > &r) IMATH_NOEXCEPT
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
GA_API const UT_StringHolder pivot
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44 & setAxisAngle(const Vec3< S > &ax, S ang) IMATH_NOEXCEPT
IMATH_HOSTDEVICE constexpr T trace() const IMATH_NOEXCEPT
Trace.
Definition: ImathMatrix.h:4616
Vec4< T > BaseVecType
The base vector type.
Definition: ImathMatrix.h:1305
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33 & rotate(S r) IMATH_NOEXCEPT
GLint GLsizei width
Definition: glcorearb.h:103
IMATH_HOSTDEVICE T * getValue() IMATH_NOEXCEPT
Return a raw pointer to the array of values.
Definition: ImathMatrix.h:2164
IMATH_HOSTDEVICE constexpr T trace() const IMATH_NOEXCEPT
Trace.
Definition: ImathMatrix.h:1925
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44 & setScale(T s) IMATH_NOEXCEPT
Definition: ImathMatrix.h:4741
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 T minorOf(const int r, const int c) const IMATH_NOEXCEPT
Calculate the matrix minor of the (r,c) element.
Definition: ImathMatrix.h:4577
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
IMATH_INTERNAL_NAMESPACE_HEADER_ENTER IMATH_HOSTDEVICE constexpr T abs(T a) IMATH_NOEXCEPT
Definition: ImathFun.h:26
IMATH_HOSTDEVICE const Matrix44 & setEulerAngles(const Vec3< S > &r) IMATH_NOEXCEPT
IMATH_HOSTDEVICE static constexpr T baseTypeSmallest() IMATH_NOEXCEPT
Smallest possible positive value.
Definition: ImathMatrix.h:770
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44 & operator/=(T a) IMATH_NOEXCEPT
Component-wise division.
Definition: ImathMatrix.h:4097
IMATH_HOSTDEVICE void multDirMatrix(const Vec2< S > &src, Vec2< S > &dst) const IMATH_NOEXCEPT
Definition: ImathMatrix.h:2545
T x[3][3]
Matrix elements.
Definition: ImathMatrix.h:380
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix33 & negate() IMATH_NOEXCEPT
Component-wise multiplication by -1.
Definition: ImathMatrix.h:2405
GLboolean r
Definition: glcorearb.h:1222
PUGI__FN char_t * translate(char_t *buffer, const char_t *from, const char_t *to, size_t to_length)
Definition: pugixml.cpp:8574
IMATH_HOSTDEVICE T * getValue() IMATH_NOEXCEPT
Return a raw pointer to the array of values.
Definition: ImathMatrix.h:1521
Definition: ImathVec.h:41
IMATH_HOSTDEVICE static constexpr T baseTypeSmallest() IMATH_NOEXCEPT
Smallest possible positive value.
Definition: ImathMatrix.h:1282
IMATH_HOSTDEVICE constexpr Matrix22 operator-() const IMATH_NOEXCEPT
Component-wise multiplication by -1.
Definition: ImathMatrix.h:1692
IMATH_HOSTDEVICE constexpr Matrix44 operator*(T a) const IMATH_NOEXCEPT
Component-wise multiplication.
Definition: ImathMatrix.h:3930
IMATH_HOSTDEVICE const Matrix33 & setRotation(S r) IMATH_NOEXCEPT
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix22 & operator/=(T a) IMATH_NOEXCEPT
Component-wise division.
Definition: ImathMatrix.h:1782
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix22 & operator-=(const Matrix22 &v) IMATH_NOEXCEPT
Component-wise subtraction.
Definition: ImathMatrix.h:1657
IMATH_HOSTDEVICE void makeIdentity() IMATH_NOEXCEPT
Set to the identity matrix.
Definition: ImathMatrix.h:3641
IMATH_HOSTDEVICE void multDirMatrix(const Vec3< S > &src, Vec3< S > &dst) const IMATH_NOEXCEPT
Definition: ImathMatrix.h:4081
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix22() IMATH_NOEXCEPT
Definition: ImathMatrix.h:1426
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 Matrix33< T > inverse() const IMATH_NOEXCEPT
Return the inverse using the determinant, leaving this unmodified.
Definition: ImathMatrix.h:2965
GLenum src
Definition: glcorearb.h:1793
IMATH_HOSTDEVICE static constexpr T baseTypeMax() IMATH_NOEXCEPT
Largest possible positive value.
Definition: ImathMatrix.h:764
IMATH_HOSTDEVICE IMATH_CONSTEXPR14 const Matrix44 & operator=(const Matrix44 &v) IMATH_NOEXCEPT
Assignment operator.
Definition: ImathMatrix.h:3510