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;
115 void lowerUpperSynchronize(
const Matrix& A,
Vector& y)
const;
116 void upperLowerSynchronize(
const Matrix& A,
Vector& y)
const;
119 void computeDiag(
const Matrix& a,
Vector& inv_diag)
const;
122 void computeInvDiag(
const Matrix& a,
Vector& inv_diag)
const;
124 void axpy(Real alpha,
const Vector& x,
Vector& r)
const;
125 void aypx(Real alpha,
Vector& y,
const Vector& x)
const;
128 void axpy(Real alpha,
const Vector& x, Integer stride_x,
Vector& r, Integer stride_r)
const;
129 void axpy(Real alpha,
const Vector& x,
Vector& r, ConstArrayView<Integer> stride_r)
const;
130 void aypx(Real alpha,
Vector& y, Integer stride_y,
const Vector& x,Integer stride_x)
const;
132 void copy(
const Vector& x, Integer stride_x,
Vector& r, Integer stride_r)
const;
133 void copy(
const Vector& x, ConstArrayView<Integer> strides_x,
Vector& r)
const;
134 void copy(
const Vector& x,
Vector& r, ConstArrayView<Integer> strides_r)
const;
137 void dot(
const Vector& x,
const Vector& y, FutureType& res)
const;
139 void scal(Real alpha,
Vector& x)
const;
142 void reciprocal(
Vector& x)
const;
144 void assign(
Vector& x, Real alpha)
const;
146 template <
typename LambdaT>
147 void assign(
Vector& x, LambdaT
const& lambda)
const
149 auto x_ptr = x.getDataPtr();
150 for (Integer i = 0; i < x.getAllocSize(); ++i) {
151 x_ptr[i] = lambda(i);
155 template <
typename PrecondT>
156 void exec(PrecondT& precond, Vector
const& x, Vector& y)
158 return precond.solve(*
this, x, y);
161 Integer computeCxr(
const Matrix& a, Matrix& cxr_a)
const ;
162 Integer computeCxr(
const Matrix& a, Matrix& cxr_a, UniqueArray<Integer>& strides)
const ;
163 Integer computeCxr(
const Matrix& a, Vector
const& diag_scal, Matrix& cxr_a)
const ;
165 static ResourceType resource(Matrix
const& A);
167 void allocate(ResourceType resource, Vector& v);
169 template <
typename T0,
typename... T>
170 void allocate(ResourceType resource, T0& v0, T&... args)
172 allocate(resource, v0);
173 allocate(resource, args...);
176 void free(Vector& v);
178 template <
typename T0,
typename... T>
179 void free(T0& v0, T&... args)
185#ifdef ALIEN_USE_PERF_TIMER
187 mutable TimerType m_timer;
191class SimpleCSRInternalLinearAlgebraExpr
195 SimpleCSRInternalLinearAlgebraExpr();
196 virtual ~SimpleCSRInternalLinearAlgebraExpr();
200 Real norm0(
const Vector& x)
const;
201 Real norm1(
const Vector& x)
const;
202 Real norm2(
const Vector& x)
const;
203 Real normInf(
const Vector& x)
const;
204 Real norm2(
const Matrix& x)
const;
206 void axpy(Real alpha,
const Vector& x,
Vector& r)
const;
207 void aypx(Real alpha,
Vector& y,
const Vector& x)
const;
210 void scal(Real alpha,
Vector& x)
const;
212 void reciprocal(
Vector& x)
const;
217 void mult(
const Matrix& a,
const UniqueArray<Real>& x, UniqueArray<Real>& r)
const;
218 void axpy(Real alpha, UniqueArray<Real>
const& x, UniqueArray<Real>& r)
const;
219 void aypx(Real alpha, UniqueArray<Real>& y, UniqueArray<Real>
const& x)
const;
220 void copy(
const UniqueArray<Real>& x, UniqueArray<Real>& r)
const;
222 Integer local_size,
const UniqueArray<Real>& x,
const UniqueArray<Real>& y)
const;
224 void scal(Real alpha, UniqueArray<Real>& x)
const;
228 void scal(Real alpha,
Matrix& r)
const;