FEI Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
fei_ostream_ops.cpp
Go to the documentation of this file.
1/*--------------------------------------------------------------------*/
2/* Copyright 2005 Sandia Corporation. */
3/* Under the terms of Contract DE-AC04-94AL85000, there is a */
4/* non-exclusive license for use of this work by or on behalf */
5/* of the U.S. Government. Export of this program may require */
6/* a license from the United States Government. */
7/*--------------------------------------------------------------------*/
8
9#include <fei_macros.hpp>
10#include <fei_ostream_ops.hpp>
11
12#include <fei_Vector.hpp>
13#include <fei_Matrix.hpp>
14#include <fei_FillableMat.hpp>
15#include <fei_CSRMat.hpp>
16#include <fei_CSVec.hpp>
17
18
20{
21 vec.writeToStream(os);
22 return(os);
23}
24
26{
27 mat.writeToStream(os);
28 return(os);
29}
30
32{
33 os << "num rows: " << mat.getNumRows() << FEI_ENDL;
35 iter = mat.begin(), iter_end = mat.end();
36
37 for(; iter!=iter_end; ++iter) {
38 int row = iter->first;
39 const fei::CSVec* v = iter->second;
40 const std::vector<int>& v_ind = v->indices();
41 const std::vector<double>& v_coef = v->coefs();
42 os << row << ": ";
43 for(size_t i=0; i<v_ind.size(); ++i) {
44 os << "("<<v_ind[i]<<","<<v_coef[i]<<") ";
45 }
46 os << FEI_ENDL;
47 }
48
49 return(os);
50}
51
53{
54 size_t len = vec.size();
55
56 os << " numEntries: " << len << FEI_ENDL;
57
58 for(size_t i=0; i<len; ++i) {
59 os << " " << vec.indices()[i]<< ": "<<vec.coefs()[i] << FEI_ENDL;
60 }
61
62 return(os);
63}
64
66{
67 os << "num rows: " << mat.getNumRows() << FEI_ENDL;
68
69 const std::vector<int>& rows = mat.getGraph().rowNumbers;
70 const int* rowoffs = &(mat.getGraph().rowOffsets[0]);
71 const std::vector<int>& cols = mat.getGraph().packedColumnIndices;
72 const double* coefs = &(mat.getPackedCoefs()[0]);
73
74 for(size_t i=0; i<rows.size(); ++i) {
75 int row = rows[i];
76
77 os << row << ": ";
78 for(int j=rowoffs[i]; j<rowoffs[i+1]; ++j) {
79 os << "("<<cols[j]<<","<<coefs[j]<<") ";
80 }
81 os << FEI_ENDL;
82 }
83
84 return(os);
85}
86
std::vector< double > & getPackedCoefs()
Definition: fei_CSRMat.hpp:30
unsigned getNumRows() const
Definition: fei_CSRMat.hpp:33
SparseRowGraph & getGraph()
Definition: fei_CSRMat.hpp:27
std::vector< int > & indices()
Definition: fei_CSVec.hpp:31
size_t size() const
Definition: fei_CSVec.hpp:36
std::vector< double > & coefs()
Definition: fei_CSVec.hpp:33
unsigned getNumRows() const
feipoolmat::iterator iterator
virtual int writeToStream(FEI_OSTREAM &ostrm, bool matrixMarketFormat=true)=0
std::vector< int > rowNumbers
std::vector< int > packedColumnIndices
std::vector< int > rowOffsets
virtual int writeToStream(FEI_OSTREAM &ostrm, bool matrixMarketFormat=true)=0
#define FEI_OSTREAM
Definition: fei_iosfwd.hpp:24
#define FEI_ENDL
FEI_OSTREAM & operator<<(FEI_OSTREAM &os, fei::Vector &vec)