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 = m_matrix.blockSize() ;
53 algebra.computeCxr(m_matrix,m_cxr_matrix,m_parent_lid) ;
55 algebra.computeCxr(m_matrix,m_cxr_matrix) ;
58 throw Arccore::FatalErrorException(A_FUNCINFO,
"Using Algebra that does not implemented computeCxr Op");
61 template<
typename AlgebraT>
62 void computeCxrMatrix(AlgebraT& algebra, VectorType
const& diag)
64 m_use_diag_scal = true ;
65 m_cxr_diag_scal.init(diag.distribution(),
true) ;
66 algebra.copy(diag,m_cxr_diag_scal) ;
67 m_block_size = algebra.computeCxr(m_matrix,m_cxr_matrix);
68 algebra.scal(m_cxr_diag_scal, m_cxr_matrix) ;
72 template<
typename AlgebraT>
73 void get(AlgebraT& algebra, VectorType
const& x,VectorType& cxr_x)
76 algebra.copy(x,m_parent_lid, cxr_x) ;
78 algebra.copy(x,m_block_size,cxr_x,1);
87 template<
typename AlgebraT>
88 void scal(AlgebraT& algebra, VectorType& cxr_x)
92 algebra.pointwiseMult(m_cxr_diag_scal,cxr_x,cxr_x) ;
96 template<
typename AlgebraT>
97 void combine(AlgebraT& algebra, VectorType
const& cxr_x, VectorType& x)
101 algebra.axpy(1.,cxr_x,x,m_parent_lid);
103 algebra.axpy(1.,cxr_x,1,x,m_block_size);
107 template<
typename AlgebraT>
108 void copy(AlgebraT& algebra, VectorType
const& cxr_x, VectorType& x)
110 if (m_block_size == 1)
111 algebra.copy(cxr_x, x, m_parent_lid);
113 algebra.copy(cxr_x,1,x,m_block_size);
117 MatrixType
const& m_matrix ;
118 MatrixType m_cxr_matrix ;
120 int m_block_size = 1 ;
121 UniqueArray<int> m_parent_lid ;
123 bool m_use_diag_scal =
false;
124 VectorType m_cxr_diag_scal ;