Go to the documentation of this file.
38 #ifndef MAT_MATRIXTRIANGULAR
39 #define MAT_MATRIXTRIANGULAR
58 template<
typename Treal,
typename Tmatrix>
59 class MatrixTriangular :
public MatrixBase<Treal, Tmatrix> {
86 (std::vector<int>
const & rowind,
87 std::vector<int>
const & colind,
88 std::vector<Treal>
const & values,
91 this->resetSizesAndBlocks(newRows, newCols);
92 this->matrixPtr->syAssignFromSparse(rowind, colind, values);
107 (std::vector<int>
const & rowind,
108 std::vector<int>
const & colind,
109 std::vector<Treal>
const & values) {
110 this->matrixPtr->syAddValues(rowind, colind, values);
115 (std::vector<int>
const & rowind,
116 std::vector<int>
const & colind,
117 std::vector<Treal> & values)
const {
118 this->matrixPtr->syGetValues(rowind, colind, values);
128 (std::vector<int> & rowind,
129 std::vector<int> & colind,
130 std::vector<Treal> & values)
const {
134 rowind.reserve(
nnz());
135 colind.reserve(
nnz());
136 values.reserve(
nnz());
137 this->matrixPtr->syGetAllValues(rowind, colind, values);
145 inline void fullmatrix(Treal*
const full,
int const size)
const {
146 this->matrixPtr->fullmatrix(full, size, size);
151 const Treal threshold,
154 Tmatrix::inch(*SPD.matrixPtr, *this->matrixPtr,
155 threshold, looking, version);
158 const Treal threshold,
161 this->matrixPtr.haveDataStructureSet(
true);
162 Tmatrix::syInch(*SPD.matrixPtr, *this->matrixPtr,
163 threshold, looking, version);
166 void thresh(Treal
const threshold,
170 return this->matrixPtr->frob();
172 Treal
eucl(Treal
const requestedAccuracy,
173 int maxIter = -1)
const;
179 this->matrixPtr->frob_thresh(threshold);
181 inline size_t nnz()
const {
182 return this->matrixPtr->nnz();
185 return this->matrixPtr->nvalues();
197 this->matrixPtr->syRandom();
204 template<
typename TRule>
206 this->matrixPtr->trSetElementsByRule(rule);
229 template<
typename Treal,
typename Tmatrix>
230 inline MatrixTriangular<Treal, Tmatrix>&
234 Tmatrix::add(sm.A, *sm.B.matrixPtr, *this->matrixPtr);
239 template<
typename Treal,
typename Tmatrix>
241 thresh(Treal
const threshold,
245 this->frob_thresh(threshold);
248 throw Failure(
"MatrixTriangular<Treal, Tmatrix>::"
249 "thresh(Treal const, "
251 "Thresholding not imlpemented for selected norm");
255 template<
typename Treal,
typename Tmatrix>
257 eucl(Treal
const requestedAccuracy,
266 maxIter = this->get_nrows() * 100;
269 lan(ztz, guess, maxIter);
270 lan.setRelTol( 100 * mat::getMachineEpsilon<Treal>() );
277 if ( euclInt.
low() < 0 )
279 if ( euclInt.
length() / 2.0 > requestedAccuracy ) {
280 std::cout <<
"req: " << (double)requestedAccuracy
281 <<
" obt: " << (
double)(euclInt.
length() / 2.0) << std::endl;
282 throw std::runtime_error(
"Desired accuracy not obtained in Lanczos.");
289 template<
typename Treal,
typename Tmatrix>
293 return TruncObj.
run( threshold );
298 template<
typename Treal,
typename Tmatrix>
303 return TruncObj.
run( threshold );
Treal template_blas_sqrt(Treal x)
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:107
void readFromFileProt(std::ifstream &file)
Definition: MatrixTriangular.h:220
Treal midPoint() const
Definition: Interval.h:115
void read_from_buffer(void *buffer, const int n_bytes)
Definition: MatrixTriangular.h:192
void write_to_buffer(void *buffer, const int n_bytes) const
Definition: MatrixTriangular.h:189
void inch(const MatrixSymmetric< Treal, Tmatrix > &SPD, const Treal threshold, const side looking=left, const inchversion version=unstable)
Definition: MatrixTriangular.h:157
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:115
size_t nnz() const
Definition: MatrixTriangular.h:181
void writeToFileProt(std::ofstream &file) const
Definition: MatrixTriangular.h:217
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:86
@ frobNorm
Definition: matInclude.h:139
side
Definition: Matrix.h:75
Treal eucl_thresh_congr_trans_measure(Treal const threshold, MatrixSymmetric< Treal, Tmatrix > &trA)
Definition: MatrixTriangular.h:300
void inch(const MatrixGeneral< Treal, Tmatrix > &SPD, const Treal threshold, const side looking=left, const inchversion version=unstable)
Definition: MatrixTriangular.h:150
MatrixTriangular< Treal, Tmatrix > & operator=(int const k)
Set matrix to zero or identity: A = 0 or A = 1.
Definition: MatrixTriangular.h:75
@ left
Definition: Matrix.h:75
Treal frob() const
Definition: MatrixTriangular.h:169
Symmetric matrix.
Definition: MatrixBase.h:51
Upper non-unit triangular matrix.
Definition: MatrixBase.h:53
MatrixTriangular< Treal, Tmatrix > & operator=(const MatrixTriangular< Treal, Tmatrix > &tri)
Definition: MatrixTriangular.h:70
void resetSizesAndBlocks(SizesAndBlocks const &newRows)
Definition: VectorGeneral.h:51
Treal length() const
Returns the length of the interval.
Definition: Interval.h:109
Definition: LanczosLargestMagnitudeEig.h:47
@ matrix_triang
Definition: MatrixBase.h:56
Treal eucl(Treal const requestedAccuracy, int maxIter=-1) const
Definition: MatrixTriangular.h:257
MatrixTriangular()
Default constructor
Definition: MatrixTriangular.h:64
Truncation of general matrices.
Definition: truncation.h:272
void getLargestMagnitudeEig(Treal &ev, Treal &accuracy)
Definition: LanczosLargestMagnitudeEig.h:58
Treal eucl_thresh(Treal const threshold)
Definition: MatrixTriangular.h:291
@ unstable
Definition: Matrix.h:76
Definition: MatrixBase.h:55
Truncation of general matrices with impact on matrix triple multiply as error measure.
Definition: truncation.h:338
Normal matrix.
Definition: MatrixBase.h:49
std::string obj_type_id() const
Definition: MatrixTriangular.h:215
mat::SizesAndBlocks cols
Definition: test.cc:52
inchversion
Definition: Matrix.h:76
Definition: allocate.cc:39
Treal real
Definition: MatrixTriangular.h:62
Treal run(Treal const threshold)
Definition: truncation.h:80
normType
Definition: matInclude.h:139
MatrixTriangular(const MatrixTriangular< Treal, Tmatrix > &tri)
Copy constructor
Definition: MatrixTriangular.h:66
Definition: Interval.h:46
Definition: mat_utils.h:78
void rand()
Definition: VectorGeneral.h:108
void thresh(Treal const threshold, normType const norm)
Definition: MatrixTriangular.h:241
Base class for matrix API.
Definition: MatrixBase.h:69
This proxy expresses the result of multiplication of two objects, of possibly different types,...
Definition: matrix_proxy.h:51
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:205
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:128
Describes dimensions of matrix and its blocks on all levels.
Definition: SizesAndBlocks.h:45
void frob_thresh(Treal threshold)
Definition: MatrixTriangular.h:178
VectorGeneral< Treal, typename Tmatrix::VectorType > VectorType
Definition: MatrixTriangular.h:61
MatrixBase< Treal, Tmatrix > & operator=(const MatrixBase< Treal, Tmatrix > &other)
Definition: MatrixBase.h:166
void random()
Definition: MatrixTriangular.h:196
size_t nvalues() const
Definition: MatrixTriangular.h:184
Treal low() const
Definition: Interval.h:144