36 #ifndef MAT_MATRIXTRIANGULAR
37 #define MAT_MATRIXTRIANGULAR
56 template<
typename Treal,
typename Tmatrix>
57 class MatrixTriangular :
public MatrixBase<Treal, Tmatrix> {
83 (std::vector<int>
const & rowind,
84 std::vector<int>
const & colind,
85 std::vector<Treal>
const & values,
89 this->
matrixPtr->syAssignFromSparse(rowind, colind, values);
104 (std::vector<int>
const & rowind,
105 std::vector<int>
const & colind,
106 std::vector<Treal>
const & values) {
107 this->
matrixPtr->syAddValues(rowind, colind, values);
112 (std::vector<int>
const & rowind,
113 std::vector<int>
const & colind,
114 std::vector<Treal> & values)
const {
115 this->
matrixPtr->syGetValues(rowind, colind, values);
125 (std::vector<int> & rowind,
126 std::vector<int> & colind,
127 std::vector<Treal> & values)
const {
128 this->
matrixPtr->syGetAllValues(rowind, colind, values);
136 inline void fullmatrix(Treal*
const full,
int const size)
const {
137 this->
matrixPtr->fullmatrix(full, size, size);
142 const Treal threshold,
145 Tmatrix::inch(*SPD.
matrixPtr, *this->matrixPtr,
146 threshold, looking, version);
149 const Treal threshold,
153 Tmatrix::syInch(*SPD.
matrixPtr, *this->matrixPtr,
154 threshold, looking, version);
157 void thresh(Treal
const threshold,
163 Treal
eucl(Treal
const requestedAccuracy,
164 int maxIter = -1)
const;
172 inline size_t nnz()
const {
195 template<
typename TRule>
197 this->
matrixPtr->trSetElementsByRule(rule);
220 template<
typename Treal,
typename Tmatrix>
221 inline MatrixTriangular<Treal, Tmatrix>&
222 MatrixTriangular<Treal, Tmatrix>::operator+=
225 Tmatrix::add(sm.A, *sm.B.matrixPtr, *this->matrixPtr);
230 template<
typename Treal,
typename Tmatrix>
236 this->frob_thresh(threshold);
239 throw Failure(
"MatrixTriangular<Treal, Tmatrix>::"
240 "thresh(Treal const, "
242 "Thresholding not imlpemented for selected norm");
246 template<
typename Treal,
typename Tmatrix>
248 eucl(Treal
const requestedAccuracy,
257 maxIter = this->get_nrows() * 100;
260 lan(ztz, guess, maxIter);
261 lan.setRelTol( 100 * std::numeric_limits<Treal>::epsilon() );
268 if ( euclInt.
low() < 0 )
270 if ( euclInt.
length() / 2.0 > requestedAccuracy ) {
271 std::cout <<
"req: " << requestedAccuracy
272 <<
" obt: " << euclInt.
length() / 2.0 << std::endl;
273 throw std::runtime_error(
"Desired accuracy not obtained in Lanczos.");
280 template<
typename Treal,
typename Tmatrix>
284 return TruncObj.
run( threshold );
289 template<
typename Treal,
typename Tmatrix>
294 return TruncObj.
run( threshold );
void thresh(Treal const threshold, normType const norm)
Definition: MatrixTriangular.h:232
MatrixTriangular< Treal, Tmatrix > & operator=(const MatrixTriangular< Treal, Tmatrix > &tri)
Definition: MatrixTriangular.h:67
Treal eucl_thresh(Treal const threshold)
Definition: MatrixTriangular.h:282
Normal matrix.
Definition: MatrixBase.h:47
Treal length() const
Returns the length of the interval.
Definition: Interval.h:107
MatrixBase< Treal, Tmatrix > & operator=(const MatrixBase< Treal, Tmatrix > &other)
Definition: MatrixBase.h:164
inchversion
Definition: Matrix.h:74
void frob_thresh(Treal threshold)
Definition: MatrixTriangular.h:169
ValidPtr< Tmatrix > matrixPtr
Definition: MatrixBase.h:151
Definition: LanczosLargestMagnitudeEig.h:44
void read_from_buffer_base(void *buffer, const int n_bytes, const matrix_type mattype)
Definition: MatrixBase.h:279
void inch(const MatrixGeneral< Treal, Tmatrix > &SPD, const Treal threshold, const side looking=left, const inchversion version=unstable)
Definition: MatrixTriangular.h:141
size_t nnz() const
Definition: MatrixTriangular.h:172
Truncation of general matrices.
Definition: truncation.h:270
Definition: MatrixBase.h:53
Definition: allocate.cc:30
Describes dimensions of matrix and its blocks on all levels.
Definition: SizesAndBlocks.h:37
MatrixTriangular()
Default constructor.
Definition: MatrixTriangular.h:61
Treal midPoint() const
Definition: Interval.h:113
Definition: Interval.h:44
void writeToFileProt(std::ofstream &file) const
Write object to file.
Definition: MatrixTriangular.h:208
VectorGeneral< Treal, typename Tmatrix::VectorType > VectorType
Definition: MatrixTriangular.h:59
void readFromFileBase(std::ifstream &file, matrix_type const mattype)
Definition: MatrixBase.h:234
void setElementsByRule(TRule &rule)
Uses rule depending on the row and column indexes to set matrix elements The Trule class should have ...
Definition: MatrixTriangular.h:196
Upper non-unit triangular matrix.
Definition: MatrixBase.h:51
MatrixTriangular(const MatrixTriangular< Treal, Tmatrix > &tri)
Copy constructor.
Definition: MatrixTriangular.h:63
Treal low() const
Definition: Interval.h:142
void readFromFileProt(std::ifstream &file)
Read object from file.
Definition: MatrixTriangular.h:211
Treal run(Treal const threshold)
Definition: truncation.h:78
void write_to_buffer(void *buffer, const int n_bytes) const
Definition: MatrixTriangular.h:180
void assign_from_sparse(std::vector< int > const &rowind, std::vector< int > const &colind, std::vector< Treal > const &values, SizesAndBlocks const &newRows, SizesAndBlocks const &newCols)
Assign from sparse matrix given by three vectors.
Definition: MatrixTriangular.h:83
Treal eucl(Treal const requestedAccuracy, int maxIter=-1) const
Definition: MatrixTriangular.h:248
void rand()
Definition: VectorGeneral.h:94
void inch(const MatrixSymmetric< Treal, Tmatrix > &SPD, const Treal threshold, const side looking=left, const inchversion version=unstable)
Definition: MatrixTriangular.h:148
void resetSizesAndBlocks(SizesAndBlocks const &newRows, SizesAndBlocks const &newCols)
Definition: MatrixBase.h:74
Treal frob() const
Definition: MatrixTriangular.h:160
Treal eucl_thresh_congr_trans_measure(Treal const threshold, MatrixSymmetric< Treal, Tmatrix > &trA)
Definition: MatrixTriangular.h:291
void add_values(std::vector< int > const &rowind, std::vector< int > const &colind, std::vector< Treal > const &values)
Add given set of values to the matrix (+=).
Definition: MatrixTriangular.h:104
void resetSizesAndBlocks(SizesAndBlocks const &newRows)
Definition: VectorGeneral.h:49
Definition: mat_utils.h:69
void random()
Definition: MatrixTriangular.h:187
Base class for matrix API.
Definition: MatrixBase.h:67
void get_values(std::vector< int > const &rowind, std::vector< int > const &colind, std::vector< Treal > &values) const
Get values given by row and column index lists.
Definition: MatrixTriangular.h:112
void read_from_buffer(void *buffer, const int n_bytes)
Definition: MatrixTriangular.h:183
void getLargestMagnitudeEig(Treal &ev, Treal &accuracy)
Definition: LanczosLargestMagnitudeEig.h:56
void get_all_values(std::vector< int > &rowind, std::vector< int > &colind, std::vector< Treal > &values) const
Get all values and corresponding row and column index lists, in matrix.
Definition: MatrixTriangular.h:125
side
Definition: Matrix.h:73
Base class for matrix API.
Definition: matInclude.h:135
void writeToFileBase(std::ofstream &file, matrix_type const mattype) const
Definition: MatrixBase.h:219
This proxy expresses the result of multiplication of two objects, of possibly different types...
Definition: matrix_proxy.h:49
void write_to_buffer_base(void *buffer, const int n_bytes, const matrix_type mattype) const
Definition: MatrixBase.h:252
void haveDataStructureSet(bool val)
Definition: ValidPtr.h:97
Definition: MatrixBase.h:54
MatrixTriangular< Treal, Tmatrix > & operator=(int const k)
Set matrix to zero or identity: A = 0 or A = 1.
Definition: MatrixTriangular.h:72
Symmetric matrix.
Definition: MatrixBase.h:49
std::string obj_type_id() const
Definition: MatrixTriangular.h:206
Truncation of general matrices with impact on matrix triple multiply as error measure.
Definition: truncation.h:336
Treal template_blas_sqrt(Treal x)
size_t nvalues() const
Definition: MatrixTriangular.h:175
normType
Definition: matInclude.h:135