当前位置:网站首页>Eigen稀疏矩阵操作
Eigen稀疏矩阵操作
2022-07-06 05:58:00 【瞻邈】
在许多应用中(例如,有限元方法),通常处理非常大的矩阵,其中只有少数系数不为零。 在这种情况下,可以通过使用仅存储非零系数的专用表示来减少内存消耗并提高性能。 这样的矩阵称为稀疏矩阵。
1. 稀疏矩阵模块
模块 | 内容 | |
#include <Eigen/SparseCore> | SparseMatrix 和 SparseVector 类、矩阵组装、 基本稀疏线性代数(包括稀疏三角求解器) | |
#include <Eigen/SparseCholesky> | 直接用稀疏 LLT 和 LDLT Cholesky 分解来解决稀疏自伴随正定问题 | |
#include<Eigen/SparseLU> | 稀疏 LU 分解来解决一般平方稀疏系统 | |
#include<Eigen/SparseQR | 用于解决稀疏线性最小二乘问题的稀疏 QR 分解 | |
#include <Eigen/IterativeLinearSolvers> | 求解大型一般线性平方问题的迭代求解器(包括自伴随正定问题) | |
#include <Eigen/Sparse> | 包含以上所有模块 |
2. 稀疏矩阵格式
SparseMatrix 类是 Eigen 稀疏模块的主要稀疏矩阵表示; 它提供高性能和低内存使用率。 它实现了广泛使用的压缩列(或行)存储方案的更通用的变体。 它由四个紧凑的数组组成:
Values:存储非零系数值。
InnerIndices:存储非零的行(或列)索引。
OuterStarts:为每一列(或行)存储前两个数组中第一个非零的索引。
InnerNNZs:存储每列(相应行)的非零数。 inner指的是一个内部向量,它是列主矩阵的列,或行主矩阵的行。 外部这个词指的是另一个方向。
目前,给定内部向量的元素保证总是通过增加内部索引进行排序。 “_”表示可以快速插入新元素的可用空间。 假设不需要重新分配,随机元素的插入因此在 O(nnz_j) 中,其中 nnz_j 是相应内部向量的非零数。 另一方面,在给定的内部向量中插入具有增加内部索引的元素效率更高,因为这仅需要增加相应的 InnerNNZs 条目,即 O(1) 操作。
没有可用空间的情况是一种特殊情况,称为压缩模式。 它对应于广泛使用的压缩列(或行)存储方案(CCS 或 CRS)。 通过调用 SparseMatrix::makeCompressed() 函数,可以将任何 SparseMatrix 转换为这种形式。 在这种情况下,可以注意到 InnerNNZs 数组与 OuterStarts 是冗余的,因为我们等式:InnerNNZs[j] = OuterStarts[j+1]-OuterStarts[j]。 因此,实际上调用 SparseMatrix::makeCompressed() 会释放此缓冲区。
参考文献
Eigen关于稀疏矩阵_爱数学的虹猫的博客-CSDN博客_eigen sparsematrix
Eigen教程3 - 稀疏矩阵操作_xuezhisdc的博客-CSDN博客_eigen 稀疏矩阵
Eigen教程5 - 求解稀疏线性方程组_xuezhisdc的博客-CSDN博客_eigen 线性方程组
边栏推荐
- The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
- Arrays and collections
- H3C firewall rbm+vrrp networking configuration
- 大型网站如何选择比较好的云主机服务商?
- 【论文阅读】NFlowJS:基于鲁棒学习的合成负数据密集异常检测
- 养了只小猫咪
- Mysql database master-slave cluster construction
- Grant Yu, build a web page you want from 0
- Investment strategy discussion and market scale prediction report of China's solid state high power amplifier industry from 2022 to 2028
- The usage and difference between strlen and sizeof
猜你喜欢
Construction of yolox based on paste framework
MIT6.s081-2020 Lab2 System Calls
P2802 回家
ArcGIS application foundation 4 thematic map making
ContentType的作用
Classes and objects (I) detailed explanation of this pointer
C language bubble sort
Practice sharing: how to safely and quickly migrate from CentOS to openeuler
Node 之 nvm 下载、安装、使用,以及node 、nrm 的相关使用
Raised a kitten
随机推荐
Title 1093: character reverse order
[email protected]树莓派
Winter 2021 pat class B problem solution (C language)
Some easy-to-use tools make your essay style more elegant
Classes and objects (I) detailed explanation of this pointer
Introduction to promql of # yyds dry goods inventory # Prometheus
Hongliao Technology: how to quickly improve Tiktok store
[SQL Server Express Way] - authentification et création et gestion de comptes utilisateurs
Dynamic programming -- knapsack problem
华为路由器忘记密码怎么恢复
[experience] when ultralso makes a startup disk, there is an error: the disk / image capacity is too small
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
Baidu online AI competition - image processing challenge: the 8th program of handwriting erasure
ArcGIS application foundation 4 thematic map making
[course notes] Compilation Principle
Redis message queue
Auto. JS learning notes 17: basic listening events and UI simple click event operations
Practice sharing: how to safely and quickly migrate from CentOS to openeuler
[C language syntax] the difference between typedef struct and struct
Station B, Master Liu Er - dataset and data loading