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; }
bool GeneralMatrix::ReSize(int iRow,int iCol, ELEMTYPE Val)const { if(iRow<0||iCol<0) return FALSE; if(iRow==0) iCol = 0; AddRows(iRow-nRow(),Val); AddCols(iCol-nCol(),Val); return TRUE; }
GeneralMatrix::GeneralMatrix(int iRow,int iCol) { pHead = new HeadNode; pHead->nRow = 0; pHead->nCol = 0; pHead->pFirst = NULL; if(iRow<=0||iCol<=0) return; AddRows(iRow,0.0); AddCols(iCol-1,0.0); }
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()); }
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; }
SMatrix::SMatrix(int iRow,int iCol,ELEMTYPE Val) { pHead = new HeadNode; pHead->nRow = 0; pHead->nCol = 0; pHead->pFirst = NULL; if(iRow<=0||iCol<=0) return; AddRows(iRow,Val); AddCols(iCol-1,Val); }
void CsxManager<IndexType, ValueType>:: DoRow(typename SparsePartition<IndexType, ValueType>::iterator &rbegin, typename SparsePartition<IndexType, ValueType>::iterator &rend, IndexType row) { vector<IndexType> cols; span_ = 0; last_col_ = 1; typename SparsePartition<IndexType, ValueType>::iterator &ri = rbegin; for (; ri != rend; ++ri) { // LOG_DEBUG << "\t" << *ri << "\n"; // Check if this element contains a pattern. if ((*ri).IsPattern()) { UpdateRowSpan(*ri); PreparePat(cols); assert(cols.size() == 0); AddPattern(*ri); const ValueType *elem_vals = &(*ri).GetValues(); copy(elem_vals, elem_vals + (*ri).GetSize(), values_ + values_idx_); values_idx_ += (*ri).GetSize(); continue; } // Check if we exceeded the maximum size for a unit. assert(cols.size() <= CTL_SIZE_MAX); if (cols.size() == CTL_SIZE_MAX) AddCols(cols); cols.push_back((*ri).GetCol()); values_[values_idx_++] = (*ri).GetValue(); } if (cols.size() > 0) AddCols(cols); }
bool GeneralMatrix::T_Self() { GeneralMatrix Temp(this->nCol(),this->nRow()); int i,j; if(this->nCol()<2&&this->nRow()<2) return TRUE; Temp = this->Transpose(); i = this->nCol() - this->nRow(); j = this->nRow() - this->nCol(); AddRows(i,0.0); AddCols(j,0.0); *this = Temp; return TRUE; }
void CsxManager<IndexType, ValueType>:: PreparePat(vector<IndexType> &cols) { if (cols.size() != 0) AddCols(cols); }