Go to the documentation of this file.
43 #ifndef MAT_TRUNCATION
44 #define MAT_TRUNCATION
52 template<
typename Tmatrix,
typename Treal>
56 Treal
run(Treal
const threshold);
60 Treal
const threshold ) = 0;
64 Treal
const threshold ) = 0;
69 template<
typename Tmatrix,
typename Treal>
79 template<
typename Tmatrix,
typename Treal>
81 assert(threshold >= (Treal)0.0);
82 if (threshold == (Treal)0.0)
84 std::vector<Treal> frobsq_norms;
85 this->getFrobSqNorms( frobsq_norms );
86 std::sort(frobsq_norms.begin(), frobsq_norms.end());
88 int high = frobsq_norms.size() - 1;
89 Treal lowFrobTrunc, highFrobTrunc;
90 this->getFrobTruncBounds( lowFrobTrunc, highFrobTrunc, threshold );
92 while( low < (
int)frobsq_norms.size() - 1 && frobsqSum < lowFrobTrunc ) {
94 frobsqSum += frobsq_norms[low];
98 while( high < (
int)frobsq_norms.size() - 1 && frobsqSum < highFrobTrunc ) {
100 frobsqSum += frobsq_norms[high];
103 int minStep = int( 0.01 * frobsq_norms.size() );
104 minStep = minStep > 0 ? minStep : 1;
105 int testIndex = high;
106 int previousTestIndex = high * 2;
110 while ( euclEInt.
upp() > threshold ) {
113 int stepSize = (int)((high - low) * 0.01);
115 stepSize = stepSize >= minStep ? stepSize : minStep;
116 previousTestIndex = testIndex;
117 testIndex -= stepSize;
119 testIndex = testIndex > low ? testIndex : low;
124 while(testIndex >= 0 && frobsq_norms[testIndex] == frobsq_norms[testIndex+1])
131 assert( previousTestIndex != testIndex );
132 Treal currentFrobTrunc = frobsq_norms[testIndex];
133 frobThreshLowLevel( currentFrobTrunc );
134 euclEInt =
euclIfSmall( Treal(threshold * 1e-2), threshold );
138 if ( testIndex <= -1 ) {
139 frobThreshLowLevel( (Treal)0.0 );
143 euclE = euclEInt.
upp();
153 template<
typename Tmatrix,
typename Treal>
160 Treal
const threshold );
164 Treal
const threshold );
167 template<
typename Tmatrix,
typename Treal>
169 Treal
const threshold ) {
171 lowTrunc = (threshold * threshold) / 2;
172 highTrunc = (threshold * threshold * this->
A.get_nrows()) / 2;
175 template<
typename Tmatrix,
typename Treal>
177 this->
A.getMatrix().getFrobSqLowestLevel(frobsq_norms);
180 template<
typename Tmatrix,
typename Treal>
182 this->
A.getMatrix().frobThreshLowestLevel( threshold, &this->E.getMatrix() );
185 template<
typename Tmatrix,
typename Treal>
187 Treal
const threshold ) {
190 if ( tmpInterval.
length() < 2*absTol )
202 template<
typename Tmatrix,
typename TmatrixZ,
typename Treal>
209 Treal
const threshold );
213 Treal
const threshold );
217 template<
typename Tmatrix,
typename TmatrixZ,
typename Treal>
219 Treal
const threshold ) {
220 Treal Zfrob = Z.frob();
221 Treal thresholdTakingZIntoAccount = threshold / (Zfrob * Zfrob);
223 lowTrunc = thresholdTakingZIntoAccount * thresholdTakingZIntoAccount / 2.0;
224 highTrunc = template_blas_get_num_limit_max<Treal>();
227 template<
typename Tmatrix,
typename TmatrixZ,
typename Treal>
229 Treal
const threshold ) {
233 if ( tmpInterval.
length() < 2*absTol )
245 template<
typename Tmatrix,
typename Treal>
257 template<
typename Tmatrix,
typename Treal>
259 this->
A.getMatrix().getFrobSqElementLevel(frobsq_norms);
262 template<
typename Tmatrix,
typename Treal>
264 this->
A.getMatrix().frobThreshElementLevel(threshold, &this->E.getMatrix() );
271 template<
typename Tmatrix,
typename Treal>
278 Treal
const threshold );
282 Treal
const threshold );
285 template<
typename Tmatrix,
typename Treal>
287 Treal
const threshold ) {
293 lowTrunc = (threshold * threshold);
298 highTrunc = (threshold * threshold * this->
A.get_nrows());
301 template<
typename Tmatrix,
typename Treal>
303 this->
A.getMatrix().getFrobSqLowestLevel(frobsq_norms);
306 template<
typename Tmatrix,
typename Treal>
308 this->
A.getMatrix().frobThreshLowestLevel( threshold, &this->E.getMatrix() );
311 template<
typename Tmatrix,
typename Treal>
313 Treal
const threshold ) {
318 Treal absTolDummy = template_blas_get_num_limit_max<Treal>();
319 Treal relTol = 100 * mat::getMachineEpsilon<Treal>();
322 if ( tmpInterval.
length() < 2*absTol )
337 template<
typename Tmatrix,
typename TmatrixB,
typename Treal>
344 Treal
const threshold );
348 Treal
const threshold );
352 template<
typename Tmatrix,
typename TmatrixB,
typename Treal>
355 Treal
const threshold ) {
356 Treal Afrob = this->
A.frob();
357 Treal Bfrob =
B.frob();
360 highTrunc = template_blas_get_num_limit_max<Treal>();
363 template<
typename Tmatrix,
typename TmatrixB,
typename Treal>
365 Treal
const threshold ) {
369 if ( tmpInterval.
length() < 2*absTol ) {
Vector< real, real > Vec_1
Definition: test_LanczosSeveralLargestEig.cc:63
void randomZeroStructure(Treal probabilityBeingZero)
Definition: MatrixSymmetric.h:588
Treal template_blas_sqrt(Treal x)
Definition: mat_utils.h:137
Vector< real, Vec_2 > Vec_3
Definition: test_LanczosSeveralLargestEig.cc:65
Treal midPoint() const
Definition: Interval.h:115
EuclTruncationSymmElementLevel(Tmatrix &A_)
Definition: truncation.h:248
EuclTruncationSymmWithZ(Tmatrix &A_, TmatrixZ const &Z_)
Definition: truncation.h:205
EuclTruncationCongrTransMeasure(Tmatrix &A_, TmatrixB const &B_)
Definition: truncation.h:340
virtual void getFrobSqNorms(std::vector< Treal > &frobsq_norms)
Definition: truncation.h:176
Treal upp() const
Definition: Interval.h:145
Matrix< real, real > Mat_1
Definition: test_LanczosSeveralLargestEig.cc:60
VectorGeneral< real, vect > normalVector
Definition: test_LanczosSeveralLargestEig.cc:72
virtual void frobThreshLowLevel(Treal const threshold)=0
TmatrixB const & B
Definition: truncation.h:349
int main()
Definition: test_vector.cc:62
Matrix< real, Mat_1 > Mat_2
Definition: test_LanczosSeveralLargestEig.cc:61
static void setNProcs(unsigned int const nP)
Definition: matInclude.h:112
MatrixSymmetric< real, matri > symmMatrix
Definition: test_LanczosSeveralLargestEig.cc:69
virtual void getFrobSqNorms(std::vector< Treal > &frobsq_norms)
Definition: truncation.h:258
static unsigned int getMatrixParallelLevel()
Definition: matInclude.h:120
Truncation of symmetric matrices.
Definition: truncation.h:154
Treal eucl() const
Definition: VectorGeneral.h:178
Vector< real, Vec_1 > Vec_2
Definition: test_LanczosSeveralLargestEig.cc:64
ergo_real real
Definition: test.cc:46
int main()
Definition: testOmpFail.cc:43
mat::SizesAndBlocks rows
Definition: test.cc:51
virtual void getFrobSqNorms(std::vector< Treal > &frobsq_norms)=0
Vector< real, real > Vec_3
Definition: test_vector.cc:55
static void setMatrixParallelLevel(unsigned int const mPL)
Definition: matInclude.h:129
double real
Definition: test_LanczosSeveralLargestEig.cc:57
Matrix< real, Mat_2 > Mat_3
Definition: test_LanczosSeveralLargestEig.cc:62
virtual void frobThreshLowLevel(Treal const threshold)
Definition: truncation.h:263
Truncation of symmetric matrices at the element level (used for mixed norm truncation)
Definition: truncation.h:246
EuclTruncationBase(Tmatrix &A_)
Definition: truncation.h:70
MatrixGeneral< real, matri > normalMatrix
Definition: test_LanczosSeveralLargestEig.cc:71
EuclTruncationGeneral(Tmatrix &A_)
Definition: truncation.h:274
MatrixTriangular< real, matri > triangMatrix
Definition: test_LanczosSeveralLargestEig.cc:70
int main()
Definition: test_LanczosSeveralLargestEig.cc:75
Symmetric matrix.
Definition: MatrixBase.h:51
Upper non-unit triangular matrix.
Definition: MatrixBase.h:53
void resetSizesAndBlocks(SizesAndBlocks const &newRows)
Definition: VectorGeneral.h:51
Mat_3 matri
Definition: test_LanczosSeveralLargestEig.cc:67
Definition: LanczosSeveralLargestEig.h:51
Treal length() const
Returns the length of the interval.
Definition: Interval.h:109
virtual void getFrobTruncBounds(Treal &lowTrunc, Treal &highTrunc, Treal const threshold)
Definition: truncation.h:218
virtual void getFrobTruncBounds(Treal &lowTrunc, Treal &highTrunc, Treal const threshold)
Definition: truncation.h:286
Tmatrix E
Definition: truncation.h:66
static unsigned int getNProcs()
Definition: matInclude.h:103
virtual Interval< Treal > euclIfSmall(Treal const absTol, Treal const threshold)=0
Truncation of general matrices.
Definition: truncation.h:272
virtual Interval< Treal > euclIfSmall(Treal const absTol, Treal const threshold)
Definition: truncation.h:364
Vector class.
Definition: Matrix.h:78
Definition: mat_utils.h:106
Definition: truncation.h:53
Truncation of symmetric matrices with Z.
Definition: truncation.h:203
virtual Interval< Treal > euclIfSmall(Treal const absTol, Treal const threshold)
Definition: truncation.h:186
Definition: MatrixBase.h:55
Interval< Treal > euclIfSmall(Tmatrix const &M, Treal const requestedAbsAccuracy, Treal const requestedRelAccuracy, Treal const maxAbsVal, typename Tmatrix::VectorType *const eVecPtr=0, int maxIter=-1)
Returns interval containing the Euclidean norm of the matrix M.
Definition: LanczosLargestMagnitudeEig.h:260
Truncation of general matrices with impact on matrix triple multiply as error measure.
Definition: truncation.h:338
EuclTruncationSymm(Tmatrix &A_)
Definition: truncation.h:156
Normal matrix.
Definition: MatrixBase.h:49
VectorGeneral< real, vect > normalVector
Definition: test_vector.cc:60
virtual void getFrobTruncBounds(Treal &lowTrunc, Treal &highTrunc, Treal const threshold)=0
mat::SizesAndBlocks cols
Definition: test.cc:52
Definition: allocate.cc:39
Treal run(Treal const threshold)
Definition: truncation.h:80
virtual Interval< Treal > euclIfSmall(Treal const absTol, Treal const threshold)
Definition: truncation.h:228
virtual ~EuclTruncationBase()
Definition: truncation.h:57
virtual void getFrobTruncBounds(Treal &lowTrunc, Treal &highTrunc, Treal const threshold)
Definition: truncation.h:353
Matrix class and heart of the matrix library.
Definition: Matrix.h:115
Definition: Interval.h:46
Definition: mat_utils.h:78
Vec_3 vect
Definition: test_vector.cc:59
virtual void frobThreshLowLevel(Treal const threshold)
Definition: truncation.h:307
void rand()
Definition: VectorGeneral.h:108
TmatrixZ const & Z
Definition: truncation.h:214
Vec_3 vect
Definition: test_LanczosSeveralLargestEig.cc:68
virtual void frobThreshLowLevel(Treal const threshold)
Definition: truncation.h:181
Describes dimensions of matrix and its blocks on all levels.
Definition: SizesAndBlocks.h:45
Class used to keep track of the block sizes used at different levels in the hierarchical matrix data ...
double real
Definition: test_vector.cc:54
virtual void getFrobTruncBounds(Treal &lowTrunc, Treal &highTrunc, Treal const threshold)
Definition: truncation.h:168
virtual void getFrobSqNorms(std::vector< Treal > &frobsq_norms)
Definition: truncation.h:302
Tmatrix & A
Definition: truncation.h:65
Treal low() const
Definition: Interval.h:144
virtual Interval< Treal > euclIfSmall(Treal const absTol, Treal const threshold)
Definition: truncation.h:312