13#include <alien/kernels/composite/CompositeMatrix.h>
14#include <alien/kernels/composite/CompositeVector.h>
15#include <alien/kernels/simple_csr/SimpleCSRMatrix.h>
16#include <alien/kernels/simple_csr/SimpleCSRVector.h>
17#include <alien/utils/Precomp.h>
71 void setAlgo(eAlgoType algo);
78 void setOpt(eOptType opt,
bool flag);
96 ConstArrayView<Integer> eq_ids)
const;
98 template <
int N,
bool check_null_pivot = false>
110 eErrorType _normalize(MatrixImpl& matrix, VectorImpl& vector)
const;
121 eErrorType _normalize(MatrixImpl& matrix, MatrixImpl& matrix2,
bool trans,
122 ConstArrayView<Integer> eq_ids, VectorImpl& vector)
const;
134 Arccore::ConstArrayView<Arccore::Integer> eq_ids,
MatrixImpl& matrix2,
bool trans,
151template <
int N,
bool check_null_pivot>
162 LU(Arccore::Real* Ap,
bool factorize =
true)
168 for (
int k = 0; k < N; ++k) {
169 if (check_null_pivot) {
170 assert(A[k][k] != 0);
171 A[k][k] = 1 / A[k][k];
177 A[k][k] = 1 / A[k][k];
179 for (
int i = k + 1; i < N; ++i) {
184 for (
int i = k + 1; i < N; ++i) {
185 for (
int j = k + 1; j < N; ++j) {
186 A[i][j] -= A[i][k] * A[k][j];
196 for (
int i = 0; i < N; ++i) {
197 for (
int j = 0; j < i; ++j) {
201 for (
int j = i + 1; j < N; ++j) {
210 Real* ptr = (Real*)
m_A;
211 for (
int i = 0; i < N * N; ++i) {
222 template <
int NRhs,
bool TransRhs>
226 typedef Real Rhs2DType[NRhs][N];
227 Rhs2DType& X = *(Rhs2DType*)Xp;
229 for (
int k = 0; k < NRhs; ++k) {
230 for (
int i = 1; i < N; ++i) {
231 for (
int j = 0; j < i; ++j) {
232 X[k][i] -=
m_A[i][j] * X[k][j];
238 typedef Real Rhs2DType[N][NRhs];
239 Rhs2DType& X = *(Rhs2DType*)Xp;
241 for (
int i = 1; i < N; ++i) {
242 for (
int j = 0; j < i; ++j) {
243 for (
int k = 0; k < NRhs; ++k) {
244 X[i][k] -=
m_A[i][j] * X[j][k];
257 template <
int NRhs,
bool TransRhs>
261 typedef Real Rhs2DType[NRhs][N];
262 Rhs2DType& X = *(Rhs2DType*)Xp;
263 for (
int i = N - 1; i >= 0; --i) {
264 for (
int k = NRhs - 1; k >= 0; --k) {
265 for (
int j = N - 1; j > i; --j) {
266 X[k][i] -=
m_A[i][j] * X[k][j];
269 for (
int k = NRhs - 1; k >= 0; --k) {
272 X[k][i] *=
m_A[i][i];
277 typedef Real Rhs2DType[N][NRhs];
278 Rhs2DType& X = *(Rhs2DType*)Xp;
280 for (
int i = N - 1; i >= 0; --i) {
281 for (
int j = N - 1; j > i; --j) {
282 for (
int k = NRhs - 1; k >= 0; --k) {
283 X[i][k] -=
m_A[i][j] * X[j][k];
286 for (
int k = NRhs - 1; k >= 0; --k) {
287 X[i][k] *=
m_A[i][i];
301 template <
int NRhs,
bool TransRhs>
332 ,
m_cols(m.getCSRProfile().getCols())
334 ,
m_matrix(m.internal()->getDataPtr())
335 ,
m_rhs(x.getDataPtr())
368 void checkNullEq(Arccore::Integer irow, Arccore::Integer diag_offset)
402 template <
bool diag_first>
423 Integer ijk(Integer i, Integer j, Integer k)
const
428 Arccore::Integer ij(Arccore::Integer i, Arccore::Integer j)
const
433 Arccore::Integer ik(Arccore::Integer i, Arccore::Integer k)
const
438 Arccore::Integer jk(Arccore::Integer j, Arccore::Integer k)
const
448 Arccore::ConstArrayView<Arccore::Integer>
m_cols;
613 :
Op(m, x, algo, sum_first_eq)
631 for (Integer i = 0; i <
m_eq_ids.size(); ++i) {
636 for (Integer ieq = 1; ieq < neq; ++ieq)
648 for (Integer i = 0; i <
m_eq_ids.size(); ++i) {
653 for (Integer ieq = 1; ieq < neq; ++ieq)
674 :
Op(m, x, algo, sum_first_eq)
703 Arccore::ConstArrayView<Arccore::Integer>
m_eq_ids;
Arccore::Integer size() const
Get square block size.
Composite matrix for heterogenous matrices.
Composite vector for heterogenous vector.
virtual const VBlock * rowBlock() const
Get row block datas of the matrix.
virtual const VBlock * colBlock() const
Get col block datas of the matrix.
virtual const Block * block() const
Get block datas of the matrix.
Interface for all matrices.
Interface for all vectors.
Arccore::Real Block2DType[N][N]
Type of the blocks.
void setIdentity()
Set identity.
void LXSolve(Arccore::Real *Xp) const
LXSolve.
void solve(Arccore::Real *Xp) const
Solve.
void UXSolve(Arccore::Real *Xp) const
UXSolve.
Block2DType & m_A
The matrix.
Normalize operator for composite matrices.
Arccore::ConstArrayView< Arccore::Integer > m_eq_ids
Ids of the equations.
Arccore::ConstArrayView< Arccore::Integer > m_extra_eq_cols
Pointer on extra equations unknowns columns.
Op2(MatrixImpl &m, Arccore::ConstArrayView< Arccore::Integer > eq_ids, MatrixImpl &m2, bool trans, VectorImpl &x, eAlgoType algo, bool sum_first_eq)
Constructor.
bool m_trans
Transposed flag.
Arccore::ConstArrayView< Arccore::Integer > m_extra_eq_row_offset
Pointer on extra equations unknowns rows.
Arccore::Integer m_nb_extra_eq
Number of extra equations.
Arccore::Integer m_nuk2
Number of unknowns in extra equations.
Op2(MatrixImpl &m, MatrixImpl &m2, bool trans, Arccore::ConstArrayView< Arccore::Integer > eq_ids, VectorImpl &x, eAlgoType algo, bool sum_first_eq)
Constructor.
void multInvDiag()
Invert diagonal.
bool m_submatrix2
Whether or not the second submatrix should be normalized.
Arccore::Real * m_extra_eq_matrix
Pointer of extra equations datas.
bool m_submatrix1
Whether or not the first submatrix should be normalized.
void checkNullEq(Arccore::Integer irow, Arccore::Integer diag_offset)
Check if an equation is null.
Arccore::ConstArrayView< Arccore::Integer > m_cols
Column pointer.
Arccore::Integer m_equations_num
The number of equations.
Arccore::Integer m_local_size
The local size.
Arccore::Real * m_rhs
The rhs.
Op(MatrixImpl &m, VectorImpl &x, eAlgoType algo, bool sum_first_eq)
Constructor.
Arccore::Integer m_local_offset
The local offset.
eAlgoType m_algo
The algorithm type.
void sumBlockEq()
Row sum of blocks equation.
Arccore::Integer m_block_size
The block size.
void multInvDiag()
Invert diagonal.
bool m_keep_diag
Whether or not diagonal should be kept.
Arccore::ConstArrayView< Arccore::Integer > m_upper_diag_offset
The indices of the upper diagonal.
Arccore::ConstArrayView< Arccore::Integer > m_row_offset
The rows offset.
Arccore::Integer m_unknowns_num
The number of unknowns.
Arccore::Real * m_matrix
The matrix.
bool m_diag_first
Whether or not the diagonal entry is stored first.
bool m_sum_first_eq
Whether or not to sum the first equation.
eErrorType
Type of the error.
eAlgoType
Type of algorithm.
eOptType
Type of the options.
SimpleCSRVector< Arccore::Real > VectorImpl
Type of the vector implementation.
bool m_sum_first_eq
Flag to sum the fist equation.
SimpleCSRMatrix< Arccore::Real > MatrixImpl
Type of the matrix implementation.
virtual ~NormalizeOpt()
Free resources.
eErrorType _normalize(MatrixImpl &matrix, Arccore::ConstArrayView< Arccore::Integer > eq_ids, MatrixImpl &matrix2, bool trans, VectorImpl &vector) const
Normalize a linear system.
NormalizeOpt()
Constructor.
eAlgoType m_algo
The algorithm.
Arccore::Integer maxBlockSize() const
Get the max size of all block size.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --