📄 vector.h
字号:
//---------------------------------------------------------------------------
#ifndef VectorH
#define VectorH
#include "Matrix.h"
//---------------------------------------------------------------------------
//列向量TColumnVector
class TCVector:protected TMatrix
{
public:
TCVector(unsigned int aRowCount):TMatrix(aRowCount,1)
{
}
TCVector(TCVector &aAnother):TMatrix(aAnother)
{
}
TCVector(TCVector *aAnother):TMatrix(aAnother)
{
}
//取元素
TMVALUE& operator()(unsigned int aI)
{
return (*(TMatrix*)this)(aI,1);
}
//转置
TMatrix operator~(void)
{
return ~(*(TMatrix*)this);
}
//重载=号操作符
TMatrix operator=(TMatrix aAnother)
{
return (*(TMatrix*)this)=(aAnother);
}
//重载+号操作符
TMatrix operator+(TMatrix aAnother)
{
return (*(TMatrix*)this)+(aAnother);
}
//重载-号操作符
TMatrix operator-(TMatrix aAnother)
{
return (*(TMatrix*)this)-(aAnother);
}
//重载*号操作符
TMatrix operator*(TMatrix aAnother)
{
return (*(TMatrix*)this)*(aAnother);
}
//重载==号操作符
bool operator==(TMatrix aAnother)
{
return (*(TMatrix*)this)==(aAnother);
}
void Reset(unsigned int aRowCount)
{
TMatrix::Reset(aRowCount,1);
}
unsigned int GetDimCount()
{
return TMatrix::GetRowCount();
}
operator<=(TMVALUE aValue)
{
unsigned int lDimCount = TMatrix::GetRowCount();
for (unsigned i=0;i<=lDimCount;i++)
if ((*(TMatrix*)this)(i,1) > aValue)
return false;
return true;
}
};
//---------------------------------------------------------------------------
//行向量
class TRVector:protected TMatrix
{
public:
TRVector(unsigned int aColCount):TMatrix(1,aColCount)
{
}
TRVector(TRVector &aAnother):TMatrix(aAnother)
{
}
TRVector(TRVector *aAnother):TMatrix(aAnother)
{
}
//取元素
TMVALUE& operator()(unsigned int aJ)
{
return (*(TMatrix*)this)(1,aJ);
}
//转置
TMatrix operator~(void)
{
return ~(*(TMatrix*)this);
}
//重载=号操作符
TMatrix operator=(TMatrix aAnother)
{
return (*(TMatrix*)this)=(aAnother);
}
//重载+号操作符
TMatrix operator+(TMatrix aAnother)
{
return (*(TMatrix*)this)+(aAnother);
}
//重载-号操作符
TMatrix operator-(TMatrix aAnother)
{
return (*(TMatrix*)this)-(aAnother);
}
//重载*号操作符
TMatrix operator*(TMatrix aAnother)
{
return (*(TMatrix*)this)*(aAnother);
}
//重载==号操作符
bool operator==(TMatrix aAnother)
{
return (*(TMatrix*)this)==(aAnother);
}
void Reset(unsigned int aColCount)
{
TMatrix::Reset(1,aColCount);
}
unsigned int GetDimCount()
{
return TMatrix::GetColCount();
}
operator<=(TMVALUE aValue)
{
unsigned int lDimCount = TMatrix::GetColCount();
for (unsigned i=0;i<=lDimCount;i++)
if ((*(TMatrix*)this)(1,i) > aValue)
return false;
return true;
}
};
//---------------------------------------------------------------------------
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -