nk
1.0.0
C++ Numerical Computing Runtime
Toggle main menu visibility
Loading...
Searching...
No Matches
la_solve.hpp
1
// ops/include/nk/ops/la_solve.hpp
2
//
3
// Internal linear-solve kernel: solve `A · X = B` (LU for square A,
4
// Householder QR for tall A). An L0.5 ops primitive — raw column-major
5
// double buffers + a memory_resource, no Value, no engine. It backs both the
6
// `\` operator in toolboxes/builtin (mldivide / mrdivide) AND the user-facing
7
// wrappers (inv / linsolve / pageinv / eig …) in toolboxes/linalg.
8
//
9
// It used to live in toolboxes/builtin/include/nk/builtin/internal/ precisely
10
// because "builtin must not include linalg" left nowhere shared for it. ops/
11
// (below both builtin and linalg) is its proper home; builtin's internal
12
// header now re-exports it for back-compat.
13
//
14
// Wide systems (m < n) are NOT supported here — MATLAB's mldivide returns the
15
// minimum-norm solution for wide matrices (needs SVD or QR-of-A'); deferred.
16
// All scratch goes through std::pmr::memory_resource (HARD RULE).
17
18
#pragma once
19
20
#include <complex>
21
#include <cstddef>
22
#include <memory_resource>
23
24
namespace
nk::ops {
25
26
// Solve A · X = B for X.
27
// A : m×n column-major (m >= n required; wide systems return false)
28
// B : m×nrhs column-major
29
// X : n×nrhs column-major (caller-allocated)
30
// Returns false on: m < n (unsupported), singular A (square, zero pivot),
31
// or rank-deficient A (tall, zero column norm or zero R diagonal). Internal
32
// scratch is allocated via the supplied memory_resource.
33
bool
la_solve(
const
double
*A, std::size_t m, std::size_t n,
34
const
double
*B, std::size_t nrhs,
35
double
*X,
36
std::pmr::memory_resource *mr);
37
38
bool
la_solve(
const
std::complex<double> *A, std::size_t m, std::size_t n,
39
const
std::complex<double> *B, std::size_t nrhs,
40
std::complex<double> *X,
41
std::pmr::memory_resource *mr);
42
43
bool
lu_factor_inplace(
double
*A, std::size_t lda, std::int32_t *piv, std::size_t m, std::size_t n);
44
bool
lu_factor_inplace(std::complex<double> *A, std::size_t lda, std::int32_t *piv, std::size_t m, std::size_t n);
45
46
}
// namespace nk::ops
src
ops
include
nk
ops
la_solve.hpp
Generated by
1.17.0