Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/matlab/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Algorithm 如何确定MATLAB用于求解稀疏矩阵的例程?_Algorithm_Matlab_Linear Algebra_Sparse Matrix - Fatal编程技术网

Algorithm 如何确定MATLAB用于求解稀疏矩阵的例程?

Algorithm 如何确定MATLAB用于求解稀疏矩阵的例程?,algorithm,matlab,linear-algebra,sparse-matrix,Algorithm,Matlab,Linear Algebra,Sparse Matrix,我试图求解一个形式为a*x=b的稀疏矩阵方程,其中a是一个已知的正方形稀疏矩阵,b是一个已知的列向量,x是要确定的列向量。解决此问题的标准MATLAB语法为: x = A\b; 在幕后,\操作符是“使用似乎最适合求解该方程的算法”的简写。因此,MATLAB选择它认为是求解该方程的最佳算法,并使用该算法求解方程组 虽然这一符号适用于所有情况,但这种方法在过去对我来说非常有效,我需要知道用哪种算法来求解我的方程组。有人知道我怎么能找到这个吗?也许有一种方法可以告诉MATLAB打印任何/所有被调用的

我试图求解一个形式为a*x=b的稀疏矩阵方程,其中a是一个已知的正方形稀疏矩阵,b是一个已知的列向量,x是要确定的列向量。解决此问题的标准MATLAB语法为:

x = A\b;
在幕后,
\
操作符是“使用似乎最适合求解该方程的算法”的简写。因此,MATLAB选择它认为是求解该方程的最佳算法,并使用该算法求解方程组


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

我认为您应该使用MATLAB中的spparms

像这样

>> 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

.另见。(我不确定它是否重复)另请参见。您可以查看函数。@Luis Mendo:不是重复的。我在问如何在运行时确定MATLAB的决策。@jvriesem我明白了。那么,也许可以在问题中说得更清楚些
>> 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