本文整理汇总了C++中GeneralMatrix::nCol方法的典型用法代码示例。如果您正苦于以下问题:C++ GeneralMatrix::nCol方法的具体用法?C++ GeneralMatrix::nCol怎么用?C++ GeneralMatrix::nCol使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeneralMatrix
的用法示例。
在下文中一共展示了GeneralMatrix::nCol方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: result
GeneralMatrix GeneralMatrix::operator * (const GeneralMatrix& other) const
{
int i,j,k;
GeneralMatrix result(this->nRow(),other.nCol());
if(other.nRow()!=this->nCol())
{
for (i=0;i<result.nRow();i++)
for (j=0;j<result.nCol();j++)
result.GetElemP(i,j)->val = ERRORVAL;
return result;
}
for (i=0;i<this->nRow();i++) //矩阵相乘的计算
{
for(j=0;j<other.nCol();j++)
{
for(k = 0; k < other.nRow(); k++)
{
if ((this->GetElem(i,k)!=0)&&(other.GetElem(k,j)!=0))
{
result[i][j] += this->GetElem(i,k) * other.GetElem(k,j);
}
}
}
}
return result;
}
示例2: Jointer_Right
bool GeneralMatrix::Jointer_Right(GeneralMatrix& other)
{
if(other.nRow()!=nRow()) return FALSE;
if(!AddCols(other.nCol(),ERRORVAL))
return FALSE;
Paste(other,0,nCol()-other.nCol());
return TRUE;
}
示例3: Paste
bool GeneralMatrix::Paste(GeneralMatrix& other,int top,int left) const
{
int i,j,iRow,iCol;
iRow = other.nRow()>(nRow()-top) ? (nRow()-top) : other.nRow();
iCol = other.nCol()>(nCol()-left) ? (nCol()-left): other.nCol();
for(i=0;i<iRow;i++)
for(j=0;j<iCol;j++)
GetElem(i+top,j+left) = other[i][j];
return TRUE;
}
示例4: Jointer_Diagonal
bool GeneralMatrix::Jointer_Diagonal(GeneralMatrix& other,ELEMTYPE Val)
{
int iCol;
iCol = nRow()==0 ? other.nCol()-1 : other.nCol();
if(!AddRows(other.nRow(),Val))
return FALSE;
if(!AddCols(iCol,Val))
return FALSE;
return Paste(other,nRow()-other.nRow(),nCol()-other.nCol());
}
示例5: GetElem
bool GeneralMatrix::CutIn2_Vertical(GeneralMatrix& Left,GeneralMatrix& Right,int iCol)
{
int i,j;
if (nCol()==0)
{
Left.ReSize(0,0);
Right.ReSize(0,0);
return TRUE;
}
if(iCol>nCol()||iCol<0) return FALSE;
if(!Left.ReSize(nRow(),iCol,ERRORVAL))
return FALSE;
if(!Right.ReSize(nRow(),nCol()-iCol,ERRORVAL))
return FALSE;
for(i=0;i<nRow();i++)
for(j=0;j<iCol;j++)
Left[i][j] = GetElem(i,j);
for(i=0;i<nRow();i++)
for(j=0;j<Right.nCol();j++)
Right[i][j] = GetElem(i,j+iCol);
return TRUE;
}
示例6: Jointer_bottom
bool GeneralMatrix::Jointer_bottom(GeneralMatrix& other)
{
if(other.nCol()!=nCol()) return FALSE;
if(!AddRows(other.nRow(),ERRORVAL))
return FALSE;
return Paste(other,nRow()-other.nRow(),0);
}
示例7: Distance_E
ELEMTYPE GeneralMatrix::Distance_E(GeneralMatrix& other) const
{
int i,j;
ELEMTYPE result = ERRORVAL;
if(nRow()!=other.nRow()||nCol()!=other.nCol()) return result;
for(result=0,i=0;i<nRow();i++)
for(j=0;j<nCol();j++)
result += pow(GetElem(i,j)-other[i][j],2);
return sqrt(result);
}
示例8: AddRows
GeneralMatrix::GeneralMatrix(const GeneralMatrix& other)
{
pHead = new HeadNode;
pHead->nRow = 0;
pHead->nCol = 0;
pHead->pFirst = NULL;
AddRows(other.nRow(),0.0);
AddCols(other.nCol()-1,0.0);
*this += other;
}
示例9: GetPart
GeneralMatrix GeneralMatrix::GetPart(int left,int top,int bottom,int right) const
{
int i,j;
GeneralMatrix result;
if(left>right||top>bottom||right>=nCol()||bottom>=nRow()||left<0||top<0||right<0||bottom<0) return result;
if(!result.ReSize(bottom-top+1,right-left+1,ERRORVAL))
return result;
for(i=0;i<result.nRow();i++)
for(j=0;j<result.nCol();j++)
result[i][j] = GetElem(i+left,j+top);
return result;
}
示例10:
//////////////////////////////////////////////////////////////////////
// 重载运算符==,判断矩阵是否相等
//
// 参数:
// 1. const GeneralMatrix& other - 用于比较的矩阵
//
// 返回值:BOOL 型,两个矩阵相等则为TRUE,否则为FALSE
//////////////////////////////////////////////////////////////////////
bool GeneralMatrix::operator==(const GeneralMatrix& other) const
{
// 首先检查行列数是否相等
if (this->nCol() != other.nCol() || this->nRow() != other.nRow())
return FALSE;
for (int i=0; i<nRow(); ++i)
{
for (int j=0; j<nCol(); ++j)
{
if (this->GetElem(i,j)!=other.GetElem(i,j))
return FALSE;
}
}
return TRUE;
}