gpt4 book ai didi

algorithm - 如何确定 MATLAB 使用哪些例程来求解稀疏矩阵?

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:42:37 24 4
gpt4 key购买 nike

我正在尝试求解 A*x = b 形式的稀疏矩阵方程,其中 A为已知方稀疏矩阵,b为已知列向量,x为待定列向量。解决这个问题的标准 MATLAB 语法是:

x = A\b;

在幕后,\ 运算符是“使用任何看起来最好的算法来求解这个方程式”的简写。 MATLAB 相应地选择它认为是求解该方程的最佳算法,并使用该算法求解方程组。

虽然这种单一符号适用于所有情况的方法在过去对我很有效,但我需要知道正在使用哪种算法来求解我的方程组。有谁知道我怎么能找到这个?也许有一种方法可以告诉 MATLAB 打印任何/所有被调用的函数,并为嵌套调用缩进?

最佳答案

我认为您应该使用来自 matlab 的 spparms forum

help spparms
spparms - Set parameters for sparse matrix routines

This MATLAB function sets one or more of the tunable parameters used in the
sparse routines.

spparms('key',value)
spparms
values = spparms
[keys,values] = spparms
spparms(values)
value = spparms('key')
spparms('default')
spparms('tight')

Reference page for spparms

See also chol, colamd, lu, qr, symamd

像这样

>> A = sparse(rand(10).*round(rand(10)-0.2));
spparms('spumoni',2)
A\rand(10,1)

sp\: bandwidth = 9+1+7.
sp\: is A diagonal? no.
sp\: is band density (0.27) > bandden (0.50) to try banded solver? no.
sp\: is A triangular? no.
sp\: is A morally triangular? no.
sp\: is A a candidate for Cholesky (symmetric, real positive diagonal)? no.
sp\: use Unsymmetric MultiFrontal PACKage with automatic reordering.
UMFPACK V5.4.0 (May 20, 2009), Control:
Matrix entry defined as: double
Int (generic integer) defined as: UF_long

0: print level: 2
1: dense row parameter: 0.2
"dense" rows have > max (16, (0.2)*16*sqrt(n_col) entries)
2: dense column parameter: 0.2
"dense" columns have > max (16, (0.2)*16*sqrt(n_row) entries)
3: pivot tolerance: 0.1
4: block size for dense matrix kernels: 32
5: strategy: 0 (auto)
6: initial allocation ratio: 0.7
7: max iterative refinement steps: 2
12: 2-by-2 pivot tolerance: 0.01
13: Q fixed during numerical factorization: 0 (auto)
14: AMD dense row/col parameter: 10
"dense" rows/columns have > max (16, (10)*sqrt(n)) entries
Only used if the AMD ordering is used.
15: diagonal pivot tolerance: 0.001
Only used if diagonal pivoting is attempted.
16: scaling: 1 (divide each row by sum of abs. values in each row)
17: frontal matrix allocation ratio: 0.5
18: drop tolerance: 0
19: AMD and COLAMD aggressive absorption: 1 (yes)

The following options can only be changed at compile-time:
8: BLAS library used: Fortran BLAS. size of BLAS integer: 8
9: compiled for MATLAB
10: CPU timer is POSIX times ( ) routine.
11: compiled for normal operation (debugging disabled)
computer/operating system: Linux
size of int: 4 UF_long: 8 Int: 8 pointer: 8 double: 8 Entry: 8 (in bytes)

sp\: UMFPACK's factorization was successful.
sp\: UMFPACK's solve was successful.
UMFPACK V5.4.0 (May 20, 2009), Info:
matrix entry defined as: double
Int (generic integer) defined as: UF_long
BLAS library used: Fortran BLAS. size of BLAS integer: 8
MATLAB: yes.
CPU timer: POSIX times ( ) routine.
number of rows in matrix A: 10
number of columns in matrix A: 10
entries in matrix A: 26
memory usage reported in: 16-byte Units
size of int: 4 bytes
size of UF_long: 8 bytes
size of pointer: 8 bytes
size of numerical entry: 8 bytes

strategy used: unsymmetric
ordering used: colamd on A
modify Q during factorization: yes
prefer diagonal pivoting: no
pivots with zero Markowitz cost: 2
submatrix S after removing zero-cost pivots:
number of "dense" rows: 0
number of "dense" columns: 0
number of empty rows: 0
number of empty columns 0
submatrix S not square or diagonal not preserved
symbolic factorization defragmentations: 0
symbolic memory usage (Units): 238
symbolic memory usage (MBytes): 0.0
Symbolic size (Units): 57
Symbolic size (MBytes): 0
symbolic factorization CPU time (sec): 0.00
symbolic factorization wallclock time(sec): 0.00

matrix scaled: yes (divided each row by sum of abs values in each row)
minimum sum (abs (rows of A)): 1.21495e-01
maximum sum (abs (rows of A)): 2.36586e+00

symbolic/numeric factorization: upper bound actual %
variable-sized part of Numeric object:
initial size (Units) 171 161 94%
peak size (Units) 938 899 96%
final size (Units) 39 28 72%
Numeric final size (Units) 130 114 88%
Numeric final size (MBytes) 0.0 0.0 88%
peak memory usage (Units) 1189 1150 97%
peak memory usage (MBytes) 0.0 0.0 97%
numeric factorization flops 1.79000e+02 3.30000e+01 18%
nz in L (incl diagonal) 31 19 61%
nz in U (incl diagonal) 36 23 64%
nz in L+U (incl diagonal) 57 32 56%
largest front (# entries) 42 6 14%
largest # rows in front 7 3 43%
largest # columns in front 6 3 50%

initial allocation ratio used: 0.7
# of forced updates due to frontal growth: 0
nz in L (incl diagonal), if none dropped 19
nz in U (incl diagonal), if none dropped 23
number of small entries dropped 0
nonzeros on diagonal of U: 10
min abs. value on diagonal of U: 1.30e-01
max abs. value on diagonal of U: 9.70e-01
estimate of reciprocal of condition number: 1.35e-01
indices in compressed pattern: 12
numerical values stored in Numeric object: 29
numeric factorization defragmentations: 1
numeric factorization reallocations: 1
costly numeric factorization reallocations: 1
numeric factorization CPU time (sec): 0.16
numeric factorization wallclock time (sec): 0.17
numeric factorization mflops (CPU time): 0.00
numeric factorization mflops (wallclock): 0.00

solve flops: 2.58000e+02
iterative refinement steps taken: 0
iterative refinement steps attempted: 0
sparse backward error omega1: 2.11e-16
sparse backward error omega2: 0.00e+00
solve CPU time (sec): 0.00
solve wall clock time (sec): 0.00

total symbolic + numeric + solve flops: 2.91000e+02


ans =

-8.8364
29.2610
72.4619
51.8905
-42.4795
-46.4504
0.5000
5.6994
12.7503
45.2984

关于algorithm - 如何确定 MATLAB 使用哪些例程来求解稀疏矩阵?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30314476/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com