accelerInt
v0.1
|
Implementation of various linear algebra functions needed in the exponential integrators. More...
#include "exponential_linear_algebra.cuh"
Go to the source code of this file.
Functions | |
__device__ void | matvec_m_by_m (const int m, const double *const __restrict__ A, const double *const __restrict__ V, double *const __restrict__ Av) |
Matrix-vector multiplication of a matrix sized MxM and a vector Mx1. More... | |
__device__ void | matvec_m_by_m_plusequal (const int m, const double *const __restrict__ A, const double *const __restrict__ V, double *const __restrict__ Av) |
Matrix-vector plus equals for a matrix of size MxM and vector of size Mx1. That is, it returns (A + I) * v. More... | |
__device__ void | matvec_n_by_m_scale (const int m, const double scale, const double *const __restrict__ A, const double *const __restrict__ V, double *const __restrict__ Av) |
Matrix-vector multiplication of a matrix sized NSPxM and a vector of size Mx1 scaled by a specified factor That is, it returns A * v * scale. More... | |
__device__ void | matvec_n_by_m_scale_special (const int m, const double *__restrict__ scale, const double *__restrict__ A, double *const __restrict__ *V, double *__restrict__ *Av) |
Matrix-vector multiplication of a matrix sized NSPxM and a vector of size Mx1 scaled by a specified factor. More... | |
__device__ void | matvec_n_by_m_scale_special2 (const int m, const double *__restrict__ scale, const double *__restrict__ A, double *const __restrict__ *V, double *__restrict__ *Av) |
Matrix-vector multiplication of a matrix sized NSPxM and a vector of size Mx1 scaled by a specified factor. More... | |
__device__ 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 factor and added to another vector. More... | |
__device__ void | matvec_n_by_m_scale_add_subtract (const int m, const double scale, const double *__restrict__ A, const double *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 factor and adds and subtracts the specified vectors note, the addition is twice the specified vector. More... | |
__device__ void | scale (const double *__restrict__ y0, const double *__restrict__ y1, double *__restrict__ sc) |
Get scaling for weighted norm. More... | |
__device__ void | scale_init (const double *__restrict__ y0, double *__restrict__ sc) |
Get scaling for weighted norm for the initial timestep (used in krylov process) More... | |
__device__ double | sc_norm (const double *__restrict__ nums, const double *__restrict__ sc) |
Perform weighted norm. More... | |
__device__ double | two_norm (const double *__restrict__ v) |
Computes and returns the two norm of a vector. More... | |
__device__ double | normalize (const double *__restrict__ v, double *__restrict__ v_out) |
Normalize the input vector using a 2-norm. More... | |
__device__ 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) More... | |
__device__ void | scale_subtract (const double s, const double *__restrict__ Vm, double *__restrict__ w) |
Subtracts Vm scaled by s from w. More... | |
__device__ void | scale_mult (const double s, const double *__restrict__ w, double *__restrict__ Vm) |
Sets Vm to s * w. More... | |
Implementation of various linear algebra functions needed in the exponential integrators.
Definition in file exponential_linear_algebra.cu.
__device__ 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)
returns \(Vm \dot w\)
[in] | w | the vector with with to dot |
[in] | Vm | the subspace vector |
Definition at line 217 of file exponential_linear_algebra.cu.
__device__ void matvec_m_by_m | ( | const int | m, |
const double *const __restrict__ | A, | ||
const double *const __restrict__ | V, | ||
double *const __restrict__ | Av | ||
) |
Matrix-vector multiplication of a matrix sized MxM and a vector Mx1.
[in] | m | size of the matrix |
[in] | A | matrix of size MxM |
[in] | V | vector of size Mx1 |
[out] | Av | vector that is A * v |
Definition at line 15 of file exponential_linear_algebra.cu.
__device__ void matvec_m_by_m_plusequal | ( | const int | m, |
const double *const __restrict__ | A, | ||
const double *const __restrict__ | V, | ||
double *const __restrict__ | Av | ||
) |
Matrix-vector plus equals for a matrix of size MxM and vector of size Mx1. That is, it returns (A + I) * v.
[in] | m | size of the matrix |
[in] | A | matrix of size MxM |
[in] | V | vector of size Mx1 |
[out] | Av | vector that is (A + I) * v |
Definition at line 31 of file exponential_linear_algebra.cu.
__device__ void matvec_n_by_m_scale | ( | const int | m, |
const double | scale, | ||
const double *const __restrict__ | A, | ||
const double *const __restrict__ | V, | ||
double *const __restrict__ | Av | ||
) |
Matrix-vector multiplication of a matrix sized NSPxM and a vector of size Mx1 scaled by a specified factor That is, it returns A * v * scale.
[in] | m | size of the matrix |
[in] | scale | a number to scale the multplication by |
[in] | A | matrix |
[in] | V | the vector |
[out] | Av | vector that is A * V * scale |
Definition at line 48 of file exponential_linear_algebra.cu.
__device__ void matvec_n_by_m_scale_add | ( | const int | m, |
const double | scale, | ||
const double *__restrict__ | add, | ||
const double *__restrict__ | A, | ||
double *__restrict__ | V, | ||
const double *__restrict__ | Av | ||
) |
Matrix-vector multiplication of a matrix sized NSPxM and a vector of size Mx1 scaled by a specified factor and added to another vector.
Computes \(A * V * scale + add\)
[in] | m | size of the matrix |
[in] | scale | a number to scale the multplication by |
[in] | add | the vector to add to the result |
[in] | A | matrix |
[in] | V | the vector |
[out] | Av | vector that is A * V * scale + add |
Definition at line 114 of file exponential_linear_algebra.cu.
__device__ void matvec_n_by_m_scale_add_subtract | ( | const int | m, |
const double | scale, | ||
const double *__restrict__ | A, | ||
const double * | 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 factor and adds and subtracts the specified vectors note, the addition is twice the specified vector.
Computes \(scale * A * V + 2 * add - sub\)
[in] | m | size of the matrix |
[in] | scale | a number to scale the multplication by |
[in] | A | matrix |
[in] | V | the vector |
[out] | Av | vector that is scale * A * V + 2 * add - sub |
[in] | add | the vector to add to the result |
[in] | sub | the vector to subtract from the result |
Definition at line 134 of file exponential_linear_algebra.cu.
__device__ void matvec_n_by_m_scale_special | ( | const int | m, |
const double *__restrict__ | scale, | ||
const double *__restrict__ | A, | ||
double *const __restrict__ * | V, | ||
double *__restrict__ * | Av | ||
) |
Matrix-vector multiplication of a matrix sized NSPxM and a vector of size Mx1 scaled by a specified factor.
Computes the following: \(Av1 = A * V1 * scale[0]\), \(Av2 = A * V2 * scale[1]\), and \(Av3 = A * V3 * scale[2] + V4 + V5\)
[in] | m | size of the matrix |
[in] | scale | a list of numbers to scale the multplication by |
[in] | A | matrix |
[in] | V | a list of 5 pointers corresponding to V1, V2, V3, V4, V5 |
[out] | Av | a list of 3 pointers corresponding to Av1, Av2, Av3 |
Definition at line 67 of file exponential_linear_algebra.cu.
__device__ void matvec_n_by_m_scale_special2 | ( | const int | m, |
const double *__restrict__ | scale, | ||
const double *__restrict__ | A, | ||
double *const __restrict__ * | V, | ||
double *__restrict__ * | Av | ||
) |
Matrix-vector multiplication of a matrix sized NSPxM and a vector of size Mx1 scaled by a specified factor.
Computes the following: \(Av1 = A * V1 * scale[0]\) and: \(Av2 = A * V2 * scale[1]\)
Performs inline matrix-vector multiplication (with unrolled loops)
[in] | m | size of the matrix |
[in] | scale | a list of numbers to scale the multplication by |
[in] | A | matrix |
[in] | V | a list of 2 pointers corresponding to V1, V2 |
[out] | Av | a list of 2 pointers corresponding to Av1, Av2 |
Definition at line 92 of file exponential_linear_algebra.cu.
__device__ double normalize | ( | const double *__restrict__ | v, |
double *__restrict__ | v_out | ||
) |
Normalize the input vector using a 2-norm.
\(v_{out} = \frac{v}{\left| v \right|}_2\)
[in] | v | vector to be normalized |
[out] | v_out | where to stick the normalized part of v (in a column) |
Definition at line 199 of file exponential_linear_algebra.cu.
__device__ double sc_norm | ( | const double *__restrict__ | nums, |
const double *__restrict__ | sc | ||
) |
Perform weighted norm.
Computes \(\left| nums * sc\right|_2\)
[in] | nums | values to be normed |
[in] | sc | scaling array for norm |
Definition at line 176 of file exponential_linear_algebra.cu.
__device__ void scale | ( | const double *__restrict__ | y0, |
const double *__restrict__ | y1, | ||
double *__restrict__ | sc | ||
) |
Get scaling for weighted norm.
Computes \(\frac{1.0}{ATOL + \max\left(\left|y0\right|, \left|y1\right|) * RTOL\right)}\)
[in] | y0 | values at current timestep |
[in] | y1 | values at next timestep |
[out] | sc | array of scaling values |
Definition at line 156 of file exponential_linear_algebra.cu.
__device__ void scale_init | ( | const double *__restrict__ | y0, |
double *__restrict__ | sc | ||
) |
Get scaling for weighted norm for the initial timestep (used in krylov process)
[in] | y0 | values at current timestep |
[out] | sc | array of scaling values |
Definition at line 166 of file exponential_linear_algebra.cu.
__device__ void scale_mult | ( | const double | s, |
const double *__restrict__ | w, | ||
double *__restrict__ | Vm | ||
) |
Sets Vm to s * w.
\(Vm = s * w\)
[in] | s | the scale multiplier to use |
[in] | w | the vector to use as a base |
[out] | Vm | the subspace matrix to set |
Definition at line 237 of file exponential_linear_algebra.cu.
__device__ void scale_subtract | ( | const double | s, |
const double *__restrict__ | Vm, | ||
double *__restrict__ | w | ||
) |
Subtracts Vm scaled by s from w.
\( w -= Vm * s\)
[in] | s | the scale multiplier to use |
[in] | Vm | the subspace matrix |
[out] | w | the vector to subtract from |
Definition at line 228 of file exponential_linear_algebra.cu.
__device__ double two_norm | ( | const double *__restrict__ | v | ) |
Computes and returns the two norm of a vector.
Computes \(\sqrt{\sum{v^2}}\)
[in] | v | the vector |
Definition at line 188 of file exponential_linear_algebra.cu.