#include <opennurbs_matrix.h>

Public Member Functions

 ON_Matrix ()
 
 ON_Matrix (int row_count, int col_count)
 
 ON_Matrix (int, int, int, int)
 
 ON_Matrix (const ON_Xform &)
 
 ON_Matrix (const ON_Matrix &)
 
 ON_Matrix (int row_count, int col_count, double **M, bool bDestructorFreeM)
 This constructor is for experts who have storage for a matrix and need to use it in ON_Matrix form. More...
 
virtual ~ON_Matrix ()
 
bool Add (const ON_Matrix &A, const ON_Matrix &B)
 Set this = A+B. More...
 
bool BackSolve (double, int, const double *, double *) const
 Solve M*X=B where M is upper triangular with a unit diagonal and B is a column of values. More...
 
bool BackSolve (double, int, const ON_3dPoint *, ON_3dPoint *) const
 Solve M*X=B where M is upper triangular with a unit diagonal and B is a column of 3d points. More...
 
bool BackSolve (double, int, int, int, const double *, int, double *) const
 Solve M*X=B where M is upper triangular with a unit diagonal and B is a column of points More...
 
int ColCount () const
 
void ColOp (int, double, int)
 
void ColScale (int, double)
 
bool Create (int, int)
 
bool Create (int, int, int, int)
 
bool Create (int row_count, int col_count, double **M, bool bDestructorFreeM)
 This constructor is for experts who have storage for a matrix and need to use it in ON_Matrix form. More...
 
void Destroy ()
 
void EmergencyDestroy ()
 
bool Invert (double)
 
bool IsColOrthoganal () const
 
bool IsColOrthoNormal () const
 
bool IsRowOrthoganal () const
 
bool IsRowOrthoNormal () const
 
int IsSquare () const
 
bool IsValid () const
 
int MaxCount () const
 
int MinCount () const
 
bool Multiply (const ON_Matrix &A, const ON_Matrix &B)
 Set this = A*B. More...
 
ON_Matrixoperator= (const ON_Matrix &)
 
ON_Matrixoperator= (const ON_Xform &)
 
double * operator[] (int)
 
const double * operator[] (int) const
 
int RowCount () const
 
void RowOp (int, double, int)
 
int RowReduce (double, double &, double &)
 Row reduce a matrix to calculate rank and determinant. More...
 
int RowReduce (double, double *, double *=nullptr)
 Row reduce a matrix as the first step in solving M*X=B where B is a column of values. More...
 
int RowReduce (double, ON_3dPoint *, double *=nullptr)
 Row reduce a matrix as the first step in solving M*X=B where B is a column of 3d points More...
 
int RowReduce (double, int, int, double *, double *=nullptr)
 Row reduce a matrix as the first step in solving M*X=B where B is a column arbitrary dimension points. More...
 
void RowScale (int, double)
 
bool Scale (double s)
 Set this = s*this. More...
 
void SetDiagonal (double)
 
void SetDiagonal (const double *)
 
void SetDiagonal (int, const double *)
 
void SetDiagonal (const ON_SimpleArray< double > &)
 
bool SwapCols (int, int)
 
bool SwapRows (int, int)
 
bool Transpose ()
 
unsigned int UnsignedColCount () const
 
unsigned int UnsignedMaxCount () const
 
unsigned int UnsignedMinCount () const
 
unsigned int UnsignedRowCount () const
 
void Zero ()
 

Static Public Member Functions

static double ** Allocate (unsigned int row_count, unsigned int col_count)
 
static void Deallocate (double **M)
 

Public Attributes

double ** m = nullptr
 

Constructor & Destructor Documentation

◆ ON_Matrix() [1/6]

ON_Matrix::ON_Matrix ( )

◆ ON_Matrix() [2/6]

ON_Matrix::ON_Matrix ( int  row_count,
int  col_count 
)

◆ ON_Matrix() [3/6]

ON_Matrix::ON_Matrix ( int  ,
int  ,
int  ,
int   
)

◆ ON_Matrix() [4/6]

ON_Matrix::ON_Matrix ( const ON_Xform )

◆ ON_Matrix() [5/6]

ON_Matrix::ON_Matrix ( const ON_Matrix )

◆ ON_Matrix() [6/6]

ON_Matrix::ON_Matrix ( int  row_count,
int  col_count,
double **  M,
bool  bDestructorFreeM 
)

This constructor is for experts who have storage for a matrix and need to use it in ON_Matrix form.

Parameters
row_count[in]
col_count[in]
M[in]
bDestructorFreeM[in] If true, ~ON_Matrix will call onfree(M). If false, caller is managing M's memory.

ON_Matrix functions that increase the value of row_count or col_count will fail on a matrix created with this constructor.

◆ ~ON_Matrix()

virtual ON_Matrix::~ON_Matrix ( )
virtual

Member Function Documentation

◆ Add()

bool ON_Matrix::Add ( const ON_Matrix A,
const ON_Matrix B 
)

Set this = A+B.

Parameters
A[in] (Can be this)
B[in] (Can be this)
Returns
True when A and B are mXn matrices; in which case "this" will be an mXn matrix = A+B. False when A and B have different sizes.

◆ Allocate()

static double** ON_Matrix::Allocate ( unsigned int  row_count,
unsigned int  col_count 
)
static
Returns
A row_count X col_count martix on the heap that can be deleted by calling ON_Matrix::Deallocate().

◆ BackSolve() [1/3]

bool ON_Matrix::BackSolve ( double  ,
int  ,
const double *  ,
double *   
) const

Solve M*X=B where M is upper triangular with a unit diagonal and B is a column of values.

Parameters
zero_tolerancein used to test for "zero" values in B in under determined systems of equations.
Bsize[in] (>=m_row_count) length of B. The values in B[m_row_count],...,B[Bsize-1] are tested to make sure they are "zero".
B[in] array of length Bsize.
X[out] array of length m_col_count. Solutions returned here.

Actual values M[i][j] with i <= j are ignored. M[i][i] is assumed to be one and M[i][j] i<j is assumed to be zero. For square M, B and X can point to the same memory.

See also
ON_Matrix::RowReduce

◆ BackSolve() [2/3]

bool ON_Matrix::BackSolve ( double  ,
int  ,
const ON_3dPoint ,
ON_3dPoint  
) const

Solve M*X=B where M is upper triangular with a unit diagonal and B is a column of 3d points.

Parameters
zero_tolerancein used to test for "zero" values in B in under determined systems of equations.
Bsize[in] (>=m_row_count) length of B. The values in B[m_row_count],...,B[Bsize-1] are tested to make sure they are "zero".
B[in] array of length Bsize.
X[out] array of length m_col_count. Solutions returned here.

Actual values M[i][j] with i <= j are ignored. M[i][i] is assumed to be one and M[i][j] i<j is assumed to be zero. For square M, B and X can point to the same memory.

See also
ON_Matrix::RowReduce

◆ BackSolve() [3/3]

bool ON_Matrix::BackSolve ( double  ,
int  ,
int  ,
int  ,
const double *  ,
int  ,
double *   
) const

Solve M*X=B where M is upper triangular with a unit diagonal and B is a column of points

Parameters
zero_tolerancein used to test for "zero" values in B in under determined systems of equations.
pt_dim[in] dimension of points
Bsize[in] (>=m_row_count) number of points in B[]. The points correspoinding to indices m_row_count, ..., (Bsize-1) are tested to make sure they are "zero".
Bpt_stride[in] stride between B points (>=pt_dim)
Bpt[in/out] array of m_row_count*Bpt_stride values. The i-th B point is (Bpt[i*Bpt_stride],...,Bpt[i*Bpt_stride+pt_dim-1]).
Xpt_stride[in] stride between X points (>=pt_dim)
Xpt[out] array of m_col_count*Xpt_stride values. The i-th X point is (Xpt[i*Xpt_stride],...,Xpt[i*Xpt_stride+pt_dim-1]).

Actual values M[i][j] with i <= j are ignored. M[i][i] is assumed to be one and M[i][j] i<j is assumed to be zero. For square M, B and X can point to the same memory.

See also
ON_Matrix::RowReduce

◆ ColCount()

int ON_Matrix::ColCount ( ) const

◆ ColOp()

void ON_Matrix::ColOp ( int  ,
double  ,
int   
)

◆ ColScale()

void ON_Matrix::ColScale ( int  ,
double   
)

◆ Create() [1/3]

bool ON_Matrix::Create ( int  ,
int   
)

◆ Create() [2/3]

bool ON_Matrix::Create ( int  ,
int  ,
int  ,
int   
)

◆ Create() [3/3]

bool ON_Matrix::Create ( int  row_count,
int  col_count,
double **  M,
bool  bDestructorFreeM 
)

This constructor is for experts who have storage for a matrix and need to use it in ON_Matrix form.

Parameters
row_count[in]
col_count[in]
M[in]
bDestructorFreeM[in] If true, ~ON_Matrix will call onfree(M). If false, caller is managing M's memory.

ON_Matrix functions that increase the value of row_count or col_count will fail on a matrix created with this constructor.

◆ Deallocate()

static void ON_Matrix::Deallocate ( double **  M)
static

◆ Destroy()

void ON_Matrix::Destroy ( )

◆ EmergencyDestroy()

void ON_Matrix::EmergencyDestroy ( )

◆ Invert()

bool ON_Matrix::Invert ( double  )

◆ IsColOrthoganal()

bool ON_Matrix::IsColOrthoganal ( ) const

◆ IsColOrthoNormal()

bool ON_Matrix::IsColOrthoNormal ( ) const

◆ IsRowOrthoganal()

bool ON_Matrix::IsRowOrthoganal ( ) const

◆ IsRowOrthoNormal()

bool ON_Matrix::IsRowOrthoNormal ( ) const

◆ IsSquare()

int ON_Matrix::IsSquare ( ) const

◆ IsValid()

bool ON_Matrix::IsValid ( ) const

◆ MaxCount()

int ON_Matrix::MaxCount ( ) const

◆ MinCount()

int ON_Matrix::MinCount ( ) const

◆ Multiply()

bool ON_Matrix::Multiply ( const ON_Matrix A,
const ON_Matrix B 
)

Set this = A*B.

Parameters
A[in] (Can be this)
B[in] (Can be this)
Returns
True when A is an mXk matrix and B is a k X n matrix; in which case "this" will be an mXn matrix = A*B. False when A.ColCount() != B.RowCount().

◆ operator=() [1/2]

ON_Matrix& ON_Matrix::operator= ( const ON_Matrix )

◆ operator=() [2/2]

ON_Matrix& ON_Matrix::operator= ( const ON_Xform )

◆ operator[]() [1/2]

double* ON_Matrix::operator[] ( int  )

◆ operator[]() [2/2]

const double* ON_Matrix::operator[] ( int  ) const

◆ RowCount()

int ON_Matrix::RowCount ( ) const

◆ RowOp()

void ON_Matrix::RowOp ( int  ,
double  ,
int   
)

◆ RowReduce() [1/4]

int ON_Matrix::RowReduce ( double  ,
double &  ,
double &   
)

Row reduce a matrix to calculate rank and determinant.

Parameters
zero_tolerancein zero tolerance for pivot test If the absolute value of a pivot is <= zero_tolerance, then the pivot is assumed to be zero.
determinant[out] value of determinant is returned here.
pivot[out] value of the smallest pivot is returned here
Returns
Rank of the matrix.

The matrix itself is row reduced so that the result is an upper triangular matrix with 1's on the diagonal.

◆ RowReduce() [2/4]

int ON_Matrix::RowReduce ( double  ,
double *  ,
double *  = nullptr 
)

Row reduce a matrix as the first step in solving M*X=B where B is a column of values.

Parameters
zero_tolerancein zero tolerance for pivot test If the absolute value of a pivot is <= zero_tolerance, then the pivot is assumed to be zero.
B[in/out] an array of m_row_count values that is row reduced with the matrix.
determinant[out] value of determinant is returned here.
pivot[out] If not nullptr, then the value of the smallest pivot is returned here
Returns
Rank of the matrix.

The matrix itself is row reduced so that the result is an upper triangular matrix with 1's on the diagonal.

Solve M*X=B;
double B[m] = ...;
double B[n] = ...;
ON_Matrix M(m,n) = ...;
M.RowReduce(ON_ZERO_TOLERANCE,B); // modifies M and B
M.BackSolve(m,B,X); // solution is in X
See also
ON_Matrix::BackSolve

◆ RowReduce() [3/4]

int ON_Matrix::RowReduce ( double  ,
ON_3dPoint ,
double *  = nullptr 
)

Row reduce a matrix as the first step in solving M*X=B where B is a column of 3d points

Parameters
zero_tolerancein zero tolerance for pivot test If the absolute value of a pivot is <= zero_tolerance, then the pivot is assumed to be zero.
B[in/out] an array of m_row_count 3d points that is row reduced with the matrix.
determinant[out] value of determinant is returned here.
pivot[out] If not nullptr, then the value of the smallest pivot is returned here
Returns
Rank of the matrix.

The matrix itself is row reduced so that the result is an upper triangular matrix with 1's on the diagonal.

See also
ON_Matrix::BackSolve

◆ RowReduce() [4/4]

int ON_Matrix::RowReduce ( double  ,
int  ,
int  ,
double *  ,
double *  = nullptr 
)

Row reduce a matrix as the first step in solving M*X=B where B is a column arbitrary dimension points.

Parameters
zero_tolerancein zero tolerance for pivot test If a the absolute value of a pivot is <= zero_tolerance, then the pivoit is assumed to be zero.
pt_dim[in] dimension of points
pt_stride[in] stride between points (>=pt_dim)
pt[in/out] array of m_row_count*pt_stride values. The i-th point is (pt[i*pt_stride],...,pt[i*pt_stride+pt_dim-1]). This array of points is row reduced along with the matrix.
pivot[out] If not nullptr, then the value of the smallest pivot is returned here
Returns
Rank of the matrix.

The matrix itself is row reduced so that the result is an upper triangular matrix with 1's on the diagonal.

See also
ON_Matrix::BackSolve

◆ RowScale()

void ON_Matrix::RowScale ( int  ,
double   
)

◆ Scale()

bool ON_Matrix::Scale ( double  s)

Set this = s*this.

Parameters
s[in]
Returns
True when A and s are valid.

◆ SetDiagonal() [1/4]

void ON_Matrix::SetDiagonal ( double  )

◆ SetDiagonal() [2/4]

void ON_Matrix::SetDiagonal ( const double *  )

◆ SetDiagonal() [3/4]

void ON_Matrix::SetDiagonal ( int  ,
const double *   
)

◆ SetDiagonal() [4/4]

void ON_Matrix::SetDiagonal ( const ON_SimpleArray< double > &  )

◆ SwapCols()

bool ON_Matrix::SwapCols ( int  ,
int   
)

◆ SwapRows()

bool ON_Matrix::SwapRows ( int  ,
int   
)

◆ Transpose()

bool ON_Matrix::Transpose ( )

◆ UnsignedColCount()

unsigned int ON_Matrix::UnsignedColCount ( ) const

◆ UnsignedMaxCount()

unsigned int ON_Matrix::UnsignedMaxCount ( ) const

◆ UnsignedMinCount()

unsigned int ON_Matrix::UnsignedMinCount ( ) const

◆ UnsignedRowCount()

unsigned int ON_Matrix::UnsignedRowCount ( ) const

◆ Zero()

void ON_Matrix::Zero ( )

Member Data Documentation

◆ m

double** ON_Matrix::m = nullptr