Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
27
Добавлен:
09.02.2015
Размер:
283.65 Кб
Скачать

Working with sparse matrices

<nnz> - Number of nonzero matrix elements.

NNZ Number of nonzero matrix elements.

nz = NNZ(S) is the number of nonzero elements in S.

The density of a sparse matrix S is nnz(S)/prod(size(S)).

See also nonzeros, nzmax, size.

Overloaded methods:

codistributed/nnz

Reference page in Help browser

doc nnz

<nonzeros> - Nonzero matrix elements.

NONZEROS Nonzero matrix elements.

NONZEROS(S) is a full column vector of the nonzero elements of S.

This gives the s, but not the i and j, from [i,j,s] = find(S).

See also nnz, find.

Overloaded methods:

codistributed/nonzeros

Reference page in Help browser

doc nonzeros

<nzmax> - Amount of storage allocated for nonzero matrix elements.

NZMAX Amount of storage allocated for nonzero matrix elements.

For a sparse matrix, NZMAX(S) is the number of storage locations

allocated for the nonzero elements in S.

For a full matrix, NZMAX(S) is prod(size(S)).

In both cases, nnz(S) <= nzmax(S) <= prod(size(S)).

See also nnz, nonzeros, spalloc.

Overloaded methods:

codistributed/nzmax

Reference page in Help browser

doc nzmax

<spones> - Replace nonzero sparse matrix elements with ones.

SPONES Replace nonzero sparse matrix elements with ones.

R = SPONES(S) generates a matrix with the same sparsity

structure as S, but with ones in the nonzero positions.

See also spfun, spalloc, nnz.

Overloaded methods:

codistributed/spones

Reference page in Help browser

doc spones

<spalloc> - Allocate space for sparse matrix.

SPALLOC Allocate space for sparse matrix.

S = SPALLOC(M,N,NZMAX) creates an M-by-N all zero sparse matrix

with room to eventually hold NZMAX nonzeros.

For example

s = spalloc(n,n,3*n);

for j = 1:n

s(:,j) = (a sparse column vector with 3 nonzero entries);

end

See also spones, spdiags, sprandn, sprandsym, speye, sparse.

Overloaded methods:

distributed/spalloc

codistributor2dbc/spalloc

codistributor1d/spalloc

codistributed/spalloc

Reference page in Help browser

doc spalloc

<issparse> - True for sparse matrix.

ISSPARSE True for sparse matrix.

ISSPARSE(S) is 1 if the storage class of S is sparse

and 0 otherwise.

See also sparse, full.

Overloaded methods:

distributed/issparse

codistributed/issparse

Reference page in Help browser

doc issparse

<spfun> - Apply function to nonzero matrix elements.

SPFUN Apply function to nonzero matrix elements.

F = SPFUN(FUN,S) evaluates the function FUN on the nonzero

elements of S.

Example

FUN can be specified using @:

S = sprand(30,30,0.2);

F = spfun(@exp,S);

has the same sparsity pattern as S (except for underflow),

whereas EXP(S) has 1's where S has 0's.

See also function_handle.

Overloaded methods:

codistributed/spfun

Reference page in Help browser

doc spfun

<spy> - Visualize sparsity pattern.

SPY Visualize sparsity pattern.

SPY(S) plots the sparsity pattern of the matrix S.

SPY(S,'LineSpec') uses the color and marker from the line

specification string 'LineSpec' (See PLOT for possibilities).

SPY(S,markersize) uses the specified marker size instead of

a size which depends upon the figure size and the matrix order.

SPY(S,'LineSpec',markersize) sets both.

SPY(S,markersize,'LineSpec') also works.

Reference page in Help browser

doc spy

Reordering algorithms

<amd> - Approximate minimum degree permutation.

AMD Approximate minimum degree permutation.

P = AMD(A) returns the approximate minimum degree permutation vector

for the sparse matrix C = A + A'. The Cholesky factorization of

C(P,P), or A(P,P), tends to be sparser than that of C or A. AMD tends

to be faster than SYMAMD. A must be square. If A is full, AMD(A) is

equivalent to AMD(SPARSE(A)).

P = AMD(A,OPTS) allows additional options for the reordering.

OPTS is structure with up to two fields:

dense --- indicates what is considered to be dense.

aggressive --- aggressive absorption

Only the fields of interest must be set.

dense is a nonnegative scalar such that if A is n-by-n, then rows/columns

with more than max(16, (dense * sqrt(n))) entries in A + A' are

considered "dense" and ignored during the ordering. They are placed

last in the output permutation. The default is 10.0 if this option

is not present.

aggressive is a scalar controlling aggressive absorption. If aggressive

is nonzero, then aggressive absorption is performed. This is the default

if this option is not present.

An assembly tree post-ordering is performed, which is typically the same

as an elimination tree post-ordering. It is not always identical because

of the approximate degree update used, and because "dense" rows/columns

do not take part in the post-order. It well-suited for a subsequent

"chol", however. If you require a precise elimination tree post-ordering,

then do:

P = amd(S);

C = spones(S) + spones(S'); % skip this if S already symmetric

[~, Q] = etree(C(P,P));

P = P(Q);

AMD Version 2.0 is written and copyrighted by Timothy A. Davis,

Patrick R. Amestoy, and Iain S. Duff.

Availability:

http://www.cise.ufl.edu/research/sparse/amd

See also colamd, colperm, symamd, symrcm, slash.

Reference page in Help browser

doc amd

<colamd> - Column approximate minimum degree permutation.

COLAMD Column approximate minimum degree permutation.

P = COLAMD(S) returns the column approximate minimum degree permutation

vector for the sparse matrix S. For a non-symmetric matrix S, S(:,P)

tends to have sparser LU factors than S. The Cholesky factorization of

S(:,P)'*S(:,P) also tends to be sparser than that of S'*S. The ordering

is followed by a column elimination tree post-ordering.

Usage: P = colamd (S)

[P, stats] = colamd (S, knobs)

knobs is an optional one- to three-element input vector. If S is m-by-n,

then rows with more than max(16,knobs(1)*sqrt(n)) entries are ignored.

Columns with more than max(16,knobs(2)*sqrt(min(m,n))) entries are

removed prior to ordering, and ordered last in the output permutation P.

Only completely dense rows or columns are removed if knobs(1) and knobs(2)

are < 0, respectively. If knobs(3) is nonzero, stats and knobs are

printed. The default is knobs = [10 10 0]. Note that knobs differs from

earlier versions of colamd.

Type the command "type colamd" for a description of the optional stats

output and for the copyright information.

Authors: S. Larimore and T. Davis, University of Florida. Developed in

collaboration with J. Gilbert and E. Ng. Version 2.5.

Acknowledgements: This work was supported by the National Science

Foundation, under grants DMS-9504974 and DMS-9803599.

See also amd, symamd, colperm, symrcm.

Reference page in Help browser

doc colamd

<symamd> - Symmetric approximate minimum degree permutation.

SYMAMD Symmetric approximate minimum degree permutation.

P = SYMAMD(S) for a symmetric positive definite matrix S, returns the

permutation vector p such that S(p,p) tends to have a sparser Cholesky

factor than S. Sometimes SYMAMD works well for symmetric indefinite

matrices too. The matrix S is assumed to be symmetric; only the

strictly lower triangular part is referenced. S must be square.

Note that p = amd(S) is much faster and generates comparable orderings.

The ordering is followed by an elimination tree post-ordering.

Usage: P = symamd (S)

[P, stats] = symamd (S, knobs)

knobs is an optional one- to two-element input vector. If S is n-by-n,

then rows and columns with more than max(16,knobs(1)*sqrt(n)) entries are

removed prior to ordering, and ordered last in the output permutation P.

No rows/columns are removed if knobs(1)<0. If knobs(2) is nonzero, stats

and knobs are printed. The default is knobs = [10 0]. Note that knobs

differs from earlier versions of symamd.

Type the command "type symamd" for a description of the optional stats

output and for the copyright information.

Authors: S. Larimore and T. Davis, University of Florida. Developed in

collaboration with J. Gilbert and E. Ng. Version 2.5.

Acknowledgements: This work was supported by the National Science

Foundation, under grants DMS-9504974 and DMS-9803599.

See also amd, colamd, colperm, symrcm.

Reference page in Help browser

doc symamd

<symrcm> - Symmetric reverse Cuthill-McKee permutation.

SYMRCM Symmetric reverse Cuthill-McKee permutation.

p = SYMRCM(S) returns a permutation vector p such that S(p,p)

tends to have its diagonal elements closer to the diagonal than S.

This is a good preordering for LU or Cholesky factorization of

matrices that come from "long, skinny" problems. It works for

both symmetric and nonsymmetric S. When S is nonsymmetric, SYMRCM

works on the structure of S + S'.

See also amd, colamd, colperm.

Reference page in Help browser

doc symrcm

<colperm> - Column permutation.

COLPERM Column permutation.

p = COLPERM(S) returns a permutation vector that reorders the

columns of the sparse matrix S in nondecreasing order of nonzero

count. This is sometimes useful as a preordering for LU

factorization: lu(S(:,p)).

Соседние файлы в папке Библиотеки Matlab