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

时间:2016-10-10 12:37:21

标签: matrix maple

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

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

我可以使用的常规吗?

2 个答案:

答案 0 :(得分:0)

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

答案 1 :(得分:0)

你写的是“稀疏带状”。虽然没有特殊的稀疏求解器用于带状情况,但可以使用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