10 #ifndef EXPONENTIAL_LINEAR_ALGEBRA_H 11 #define EXPONENTIAL_LINEAR_ALGEBRA_H 29 const double * __restrict__ V,
double * __restrict__ Av) {
32 for (
int i = 0; i < m; ++i) {
36 for (
int j = 1; j < m; ++j) {
37 Av[i] += A[j *
STRIDE + i] * V[j];
55 const double * __restrict__ V,
double * __restrict__ Av)
59 for (
int i = 0; i < m; ++i) {
64 for (
int j = 1; j < m; ++j) {
65 Av[i] += A[j *
STRIDE + i] * V[j];
85 const double * __restrict__ A,
const double * __restrict__ V,
86 double * __restrict__ Av) {
89 for (
int i = 0; i <
NSP; ++i) {
94 for (
int j = 1; j < m; ++j) {
95 Av[i] += A[j *
NSP + i] * V[j];
119 const double * __restrict__ A,
const double** __restrict__ V,
120 double** __restrict__ Av) {
122 for (
int i = 0; i <
NSP; ++i) {
123 Av[0][i] = A[i] * V[0][0];
124 Av[1][i] = A[i] * V[1][0];
125 Av[2][i] = A[i] * V[2][0];
129 for (
int j = 1; j < m; ++j) {
130 Av[0][i] += A[j *
NSP + i] * V[0][j];
131 Av[1][i] += A[j *
NSP + i] * V[1][j];
132 Av[2][i] += A[j *
NSP + i] * V[2][j];
135 Av[0][i] *=
scale[0];
136 Av[1][i] *=
scale[1];
137 Av[2][i] = Av[2][i] *
scale[2] + V[3][i] + V[4][i];
159 const double* __restrict__ A,
const double** __restrict__ V,
160 double** __restrict__ Av) {
162 for (
int i = 0; i <
NSP; ++i) {
163 Av[0][i] = A[i] * V[0][0];
164 Av[1][i] = A[i] * V[1][0];
168 for (
int j = 1; j < m; ++j) {
169 Av[0][i] += A[j *
NSP + i] * V[0][j];
170 Av[1][i] += A[j *
NSP + i] * V[1][j];
173 Av[0][i] *=
scale[0];
174 Av[1][i] *=
scale[1];
194 const double* __restrict__ V,
double* __restrict__ Av,
195 const double* __restrict__ add) {
197 for (
int i = 0; i <
NSP; ++i) {
202 for (
int j = 1; j < m; ++j) {
203 Av[i] += A[j *
NSP + i] * V[j];
206 Av[i] = Av[i] *
scale + add[i];
228 const double* __restrict__ A,
const double* __restrict__ V,
229 double* __restrict__ Av,
const double* __restrict__ add,
230 const double* __restrict__ sub) {
233 for (
int i = 0; i <
NSP; ++i) {
238 for (
int j = 1; j < m; ++j) {
239 Av[i] += A[j *
NSP + i] * V[j];
242 Av[i] = Av[i] *
scale + 2.0 * add[i] - sub[i];
258 void scale (
const double* __restrict__ y0,
const double* __restrict__ y1,
double* __restrict__ sc) {
260 for (
int i = 0; i <
NSP; ++i) {
261 sc[i] = 1.0 / (
ATOL + fmax(fabs(y0[i]), fabs(y1[i])) *
RTOL);
274 void scale_init (
const double* __restrict__ y0,
double* __restrict__ sc) {
276 for (
int i = 0; i <
NSP; ++i) {
277 sc[i] = 1.0 / (
ATOL + fabs(y0[i]) *
RTOL);
293 double sc_norm (
const double* __restrict__ nums,
const double* __restrict__ sc) {
296 for (
int i = 0; i <
NSP; ++i) {
297 norm += nums[i] * nums[i] * sc[i] * sc[i];
300 return sqrt(norm /
NSP);
315 for (
int i = 0; i <
NSP; ++i) {
330 double normalize (
const double* __restrict__ v,
double* __restrict__ v_out) {
337 double m_norm = 1.0 / norm;
340 for (
int i = 0; i <
NSP; ++i) {
341 v_out[i] = v[i] * m_norm;
356 double dotproduct(
const double* __restrict__ w,
const double* __restrict__ Vm)
360 for(
int i = 0; i <
NSP; i++)
376 static inline void scale_subtract(
const double s,
const double* __restrict__ Vm,
double* __restrict__ w)
379 for (
int i = 0; i <
NSP; i++)
395 static inline void scale_mult(
const double s,
const double* __restrict__ w,
double* __restrict__ Vm)
398 for (
int i = 0; i <
NSP; i++)
static void scale_init(const double *__restrict__ y0, double *__restrict__ sc)
Get scaling for weighted norm for the initial timestep (used in krylov process)
static void scale_mult(const double s, const double *__restrict__ w, double *__restrict__ Vm)
Sets Vm to s * w.
static double sc_norm(const double *__restrict__ nums, const double *__restrict__ sc)
Perform weighted norm.
static void matvec_n_by_m_scale_special2(const int m, const double *__restrict__ scale, const double *__restrict__ A, const double **__restrict__ V, double **__restrict__ Av)
Matrix-vector multiplication of a matrix sized NSPxM and a vector of size Mx1 scaled by a specified f...
#define STRIDE
the matrix dimensions
A file generated by Scons that specifies various options to the solvers.
static double dotproduct(const double *__restrict__ w, const double *__restrict__ Vm)
Performs the dot product of the w (NSP x 1) vector with the given subspace vector (NSP x 1) ...
static void matvec_n_by_m_scale_add_subtract(const int m, const double scale, const double *__restrict__ A, const double *__restrict__ V, double *__restrict__ Av, const double *__restrict__ add, const double *__restrict__ sub)
Matrix-vector multiplication of a matrix sized NSPxM and a vector of size Mx1 scaled by a specified f...
static void matvec_m_by_m(const int m, const double *__restrict__ A, const double *__restrict__ V, double *__restrict__ Av)
Matrix-vector multiplication of a matrix sized MxM and a vector Mx1.
static double normalize(const double *__restrict__ v, double *__restrict__ v_out)
Normalize the input vector using a 2-norm.
static void matvec_n_by_m_scale_add(const int m, const double scale, const double *__restrict__ A, const double *__restrict__ V, double *__restrict__ Av, const double *__restrict__ add)
Matrix-vector multiplication of a matrix sized NSPxM and a vector of size Mx1 scaled by a specified f...
static void scale_subtract(const double s, const double *__restrict__ Vm, double *__restrict__ w)
Subtracts Vm scaled by s from w.
simple convenience file to include the correct solver properties file
static void scale(const double *__restrict__ y0, const double *__restrict__ y1, double *__restrict__ sc)
Get scaling for weighted norm.
static void matvec_m_by_m_plusequal(const int m, const double *__restrict__ A, const double *__restrict__ V, double *__restrict__ Av)
Matrix-vector plus equals for a matrix of size MxM and vector of size Mx1. That is, it returns (A + I) * v.
static void matvec_n_by_m_scale(const int m, const double scale, const double *__restrict__ A, const double *__restrict__ V, double *__restrict__ Av)
Matrix-vector multiplication of a matrix sized NSPxM and a vector of size Mx1 scaled by a specified f...
static double two_norm(const double *__restrict__ v)
Computes and returns the two norm of a vector.
static void matvec_n_by_m_scale_special(const int m, const double *__restrict__ scale, const double *__restrict__ A, const double **__restrict__ V, double **__restrict__ Av)
Matrix-vector multiplication of a matrix sized NSPxM and a vector of size Mx1 scaled by a specified f...