Maple compact ludecomposition A.x=B, x为矩阵

Maple compact ludecomposition A.x=B, x is matrix

我最近实现了 Numerical Recipe 第 2 版中名为 bandec() 的 LUDecomposition 例程。它使用紧凑形式的带状矩阵创建 lu 分解(它还 returns 紧凑形式的 L 和 U)。我的问题是,如何求解方程组

A.x=B,如果x是矩阵?

有我可以使用的例程吗?

常规命令 LinearAlgebra:-LinearSolve 处理。如果 B 是一个矩阵,那么 x 也是。

您写了"sparse banded"。虽然带状情况没有特殊的稀疏求解器,但可以使用 LAPACK 的(密集)带求解器。我写这篇文章的可能性很小。

例如,

restart;
with(LinearAlgebra):
N:=10000:
M:=RandomMatrix(N,datatype=float[8]):
V:=RandomVector(N,datatype=float[8]):
infolevel[LinearAlgebra]:=1:
X:=CodeTools:-Usage(LinearSolve(M,V)):
  LinearSolve: using method LU
  LinearSolve: calling external function
  LinearSolve: NAG hw_f07adf
  LinearSolve: NAG hw_f07aef
  memory used=0.75GiB, alloc change=0.78GiB, cpu time=16.24s, real time=4.30s, gc time=8.00ms
Norm(M.X-V);
  unknown: NAG hw_f06paf
  unknown: NAG hw_f06paf
  Norm: calling external function
  Norm: NAG:  hw_f06raf
                                      -8
                1.06381179421077832 10  

restart;
with(LinearAlgebra):
N:=10000:
B:=max(1,floor(0.005*N)):
2*B+1;
                          101
M:=RandomMatrix(N,shape=band[B,B],datatype=float[8]):
V:=RandomVector(N,datatype=float[8]):
infolevel[LinearAlgebra]:=1:
X:=CodeTools:-Usage(LinearSolve(M,V)):
  LinearSolve: using method LU
  LinearSolve: calling external function
  LinearSolve: CLAPACK hw_dgbtrf_
  LinearSolve: CLAPACK hw_dgbtrs_
  memory used=13.09MiB, alloc change=11.52MiB, cpu time=20.00ms, real time=23.00ms, gc time=0ns
Norm(M.X-V);
  Multiply: calling external function
  Multiply: NAG hw_f06pbf
  Multiply: calling external function
  Multiply: NAG hw_f06pbf
Norm: calling external function
  Norm: NAG:  hw_f06raf
                                     -11
               8.03126454229641240 10