📄 cmat.h
字号:
#ifndef MATRIX_H
#define MATRIX_H
#define valtype float
#define valtype2 float
#define MAX_NAME 10
#include "CMemory.h"
class CMatrixSym;
class CVect;
class CDiag;
class CMatrix : public CObject
{
protected:
long col, li; /*Number of columns and lines of the matrix*/
CMemory *pMem; /*Ptr to a CMemory obj containing the*/
/*values : a(1,1) a(1,2) ... a(1,col) ... a(li,col)*/
valtype *pData; /*Pointer to the matrix's value if pMem is locked*/
BOOL bTranspose; /*tells if the matrix is transposed*/
BOOL bLocked; /*tells if pMem is locked */
CMemory *pMemName; /*points to a list of string, containing the name of each column vector*/
public:
CMatrix();
CMatrix(long l, long c);
~CMatrix();
int Save(char *filename);
int Load(char *filename);
void Add(CMatrix *pMat2); /*Add to this matrix the matrix pMat2*/
void Multiply(CMatrix *pMat1, CMatrix *pMat2, BOOL bResize = FALSE, long lNewRow = 0, long lNewCol = 0);
/*Put into this pMat1*pMat2*/
void Multiply(CDiag *pDiag, BOOL bResize = TRUE);
/*Multiply this matrix by the diagonal matrix pDiag*/
void NormalizeCol(); /*Normalize each column*/
void OuterProduct(CMatrixSym *pMat); /*Compute the outer product of pMat*/
void InnerProduct(CMatrixSym *pMat); /*Compute the inner product of pMat*/
void InnerProduct(CMatrix *pMat); /*Compute the inner product of pMat*/
void Initialize(); /*Sets all the elements to 0*/
void SetTranspose(BOOL bTransposet); /*Set the bTranspose parameter*/
virtual long GetCol();
virtual long GetLi();
virtual void Lock(); /*Lock pMem and validate pData*/
virtual void Unlock(); /*Unlock pMem and Unvalidate pData*/
virtual int Eigen(CVect *ev, long leigen); /*Compute the eigenvectors of this matrix*/
void Expand(long c, float *scale, float *shift, valtype dest_min, valtype dest_max);
int GetColName(long c, char *str, int len); /*copy in str the name of the column vector c*/
int SetColName(long c, char *str); /*set the name of the column vector c to str*/
public:
virtual void Allocate(long, long);
virtual void Allocate(); /*Allocate (or reallocate) the memory*/
/*needed by pData; Call the CMemory's Allocate fct*/
public:
virtual valtype GetAt(long l, long c);
virtual void SetAt(long l, long c, valtype value);
};
#endif /*MATRIX_H*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -