HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_Matrix2T< T > Class Template Reference

#include <UT_Matrix2.h>

Public Types

typedef T value_type
 

Public Member Functions

SYS_FORCE_INLINE UT_Matrix2T ()=default
 Construct uninitialized matrix. More...
 
constexpr UT_Matrix2T (const UT_Matrix2T &)=default
 Default copy constructor. More...
 
constexpr UT_Matrix2T (UT_Matrix2T &&)=default
 Default move constructor. More...
 
constexpr UT_Matrix2T (T val) noexcept
 Construct identity matrix, multipled by scalar. More...
 
 T (0)
 
UT_Matrix2T< T > & operator= (UT_Matrix2T< T > &&m)=default
 Default move assignment operator. More...
 
template<typename S >
UT_Matrix2T< T > & operator= (const UT_Matrix3T< S > &m)
 
UT_Matrix2T< Toperator- () const
 
UT_Matrix2T< T > & operator+= (const UT_Matrix2T< T > &m)
 
UT_Matrix2T< T > & operator-= (const UT_Matrix2T< T > &m)
 
UT_Matrix2T< T > & operator*= (const UT_Matrix2T< T > &m)
 
constexpr bool operator== (const UT_Matrix2T< T > &m) const noexcept
 
constexpr bool operator!= (const UT_Matrix2T< T > &m) const noexcept
 
UT_Matrix2T< T > & operator= (T val)
 
UT_Matrix2T< T > & operator+= (T scalar)
 
UT_Matrix2T< T > & operator-= (T scalar)
 
UT_Matrix2T< T > & operator*= (T scalar)
 
UT_Matrix2T< T > & operator/= (T scalar)
 
template<typename S >
UT_Matrix2T< T > & operator= (const UT_Vector2T< S > &vec)
 
template<typename S >
UT_Matrix2T< T > & operator+= (const UT_Vector2T< S > &vec)
 
template<typename S >
UT_Matrix2T< T > & operator-= (const UT_Vector2T< S > &vec)
 
constexpr T determinant () const noexcept
 
constexpr T trace () const noexcept
 
template<typename S >
int eigenvalues (UT_Vector2T< S > &r, UT_Vector2T< S > &i) const
 Returns eigenvalues of this matrix. More...
 
int invert ()
 
int invert (UT_Matrix2T< T > &m) const
 
T tolerance () const
 Returns the tolerance of our class. More...
 
template<typename S >
int solve (const UT_Vector2T< S > &b, UT_Vector2T< S > &x) const
 
template<typename S >
int solveTranspose (const UT_Vector2T< S > &b, UT_Vector2T< S > &x) const
 
void diagonalizeSymmetric (UT_Matrix2T< T > &R, UT_Matrix2T< T > &D, T tol=1e-6f) const
 
void svdDecomposition (UT_Matrix2T< T > &U, UT_Matrix2T< T > &S, UT_Matrix2T< T > &V, T tol=1e-6f) const
 
bool isSymmetric (T tolerance=T(SYS_FTOLERANCE)) const
 Check if symmetric up to a tolerance level to 0. More...
 
void transpose ()
 
UT_Matrix2T< Ttranspose () const
 
bool isEqual (const UT_Matrix2T< T > &m, T tolerance=T(SYS_FTOLERANCE)) const
 
template<typename S >
void outerproductUpdate (T b, const UT_Vector2T< S > &v1, const UT_Vector2T< S > &v2)
 
void identity ()
 Set the matrix to identity. More...
 
void zero ()
 Set the matrix to zero. More...
 
bool isIdentity () const
 
bool isZero () const
 
void rotate (T theta)
 Rotate by theta radians. More...
 
void initialize ()
 Initialize this matrix to zero. More...
 
unsigned hash () const
 Compute a hash. More...
 
T dot (const UT_Matrix2T< T > &m) const
 
T getEuclideanNorm () const
 
T getEuclideanNorm2 () const
 Euclidean norm squared. More...
 
T getNorm1 () const
 
T getNormInf () const
 
T getNormMax () const
 
T getNormSpectral () const
 
int save (std::ostream &os, int binary) const
 
bool load (UT_IStream &is)
 
void outAsciiNoName (std::ostream &os) const
 
template<>
float tolerance () const
 
template<>
int32 tolerance () const
 
template<>
int64 tolerance () const
 
constexpr UT_Matrix2T (const fpreal32 m[2][2]) noexcept
 
void scale (T sx, T sy)
 
void scale (const UT_Vector2T< T > &s)
 
SYS_FORCE_INLINE Toperator() (unsigned row, unsigned col) noexcept
 Return a matrix entry. No bounds checking on subscripts. More...
 
SYS_FORCE_INLINE T operator() (unsigned row, unsigned col) const noexcept
 Return a matrix entry. No bounds checking on subscripts. More...
 
const Tdata () const
 Return the raw matrix data. More...
 
Tdata ()
 Return the raw matrix data. More...
 
Toperator() (unsigned row)
 Return a matrix row. No bounds checking on subscript. More...
 
const Toperator() (unsigned row) const
 Return a matrix row. No bounds checking on subscript. More...
 
const UT_Vector2T< T > & operator[] (unsigned row) const
 Return a matrix row. No bounds checking on subscript. More...
 
UT_Vector2T< T > & operator[] (unsigned row)
 Return a matrix row. No bounds checking on subscript. More...
 
bool save (UT_JSONWriter &w) const
 
bool save (UT_JSONValue &v) const
 
bool load (UT_JSONParser &p)
 

Static Public Member Functions

static UT_Matrix2T< TrotationMat (T theta)
 Create a rotation matrix for the given angle in radians. More...
 
static int entries ()
 Returns the vector size. More...
 

Public Attributes

 val
 
T matx [2][2]
 
T myFloats [tuple_size]
 

Static Public Attributes

static constexpr int tuple_size = 4
 

Friends

std::ostream & operator<< (std::ostream &os, const UT_Matrix2T< T > &v)
 

Detailed Description

template<typename T>
class UT_Matrix2T< T >

This class implements a 2x2 matrix in row-major order.

Most of Houdini operates with row vectors that are left-multiplied with matrices. e.g., z = v * M

Definition at line 89 of file UT_Matrix2.h.

Member Typedef Documentation

template<typename T>
typedef T UT_Matrix2T< T >::value_type

Definition at line 93 of file UT_Matrix2.h.

Constructor & Destructor Documentation

template<typename T>
SYS_FORCE_INLINE UT_Matrix2T< T >::UT_Matrix2T ( )
default

Construct uninitialized matrix.

template<typename T>
constexpr UT_Matrix2T< T >::UT_Matrix2T ( const UT_Matrix2T< T > &  )
default

Default copy constructor.

template<typename T>
constexpr UT_Matrix2T< T >::UT_Matrix2T ( UT_Matrix2T< T > &&  )
default

Default move constructor.

template<typename T>
constexpr UT_Matrix2T< T >::UT_Matrix2T ( T  val)
inlineexplicitnoexcept

Construct identity matrix, multipled by scalar.

Definition at line 106 of file UT_Matrix2.h.

template<typename T>
constexpr UT_Matrix2T< T >::UT_Matrix2T ( const fpreal32  m[2][2])
inlineexplicitnoexcept

Construct a deep copy of the input row-major data.

Definition at line 113 of file UT_Matrix2.h.

Member Function Documentation

template<typename T>
const T* UT_Matrix2T< T >::data ( ) const
inline

Return the raw matrix data.

Definition at line 442 of file UT_Matrix2.h.

template<typename T>
T* UT_Matrix2T< T >::data ( )
inline

Return the raw matrix data.

Definition at line 443 of file UT_Matrix2.h.

template<typename T>
constexpr T UT_Matrix2T< T >::determinant ( ) const
inlinenoexcept

Definition at line 220 of file UT_Matrix2.h.

template<typename T>
void UT_Matrix2T< T >::diagonalizeSymmetric ( UT_Matrix2T< T > &  R,
UT_Matrix2T< T > &  D,
T  tol = 1e-6f 
) const
template<typename T>
T UT_Matrix2T< T >::dot ( const UT_Matrix2T< T > &  m) const

Dot product with another matrix Does dot(a,b) = sum_ij a_ij * b_ij

template<typename T>
template<typename S >
int UT_Matrix2T< T >::eigenvalues ( UT_Vector2T< S > &  r,
UT_Vector2T< S > &  i 
) const

Returns eigenvalues of this matrix.

template<typename T>
static int UT_Matrix2T< T >::entries ( )
inlinestatic

Returns the vector size.

Definition at line 517 of file UT_Matrix2.h.

template<typename T>
T UT_Matrix2T< T >::getEuclideanNorm ( ) const
inline

Euclidean or Frobenius norm of a matrix. Does sqrt(sum(a_ij ^2))

Definition at line 473 of file UT_Matrix2.h.

template<typename T>
T UT_Matrix2T< T >::getEuclideanNorm2 ( ) const

Euclidean norm squared.

template<typename T>
T UT_Matrix2T< T >::getNorm1 ( ) const

Get the 1-norm of this matrix, assuming a row vector convention. Returns the maximum absolute row sum. ie. max_i(sum_j(abs(a_ij)))

template<typename T>
T UT_Matrix2T< T >::getNormInf ( ) const

Get the inf-norm of this matrix, assuming a row vector convention. Returns the maximum absolute column sum. ie. max_j(sum_i(abs(a_ij)))

template<typename T>
T UT_Matrix2T< T >::getNormMax ( ) const

Get the max-norm of this matrix Returns the maximum absolute entry. ie. max_j(max_i(abs(a_ij)))

template<typename T>
T UT_Matrix2T< T >::getNormSpectral ( ) const

Get the spectral norm of this matrix Returns the maximum singular value.

template<typename T>
unsigned UT_Matrix2T< T >::hash ( void  ) const
inline

Compute a hash.

Definition at line 447 of file UT_Matrix2.h.

template<typename T>
void UT_Matrix2T< T >::identity ( )
inline

Set the matrix to identity.

Definition at line 378 of file UT_Matrix2.h.

template<typename T>
void UT_Matrix2T< T >::initialize ( )
inline

Initialize this matrix to zero.

Definition at line 420 of file UT_Matrix2.h.

template<typename T>
int UT_Matrix2T< T >::invert ( )
inline

Invert this matrix and return 0 if OK, 1 if singular. If singular, the matrix will be unchanged.

Definition at line 233 of file UT_Matrix2.h.

template<typename T>
int UT_Matrix2T< T >::invert ( UT_Matrix2T< T > &  m) const
inline

Invert the matrix and return 0 if OK, 1 if singular. Puts the inverted matrix in m, and leaves this matrix unchanged. If singular, the matrix will be unchanged.

Definition at line 243 of file UT_Matrix2.h.

template<typename T>
bool UT_Matrix2T< T >::isEqual ( const UT_Matrix2T< T > &  m,
T  tolerance = T(SYS_FTOLERANCE) 
) const
inline

Definition at line 352 of file UT_Matrix2.h.

template<typename T>
bool UT_Matrix2T< T >::isIdentity ( ) const
inline

Definition at line 386 of file UT_Matrix2.h.

template<typename T>
bool UT_Matrix2T< T >::isSymmetric ( T  tolerance = T(SYS_FTOLERANCE)) const
inline

Check if symmetric up to a tolerance level to 0.

Definition at line 338 of file UT_Matrix2.h.

template<typename T>
bool UT_Matrix2T< T >::isZero ( ) const
inline

Definition at line 393 of file UT_Matrix2.h.

template<typename T>
bool UT_Matrix2T< T >::load ( UT_IStream is)
template<typename T>
bool UT_Matrix2T< T >::load ( UT_JSONParser p)

Methods to serialize to a JSON stream. The matrix is stored as an array of 4 reals.

template<typename T>
constexpr bool UT_Matrix2T< T >::operator!= ( const UT_Matrix2T< T > &  m) const
inlinenoexcept

Definition at line 177 of file UT_Matrix2.h.

template<typename T>
SYS_FORCE_INLINE T& UT_Matrix2T< T >::operator() ( unsigned  row,
unsigned  col 
)
inlinenoexcept

Return a matrix entry. No bounds checking on subscripts.

Definition at line 428 of file UT_Matrix2.h.

template<typename T>
SYS_FORCE_INLINE T UT_Matrix2T< T >::operator() ( unsigned  row,
unsigned  col 
) const
inlinenoexcept

Return a matrix entry. No bounds checking on subscripts.

Definition at line 433 of file UT_Matrix2.h.

template<typename T>
T* UT_Matrix2T< T >::operator() ( unsigned  row)
inline

Return a matrix row. No bounds checking on subscript.

Definition at line 451 of file UT_Matrix2.h.

template<typename T>
const T* UT_Matrix2T< T >::operator() ( unsigned  row) const
inline

Return a matrix row. No bounds checking on subscript.

Definition at line 456 of file UT_Matrix2.h.

template<typename T>
UT_Matrix2T<T>& UT_Matrix2T< T >::operator*= ( const UT_Matrix2T< T > &  m)
template<typename T>
UT_Matrix2T<T>& UT_Matrix2T< T >::operator*= ( T  scalar)
inline

Definition at line 198 of file UT_Matrix2.h.

template<typename T>
UT_Matrix2T<T>& UT_Matrix2T< T >::operator+= ( const UT_Matrix2T< T > &  m)
inline

Definition at line 157 of file UT_Matrix2.h.

template<typename T>
UT_Matrix2T<T>& UT_Matrix2T< T >::operator+= ( T  scalar)
inline

Definition at line 188 of file UT_Matrix2.h.

template<typename T >
template<typename S >
UT_Matrix2T< T > & UT_Matrix2T< T >::operator+= ( const UT_Vector2T< S > &  vec)
inline

Definition at line 573 of file UT_Matrix2.h.

template<typename T>
UT_Matrix2T<T> UT_Matrix2T< T >::operator- ( ) const
inline

Definition at line 150 of file UT_Matrix2.h.

template<typename T>
UT_Matrix2T<T>& UT_Matrix2T< T >::operator-= ( const UT_Matrix2T< T > &  m)
inline

Definition at line 163 of file UT_Matrix2.h.

template<typename T>
UT_Matrix2T<T>& UT_Matrix2T< T >::operator-= ( T  scalar)
inline

Definition at line 194 of file UT_Matrix2.h.

template<typename T >
template<typename S >
UT_Matrix2T< T > & UT_Matrix2T< T >::operator-= ( const UT_Vector2T< S > &  vec)
inline

Definition at line 583 of file UT_Matrix2.h.

template<typename T>
UT_Matrix2T<T>& UT_Matrix2T< T >::operator/= ( T  scalar)
inline

Definition at line 204 of file UT_Matrix2.h.

template<typename T>
UT_Matrix2T<T>& UT_Matrix2T< T >::operator= ( UT_Matrix2T< T > &&  m)
default

Default move assignment operator.

template<typename T>
template<typename S >
UT_Matrix2T<T>& UT_Matrix2T< T >::operator= ( const UT_Matrix3T< S > &  m)

Conversion operator that returns a 2x2 from a 3x3 matrix by ignoring the last row and last column.

template<typename T>
UT_Matrix2T<T>& UT_Matrix2T< T >::operator= ( T  val)
inline

Definition at line 182 of file UT_Matrix2.h.

template<typename T >
template<typename S >
UT_Matrix2T< T > & UT_Matrix2T< T >::operator= ( const UT_Vector2T< S > &  vec)
inline

Definition at line 563 of file UT_Matrix2.h.

template<typename T>
constexpr bool UT_Matrix2T< T >::operator== ( const UT_Matrix2T< T > &  m) const
inlinenoexcept

Definition at line 171 of file UT_Matrix2.h.

template<typename T >
const UT_Vector2T< T > & UT_Matrix2T< T >::operator[] ( unsigned  row) const
inline

Return a matrix row. No bounds checking on subscript.

Definition at line 592 of file UT_Matrix2.h.

template<typename T >
UT_Vector2T< T > & UT_Matrix2T< T >::operator[] ( unsigned  row)
inline

Return a matrix row. No bounds checking on subscript.

Definition at line 600 of file UT_Matrix2.h.

template<typename T>
void UT_Matrix2T< T >::outAsciiNoName ( std::ostream &  os) const
template<typename T>
template<typename S >
void UT_Matrix2T< T >::outerproductUpdate ( T  b,
const UT_Vector2T< S > &  v1,
const UT_Vector2T< S > &  v2 
)
inline

Definition at line 365 of file UT_Matrix2.h.

template<typename T>
void UT_Matrix2T< T >::rotate ( T  theta)
inline

Rotate by theta radians.

Definition at line 405 of file UT_Matrix2.h.

template<typename T>
static UT_Matrix2T<T> UT_Matrix2T< T >::rotationMat ( T  theta)
static

Create a rotation matrix for the given angle in radians.

template<typename T>
int UT_Matrix2T< T >::save ( std::ostream &  os,
int  binary 
) const
template<typename T>
bool UT_Matrix2T< T >::save ( UT_JSONWriter w) const

Methods to serialize to a JSON stream. The matrix is stored as an array of 4 reals.

template<typename T>
bool UT_Matrix2T< T >::save ( UT_JSONValue v) const

Methods to serialize to a JSON stream. The matrix is stored as an array of 4 reals.

template<typename T>
void UT_Matrix2T< T >::scale ( T  sx,
T  sy 
)
inline

Multiply this matrix by a scale matrix with diagonal (sx, sy):

Definition at line 410 of file UT_Matrix2.h.

template<typename T>
void UT_Matrix2T< T >::scale ( const UT_Vector2T< T > &  s)
inline

Multiply this matrix by a scale matrix with diagonal (sx, sy):

Definition at line 415 of file UT_Matrix2.h.

template<typename T>
template<typename S >
int UT_Matrix2T< T >::solve ( const UT_Vector2T< S > &  b,
UT_Vector2T< S > &  x 
) const
inline

Definition at line 273 of file UT_Matrix2.h.

template<typename T>
template<typename S >
int UT_Matrix2T< T >::solveTranspose ( const UT_Vector2T< S > &  b,
UT_Vector2T< S > &  x 
) const
inline

Definition at line 298 of file UT_Matrix2.h.

template<typename T>
void UT_Matrix2T< T >::svdDecomposition ( UT_Matrix2T< T > &  U,
UT_Matrix2T< T > &  S,
UT_Matrix2T< T > &  V,
T  tol = 1e-6f 
) const
template<typename T>
UT_Matrix2T< T >::T ( )
template<typename T>
T UT_Matrix2T< T >::tolerance ( ) const

Returns the tolerance of our class.

template<>
float UT_Matrix2T< float >::tolerance ( ) const
inline

Definition at line 533 of file UT_Matrix2.h.

template<>
int32 UT_Matrix2T< int32 >::tolerance ( ) const
inline

Definition at line 548 of file UT_Matrix2.h.

template<>
int64 UT_Matrix2T< int64 >::tolerance ( ) const
inline

Definition at line 555 of file UT_Matrix2.h.

template<typename T>
constexpr T UT_Matrix2T< T >::trace ( ) const
inlinenoexcept

Definition at line 224 of file UT_Matrix2.h.

template<typename T>
void UT_Matrix2T< T >::transpose ( )
inline

Definition at line 344 of file UT_Matrix2.h.

template<typename T>
UT_Matrix2T<T> UT_Matrix2T< T >::transpose ( ) const
template<typename T>
void UT_Matrix2T< T >::zero ( )
inline

Set the matrix to zero.

Definition at line 384 of file UT_Matrix2.h.

Friends And Related Function Documentation

template<typename T>
std::ostream& operator<< ( std::ostream &  os,
const UT_Matrix2T< T > &  v 
)
friend

Definition at line 509 of file UT_Matrix2.h.

Member Data Documentation

template<typename T>
T UT_Matrix2T< T >::matx[2][2]

Definition at line 524 of file UT_Matrix2.h.

template<typename T>
T UT_Matrix2T< T >::myFloats[tuple_size]

Definition at line 525 of file UT_Matrix2.h.

template<typename T>
constexpr int UT_Matrix2T< T >::tuple_size = 4
static

Definition at line 94 of file UT_Matrix2.h.

template<typename T>
UT_Matrix2T< T >::val
Initial value:
{

Definition at line 108 of file UT_Matrix2.h.


The documentation for this class was generated from the following file: