28 memset(work, 0,
sizeof(*work));
36 inverse_workspace_destroy(work);
55 for (
size_t i = 0; i < A->
rows; i++) {
56 for (
size_t j = 0; j < A->
rows; j++) {
60 norm_A = sqrt(norm_A);
69 for (
size_t i = 0; i < A->
rows; i++) {
70 for (
size_t j = 0; j < A->
rows; j++) {
82 fill_real_shift(A, mu + perturb, &work->
shifted);
85 perturb = sqrt(eps) * norm_A;
86 fill_real_shift(A, mu + perturb, &work->
shifted);
98 for (i = 0; i < n2; i++) {
99 for (j = 0; j < n2; j++) {
105 for (i = 0; i < n; i++) {
106 for (j = 0; j < n; j++) {
112 for (i = 0; i < n; i++) {
117 for (i = 0; i < n; i++) {
122 for (i = 0; i < n; i++) {
123 for (j = 0; j < n; j++) {
124 MAT_ELEM(big, n + i, n + j) =
MAT_ELEM(A, i, j) - ((i == j) ? alpha_p : 0.0);
134 for (i = 0; i < n; i++) {
135 for (j = 0; j < n; j++) {
141 for (i = 0; i < n; i++) {
153 fill_complex_shift(A, alpha + perturb, beta, &work->
shifted);
156 retry_complex_shift(A, alpha + sqrt(eps) * norm_A, beta, &work->
shifted);
165 for (
size_t i = 0; i < vector->
size; i++) nrm += vector->
data[i] * vector->
data[i];
171 for (
size_t i = 0; i < n; i++) {
175 for (
size_t i = 0; i < n; i++) {
181 for (
size_t i = 0; i < work->
rhs.
size; i++) work->
rhs.
data[i] /= nrm;
187 const size_t max_iter = 20;
188 for (
size_t iter = 0; iter < max_iter; iter++) {
219 for (
size_t j = 0; j < n; j++) {
233 for (
size_t i = 0; i < n;) {
235 status = inverse_workspace_resize(&work, is_real ? n : 2 * n);
248 inverse_start_vector(n, &work);
249 status = inverse_iterate(&work);
254 store_real_vector(result, i, &work);
257 store_complex_vectors(result, i, &work);
261 inverse_workspace_destroy(&work);
LMMC binary real type and arithmetic spelling.
double lmmc_real_t
Public and internal LMMC real type.
lmmc_status_t lmmc_mat_create(size_t rows, size_t cols, lmmc_mat_t *out_mat)
创建 rows x cols 的零矩阵。
lmmc_status_t lmmc_vec_create(size_t size, lmmc_vec_t *out_vec)
创建长度为 size 的零向量。
void lmmc_mat_destroy(lmmc_mat_t *mat)
销毁矩阵,释放其拥有的缓冲区并清零结构体字段。
void lmmc_vec_destroy(lmmc_vec_t *vec)
销毁向量,释放其拥有的缓冲区并清零字段。
一般实矩阵完整特征分解结果(特征值 + 特征向量).
lmmc_status_t lmmc_eigen_inverse_vectors(const lmmc_mat_t *a, lmmc_eigen_gen_full_result_t *result)
特征值 / SVD 模块内部共享的缩放、Householder 与 Givens 辅助接口(仅源文件可见)。
#define MAT_ELEM(mat, i, j)
特征向量计算阶段独占的工作区,各移位复用同一缓冲区。
稠密矩阵直接分解接口(LU、Cholesky、QR)。
lmmc_status_t lmmc_lu_solve(const lmmc_mat_t *lu, const size_t *pivots, const lmmc_vec_t *b, lmmc_vec_t *x)
利用 LU 分解结果求解线性系统 A*x = b。
lmmc_status_t lmmc_lu_decompose_inplace(lmmc_mat_t *a, size_t *pivots, size_t *out_swap_count)
就地 LU 分解(带部分主元选取):P*A = L*U。
void * lmmc_memory_alloc_array(size_t count, size_t element_size)
void lmmc_memory_free(void *pointer)
Private recoverable allocator for persistent LMMC ownership.
lmmc_status_t
LMMC 库统一返回的状态码.
@ LMMC_STATUS_ALLOCATION_FAILED
@ LMMC_STATUS_SINGULAR_MATRIX