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 ()
 Invert this matrix and return 0 if OK, 1 if singular. More...
 
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 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
 
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 90 of file UT_Matrix2.h.

Member Typedef Documentation

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

Definition at line 94 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 107 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 114 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 423 of file UT_Matrix2.h.

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

Return the raw matrix data.

Definition at line 424 of file UT_Matrix2.h.

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

Definition at line 227 of file UT_Matrix2.h.

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 494 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 454 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>
unsigned UT_Matrix2T< T >::hash ( void  ) const
inline

Compute a hash.

Definition at line 428 of file UT_Matrix2.h.

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

Set the matrix to identity.

Definition at line 359 of file UT_Matrix2.h.

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

Initialize this matrix to zero.

Definition at line 401 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.

Definition at line 239 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.

Definition at line 248 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 333 of file UT_Matrix2.h.

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

Definition at line 367 of file UT_Matrix2.h.

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

Definition at line 374 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 184 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 409 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 414 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 432 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 437 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 205 of file UT_Matrix2.h.

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

Definition at line 164 of file UT_Matrix2.h.

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

Definition at line 195 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 550 of file UT_Matrix2.h.

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

Definition at line 157 of file UT_Matrix2.h.

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

Definition at line 170 of file UT_Matrix2.h.

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

Definition at line 201 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 560 of file UT_Matrix2.h.

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

Definition at line 211 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 189 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 540 of file UT_Matrix2.h.

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

Definition at line 178 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 569 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 577 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 346 of file UT_Matrix2.h.

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

Rotate by theta radians.

Definition at line 386 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 391 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 396 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 278 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 303 of file UT_Matrix2.h.

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 510 of file UT_Matrix2.h.

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

Definition at line 525 of file UT_Matrix2.h.

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

Definition at line 532 of file UT_Matrix2.h.

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

Definition at line 231 of file UT_Matrix2.h.

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

Definition at line 325 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 365 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 486 of file UT_Matrix2.h.

Member Data Documentation

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

Definition at line 501 of file UT_Matrix2.h.

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

Definition at line 502 of file UT_Matrix2.h.

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

Definition at line 95 of file UT_Matrix2.h.

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

Definition at line 109 of file UT_Matrix2.h.


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