HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GfMatrix2d Class Reference

#include <matrix2d.h>

Public Types

typedef double ScalarType
 

Public Member Functions

 GfMatrix2d ()=default
 Default constructor. Leaves the matrix component values undefined. More...
 
 GfMatrix2d (double m00, double m01, double m10, double m11)
 
 GfMatrix2d (const double m[2][2])
 
 GfMatrix2d (double s)
 
 GfMatrix2d (int s)
 
 GfMatrix2d (const GfVec2d &v)
 
GF_API GfMatrix2d (const std::vector< std::vector< double > > &v)
 
GF_API GfMatrix2d (const std::vector< std::vector< float > > &v)
 
GF_API GfMatrix2d (const class GfMatrix2f &m)
 This explicit constructor converts a "float" matrix to a "double" matrix. More...
 
void SetRow (int i, const GfVec2d &v)
 Sets a row of the matrix from a Vec2. More...
 
void SetColumn (int i, const GfVec2d &v)
 Sets a column of the matrix from a Vec2. More...
 
GfVec2d GetRow (int i) const
 Gets a row of the matrix as a Vec2. More...
 
GfVec2d GetColumn (int i) const
 Gets a column of the matrix as a Vec2. More...
 
GfMatrix2dSet (double m00, double m01, double m10, double m11)
 
GfMatrix2dSet (const double m[2][2])
 
GfMatrix2dSetIdentity ()
 Sets the matrix to the identity matrix. More...
 
GfMatrix2dSetZero ()
 Sets the matrix to zero. More...
 
GF_API GfMatrix2dSetDiagonal (double s)
 Sets the matrix to s times the identity matrix. More...
 
GF_API GfMatrix2dSetDiagonal (const GfVec2d &)
 Sets the matrix to have diagonal (v[0], v[1]). More...
 
GF_API double * Get (double m[2][2]) const
 
double * data ()
 
const double * data () const
 
double * GetArray ()
 Returns vector components as an array of double values. More...
 
const double * GetArray () const
 Returns vector components as a const array of double values. More...
 
double * operator[] (int i)
 
const double * operator[] (int i) const
 
GF_API bool operator== (const GfMatrix2d &m) const
 
GF_API bool operator== (const GfMatrix2f &m) const
 
bool operator!= (const GfMatrix2d &m) const
 
bool operator!= (const GfMatrix2f &m) const
 
GF_API GfMatrix2d GetTranspose () const
 Returns the transpose of the matrix. More...
 
GF_API GfMatrix2d GetInverse (double *det=NULL, double eps=0) const
 
GF_API double GetDeterminant () const
 Returns the determinant of the matrix. More...
 
GF_API GfMatrix2doperator*= (const GfMatrix2d &m)
 Post-multiplies matrix m into this matrix. More...
 
GF_API GfMatrix2doperator*= (double)
 Multiplies the matrix by a double. More...
 
GF_API GfMatrix2doperator+= (const GfMatrix2d &m)
 Adds matrix m to this matrix. More...
 
GF_API GfMatrix2doperator-= (const GfMatrix2d &m)
 Subtracts matrix m from this matrix. More...
 

Static Public Attributes

static const size_t numRows = 2
 
static const size_t numColumns = 2
 

Friends

class GfMatrix2f
 
size_t hash_value (GfMatrix2d const &m)
 Hash. More...
 
GfMatrix2d operator* (const GfMatrix2d &m1, double d)
 Returns the product of a matrix and a double. More...
 
GfMatrix2d operator* (double d, const GfMatrix2d &m)
 
GF_API friend GfMatrix2d operator- (const GfMatrix2d &m)
 Returns the unary negation of matrix m. More...
 
GfMatrix2d operator+ (const GfMatrix2d &m1, const GfMatrix2d &m2)
 Adds matrix m2 to m1. More...
 
GfMatrix2d operator- (const GfMatrix2d &m1, const GfMatrix2d &m2)
 Subtracts matrix m2 from m1. More...
 
GfMatrix2d operator* (const GfMatrix2d &m1, const GfMatrix2d &m2)
 Multiplies matrix m1 by m2. More...
 
GfMatrix2d operator/ (const GfMatrix2d &m1, const GfMatrix2d &m2)
 Divides matrix m1 by m2 (that is, m1 * inv(m2)). More...
 
GfVec2d operator* (const GfMatrix2d &m, const GfVec2d &vec)
 Returns the product of a matrix m and a column vector vec. More...
 
GfVec2d operator* (const GfVec2d &vec, const GfMatrix2d &m)
 Returns the product of row vector vec and a matrix m. More...
 
GF_API friend GfVec2f operator* (const GfMatrix2d &m, const GfVec2f &vec)
 
GF_API friend GfVec2f operator* (const GfVec2f &vec, const GfMatrix2d &m)
 

Detailed Description

Stores a 2x2 matrix of double elements. A basic type.

Matrices are defined to be in row-major order, so matrix[i][j] indexes the element in the i th row and the j th column.

Definition at line 61 of file matrix2d.h.

Member Typedef Documentation

typedef double GfMatrix2d::ScalarType

Definition at line 64 of file matrix2d.h.

Constructor & Destructor Documentation

GfMatrix2d::GfMatrix2d ( )
default

Default constructor. Leaves the matrix component values undefined.

GfMatrix2d::GfMatrix2d ( double  m00,
double  m01,
double  m10,
double  m11 
)
inline

Constructor. Initializes the matrix from 4 independent double values, specified in row-major order. For example, parameter m10 specifies the value in row 1 and column 0.

Definition at line 75 of file matrix2d.h.

GfMatrix2d::GfMatrix2d ( const double  m[2][2])
inline

Constructor. Initializes the matrix from a 2x2 array of double values, specified in row-major order.

Definition at line 83 of file matrix2d.h.

GfMatrix2d::GfMatrix2d ( double  s)
inlineexplicit

Constructor. Explicitly initializes the matrix to s times the identity matrix.

Definition at line 89 of file matrix2d.h.

GfMatrix2d::GfMatrix2d ( int  s)
inlineexplicit

This explicit constructor initializes the matrix to s times the identity matrix.

Definition at line 95 of file matrix2d.h.

GfMatrix2d::GfMatrix2d ( const GfVec2d v)
inlineexplicit

Constructor. Explicitly initializes the matrix to diagonal form, with the i th element on the diagonal set to v[i].

Definition at line 101 of file matrix2d.h.

GF_API GfMatrix2d::GfMatrix2d ( const std::vector< std::vector< double > > &  v)
explicit

Constructor. Initialize the matrix from a vector of vectors of double. The vector is expected to be 2x2. If it is too big, only the first 2 rows and/or columns will be used. If it is too small, uninitialized elements will be filled in with the corresponding elements from an identity matrix.

GF_API GfMatrix2d::GfMatrix2d ( const std::vector< std::vector< float > > &  v)
explicit

Constructor. Initialize the matrix from a vector of vectors of float. The vector is expected to be 2x2. If it is too big, only the first 2 rows and/or columns will be used. If it is too small, uninitialized elements will be filled in with the corresponding elements from an identity matrix.

GF_API GfMatrix2d::GfMatrix2d ( const class GfMatrix2f m)
explicit

This explicit constructor converts a "float" matrix to a "double" matrix.

Member Function Documentation

double* GfMatrix2d::data ( )
inline

Returns raw access to components of matrix as an array of double values. Components are in row-major order.

Definition at line 194 of file matrix2d.h.

const double* GfMatrix2d::data ( ) const
inline

Returns const raw access to components of matrix as an array of double values. Components are in row-major order.

Definition at line 200 of file matrix2d.h.

GF_API double* GfMatrix2d::Get ( double  m[2][2]) const

Fills a 2x2 array of double values with the values in the matrix, specified in row-major order.

double* GfMatrix2d::GetArray ( )
inline

Returns vector components as an array of double values.

Definition at line 205 of file matrix2d.h.

const double* GfMatrix2d::GetArray ( ) const
inline

Returns vector components as a const array of double values.

Definition at line 210 of file matrix2d.h.

GfVec2d GfMatrix2d::GetColumn ( int  i) const
inline

Gets a column of the matrix as a Vec2.

Definition at line 145 of file matrix2d.h.

GF_API double GfMatrix2d::GetDeterminant ( ) const

Returns the determinant of the matrix.

GF_API GfMatrix2d GfMatrix2d::GetInverse ( double *  det = NULL,
double  eps = 0 
) const

Returns the inverse of the matrix, or FLT_MAX * SetIdentity() if the matrix is singular. (FLT_MAX is the largest value a float can have, as defined by the system.) The matrix is considered singular if the determinant is less than or equal to the optional parameter eps. If det is non-null, *det is set to the determinant.

GfVec2d GfMatrix2d::GetRow ( int  i) const
inline

Gets a row of the matrix as a Vec2.

Definition at line 140 of file matrix2d.h.

GF_API GfMatrix2d GfMatrix2d::GetTranspose ( ) const

Returns the transpose of the matrix.

bool GfMatrix2d::operator!= ( const GfMatrix2d m) const
inline

Tests for element-wise matrix inequality. All elements must match exactly for matrices to be considered equal.

Definition at line 246 of file matrix2d.h.

bool GfMatrix2d::operator!= ( const GfMatrix2f m) const
inline

Tests for element-wise matrix inequality. All elements must match exactly for matrices to be considered equal.

Definition at line 252 of file matrix2d.h.

GF_API GfMatrix2d& GfMatrix2d::operator*= ( const GfMatrix2d m)

Post-multiplies matrix m into this matrix.

GF_API GfMatrix2d& GfMatrix2d::operator*= ( double  )

Multiplies the matrix by a double.

GF_API GfMatrix2d& GfMatrix2d::operator+= ( const GfMatrix2d m)

Adds matrix m to this matrix.

GF_API GfMatrix2d& GfMatrix2d::operator-= ( const GfMatrix2d m)

Subtracts matrix m from this matrix.

GF_API bool GfMatrix2d::operator== ( const GfMatrix2d m) const

Tests for element-wise matrix equality. All elements must match exactly for matrices to be considered equal.

GF_API bool GfMatrix2d::operator== ( const GfMatrix2f m) const

Tests for element-wise matrix equality. All elements must match exactly for matrices to be considered equal.

double* GfMatrix2d::operator[] ( int  i)
inline

Accesses an indexed row i of the matrix as an array of 2 double values so that standard indexing (such as m[0][1]) works correctly.

Definition at line 217 of file matrix2d.h.

const double* GfMatrix2d::operator[] ( int  i) const
inline

Accesses an indexed row i of the matrix as an array of 2 double values so that standard indexing (such as m[0][1]) works correctly.

Definition at line 222 of file matrix2d.h.

GfMatrix2d& GfMatrix2d::Set ( double  m00,
double  m01,
double  m10,
double  m11 
)
inline

Sets the matrix from 4 independent double values, specified in row-major order. For example, parameter m10 specifies the value in row 1 and column 0.

Definition at line 152 of file matrix2d.h.

GfMatrix2d& GfMatrix2d::Set ( const double  m[2][2])
inline

Sets the matrix from a 2x2 array of double values, specified in row-major order.

Definition at line 161 of file matrix2d.h.

void GfMatrix2d::SetColumn ( int  i,
const GfVec2d v 
)
inline

Sets a column of the matrix from a Vec2.

Definition at line 134 of file matrix2d.h.

GF_API GfMatrix2d& GfMatrix2d::SetDiagonal ( double  s)

Sets the matrix to s times the identity matrix.

GF_API GfMatrix2d& GfMatrix2d::SetDiagonal ( const GfVec2d )

Sets the matrix to have diagonal (v[0], v[1]).

GfMatrix2d& GfMatrix2d::SetIdentity ( )
inline

Sets the matrix to the identity matrix.

Definition at line 170 of file matrix2d.h.

void GfMatrix2d::SetRow ( int  i,
const GfVec2d v 
)
inline

Sets a row of the matrix from a Vec2.

Definition at line 128 of file matrix2d.h.

GfMatrix2d& GfMatrix2d::SetZero ( )
inline

Sets the matrix to zero.

Definition at line 175 of file matrix2d.h.

Friends And Related Function Documentation

friend class GfMatrix2f
friend

Definition at line 365 of file matrix2d.h.

size_t hash_value ( GfMatrix2d const &  m)
friend

Hash.

Definition at line 225 of file matrix2d.h.

GfMatrix2d operator* ( const GfMatrix2d m1,
double  d 
)
friend

Returns the product of a matrix and a double.

Definition at line 282 of file matrix2d.h.

GfMatrix2d operator* ( double  d,
const GfMatrix2d m 
)
friend

Definition at line 290 of file matrix2d.h.

GfMatrix2d operator* ( const GfMatrix2d m1,
const GfMatrix2d m2 
)
friend

Multiplies matrix m1 by m2.

Definition at line 324 of file matrix2d.h.

GfVec2d operator* ( const GfMatrix2d m,
const GfVec2d vec 
)
friend

Returns the product of a matrix m and a column vector vec.

Definition at line 338 of file matrix2d.h.

GfVec2d operator* ( const GfVec2d vec,
const GfMatrix2d m 
)
friend

Returns the product of row vector vec and a matrix m.

Definition at line 344 of file matrix2d.h.

GF_API friend GfVec2f operator* ( const GfMatrix2d m,
const GfVec2f vec 
)
friend

Returns the product of a matrix m and a column vector vec. Note that the return type is a GfVec2f.

GF_API friend GfVec2f operator* ( const GfVec2f vec,
const GfMatrix2d m 
)
friend

Returns the product of row vector vec and a matrix m. Note that the return type is a GfVec2f.

GfMatrix2d operator+ ( const GfMatrix2d m1,
const GfMatrix2d m2 
)
friend

Adds matrix m2 to m1.

Definition at line 308 of file matrix2d.h.

GF_API friend GfMatrix2d operator- ( const GfMatrix2d m)
friend

Returns the unary negation of matrix m.

GfMatrix2d operator- ( const GfMatrix2d m1,
const GfMatrix2d m2 
)
friend

Subtracts matrix m2 from m1.

Definition at line 316 of file matrix2d.h.

GfMatrix2d operator/ ( const GfMatrix2d m1,
const GfMatrix2d m2 
)
friend

Divides matrix m1 by m2 (that is, m1 * inv(m2)).

Definition at line 332 of file matrix2d.h.

Member Data Documentation

const size_t GfMatrix2d::numColumns = 2
static

Definition at line 67 of file matrix2d.h.

const size_t GfMatrix2d::numRows = 2
static

Definition at line 66 of file matrix2d.h.


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