19 : matrixGraph_(matrixGraph),
20 sparseRowGraph_(sparseRowGraph),
21 coefs_(sparseRowGraph->packedColumnIndices.size(), 0.0),
46 {
return(
"fei::Matrix_Local" ); }
90 if (idx < 0)
return(idx);
100 for(
unsigned i=0; i<
coefs_.size(); ++i)
coefs_[i] = scalar;
109 if (idx < 0)
return(idx);
113 if (length > len) length = len;
115 for(
int i=0; i<length; ++i) {
117 coefs[i] =
coefs_[offset+i];
125 int numCols,
const int* cols,
126 const double*
const* values,
130 if (numRows == 0 || numCols == 0) {
138 const double** myvalues =
const_cast<const double**
>(values);
145 for(
int i=0; i<numRows; ++i) {
148 throw std::runtime_error(
"fei::Matrix_Local::sumIn ERROR, row not found.");
155 double* coefs = &(
coefs_[offset]);
157 for(
int j=0; j<numCols; ++j) {
160 throw std::runtime_error(
"fei::Matrix_Local::sumIn ERROR, col not found.");
164 coefs[idx2] += myvalues[i][j];
167 coefs[idx2] = myvalues[i][j];
178 int numCols,
const int* cols,
179 const double*
const* values,
182 return(
giveToMatrix(numRows, rows, numCols, cols, values,
188 int numCols,
const int* cols,
189 const double*
const* values,
192 return(
giveToMatrix(numRows, rows, numCols, cols, values,
201 const double*
const* data,
208 std::vector<int> indices(2*fieldSize);
211 for(
int i=1; i<fieldSize; ++i) {
212 indices[i] = indices[0]+i;
215 cspace->
getGlobalIndex(idType, colID, fieldID, indices[fieldSize]);
216 for(
int i=1; i<fieldSize; ++i) {
217 indices[fieldSize+i] = indices[fieldSize]+i;
220 return(
giveToMatrix(fieldSize, &indices[0], fieldSize, &indices[fieldSize],
221 data,
true, format) );
235 std::vector<const double*> data2D(fieldSize);
238 for(
int i=0; i<fieldSize; ++i) {
239 data2D[i] = &data[offset];
244 &data2D[0], format) );
249 const double*
const* values,
253 std::vector<int> indices(numIndices);
256 numIndices, &indices[0], numIndices);
258 return(
giveToMatrix(numIndices, &indices[0], numIndices, &indices[0],
259 values,
true, format) );
288 bool matrixMarketFormat)
297 osstr << filename <<
"." << localProc <<
".mtx";
298 std::string fullname = osstr.str();
307 bool matrixMarketFormat)
309 static char mmbanner[] =
"%%MatrixMarket matrix coordinate real general";
318 if (matrixMarketFormat) {
320 ostrm << numRows <<
" " << numCols <<
" " << nnz <<
FEI_ENDL;
323 ostrm << numRows <<
" " << numCols <<
" "<<
FEI_ENDL;
334 for(
unsigned i=0; i<rowNumbers.size(); ++i) {
335 int rowlen = rowOffsets[i+1]-rowOffsets[i];
337 for(
int j=0; j<rowlen; ++j) {
338 if (matrixMarketFormat) {
339 ostrm << rowNumbers[i]+1 <<
" " << colIndices[offset]+1
343 ostrm << rowNumbers[i] <<
" " << colIndices[offset]
367 const std::vector<int>&
371 const std::vector<int>&
375 const std::vector<int>&
379 const std::vector<double>&
bool usingBlockEntryStorage()
Matrix_Local(fei::SharedPtr< fei::MatrixGraph > matrixGraph, fei::SharedPtr< fei::SparseRowGraph > sparseRowGraph)
MPI_Comm getCommunicator() const
const std::vector< int > & getRowOffsets() const
int getRowIndex(int rowNumber) const
int sumInFieldData(int fieldID, int idType, int rowID, int colID, const double *const *data, int format=0)
int copyIn(int numRows, const int *rows, int numCols, const int *cols, const double *const *values, int format=0)
int sumIn(int numRows, const int *rows, int numCols, const int *cols, const double *const *values, int format=0)
int getLocalNumRows() const
std::vector< int > rowNumbers
fei::SharedPtr< fei::SparseRowGraph > sparseRowGraph_
std::vector< double > coefs_
int multiply(fei::Vector *x, fei::Vector *y)
std::vector< const double * > work_data2D_
virtual fei::SharedPtr< fei::SparseRowGraph > createGraph(bool blockEntryGraph, bool localRowGraph_includeSharedRows=false)=0
int giveToMatrix(int numRows, const int *rows, int numCols, const int *cols, const double *const *values, bool sumInto, int format)
virtual int getConnectivityNumIndices(int blockID) const =0
std::vector< int > packedColumnIndices
int parameters(const fei::ParameterSet ¶mset)
std::vector< int > rowOffsets
const std::vector< int > & getRowNumbers() const
const std::vector< int > & getColumnIndices() const
std::vector< double > work_data1D_
int getGlobalIndex(int idType, int ID, int fieldID, int fieldOffset, int whichComponentOfField, int &globalIndex)
int gatherFromOverlap(bool accumulate=true)
virtual fei::SharedPtr< fei::VectorSpace > getRowSpace()=0
int binarySearch(const T &item, const T *list, int len)
int writeToStream(FEI_OSTREAM &ostrm, bool matrixMarketFormat=true)
virtual int getConnectivityIndices(int blockID, int connectivityID, int indicesAllocLen, int *indices, int &numIndices)=0
virtual fei::SharedPtr< fei::VectorSpace > getColSpace()=0
int writeToFile(const char *filename, bool matrixMarketFormat=true)
int getGlobalNumRows() const
int putScalar(double scalar)
const std::vector< double > & getCoefs() const
void setMatrixGraph(fei::SharedPtr< fei::MatrixGraph > matrixGraph)
static void copyTransposeToWorkArrays(int numRows, int numCols, const double *const *values, std::vector< double > &work_1D, std::vector< const double * > &work_2D)
fei::SharedPtr< fei::MatrixGraph > matrixGraph_
int localProc(MPI_Comm comm)
unsigned getFieldSize(int fieldID)
int copyOutRow(int row, int len, double *coefs, int *indices) const
static fei::SharedPtr< fei::Matrix > create_Matrix_Local(fei::SharedPtr< fei::MatrixGraph > matrixGraph, bool blockEntry)
#define FEI_OSTRINGSTREAM
fei::SharedPtr< fei::MatrixGraph > getMatrixGraph() const
std::vector< int > & getEqnNumbers()
int getRowLength(int row, int &length) const