本文整理汇总了C++中GeneralMatrix类的典型用法代码示例。如果您正苦于以下问题:C++ GeneralMatrix类的具体用法?C++ GeneralMatrix怎么用?C++ GeneralMatrix使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GeneralMatrix类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetElem
bool GeneralMatrix::CutIn2_Across(GeneralMatrix& Upper,GeneralMatrix& Lower,int iRow)
{
int i,j;
if (nCol()==0)
{
Upper.ReSize(0,0);
Lower.ReSize(0,0);
return TRUE;
}
if(iRow>nRow()||iRow<0) return FALSE;
if(!Upper.ReSize(iRow,nCol(),ERRORVAL))
return FALSE;
if(!Lower.ReSize(nRow()-iRow,nCol(),ERRORVAL))
return FALSE;
for(i=0;i<iRow;i++)
for(j=0;j<nCol();j++)
Upper[i][j] = GetElem(i,j);
for(i=0;i<Lower.nRow();i++)
for(j=0;j<nCol();j++)
Lower[i][j] = GetElem(i+iRow,j);
return TRUE;
}
示例2: tr
void GetSubMatrix::operator<<(const BaseMatrix& bmx)
{
REPORT
Tracer tr("SubMatrix(<<)"); GeneralMatrix* gmx = 0;
Try
{
SetUpLHS(); gmx = ((BaseMatrix&)bmx).Evaluate();
if (row_number != gmx->Nrows() || col_number != gmx->Ncols())
Throw(IncompatibleDimensionsException());
MatrixRow mrx(gmx, LoadOnEntry);
MatrixRow mr(gm, LoadOnEntry+StoreOnExit+DirectPart, row_skip);
// do need LoadOnEntry
MatrixRowCol sub; int i = row_number;
while (i--)
{
mr.SubRowCol(sub, col_skip, col_number); // put values in sub
sub.Copy(mrx); mr.Next(); mrx.Next();
}
gmx->tDelete();
}
CatchAll
{
if (gmx) gmx->tDelete();
ReThrow;
}
}
示例3: tr
void GetSubMatrix::operator-=(const BaseMatrix& bmx)
{
REPORT
Tracer tr("SubMatrix(-=)"); GeneralMatrix* gmx = 0;
// MatrixConversionCheck mcc; // Check for loss of info
Try
{
SetUpLHS(); gmx = ((BaseMatrix&)bmx).Evaluate();
if (row_number != gmx->Nrows() || col_number != gmx->Ncols())
Throw(IncompatibleDimensionsException());
MatrixRow mrx(gmx, LoadOnEntry);
MatrixRow mr(gm, LoadOnEntry+StoreOnExit+DirectPart, row_skip);
// do need LoadOnEntry
MatrixRowCol sub; int i = row_number;
while (i--)
{
mr.SubRowCol(sub, col_skip, col_number); // put values in sub
sub.Check(mrx); // check for loss of info
sub.Sub(mrx); mr.Next(); mrx.Next();
}
gmx->tDelete();
#ifdef TEMPS_DESTROYED_QUICKLY
delete this;
#endif
}
CatchAll
{
if (gmx) gmx->tDelete();
#ifdef TEMPS_DESTROYED_QUICKLY
delete this;
#endif
ReThrow;
}
}
示例4: warn_deprecated
void BandMatrix::copyData(const GeneralMatrix& y)
{
warn_deprecated("BandMatrix::copyData", "To be removed after Cantera 2.2.");
m_factored = false;
size_t n = sizeof(doublereal) * m_n * (2 *m_kl + m_ku + 1);
GeneralMatrix* yyPtr = const_cast<GeneralMatrix*>(&y);
(void) memcpy(DATA_PTR(data), yyPtr->ptrColumn(0), n);
}
示例5: 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);
}
示例6: lambda
SymSchurDecomp::SymSchurDecomp(const GeneralMatrix& mata)
: lambda(mata.numRows()), q(mata.numRows())
{
// check mata is square
if (mata.numRows() != mata.numCols())
throw SYLV_MES_EXCEPTION("Matrix is not square in SymSchurDecomp constructor");
// prepare for dsyevr
const char* jobz = "V";
const char* range = "A";
const char* uplo = "U";
lapack_int n = mata.numRows();
GeneralMatrix tmpa(mata);
double* a = tmpa.base();
lapack_int lda = tmpa.getLD();
double dum;
double* vl = &dum;
double* vu = &dum;
lapack_int idum;
lapack_int* il = &idum;
lapack_int* iu = &idum;
double abstol = 0.0;
lapack_int m = n;
double* w = lambda.base();
double* z = q.base();
lapack_int ldz = q.getLD();
lapack_int* isuppz = new lapack_int[2*std::max(1,(int) m)];
double tmpwork;
lapack_int lwork = -1;
lapack_int tmpiwork;
lapack_int liwork = -1;
lapack_int info;
// query for lwork and liwork
dsyevr(jobz, range, uplo, &n, a, &lda, vl, vu, il, iu, &abstol,
&m, w, z, &ldz, isuppz, &tmpwork, &lwork, &tmpiwork, &liwork, &info);
lwork = (int)tmpwork;
liwork = tmpiwork;
// allocate work arrays
double* work = new double[lwork];
lapack_int* iwork = new lapack_int[liwork];
// do the calculation
dsyevr(jobz, range, uplo, &n, a, &lda, vl, vu, il, iu, &abstol,
&m, w, z, &ldz, isuppz, work, &lwork, iwork, &liwork, &info);
if (info < 0)
throw SYLV_MES_EXCEPTION("Internal error in SymSchurDecomp constructor");
if (info > 0)
throw SYLV_MES_EXCEPTION("Internal LAPACK error in DSYEVR");
delete [] work;
delete [] iwork;
delete [] isuppz;
}
示例7: SortDescending
void SortDescending(GeneralMatrix& GM)
{
Tracer et("QuickSortDescending");
Real* data = GM.Store(); int max = GM.Storage();
if (max > DoSimpleSort) MyQuickSortDescending(data, data + max - 1, 0);
InsertionSortDescending(data, max, DoSimpleSort);
}
示例8: 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;
}
示例9: result
GeneralMatrix operator * (double value ,const GeneralMatrix& other)
{
int i,j;
GeneralMatrix result(other);
for (i=0;i<other.nRow();i++)
for(j=0;j<other.nCol();j++)
result[i][j] *= value;
return result;
}
示例10: 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;
}
示例11: 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());
}
示例12: 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;
}
示例13: 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);
}
示例14: MatrixDetails
static void MatrixDetails(const GeneralMatrix& A)
// write matrix details to Exception buffer
{
MatrixBandWidth bw = A.BandWidth(); int ubw = bw.upper; int lbw = bw.lower;
Exception::AddMessage("MatrixType = ");
Exception::AddMessage(A.Type().Value());
Exception::AddMessage(" # Rows = "); Exception::AddInt(A.Nrows());
Exception::AddMessage("; # Cols = "); Exception::AddInt(A.Ncols());
if (lbw >=0)
{ Exception::AddMessage("; lower BW = "); Exception::AddInt(lbw); }
if (ubw >=0)
{ Exception::AddMessage("; upper BW = "); Exception::AddInt(ubw); }
Exception::AddMessage("\n");
}
示例15:
//----------------------------------------------------------------------
GeneralMatrix GeneralMatrix::operator * (double x)
{
GeneralMatrix m;
m.copyFrom(this);
if (!isSparse)
{
for (int j=0; j<nBlock; j++) m.mat[j] = x*mat[j];
return m;
}
else
{
for (int j=0; j<nBlock; j++) m.smat[j] = x*smat[j];
return m;
}
}