Commit 5d73507d by PIACIBELLO Cyrille

### Forget Utils.hpp

parent 49e17ea6
src/Utils.hpp 0 → 100644
 #ifndef UTILS_HPP #define UTILS_HPP #include "Base.hpp" #include "Block.hpp" /** * @brief This struct will hold some output concerning an arnoldi * procedure. */ struct ArnReturn{ int nbIteDone; bool hasConverged; }; /** * @brief This function test if the current solution is accurate * enough. It will works only if the RHS are scaled, (i.e each column * vector of B has a norm of 1) * * @param A Matrix provided buy the user * @param B RHS (each column vector of B must be of norm 1) * @param X0 : initial guess, will be overwritten by * solution if criteria is satisfied * @param Base Current base * @param Y Current solution of least square problem * @param epsilon target accuracy */ template bool CheckCurrentSolution(Matrix&A, Block& B, Block& X0, Base& Base, Block& Y, Primary epsilon){ int dim = A.size(); int SizeBlock = B.getSizeBlock(); //Create temporary block to store solution Block Sol(SizeBlock,dim); if(A.useRightPreCond()){ Block temp(SizeBlock,dim); Base.ComputeProduct(Y,temp); A.preCondBlockVect(temp,Sol); }else{//No pre Cond used Base.ComputeProduct(Y,Sol); } //Adding X0 for(int i=0 ; i AxSol(SizeBlock,dim); A.MatBlockVect(Sol,AxSol); for(int i=0 ; i RealMinMax = AxSol.getMinMaxNorm(); if(RealMinMax.second < epsilon){ std::cout<<"Convergence !!"< std::pair CompareBlocks(Block& block1, Block& block2){ std::pair MinMax{1000,0}; if(block1.getSizeBlock() != block2.getSizeBlock()){ std::cout<<"Size of blocks not compatible\nExiting\n"; exit(0); } if(block1.getLeadingDim() != block2.getLeadingDim()){ std::cout<<"Leading dim of blocks not compatible\nExiting\n"; exit(0); } for(int i=0 ; i(block1.getPtr(i)[j] - block2.getPtr(i)[j]); } auto norm2 = std::sqrt(norm); if(norm2 > MinMax.second){ MinMax.second = norm2; } if(norm2 < MinMax.first){ MinMax.first = norm2; } } return MinMax; } #endif //UTILS_HPP
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!