template<class T, class MATRIX_TYPE>
class oomph::Matrix< T, MATRIX_TYPE >
Abstract base class for matrices, templated by the type of object that is stored in them and the type of matrix. The MATRIX_TYPE template argument is used as part of the Curiously Recurring Template Pattern, see http://en.wikipedia.org/wiki/Curiously_Recurring_Template_Pattern The pattern is used to force the inlining of the round bracket access functions by ensuring that they are NOT virtual functions.
template<class T , class MATRIX_TYPE >
virtual void oomph::Matrix< T, MATRIX_TYPE >::output |
( |
std::ostream & |
outfile | ) |
const |
|
inlinevirtual |
Output function to print a matrix row-by-row, in the form a(0,0) a(0,1) ... a(1,0) a(1,1) ... ... to the stream outfile. Broken virtual since it might not be sensible to implement this for some sparse matrices.
Reimplemented in oomph::DenseMatrix< T >, oomph::DenseMatrix< oomph::MatrixVectorProduct * >, oomph::DenseMatrix< double >, oomph::DenseMatrix< int >, oomph::DenseMatrix< double * >, oomph::DenseMatrix< oomph::CRDoubleMatrix * >, oomph::DenseMatrix< std::complex< double > >, and oomph::DenseMatrix< bool >.
155 "Output function is not implemented for this matrix class",
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86
References OOMPH_CURRENT_FUNCTION, and OOMPH_EXCEPTION_LOCATION.
template<class T , class MATRIX_TYPE >
virtual void oomph::Matrix< T, MATRIX_TYPE >::output_bottom_right_zero_helper |
( |
std::ostream & |
outfile | ) |
const |
|
pure virtual |
Output the "bottom right" entry regardless of it being zero or not (this allows automatic detection of matrix size in e.g. matlab, python). This functionality was moved from the function sparse_indexed_output(...) because at the moment, generalisation of this functionality does not work in parallel. CRDoubleMatrix has an nrow() function but it should it should use nrow_local() - which is the N variable in the underlaying CRMatrix.
Implemented in oomph::SumOfMatrices, oomph::CCMatrix< T >, oomph::CCMatrix< double >, oomph::CCMatrix< std::complex< double > >, oomph::CRDoubleMatrix, oomph::CRMatrix< T >, oomph::CRMatrix< double >, oomph::CRMatrix< std::complex< double > >, oomph::SparseMatrix< T, MATRIX_TYPE >, oomph::SparseMatrix< T, CCMatrix< T > >, oomph::SparseMatrix< T, CRMatrix< T > >, oomph::DenseMatrix< T >, oomph::DenseMatrix< oomph::MatrixVectorProduct * >, oomph::DenseMatrix< double >, oomph::DenseMatrix< int >, oomph::DenseMatrix< double * >, oomph::DenseMatrix< oomph::CRDoubleMatrix * >, oomph::DenseMatrix< std::complex< double > >, and oomph::DenseMatrix< bool >.
Referenced by oomph::Matrix< T, MATRIX_TYPE >::sparse_indexed_output().
template<class T , class MATRIX_TYPE >
Range check to catch when an index is out of bounds, if so, it issues a warning message and dies by throwing an OomphLibError
82 std::ostringstream error_message;
83 error_message <<
"Range Error: i=" <<
i <<
" is not in the range (0,"
84 <<
nrow() - 1 <<
")." << std::endl;
86 throw OomphLibError(error_message.str(),
92 std::ostringstream error_message;
93 error_message <<
"Range Error: j=" <<
j <<
" is not in the range (0,"
94 <<
ncol() - 1 <<
")." << std::endl;
96 throw OomphLibError(error_message.str(),
virtual unsigned long nrow() const =0
Return the number of rows of the matrix.
virtual unsigned long ncol() const =0
Return the number of columns of the matrix.
References i, j, oomph::Matrix< T, MATRIX_TYPE >::ncol(), oomph::Matrix< T, MATRIX_TYPE >::nrow(), OOMPH_CURRENT_FUNCTION, and OOMPH_EXCEPTION_LOCATION.
Referenced by oomph::CRMatrix< T >::get_entry(), and oomph::CCMatrix< T >::get_entry().
template<class T , class MATRIX_TYPE >
void oomph::Matrix< T, MATRIX_TYPE >::sparse_indexed_output |
( |
std::ostream & |
outfile, |
|
|
const unsigned & |
precision = 0 , |
|
|
const bool & |
output_bottom_right_zero = false |
|
) |
| const |
|
inline |
Indexed output function to print a matrix to the stream outfile as i,j,a(i,j) for a(i,j)!=0 only with specified precision (if precision=0 then nothing is changed). If optional boolean flag is set to true we also output the "bottom right" entry regardless of it being zero or not (this allows automatic detection of matrix size in e.g. matlab, python).
195 unsigned old_precision = 0;
198 old_precision = outfile.precision();
199 outfile.precision(precision);
207 if (output_bottom_right_zero &&
ncol() > 0 &&
nrow() > 0)
217 outfile.precision(old_precision);
virtual void output_bottom_right_zero_helper(std::ostream &outfile) const =0
virtual void sparse_indexed_output_helper(std::ostream &outfile) const =0
References oomph::Matrix< T, MATRIX_TYPE >::ncol(), oomph::Matrix< T, MATRIX_TYPE >::nrow(), oomph::Matrix< T, MATRIX_TYPE >::output_bottom_right_zero_helper(), and oomph::Matrix< T, MATRIX_TYPE >::sparse_indexed_output_helper().
Referenced by oomph::BlackBoxFDNewtonSolver::black_box_fd_newton_solve(), BiharmonicTestProblem1::dump_jacobian(), main(), print_elemental_jacobian(), and oomph::Matrix< T, MATRIX_TYPE >::sparse_indexed_output().
template<class T , class MATRIX_TYPE >
void oomph::Matrix< T, MATRIX_TYPE >::sparse_indexed_output |
( |
std::string |
filename, |
|
|
const unsigned & |
precision = 0 , |
|
|
const bool & |
output_bottom_right_zero = false |
|
) |
| const |
|
inline |
Indexed output function to print a matrix to the file named filename as i,j,a(i,j) for a(i,j)!=0 only with specified precision. If optional boolean flag is set to true we also output the "bottom right" entry regardless of it being zero or not (this allows automatic detection of matrix size in e.g. matlab, python).
236 std::ofstream some_file(
filename.c_str());
void sparse_indexed_output(std::ostream &outfile, const unsigned &precision=0, const bool &output_bottom_right_zero=false) const
Definition: matrices.h:182
string filename
Definition: MergeRestartFiles.py:39
References MergeRestartFiles::filename, and oomph::Matrix< T, MATRIX_TYPE >::sparse_indexed_output().