Files
GlobalCppEnv/halcon/include/halconcpp/HMatrix.h
T

437 lines
14 KiB
C++
Raw Normal View History

2025-03-26 01:06:45 +08:00
/***********************************************************
* File generated by the HALCON-Compiler hcomp version 18.05
* Usage: Interface to C++
*
* Software by: MVTec Software GmbH, www.mvtec.com
***********************************************************/
#ifndef HCPP_HMATRIX
#define HCPP_HMATRIX
namespace HalconCpp
{
// Represents an instance of a matrix.
class LIntExport HMatrix : public HHandle
{
public:
// Create an uninitialized instance
HMatrix():HHandle() {}
// Copy constructor
HMatrix(const HMatrix& source) : HHandle(source) {}
// Copy constructor
HMatrix(const HHandle& handle);
// Create HMatrix from handle, taking ownership
explicit HMatrix(Hlong handle);
bool operator==(const HHandle& obj) const
{
return HHandleBase::operator==(obj);
}
bool operator!=(const HHandle& obj) const
{
return HHandleBase::operator!=(obj);
}
protected:
// Verify matching semantic type ('matrix')!
virtual void AssertType(Hphandle handle) const;
public:
// Deep copy of all data represented by this object instance
HMatrix Clone() const;
/*****************************************************************************
* Operator-based class constructors
*****************************************************************************/
// read_matrix: Read a matrix from a file.
explicit HMatrix(const HString& FileName);
// read_matrix: Read a matrix from a file.
explicit HMatrix(const char* FileName);
// create_matrix: Create a matrix.
explicit HMatrix(Hlong Rows, Hlong Columns, const HTuple& Value);
// create_matrix: Create a matrix.
explicit HMatrix(Hlong Rows, Hlong Columns, double Value);
/*****************************************************************************
* Operator overloads (non-member overloads reside in HOperatorOverloads.h)
*****************************************************************************/
// Negate matrix
HMatrix operator - () const;
// Cast to HTuple
#if defined(HCPP_LEGACY_HANDLE_API)
// Up to HALCON 13.0 it used to return all matrix elements,
// keep this behavior in place for legacy code
operator HTuple() const
{
return GetFullMatrix();
}
#else
// However for consistency with new handle mechanism cast HMatrix
// should keep the case class behavior and wrap the handle instead.
#endif
// Access matrix element
double operator () (Hlong row, Hlong column) const;
/*****************************************************************************
* Non-generic convenience members
*****************************************************************************/
Hlong NumRows() const;
Hlong NumColumns() const;
/***************************************************************************
* Operators *
***************************************************************************/
// Deserialize a serialized matrix.
void DeserializeMatrix(const HSerializedItem& SerializedItemHandle);
// Serialize a matrix.
HSerializedItem SerializeMatrix() const;
// Read a matrix from a file.
void ReadMatrix(const HString& FileName);
// Read a matrix from a file.
void ReadMatrix(const char* FileName);
// Write a matrix to a file.
void WriteMatrix(const HString& FileFormat, const HString& FileName) const;
// Write a matrix to a file.
void WriteMatrix(const char* FileFormat, const char* FileName) const;
// Perform an orthogonal decomposition of a matrix.
HMatrix OrthogonalDecomposeMatrix(const HString& DecompositionType, const HString& OutputMatricesType, const HString& ComputeOrthogonal, HMatrix* MatrixTriangularID) const;
// Perform an orthogonal decomposition of a matrix.
HMatrix OrthogonalDecomposeMatrix(const char* DecompositionType, const char* OutputMatricesType, const char* ComputeOrthogonal, HMatrix* MatrixTriangularID) const;
// Decompose a matrix.
HMatrix DecomposeMatrix(const HString& MatrixType, HMatrix* Matrix2ID) const;
// Decompose a matrix.
HMatrix DecomposeMatrix(const char* MatrixType, HMatrix* Matrix2ID) const;
// Compute the singular value decomposition of a matrix.
HMatrix SvdMatrix(const HString& SVDType, const HString& ComputeSingularVectors, HMatrix* MatrixSID, HMatrix* MatrixVID) const;
// Compute the singular value decomposition of a matrix.
HMatrix SvdMatrix(const char* SVDType, const char* ComputeSingularVectors, HMatrix* MatrixSID, HMatrix* MatrixVID) const;
// Compute the generalized eigenvalues and optionally the generalized eigenvectors of general matrices.
void GeneralizedEigenvaluesGeneralMatrix(const HMatrix& MatrixBID, const HString& ComputeEigenvectors, HMatrix* EigenvaluesRealID, HMatrix* EigenvaluesImagID, HMatrix* EigenvectorsRealID, HMatrix* EigenvectorsImagID) const;
// Compute the generalized eigenvalues and optionally the generalized eigenvectors of general matrices.
void GeneralizedEigenvaluesGeneralMatrix(const HMatrix& MatrixBID, const char* ComputeEigenvectors, HMatrix* EigenvaluesRealID, HMatrix* EigenvaluesImagID, HMatrix* EigenvectorsRealID, HMatrix* EigenvectorsImagID) const;
// Compute the generalized eigenvalues and optionally generalized eigenvectors of symmetric input matrices.
HMatrix GeneralizedEigenvaluesSymmetricMatrix(const HMatrix& MatrixBID, const HString& ComputeEigenvectors, HMatrix* EigenvectorsID) const;
// Compute the generalized eigenvalues and optionally generalized eigenvectors of symmetric input matrices.
HMatrix GeneralizedEigenvaluesSymmetricMatrix(const HMatrix& MatrixBID, const char* ComputeEigenvectors, HMatrix* EigenvectorsID) const;
// Compute the eigenvalues and optionally the eigenvectors of a general matrix.
void EigenvaluesGeneralMatrix(const HString& ComputeEigenvectors, HMatrix* EigenvaluesRealID, HMatrix* EigenvaluesImagID, HMatrix* EigenvectorsRealID, HMatrix* EigenvectorsImagID) const;
// Compute the eigenvalues and optionally the eigenvectors of a general matrix.
void EigenvaluesGeneralMatrix(const char* ComputeEigenvectors, HMatrix* EigenvaluesRealID, HMatrix* EigenvaluesImagID, HMatrix* EigenvectorsRealID, HMatrix* EigenvectorsImagID) const;
// Compute the eigenvalues and optionally eigenvectors of a symmetric matrix.
HMatrix EigenvaluesSymmetricMatrix(const HString& ComputeEigenvectors, HMatrix* EigenvectorsID) const;
// Compute the eigenvalues and optionally eigenvectors of a symmetric matrix.
HMatrix EigenvaluesSymmetricMatrix(const char* ComputeEigenvectors, HMatrix* EigenvectorsID) const;
// Compute the solution of a system of equations.
HMatrix SolveMatrix(const HString& MatrixLHSType, double Epsilon, const HMatrix& MatrixRHSID) const;
// Compute the solution of a system of equations.
HMatrix SolveMatrix(const char* MatrixLHSType, double Epsilon, const HMatrix& MatrixRHSID) const;
// Compute the determinant of a matrix.
double DeterminantMatrix(const HString& MatrixType) const;
// Compute the determinant of a matrix.
double DeterminantMatrix(const char* MatrixType) const;
// Invert a matrix.
void InvertMatrixMod(const HString& MatrixType, double Epsilon) const;
// Invert a matrix.
void InvertMatrixMod(const char* MatrixType, double Epsilon) const;
// Invert a matrix.
HMatrix InvertMatrix(const HString& MatrixType, double Epsilon) const;
// Invert a matrix.
HMatrix InvertMatrix(const char* MatrixType, double Epsilon) const;
// Transpose a matrix.
void TransposeMatrixMod() const;
// Transpose a matrix.
HMatrix TransposeMatrix() const;
// Returns the elementwise maximum of a matrix.
HMatrix MaxMatrix(const HString& MaxType) const;
// Returns the elementwise maximum of a matrix.
HMatrix MaxMatrix(const char* MaxType) const;
// Returns the elementwise minimum of a matrix.
HMatrix MinMatrix(const HString& MinType) const;
// Returns the elementwise minimum of a matrix.
HMatrix MinMatrix(const char* MinType) const;
// Compute the power functions of a matrix.
void PowMatrixMod(const HString& MatrixType, const HTuple& Power) const;
// Compute the power functions of a matrix.
void PowMatrixMod(const HString& MatrixType, double Power) const;
// Compute the power functions of a matrix.
void PowMatrixMod(const char* MatrixType, double Power) const;
// Compute the power functions of a matrix.
HMatrix PowMatrix(const HString& MatrixType, const HTuple& Power) const;
// Compute the power functions of a matrix.
HMatrix PowMatrix(const HString& MatrixType, double Power) const;
// Compute the power functions of a matrix.
HMatrix PowMatrix(const char* MatrixType, double Power) const;
// Compute the power functions of the elements of a matrix.
void PowElementMatrixMod(const HMatrix& MatrixExpID) const;
// Compute the power functions of the elements of a matrix.
HMatrix PowElementMatrix(const HMatrix& MatrixExpID) const;
// Compute the power functions of the elements of a matrix.
void PowScalarElementMatrixMod(const HTuple& Power) const;
// Compute the power functions of the elements of a matrix.
void PowScalarElementMatrixMod(double Power) const;
// Compute the power functions of the elements of a matrix.
HMatrix PowScalarElementMatrix(const HTuple& Power) const;
// Compute the power functions of the elements of a matrix.
HMatrix PowScalarElementMatrix(double Power) const;
// Compute the square root values of the elements of a matrix.
void SqrtMatrixMod() const;
// Compute the square root values of the elements of a matrix.
HMatrix SqrtMatrix() const;
// Compute the absolute values of the elements of a matrix.
void AbsMatrixMod() const;
// Compute the absolute values of the elements of a matrix.
HMatrix AbsMatrix() const;
// Norm of a matrix.
double NormMatrix(const HString& NormType) const;
// Norm of a matrix.
double NormMatrix(const char* NormType) const;
// Returns the elementwise mean of a matrix.
HMatrix MeanMatrix(const HString& MeanType) const;
// Returns the elementwise mean of a matrix.
HMatrix MeanMatrix(const char* MeanType) const;
// Returns the elementwise sum of a matrix.
HMatrix SumMatrix(const HString& SumType) const;
// Returns the elementwise sum of a matrix.
HMatrix SumMatrix(const char* SumType) const;
// Divide matrices element-by-element.
void DivElementMatrixMod(const HMatrix& MatrixBID) const;
// Divide matrices element-by-element.
HMatrix DivElementMatrix(const HMatrix& MatrixBID) const;
// Multiply matrices element-by-element.
void MultElementMatrixMod(const HMatrix& MatrixBID) const;
// Multiply matrices element-by-element.
HMatrix MultElementMatrix(const HMatrix& MatrixBID) const;
// Scale a matrix.
void ScaleMatrixMod(const HTuple& Factor) const;
// Scale a matrix.
void ScaleMatrixMod(double Factor) const;
// Scale a matrix.
HMatrix ScaleMatrix(const HTuple& Factor) const;
// Scale a matrix.
HMatrix ScaleMatrix(double Factor) const;
// Subtract two matrices.
void SubMatrixMod(const HMatrix& MatrixBID) const;
// Subtract two matrices.
HMatrix SubMatrix(const HMatrix& MatrixBID) const;
// Add two matrices.
void AddMatrixMod(const HMatrix& MatrixBID) const;
// Add two matrices.
HMatrix AddMatrix(const HMatrix& MatrixBID) const;
// Multiply two matrices.
void MultMatrixMod(const HMatrix& MatrixBID, const HString& MultType) const;
// Multiply two matrices.
void MultMatrixMod(const HMatrix& MatrixBID, const char* MultType) const;
// Multiply two matrices.
HMatrix MultMatrix(const HMatrix& MatrixBID, const HString& MultType) const;
// Multiply two matrices.
HMatrix MultMatrix(const HMatrix& MatrixBID, const char* MultType) const;
// Get the size of a matrix.
void GetSizeMatrix(Hlong* Rows, Hlong* Columns) const;
// Repeat a matrix.
HMatrix RepeatMatrix(Hlong Rows, Hlong Columns) const;
// Copy a matrix.
HMatrix CopyMatrix() const;
// Set the diagonal elements of a matrix.
void SetDiagonalMatrix(const HMatrix& VectorID, Hlong Diagonal) const;
// Get the diagonal elements of a matrix.
HMatrix GetDiagonalMatrix(Hlong Diagonal) const;
// Set a sub-matrix of a matrix.
void SetSubMatrix(const HMatrix& MatrixSubID, Hlong Row, Hlong Column) const;
// Get a sub-matrix of a matrix.
HMatrix GetSubMatrix(Hlong Row, Hlong Column, Hlong RowsSub, Hlong ColumnsSub) const;
// Set all values of a matrix.
void SetFullMatrix(const HTuple& Values) const;
// Set all values of a matrix.
void SetFullMatrix(double Values) const;
// Return all values of a matrix.
HTuple GetFullMatrix() const;
// Set one or more elements of a matrix.
void SetValueMatrix(const HTuple& Row, const HTuple& Column, const HTuple& Value) const;
// Set one or more elements of a matrix.
void SetValueMatrix(Hlong Row, Hlong Column, double Value) const;
// Return one ore more elements of a matrix.
HTuple GetValueMatrix(const HTuple& Row, const HTuple& Column) const;
// Return one ore more elements of a matrix.
double GetValueMatrix(Hlong Row, Hlong Column) const;
// Free the memory of a matrix.
static void ClearMatrix(const HMatrixArray& MatrixID);
// Free the memory of a matrix.
void ClearMatrix() const;
// Create a matrix.
void CreateMatrix(Hlong Rows, Hlong Columns, const HTuple& Value);
// Create a matrix.
void CreateMatrix(Hlong Rows, Hlong Columns, double Value);
};
// forward declarations and types for internal array implementation
template<class T> class HSmartPtr;
template<class T> class HHandleBaseArrayRef;
typedef HHandleBaseArrayRef<HMatrix> HMatrixArrayRef;
typedef HSmartPtr< HMatrixArrayRef > HMatrixArrayPtr;
// Represents multiple tool instances
class LIntExport HMatrixArray : public HHandleBaseArray
{
public:
// Create empty array
HMatrixArray();
// Create array from native array of tool instances
HMatrixArray(HMatrix* classes, Hlong length);
// Copy constructor
HMatrixArray(const HMatrixArray &tool_array);
// Destructor
virtual ~HMatrixArray();
// Assignment operator
HMatrixArray &operator=(const HMatrixArray &tool_array);
// Clears array and all tool instances
virtual void Clear();
// Get array of native tool instances
const HMatrix* Tools() const;
// Get number of tools
virtual Hlong Length() const;
// Create tool array from tuple of handles
virtual void SetFromTuple(const HTuple& handles);
// Get tuple of handles for tool array
virtual HTuple ConvertToTuple() const;
protected:
// Smart pointer to internal data container
HMatrixArrayPtr *mArrayPtr;
};
}
#endif