![]() |
KSquare Utilities
|
Supports two dimensional matrices. More...
#include <Matrix.h>
Public Types | |
| typedef Matrix * | MatrixPtr |
Public Member Functions | |
| Matrix () | |
| Matrix (kkint32 _numOfRows, kkint32 _numOfCols) | |
| Matrix (const Matrix &_matrix) | |
| Matrix (const VectorDouble &_v) | |
| ~Matrix () | |
| MatrixPtr | CalcCoFactorMatrix () |
| MatrixPtr | Covariance () const |
| Returns a Covariance matrix. More... | |
| double **const | Data () const |
| double | Determinant () |
| double | DeterminantSlow () |
| Recursive Implementation. More... | |
| void | EigenVectors (MatrixPtr &eigenVectors, VectorDouble *&eigenValues) const |
| Will derive the Eigen vectors and values of the matrix. More... | |
| void | FindMaxValue (double &maxVal, kkint32 &row, kkint32 &col) |
| Locates the maximum value in a matrix along with the row and column that is located. More... | |
| VectorDouble | GetCol (kkint32 col) const |
| Matrix | Inverse () |
| kkint32 | NumOfCols () const |
| kkint32 | NumOfRows () const |
| Matrix | operator* (const Matrix &right) |
| Matrix | operator* (double right) |
| Matrix & | operator*= (double right) |
| Matrix | operator+ (const Matrix &right) |
| Matrix | operator+ (double right) |
| Matrix & | operator+= (double right) |
| Matrix & | operator+= (const Matrix &right) |
| Matrix | operator- (const Matrix &right) |
| Matrix | operator- (double right) |
| Matrix & | operator= (const Matrix &right) |
| Matrix & | operator= (const VectorDouble &right) |
| Row & | operator[] (kkint32 rowIDX) const |
| void | ReSize (kkint32 _numOfRows, kkint32 _numOfCols) |
| bool | Symmetric () const |
| Matrix | Transpose () |
Static Public Member Functions | |
| template<typename T > | |
| static MatrixPtr | BuildFromArray (kkint32 numOfRows, kkint32 numOfCols, T **data) |
| Will create a new matrix using the 2dArray "data" for source. More... | |
Friends | |
| Matrix | operator- (double left, const Matrix &right) |
| std::ostream & | operator<< (std::ostream &os, const Matrix &matrix) |
Supports two dimensional matrices.
Developed for Machine Learning Project for support of Import Vector Machine. Handles two dimensional matrices. Functions supported are matrix addition, subtraction multiplication, transpose, determinant, and inversion. Where appropriate arithmetic arithmetic operators +, -, * were overloaded. Addition, Subtraction and Multiplication can be done against either another matrix or scaler. Also Transpose and Determinant operations are supported.
| typedef Matrix* KKB::Matrix::MatrixPtr |
| Matrix::Matrix | ( | ) |
Definition at line 94 of file Matrix.cpp.
Definition at line 108 of file Matrix.cpp.
References KKB::KKStr::Concat(), KKB::KKException::KKException(), and KKB::KKStr::KKStr().
Referenced by KKB::Raster::BuildGaussian2dKernel(), CalcCoFactorMatrix(), Covariance(), KKB::Raster::CreateGrayScaleKLT(), KKB::Raster::CreateGrayScaleKLTOnMaskedArea(), operator*(), KKB::operator-(), KKMLL::ClassificationBiasMatrix::PerformAdjustmnts(), and Transpose().
| Matrix::Matrix | ( | const Matrix & | _matrix | ) |
Definition at line 142 of file Matrix.cpp.
Referenced by KKMLL::ClassificationBiasMatrix::ClassificationBiasMatrix(), EigenVectors(), operator*(), operator+(), and operator-().
| Matrix::Matrix | ( | const VectorDouble & | _v | ) |
| Matrix::~Matrix | ( | ) |
Definition at line 173 of file Matrix.cpp.
|
static |
Will create a new matrix using the 2dArray "data" for source.
If any row in "data" is equal to NULL then the corresponding row in the returned matrix will be initialized to zeros.
| [in] | numOfRows | Number of rows in resultant matrix. |
| [in] | numOfCols | Number of cols if resultant matrix. |
| [in] | data | A two dimensional array. |
Definition at line 190 of file Matrix.cpp.
| MatrixPtr Matrix::CalcCoFactorMatrix | ( | ) |
Definition at line 606 of file Matrix.cpp.
References Determinant(), Matrix(), operator[](), KKB::Row::operator[](), and KKB::osWaitForEnter().
Referenced by Inverse().
| MatrixPtr Matrix::Covariance | ( | ) | const |
Returns a Covariance matrix.
Each column represents a variable and each row represents an instance of each variable.
Definition at line 1004 of file Matrix.cpp.
References Matrix(), operator[](), and KKB::Row::operator[]().
|
inline |
| double Matrix::Determinant | ( | ) |
Definition at line 945 of file Matrix.cpp.
Referenced by CalcCoFactorMatrix(), and Inverse().
| double Matrix::DeterminantSlow | ( | ) |
Recursive Implementation.
Definition at line 286 of file Matrix.cpp.
References KKB::KKStr::Concat(), KKB::KKException::KKException(), and KKB::KKStr::KKStr().
| void Matrix::EigenVectors | ( | MatrixPtr & | eigenVectors, |
| VectorDouble *& | eigenValues | ||
| ) | const |
Will derive the Eigen vectors and values of the matrix.
Will make use of routines from Numerical Recipes for c++, ex: Tred2 and Tqli.
Definition at line 768 of file Matrix.cpp.
References Matrix(), and Symmetric().
Referenced by KKB::Raster::CreateGrayScaleKLT(), and KKB::Raster::CreateGrayScaleKLTOnMaskedArea().
Locates the maximum value in a matrix along with the row and column that is located.
Definition at line 818 of file Matrix.cpp.
Referenced by KKB::SegmentorOTSU::SegmentImage(), and KKB::SegmentorOTSU::SegmentMaskedImage().
| VectorDouble Matrix::GetCol | ( | kkint32 | col | ) | const |
Definition at line 891 of file Matrix.cpp.
Referenced by KKB::Raster::CreateGrayScaleKLT(), and KKB::Raster::CreateGrayScaleKLTOnMaskedArea().
| Matrix Matrix::Inverse | ( | ) |
Definition at line 731 of file Matrix.cpp.
References CalcCoFactorMatrix(), KKB::KKStr::Concat(), Determinant(), KKB::KKException::KKException(), KKB::KKStr::KKStr(), operator*=(), and Transpose().
Referenced by KKMLL::ClassificationBiasMatrix::PerformAdjustmnts().
|
inline |
Definition at line 126 of file Matrix.h.
Referenced by KKB::operator-(), and operator<<().
|
inline |
Definition at line 128 of file Matrix.h.
Referenced by KKB::operator-(), and operator<<().
Definition at line 478 of file Matrix.cpp.
References KKB::KKStr::Concat(), KKB::KKException::KKException(), KKB::KKStr::KKStr(), and Matrix().
Referenced by KKMLL::ClassificationBiasMatrix::PerformAdjustmnts().
| Matrix Matrix::operator* | ( | double | right | ) |
| Matrix & Matrix::operator*= | ( | double | right | ) |
Definition at line 369 of file Matrix.cpp.
References KKB::KKStr::Concat(), KKB::KKException::KKException(), KKB::KKStr::KKStr(), and Matrix().
Referenced by KKB::SegmentorOTSU::SegmentImage(), and KKB::SegmentorOTSU::SegmentMaskedImage().
| Matrix Matrix::operator+ | ( | double | right | ) |
| Matrix & Matrix::operator+= | ( | double | right | ) |
Definition at line 359 of file Matrix.cpp.
Definition at line 396 of file Matrix.cpp.
References KKB::KKStr::Concat(), KKB::KKException::KKException(), and KKB::KKStr::KKStr().
Definition at line 419 of file Matrix.cpp.
References KKB::KKStr::Concat(), KKB::KKException::KKException(), KKB::KKStr::KKStr(), and Matrix().
Referenced by KKB::SegmentorOTSU::SegmentImage(), and KKB::SegmentorOTSU::SegmentMaskedImage().
| Matrix Matrix::operator- | ( | double | right | ) |
Definition at line 443 of file Matrix.cpp.
References Matrix().
Referenced by KKB::SegmentorOTSU::SegmentImage(), and KKB::SegmentorOTSU::SegmentMaskedImage().
| Matrix & Matrix::operator= | ( | const VectorDouble & | right | ) |
Definition at line 337 of file Matrix.cpp.
Definition at line 270 of file Matrix.cpp.
References KKB::KKStr::Concat(), KKB::KKException::KKException(), and KKB::KKStr::KKStr().
Referenced by KKB::Raster::BuildGaussian2dKernel(), CalcCoFactorMatrix(), Covariance(), KKB::Raster::CreateGrayScaleKLT(), KKB::Raster::CreateGrayScaleKLTOnMaskedArea(), KKMLL::ClassificationBiasMatrix::PerformAdjustmnts(), and KKMLL::ClassificationBiasMatrix::PrintBiasMatrix().
Definition at line 224 of file Matrix.cpp.
Referenced by operator=().
| bool Matrix::Symmetric | ( | ) | const |
Returns true is the matrix is Symmetric
Definition at line 688 of file Matrix.cpp.
Referenced by EigenVectors().
| Matrix Matrix::Transpose | ( | ) |
Definition at line 707 of file Matrix.cpp.
References Matrix().
Referenced by Inverse(), and KKMLL::ClassificationBiasMatrix::PerformAdjustmnts().
|
friend |