Rhino C++ API
8.13
|
#include <opennurbs_matrix.h>
Public Member Functions | |
ON_Matrix () | |
ON_Matrix (const ON_Matrix &) | |
ON_Matrix (const ON_Xform &) | |
ON_Matrix (int row_count, int col_count) | |
ON_Matrix (int row_count, int col_count, double **M, bool bDestructorFreeM) | |
ON_Matrix (int, int, int, int) | |
virtual | ~ON_Matrix () |
bool | Add (const ON_Matrix &A, const ON_Matrix &B) |
bool | BackSolve (double, int, const double *, double *) const |
bool | BackSolve (double, int, const ON_3dPoint *, ON_3dPoint *) const |
bool | BackSolve (double, int, int, int, const double *, int, double *) const |
int | ColCount () const |
void | ColOp (int, double, int) |
void | ColScale (int, double) |
bool | Create (int row_count, int col_count, double **M, bool bDestructorFreeM) |
bool | Create (int, int) |
bool | Create (int, int, int, int) |
void | Destroy () |
void | EmergencyDestroy () |
call if memory pool used matrix by becomes invalid More... | |
bool | Invert (double) |
bool | IsColOrthoganal () const |
bool | IsColOrthoNormal () const |
bool | IsRowOrthoganal () const |
bool | IsRowOrthoNormal () const |
int | IsSquare () const |
returns 0 for no and m_row_count (= m_col_count) for yes More... | |
bool | IsValid () const |
int | MaxCount () const |
largest of row and column count More... | |
int | MinCount () const |
smallest of row and column count More... | |
bool | Multiply (const ON_Matrix &A, const ON_Matrix &B) |
ON_Matrix & | operator= (const ON_Matrix &) |
ON_Matrix & | operator= (const ON_Xform &) |
double * | operator[] (int) |
const double * | operator[] (int) const |
int | RowCount () const |
void | RowOp (int, double, int) |
int | RowReduce (double, double &, double &) |
int | RowReduce (double, double *, double *=nullptr) |
int | RowReduce (double, int, int, double *, double *=nullptr) |
int | RowReduce (double, ON_3dPoint *, double *=nullptr) |
void | RowScale (int, double) |
bool | Scale (double s) |
void | SetDiagonal (const double *) |
sets diagonal values and zeros off diagonal values More... | |
void | SetDiagonal (const ON_SimpleArray< double > &) |
sets size to length X lengthdiagonal values and zeros off diagonal values More... | |
void | SetDiagonal (double) |
sets diagonal value and zeros off diagonal values More... | |
void | SetDiagonal (int, const double *) |
sets size to count x count and diagonal values and zeros off diagonal values More... | |
bool | SwapCols (int, int) |
ints are col indices to swap More... | |
bool | SwapRows (int, int) |
ints are row indices to swap More... | |
bool | Transpose () |
unsigned int | UnsignedColCount () const |
unsigned int | UnsignedMaxCount () const |
largest of row and column count More... | |
unsigned int | UnsignedMinCount () const |
smallest of row and column count More... | |
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 |
ON_Matrix::ON_Matrix | ( | ) |
ON_Matrix::ON_Matrix | ( | int | row_count, |
int | col_count | ||
) |
ON_Matrix::ON_Matrix | ( | int | , |
int | , | ||
int | , | ||
int | |||
) |
ON_Matrix::ON_Matrix | ( | const ON_Xform & | ) |
ON_Matrix::ON_Matrix | ( | const ON_Matrix & | ) |
ON_Matrix::ON_Matrix | ( | int | row_count, |
int | col_count, | ||
double ** | M, | ||
bool | bDestructorFreeM | ||
) |
Description: 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. Remarks: ON_Matrix functions that increase the value of row_count or col_count will fail on a matrix created with this constructor.
|
virtual |
Description: 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.
|
static |
Returns: A row_count X col_count martix on the heap that can be deleted by calling ON_Matrix::Deallocate().
bool ON_Matrix::BackSolve | ( | double | , |
int | , | ||
const double * | , | ||
double * | |||
) | const |
Description: Solve M*X=B where M is upper triangular with a unit diagonal and B is a column of values. Parameters: zero_tolerance - in 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. Remarks: 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
bool ON_Matrix::BackSolve | ( | double | , |
int | , | ||
const ON_3dPoint * | , | ||
ON_3dPoint * | |||
) | const |
Description: Solve M*X=B where M is upper triangular with a unit diagonal and B is a column of 3d points. Parameters: zero_tolerance - in 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. Remarks: 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
bool ON_Matrix::BackSolve | ( | double | , |
int | , | ||
int | , | ||
int | , | ||
const double * | , | ||
int | , | ||
double * | |||
) | const |
Description: Solve M*X=B where M is upper triangular with a unit diagonal and B is a column of points Parameters: zero_tolerance - in 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 corresponding 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]). Remarks: 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
int ON_Matrix::ColCount | ( | ) | const |
void ON_Matrix::ColOp | ( | int | , |
double | , | ||
int | |||
) |
void ON_Matrix::ColScale | ( | int | , |
double | |||
) |
bool ON_Matrix::Create | ( | int | row_count, |
int | col_count, | ||
double ** | M, | ||
bool | bDestructorFreeM | ||
) |
Description: 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] M should point to the start of an array of double*, each pointing to the start of the storage for a row. bDestructorFreeM - [in] If true, ~ON_Matrix will call onfree(M). If false, caller is managing M's memory. Remarks: ON_Matrix functions that increase the value of row_count or col_count will fail on a matrix created with this constructor.
bool ON_Matrix::Create | ( | int | , |
int | |||
) |
bool ON_Matrix::Create | ( | int | , |
int | , | ||
int | , | ||
int | |||
) |
|
static |
void ON_Matrix::Destroy | ( | ) |
void ON_Matrix::EmergencyDestroy | ( | ) |
call if memory pool used matrix by becomes invalid
bool ON_Matrix::Invert | ( | double | ) |
bool ON_Matrix::IsColOrthoganal | ( | ) | const |
bool ON_Matrix::IsColOrthoNormal | ( | ) | const |
bool ON_Matrix::IsRowOrthoganal | ( | ) | const |
bool ON_Matrix::IsRowOrthoNormal | ( | ) | const |
int ON_Matrix::IsSquare | ( | ) | const |
returns 0 for no and m_row_count (= m_col_count) for yes
bool ON_Matrix::IsValid | ( | ) | const |
int ON_Matrix::MaxCount | ( | ) | const |
largest of row and column count
int ON_Matrix::MinCount | ( | ) | const |
smallest of row and column count
Description: 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().
double* ON_Matrix::operator[] | ( | int | ) |
ON_Matrix[i][j] = value at row i and column j 0 <= i < RowCount() 0 <= j < ColCount()
const double* ON_Matrix::operator[] | ( | int | ) | const |
int ON_Matrix::RowCount | ( | ) | const |
void ON_Matrix::RowOp | ( | int | , |
double | , | ||
int | |||
) |
int ON_Matrix::RowReduce | ( | double | , |
double & | , | ||
double & | |||
) |
Description: Row reduce a matrix to calculate rank and determinant. Parameters: zero_tolerance - in 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. Remarks: The matrix itself is row reduced so that the result is an upper triangular matrix with 1's on the diagonal.
int ON_Matrix::RowReduce | ( | double | , |
double * | , | ||
double * | = nullptr |
||
) |
Description: Row reduce a matrix as the first step in solving M*X=B where B is a column of values. Parameters: zero_tolerance - in 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. Remarks: The matrix itself is row reduced so that the result is an upper triangular matrix with 1's on the diagonal. Example: 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
int ON_Matrix::RowReduce | ( | double | , |
int | , | ||
int | , | ||
double * | , | ||
double * | = nullptr |
||
) |
Description: Row reduce a matrix as the first step in solving M*X=B where B is a column arbitrary dimension points. Parameters: zero_tolerance - in 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. Remarks: 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
int ON_Matrix::RowReduce | ( | double | , |
ON_3dPoint * | , | ||
double * | = nullptr |
||
) |
Description: Row reduce a matrix as the first step in solving M*X=B where B is a column of 3d points Parameters: zero_tolerance - in 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. Remarks: 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
void ON_Matrix::RowScale | ( | int | , |
double | |||
) |
bool ON_Matrix::Scale | ( | double | s | ) |
Description: Set this = s*this. Parameters: s - [in] Returns: True when A and s are valid.
void ON_Matrix::SetDiagonal | ( | const double * | ) |
sets diagonal values and zeros off diagonal values
void ON_Matrix::SetDiagonal | ( | const ON_SimpleArray< double > & | ) |
sets size to length X lengthdiagonal values and zeros off diagonal values
void ON_Matrix::SetDiagonal | ( | double | ) |
sets diagonal value and zeros off diagonal values
void ON_Matrix::SetDiagonal | ( | int | , |
const double * | |||
) |
sets size to count x count and diagonal values and zeros off diagonal values
bool ON_Matrix::SwapCols | ( | int | , |
int | |||
) |
ints are col indices to swap
bool ON_Matrix::SwapRows | ( | int | , |
int | |||
) |
ints are row indices to swap
bool ON_Matrix::Transpose | ( | ) |
unsigned int ON_Matrix::UnsignedColCount | ( | ) | const |
unsigned int ON_Matrix::UnsignedMaxCount | ( | ) | const |
largest of row and column count
unsigned int ON_Matrix::UnsignedMinCount | ( | ) | const |
smallest of row and column count
unsigned int ON_Matrix::UnsignedRowCount | ( | ) | const |
void ON_Matrix::Zero | ( | ) |
double** ON_Matrix::m = nullptr |
2024-09-05, Pierre: Note that this does not mean the memory allocated is contiguous. m points to the start of m_rowmem[0] in most cases. When the matrix is bigger than max_dblblk_size (see ON_Matrix::Create), m_rowmem does not point to contiguous pieces of memory, and indexing as **(m + i*m_col_count + j) would read into the wrong place. m[i][j] = value at row i and column j