46class ALIEN_EXPORT SimpleCSRInternalLinearAlgebra
52 typedef std::tuple<VectorDistribution const*,Integer> ResourceType;
54 class NullValueException
59 NullValueException(std::string
const& type)
60 : BaseType(type, __LINE__)
96 SimpleCSRInternalLinearAlgebra();
97 virtual ~SimpleCSRInternalLinearAlgebra();
101 Real norm0(
const Vector& x)
const;
102 Real norm1(
const Vector& x)
const;
103 Real norm2(
const Vector& x)
const;
104 Real normInf(
const Vector& x)
const;
113 void computeDiag(
const Matrix& a,
Vector& inv_diag)
const;
116 void computeInvDiag(
const Matrix& a,
Vector& inv_diag)
const;
118 void axpy(Real alpha,
const Vector& x,
Vector& r)
const;
119 void aypx(Real alpha,
Vector& y,
const Vector& x)
const;
122 void axpy(Real alpha,
const Vector& x,Integer stride_x,
Vector& r,Integer stride_r)
const;
123 void aypx(Real alpha,
Vector& y, Integer stride_y,
const Vector& x,Integer stride_x)
const;
124 void copy(
const Vector& x, Integer stride_x,
Vector& r, Integer stride_r)
const;
127 void dot(
const Vector& x,
const Vector& y, FutureType& res)
const;
129 void scal(Real alpha,
Vector& x)
const;
132 void reciprocal(
Vector& x)
const;
134 void assign(
Vector& x, Real alpha)
const;
136 template <
typename LambdaT>
137 void assign(
Vector& x, LambdaT
const& lambda)
const
139 auto x_ptr = x.getDataPtr();
140 for (Integer i = 0; i < x.getAllocSize(); ++i) {
141 x_ptr[i] = lambda(i);
145 template <
typename PrecondT>
146 void exec(PrecondT& precond, Vector
const& x, Vector& y)
148 return precond.solve(*
this, x, y);
151 Integer computeCxr(
const Matrix& a, Matrix& cxr_a)
const ;
152 Integer computeCxr(
const Matrix& a, Vector
const& diag_scal, Matrix& cxr_a)
const ;
154 static ResourceType resource(Matrix
const& A);
156 void allocate(ResourceType resource, Vector& v);
158 template <
typename T0,
typename... T>
159 void allocate(ResourceType resource, T0& v0, T&... args)
161 allocate(resource, v0);
162 allocate(resource, args...);
165 void free(Vector& v);
167 template <
typename T0,
typename... T>
168 void free(T0& v0, T&... args)
174#ifdef ALIEN_USE_PERF_TIMER
176 mutable TimerType m_timer;
180class SimpleCSRInternalLinearAlgebraExpr
184 SimpleCSRInternalLinearAlgebraExpr();
185 virtual ~SimpleCSRInternalLinearAlgebraExpr();
189 Real norm0(
const Vector& x)
const;
190 Real norm1(
const Vector& x)
const;
191 Real norm2(
const Vector& x)
const;
192 Real normInf(
const Vector& x)
const;
193 Real norm2(
const Matrix& x)
const;
195 void axpy(Real alpha,
const Vector& x,
Vector& r)
const;
196 void aypx(Real alpha,
Vector& y,
const Vector& x)
const;
199 void scal(Real alpha,
Vector& x)
const;
201 void reciprocal(
Vector& x)
const;
206 void mult(
const Matrix& a,
const UniqueArray<Real>& x, UniqueArray<Real>& r)
const;
207 void axpy(Real alpha, UniqueArray<Real>
const& x, UniqueArray<Real>& r)
const;
208 void aypx(Real alpha, UniqueArray<Real>& y, UniqueArray<Real>
const& x)
const;
209 void copy(
const UniqueArray<Real>& x, UniqueArray<Real>& r)
const;
211 Integer local_size,
const UniqueArray<Real>& x,
const UniqueArray<Real>& y)
const;
213 void scal(Real alpha, UniqueArray<Real>& x)
const;
217 void scal(Real alpha,
Matrix& r)
const;