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;
112 void lowerUpperSynchronize(
const Matrix& A,
Vector& y)
const;
113 void upperLowerSynchronize(
const Matrix& A,
Vector& y)
const;
116 void computeDiag(
const Matrix& a,
Vector& inv_diag)
const;
119 void computeInvDiag(
const Matrix& a,
Vector& inv_diag)
const;
121 void axpy(Real alpha,
const Vector& x,
Vector& r)
const;
122 void aypx(Real alpha,
Vector& y,
const Vector& x)
const;
125 void axpy(Real alpha,
const Vector& x,Integer stride_x,
Vector& r,Integer stride_r)
const;
126 void aypx(Real alpha,
Vector& y, Integer stride_y,
const Vector& x,Integer stride_x)
const;
127 void copy(
const Vector& x, Integer stride_x,
Vector& r, Integer stride_r)
const;
130 void dot(
const Vector& x,
const Vector& y, FutureType& res)
const;
132 void scal(Real alpha,
Vector& x)
const;
135 void reciprocal(
Vector& x)
const;
137 void assign(
Vector& x, Real alpha)
const;
139 template <
typename LambdaT>
140 void assign(
Vector& x, LambdaT
const& lambda)
const
142 auto x_ptr = x.getDataPtr();
143 for (Integer i = 0; i < x.getAllocSize(); ++i) {
144 x_ptr[i] = lambda(i);
148 template <
typename PrecondT>
149 void exec(PrecondT& precond, Vector
const& x, Vector& y)
151 return precond.solve(*
this, x, y);
154 Integer computeCxr(
const Matrix& a, Matrix& cxr_a)
const ;
155 Integer computeCxr(
const Matrix& a, Vector
const& diag_scal, Matrix& cxr_a)
const ;
157 static ResourceType resource(Matrix
const& A);
159 void allocate(ResourceType resource, Vector& v);
161 template <
typename T0,
typename... T>
162 void allocate(ResourceType resource, T0& v0, T&... args)
164 allocate(resource, v0);
165 allocate(resource, args...);
168 void free(Vector& v);
170 template <
typename T0,
typename... T>
171 void free(T0& v0, T&... args)
177#ifdef ALIEN_USE_PERF_TIMER
179 mutable TimerType m_timer;
183class SimpleCSRInternalLinearAlgebraExpr
187 SimpleCSRInternalLinearAlgebraExpr();
188 virtual ~SimpleCSRInternalLinearAlgebraExpr();
192 Real norm0(
const Vector& x)
const;
193 Real norm1(
const Vector& x)
const;
194 Real norm2(
const Vector& x)
const;
195 Real normInf(
const Vector& x)
const;
196 Real norm2(
const Matrix& x)
const;
198 void axpy(Real alpha,
const Vector& x,
Vector& r)
const;
199 void aypx(Real alpha,
Vector& y,
const Vector& x)
const;
202 void scal(Real alpha,
Vector& x)
const;
204 void reciprocal(
Vector& x)
const;
209 void mult(
const Matrix& a,
const UniqueArray<Real>& x, UniqueArray<Real>& r)
const;
210 void axpy(Real alpha, UniqueArray<Real>
const& x, UniqueArray<Real>& r)
const;
211 void aypx(Real alpha, UniqueArray<Real>& y, UniqueArray<Real>
const& x)
const;
212 void copy(
const UniqueArray<Real>& x, UniqueArray<Real>& r)
const;
214 Integer local_size,
const UniqueArray<Real>& x,
const UniqueArray<Real>& y)
const;
216 void scal(Real alpha, UniqueArray<Real>& x)
const;
220 void scal(Real alpha,
Matrix& r)
const;