环境数据分析中的矩阵运算与模型参数处理
1. 矩阵乘法与双共轭梯度求解器
在矩阵运算中, * 运算符在不同情况下有不同的作用。对于稀疏矩阵,它执行矩阵乘法;而对于稠密(非稀疏)矩阵,它执行逐元素乘法。双共轭梯度求解器在 MATLAB 和 Python 中的使用方式有所不同。
1.1 MATLAB 实现
% eda05_07: sparse matrix implementation of Fm=f
...
% need this to communicate with edaFTFmul
clear edaFsparse;
global edaFsparse;
...
% solve using conjugate gradient algorithm
mest=bicg(@FTFmul,edaFsparse'*fobs,1e-12,3*(M+N));
在 MATLAB 中,矩阵 edaFsparse 需要在主脚本中声明为全局变量,并且 FTFmul() 函数直接传递给 bicg 函数。
1.2 Python 实现
# edapy_05_07: sparse matrix implementation of Fm=f
...
# define linear operator needed for conjugate gradienet solver
LO=
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



