当前位置:网站首页>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 线性方程组
边栏推荐
- 进程和线程
- 华为BFD的配置规范
- Clock in during winter vacation
- Report on the competition status and investment decision recommendations of Guangxi hospital industry in China from 2022 to 2028
- B站刘二大人-线性回归及梯度下降
- Usage of test macro of GTEST
- [email protected]树莓派
- IPv6 comprehensive experiment
- Redistemplate common collection instructions opsforvalue (II)
- Wib3.0 leapfrogging, in leapfrogging (ง • ̀_•́) ง
猜你喜欢

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

授予渔,从0开始搭建一个自己想要的网页

Clock in during winter vacation

Grant Yu, build a web page you want from 0
[email protected] raspberry pie"/>[email protected] raspberry pie

Huawei BFD configuration specification

功能安全之故障(fault),错误(error),失效(failure)

Report on the competition status and investment decision recommendations of Guangxi hospital industry in China from 2022 to 2028

How can large websites choose better virtual machine service providers?
![[Baiwen smart home] first day of the course_ Learn Embedded and understand the development mode of bare metal and RTOS](/img/ed/8d112054f31bd7e593050d1278b9f1.jpg)
[Baiwen smart home] first day of the course_ Learn Embedded and understand the development mode of bare metal and RTOS
随机推荐
[paper reading] nflowjs: synthetic negative data intensive anomaly detection based on robust learning
Baidu online AI competition - image processing challenge: the 8th program of handwriting erasure
Embedded interview questions (IV. common algorithms)
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
请求转发与重定向
Garbage collector with serial, throughput priority and response time priority
Pytorch代码注意的细节,容易敲错的地方
Li Chuang EDA learning notes 12: common PCB board layout constraint principles
[email protected]树莓派
High quality coding tool clion
Is it difficult for an information system project manager?
How can large websites choose better virtual machine service providers?
CoDeSys note 2: set coil and reset coil
H3C防火墙RBM+VRRP 组网配置
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
Redistemplate common collection instructions opsforvalue (II)
授予渔,从0开始搭建一个自己想要的网页
Huawei BFD configuration specification
Classes and objects (I) detailed explanation of this pointer
OSPF configuration command of Huawei equipment