- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在尝试求解 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/
我正在使用混合效应模型,并且由于我的方法的特殊性我需要解决下面模型的积分,然后制作图表获得的估计值。 换句话说,我需要求解下面的积分: 其中,di^2 是我模型中的 Var3,dh 是混合效应模型对应
我有一个方程组,我想用数值方法求解它。给定起始种子,我想得到一个接近的解决方案。让我解释。 我有一个常量向量,X,值: X <- (c(1,-2,3,4)) 和一个向量 W 的权重: W <- (c(
假设我有以下方程组: a * b = 5 sqrt(a * b^2) = 10 如何求解 R 中 a 和 b 的这些方程? 我想这个问题可以说是一个优化问题,具有以下功能......? fn <- f
我在 R 中有一个简单的通量模型。它归结为两个微分方程,对模型中的两个状态变量进行建模,我们将它们称为 A和 B .它们被计算为四个分量通量的简单差分方程 flux1-flux4 , 5 个参数 p1
R有什么办法吗?求解给定单变量函数的反函数?动机是我以后告诉R使用值向量作为反函数的输入,以便它可以吐出反函数值。 例如,我有函数 y(x) = x^2 ,逆是 y = sqrt(x) .有没有办法R
我在字符串中有以下方程 y = 18774x + 82795 求解x我会这样做:- x = (y-82795) / 18774 我知道y的值 但是方程一直在变化,并且始终采用字符串格式 是否可以简单地
如果我用 diophantine(2*x+3*y-5*z-77) 我收到了这个结果。 {(t_0, -9*t_0 - 5*t_1 + 154, -5*t_0 - 3*t_1 + 77)} 到目前为止还
我正在尝试求解仅限于正解的 ODE,即: dx/dt=f(x) x>=0。 在 MATLAB 中这很容易实现。 R 是否有任何变通方法或包来将解决方案空间限制为仅正值? 这对我来说非常重要,不幸的是没
下面的 ANTLR 文法中的 'expr' 规则显然是相互左递归的。作为一个 ANTLR 新手,我很难解决这个问题。我已经阅读了 ANTLR 引用书中的“解决非 LL(*) 冲突”,但我仍然没有看到解
我有一个关于在 R 中求解函数的可能性的非常基本的问题,但知道答案确实有助于更好地理解 R。 我有以下等式: 0=-100/(1+r)+(100-50)/(1+r)^2+(100-50)/(1+r)^
我正在编写使用递归回溯来解决 8 个皇后问题的代码(将 n 个国际象棋皇后放在 n × n 的棋盘上,这样皇后就不会互相攻击)。 我的任务是创建两个方法:编写一个公共(public)solveQuee
我不知道在以下情况下如何进行,因为最后一个方程没有所有 4 个变量。所以使用了等式下面的代码,但这是错误的......有谁知道如何进行? 方程: 3a + 4b - 5c + d = 10 2a +
假设我们有这个递归关系,它出现在 AVL 树的分析中: F1 = 1 F2 = 2 Fn = Fn - 1 + Fn - 2 + 1(其中 n ≥ 3) 你将如何解决这个递归以获得 F(n) 的封闭形
在Maple中,有谁知道是否存在一个函数来求解变量?例如,我正在尝试求解 r 的 solve4r=(M-x^y)*(r^(-1)) mod (p-1)。所以我知道 M、x、y 和 p 的值,但不知道
我也问过这个here在声音设计论坛上,但问题是沉重的计算机科学/数学,所以它实际上可能属于这个论坛: 因此,通过读取文件中的二进制文件,我能够成功地找到关于 WAV 文件的所有信息,除了 big si
我有以下问题: 设 a 和 b 为 boolean 变量。是否可以设置 a 和 b 的值以使以下表达式的计算结果为 false? b or (((not a) or (not a)) or (a or
我需要用 C 求解这个超越方程: x = 2.0 - 0.5sen(x) 我试过这个: double x, newx, delta; x = 2.0 - 0.5; newx = sin(x); del
我在 Windows 上使用 OpenCV 3.1。 一段代码: RNG rng; // random number generator cv::Mat rVec = (cv::Mat_(3, 1)
我正在尝试求解一个包含 3 个变量和数量可变的方程的方程组。 基本上,系统的长度在 5 到 12 个方程之间,无论有多少个方程,我都试图求解 3 个变量。 看起来像这样: (x-A)**2 + (y-
我正在尝试为有限差分法设计一种算法,但我有点困惑。所讨论的 ODE 是 y''-5y'+10y = 10x,其中 y(0)=0 且 y(1)=100。所以我需要一种方法来以某种方式获得将从关系中乘以“
我是一名优秀的程序员,十分优秀!