matrixop

版本 1.0.0.0 (66.1 KB) 作者: David Gleich
A Matlab object that acts just like a matrix but represents a linear operator as a function.
1.7K 次下载
更新时间 2007/3/2

无许可证

Many of the iterative methods in Matlab are designed to work with either a function handle to provide A*x, or a matrix A directly. Developing code for each paradigm is a pain. The matrixop class yields the flexibility of Matlab syntax using function handles or anonymous functions.

n = 100;
A = spdiags([e -2*e e], -1:1, n, n);
Afun = @(x) [-2*x(1) + x(2); x(1:n-2) - 2*x(2:n-1) + x(3:n); x(n-1)-2*x(n)];
op = matrixop(A);
x = linspace(-1,1,n)';
b = op*x; % calls Afun(x)
xminres = minres(op,b,[],200); % runs minres on op where op*x = Afun(x)
xgmres = gmres(op,b,[], [],200);

The advantage of the matrixop class is that you can write a single code that works for either a Matlab matrix or a function handle/linear operator representation. This simplifies the code and eliminates syntactic juggling that can cause bugs.

The zip file includes numerous examples of how to use the matrixop class along with a sample showing the performance implications. See the demo directory.

引用格式

David Gleich (2024). matrixop (https://www.mathworks.com/matlabcentral/fileexchange/14137-matrixop), MATLAB Central File Exchange. 检索时间: .

MATLAB 版本兼容性
创建方式 R14
兼容任何版本
平台兼容性
Windows macOS Linux
类别
Help CenterMATLAB Answers 中查找有关 Sparse Matrices 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

matrixop-1.0/@matrixop/

matrixop-1.0/demo/

matrixop-1.0/test/

版本 已发布 发行说明
1.0.0.0