Loading...
Searching...
No Matches
gpr::linalg::fixed Namespace Reference

Functions

bool choleskyLower (double *a, std::int64_t lda, std::int64_t n)
void solveRightLowerTranspose (const double *l, std::int64_t ldl, std::int64_t n, double *x, std::int64_t ldx, std::int64_t rows)
void solveLeftTriangular (const double *t, std::int64_t ldt, std::int64_t n, bool lower, double *b, std::int64_t ldb, std::int64_t cols)
void subtractProduct (const double *a, std::int64_t lda, bool transpose_a, const double *b, std::int64_t ldb, double *c, std::int64_t ldc, std::int64_t m, std::int64_t n, std::int64_t k)
void subtractProductTransposed (const double *a, std::int64_t lda, const double *bt, std::int64_t ldbt, double *c, std::int64_t ldc, std::int64_t m, std::int64_t n, std::int64_t k)

Function Documentation

◆ choleskyLower()

bool gpr::linalg::fixed::choleskyLower ( double * a,
std::int64_t lda,
std::int64_t n )
inline

Cholesky factor of the lower triangle of the n x n block a (column-major, leading dimension lda), in place. Left-looking: column j receives a(j:, j) -= a(j:, l) a(j, l) for l = 0 .. j-1 in ascending order, then is scaled by its pivot. Returns false at the first pivot that is not positive and finite; the block is then partly overwritten.

Definition at line 23 of file FixedOrderKernels.h.

24{
25 for (std::int64_t j = 0; j < n; ++j) {
26 double* column = a + j * lda;
27 for (std::int64_t l = 0; l < j; ++l) {
28 const double* source = a + l * lda;
29 const double factor = source[j];
30 for (std::int64_t i = j; i < n; ++i)
31 column[i] -= source[i] * factor;
32 }
33 const double pivot = column[j];
34 if (!(pivot > 0.0) || !std::isfinite(pivot)) return false;
35 const double root = std::sqrt(pivot);
36 column[j] = root;
37 for (std::int64_t i = j + 1; i < n; ++i)
38 column[i] /= root;
39 }
40 return true;
41}

◆ solveLeftTriangular()

void gpr::linalg::fixed::solveLeftTriangular ( const double * t,
std::int64_t ldt,
std::int64_t n,
bool lower,
double * b,
std::int64_t ldb,
std::int64_t cols )
inline

B := T^-1 B for the lower (lower == true) or upper triangle of T (n x n) and B (n x cols): forward or back substitution, one right-hand side at a time, row r taking the terms of the solved rows in order of solution.

Definition at line 67 of file FixedOrderKernels.h.

70{
71 for (std::int64_t j = 0; j < cols; ++j) {
72 double* x = b + j * ldb;
73 if (lower) {
74 for (std::int64_t r = 0; r < n; ++r) {
75 x[r] /= t[r + r * ldt];
76 const double solved = x[r];
77 const double* below = t + r * ldt;
78 for (std::int64_t i = r + 1; i < n; ++i)
79 x[i] -= below[i] * solved;
80 }
81 } else {
82 for (std::int64_t r = n - 1; r >= 0; --r) {
83 x[r] /= t[r + r * ldt];
84 const double solved = x[r];
85 const double* above = t + r * ldt;
86 for (std::int64_t i = 0; i < r; ++i)
87 x[i] -= above[i] * solved;
88 }
89 }
90 }
91}
@ x
Definition Enums.h:28

◆ solveRightLowerTranspose()

void gpr::linalg::fixed::solveRightLowerTranspose ( const double * l,
std::int64_t ldl,
std::int64_t n,
double * x,
std::int64_t ldx,
std::int64_t rows )
inline

X := X L^-T for X (rows x n, leading dimension ldx) and the lower triangle of L (n x n). Column c of X is (X(:, c) - sum_{l<c} X(:, l) L(c, l)) / L(c, c), terms in ascending l.

Definition at line 46 of file FixedOrderKernels.h.

49{
50 for (std::int64_t c = 0; c < n; ++c) {
51 double* column = x + c * ldx;
52 for (std::int64_t q = 0; q < c; ++q) {
53 const double factor = l[c + q * ldl];
54 const double* source = x + q * ldx;
55 for (std::int64_t i = 0; i < rows; ++i)
56 column[i] -= source[i] * factor;
57 }
58 const double pivot = l[c + c * ldl];
59 for (std::int64_t i = 0; i < rows; ++i)
60 column[i] /= pivot;
61 }
62}

◆ subtractProduct()

void gpr::linalg::fixed::subtractProduct ( const double * a,
std::int64_t lda,
bool transpose_a,
const double * b,
std::int64_t ldb,
double * c,
std::int64_t ldc,
std::int64_t m,
std::int64_t n,
std::int64_t k )
inline

C -= op(A) B with op(A) = A (m x k) or A^T (A stored k x m), B (k x n): entry (i, j) subtracts its k terms one at a time in ascending order. For products too narrow to amortize a Scheme II reconstruction.

Definition at line 96 of file FixedOrderKernels.h.

100{
101 for (std::int64_t j = 0; j < n; ++j) {
102 double* out = c + j * ldc;
103 for (std::int64_t l = 0; l < k; ++l) {
104 const double factor = b[l + j * ldb];
105 if (!transpose_a) {
106 const double* column = a + l * lda;
107 for (std::int64_t i = 0; i < m; ++i)
108 out[i] -= column[i] * factor;
109 } else {
110 for (std::int64_t i = 0; i < m; ++i)
111 out[i] -= a[l + i * lda] * factor;
112 }
113 }
114 }
115}
eon_relax_band_t eon_relax_surface_fn void eon_relax_outcome_t * out

◆ subtractProductTransposed()

void gpr::linalg::fixed::subtractProductTransposed ( const double * a,
std::int64_t lda,
const double * bt,
std::int64_t ldbt,
double * c,
std::int64_t ldc,
std::int64_t m,
std::int64_t n,
std::int64_t k )
inline

C -= A Bt^T with A (m x k, leading dimension lda) and Bt (n x k, leading dimension ldbt): entry (i, j) subtracts A(i, l) Bt(j, l) one term at a time, l ascending.

Definition at line 120 of file FixedOrderKernels.h.

125{
126 for (std::int64_t j = 0; j < n; ++j) {
127 double* out = c + j * ldc;
128 for (std::int64_t l = 0; l < k; ++l) {
129 const double factor = bt[j + l * ldbt];
130 const double* column = a + l * lda;
131 for (std::int64_t i = 0; i < m; ++i)
132 out[i] -= column[i] * factor;
133 }
134 }
135}