|
LMMC
Lamina Mathematic core
|
稀疏矩阵乘法:矩阵-向量、矩阵-稠密矩阵与稀疏×稀疏。 更多...
#include <string.h>#include <stdlib.h>#include "memory_bridge.h"#include "internal.h"#include "sparse_internal.h"#include "lmmc/sparse.h"函数 | |
| lmmc_status_t | lmmc_sparse_mat_vec_mul (const lmmc_sparse_mat_t *sparse, const lmmc_vec_t *x, lmmc_vec_t *y) |
| 稀疏矩阵-稠密向量乘法:y = A * x。 | |
| lmmc_status_t | lmmc_sparse_mat_mat_mul_dense (const lmmc_sparse_mat_t *sparse, const lmmc_mat_t *b, lmmc_mat_t *c) |
| 稀疏矩阵 x 稠密矩阵:C = A * B(结果为稠密矩阵)。 | |
| lmmc_status_t | lmmc_sparse_mat_mat_mul_sparse (const lmmc_sparse_mat_t *a, const lmmc_sparse_mat_t *b, lmmc_sparse_mat_t *c) |
| 稀疏矩阵-稀疏矩阵乘法(SpGEMM):C = A * B。 | |
稀疏矩阵乘法:矩阵-向量、矩阵-稠密矩阵与稀疏×稀疏。
在文件 sparse_products.c 中定义.
| lmmc_status_t lmmc_sparse_mat_vec_mul | ( | const lmmc_sparse_mat_t * | sparse, |
| const lmmc_vec_t * | x, | ||
| lmmc_vec_t * | y ) |
稀疏矩阵-稠密向量乘法:y = A * x。
支持 CSR 和 CSC 格式.CSR 时使用 4-展开内循环优化。 x->size 须等于 sparse->cols,y->size 须等于 sparse->rows。
| [in] | sparse | 输入稀疏矩阵(不被修改)。 |
| [in] | x | 输入向量(不被修改)。 |
| [out] | y | 输出向量,内容被完全覆写。 |
在文件 sparse_products.c 第 13 行定义.
引用了 lmmc_sparse_mat_t::col_idx, lmmc_sparse_mat_t::cols, lmmc_vec_t::data, lmmc_sparse_mat_t::format, LMMC_REAL_ADD, LMMC_REAL_CLEAR, LMMC_REAL_INIT, LMMC_REAL_MUL, LMMC_REAL_SET, LMMC_REAL_SET_D, LMMC_SPARSE_CSR, lmmc_sparse_mat_vec_mul(), LMMC_STATUS_DIMENSION_MISMATCH, LMMC_STATUS_INVALID_ARGUMENT, LMMC_STATUS_OK, lmmc_vec_fill(), lmmc_sparse_mat_t::row_ptr, lmmc_sparse_mat_t::rows, lmmc_vec_t::size , 以及 lmmc_sparse_mat_t::values.
被这些函数引用 lmmc_gmres_arnoldi(), lmmc_itersolve_matvec(), lmmc_itersolve_residual() , 以及 lmmc_sparse_mat_vec_mul().
| lmmc_status_t lmmc_sparse_mat_mat_mul_dense | ( | const lmmc_sparse_mat_t * | sparse, |
| const lmmc_mat_t * | b, | ||
| lmmc_mat_t * | c ) |
稀疏矩阵 x 稠密矩阵:C = A * B(结果为稠密矩阵)。
sparse 为 mxk,b 为 kxn,c 必须已创建为 mxn。 支持 CSR 和 CSC 格式,使用 4-展开优化。
| [in] | sparse | 输入稀疏矩阵(不被修改)。 |
| [in] | b | 输入稠密矩阵(不被修改)。 |
| [out] | c | 输出稠密矩阵,内容被完全覆写。 |
在文件 sparse_products.c 第 220 行定义.
引用了 lmmc_sparse_mat_t::col_idx, lmmc_mat_t::cols, lmmc_sparse_mat_t::cols, lmmc_mat_t::data, lmmc_sparse_mat_t::format, lmmc_mat_fill(), LMMC_REAL_CLEAR, LMMC_REAL_INIT, LMMC_REAL_SET, LMMC_REAL_SET_D, LMMC_SPARSE_CSR, lmmc_sparse_mat_mat_mul_dense(), LMMC_STATUS_DIMENSION_MISMATCH, LMMC_STATUS_INVALID_ARGUMENT, LMMC_STATUS_OK, lmmc_sparse_mat_t::row_ptr, lmmc_mat_t::rows, lmmc_sparse_mat_t::rows, lmmc_mat_t::stride , 以及 lmmc_sparse_mat_t::values.
被这些函数引用 lmmc_sparse_mat_mat_mul_dense().
| lmmc_status_t lmmc_sparse_mat_mat_mul_sparse | ( | const lmmc_sparse_mat_t * | a, |
| const lmmc_sparse_mat_t * | b, | ||
| lmmc_sparse_mat_t * | c ) |
稀疏矩阵-稀疏矩阵乘法(SpGEMM):C = A * B。
输出为 CSR 格式.内部使用行累加器(marker + accumulator)两遍算法: 第一遍计算 nnz 结构,第二遍填充数值。 若输入为 CSC 格式会先内部转换为 CSR。
| [in] | a | 左稀疏矩阵(不被修改)。 |
| [in] | b | 右稀疏矩阵(不被修改),a->cols 须等于 b->rows。 |
| [out] | c | 输出稀疏矩阵(CSR),调用方需配对调用 lmmc_sparse_destroy 释放。 |
在文件 sparse_products.c 第 310 行定义.
引用了 lmmc_sparse_mat_t::col_idx, lmmc_sparse_mat_t::cols, lmmc_sparse_mat_t::format, lmmc_memory_alloc_array(), lmmc_memory_alloc_array_plus(), LMMC_SPARSE_CSC, LMMC_SPARSE_CSR, lmmc_sparse_destroy(), lmmc_sparse_mat_mat_mul_sparse(), lmmc_sparse_to_csr(), LMMC_STATUS_ALLOCATION_FAILED, LMMC_STATUS_DIMENSION_MISMATCH, LMMC_STATUS_INVALID_ARGUMENT, LMMC_STATUS_OK, lmmc_sparse_mat_t::nnz, lmmc_sparse_mat_t::owns_data, lmmc_sparse_mat_t::row_ptr, lmmc_sparse_mat_t::rows , 以及 lmmc_sparse_mat_t::values.
被这些函数引用 lmmc_sparse_mat_mat_mul_sparse().