16 using MatrixType = MatrixT ;
17 using VectorType = VectorT ;
20 CxrOperator(MatrixT
const& matrix)
22 , m_cxr_matrix(matrix.impls()->clone())
25 virtual ~CxrOperator()
28 template<
typename AlgebraT>
29 void apply(AlgebraT& algebra,
const VectorType &x, VectorType &y)
31 if(m_v.getAllocSize()==0)
32 algebra.allocate(AlgebraT::resource(m_matrix),m_v);
33 algebra.mult(m_matrix,x,m_v) ;
38 MatrixType
const& getCxrMatrix()
const {
42 MatrixType& getCxrMatrix() {
46 template<
typename AlgebraT>
47 void computeCxrMatrix(AlgebraT& algebra)
49 if constexpr (
requires{algebra.computeCxr(m_matrix,m_cxr_matrix) ;})
51 m_block_size = algebra.computeCxr(m_matrix,m_cxr_matrix) ;
54 throw Arccore::FatalErrorException(A_FUNCINFO,
"Using Algebra that does not implemented computeCxr Op");
57 template<
typename AlgebraT>
58 void computeCxrMatrix(AlgebraT& algebra, VectorType
const& diag)
60 m_use_diag_scal = true ;
61 m_cxr_diag_scal.init(diag.distribution(),
true) ;
62 algebra.copy(diag,m_cxr_diag_scal) ;
63 m_block_size = algebra.computeCxr(m_matrix,m_cxr_matrix);
64 algebra.scal(m_cxr_diag_scal, m_cxr_matrix) ;
68 template<
typename AlgebraT>
69 void get(AlgebraT& algebra, VectorType
const& x,VectorType& cxr_x)
71 algebra.copy(x,m_block_size,cxr_x,1);
80 template<
typename AlgebraT>
81 void scal(AlgebraT& algebra, VectorType& cxr_x)
85 algebra.pointwiseMult(m_cxr_diag_scal,cxr_x,cxr_x) ;
89 template<
typename AlgebraT>
90 void combine(AlgebraT& algebra, VectorType
const& cxr_x, VectorType& x)
92 algebra.axpy(1.,cxr_x,1,x,m_block_size);
96 template<
typename AlgebraT>
97 void copy(AlgebraT& algebra, VectorType
const& cxr_x, VectorType& x)
99 algebra.copy(cxr_x,1,x,m_block_size);
103 MatrixType
const& m_matrix ;
104 MatrixType m_cxr_matrix ;
106 int m_block_size = 1 ;
108 bool m_use_diag_scal =
false;
109 VectorType m_cxr_diag_scal ;