- •If a is a 2-d matrix.
- •In which case they are expanded so that the first three arguments
- •Working with sparse matrices
- •If s is symmetric, then colperm generates a permutation so that
- •Linear algebra
- •If sigma is a real or complex scalar including 0, eigs finds the
- •Is compensated so that column sums are preserved. That is, the
- •Xreginterprbf/condest
- •X and y are vectors of coordinates in the unit square at which
- •If you have a fill-reducing permutation p, you can combine it with an
- •Miscellaneous
- •In previous versions of matlab, the augmented matrix was used by
matlab\sparfun – Разряженные матрицы
Elementary sparse matrices
<speye> - Sparse identity matrix.
SPEYE Sparse identity matrix.
SPEYE(M,N) and SPEYE([M N]) form an M-by-N sparse
matrix with 1's on the main diagonal. SPEYE(N)
abbreviates SPEYE(N,N).
SPEYE(SIZE(A)) is a space-saving SPARSE(EYE(SIZE(A)))
If a is a 2-d matrix.
See also spones, spdiags, spalloc, sprand, sprandn.
Overloaded methods:
distributed/speye
codistributor2dbc/speye
codistributor1d/speye
codistributed/speye
Reference page in Help browser
doc speye
<sprand> - Sparse uniformly distributed random matrix.
SPRAND Sparse uniformly distributed random matrix.
R = SPRAND(S) has the same sparsity structure as S, but uniformly
distributed random entries.
R = SPRAND(m,n,density) is a random, m-by-n, sparse matrix with
approximately density*m*n uniformly distributed nonzero entries.
SPRAND is designed to produce large matrices with small density
and will generate significantly fewer nonzeros than requested
if m*n is small or density is large.
R = SPRAND(m,n,density,rc) also has reciprocal condition number
approximately equal to rc. R is constructed from a sum of
matrices of rank one.
If rc is a vector of length lr <= min(m,n), then R has
rc as its first lr singular values, all others are zero.
In this case, R is generated by random plane rotations
applied to a diagonal matrix with the given singular values
It has a great deal of topological and algebraic structure.
See also sprandn, sprandsym.
Overloaded methods:
distributed/sprand
codistributor2dbc/sprand
codistributor1d/sprand
codistributed/sprand
Reference page in Help browser
doc sprand
<sprandn> - Sparse normally distributed random matrix.
SPRANDN Sparse normally distributed random matrix.
R = SPRANDN(S) has the same sparsity structure as S, but normally
distributed random entries.
R = SPRANDN(m,n,density) is a random, m-by-n, sparse matrix with
approximately density*m*n normally distributed nonzero entries.
SPRANDN is designed to produce large matrices with small density
and will generate significantly fewer nonzeros than requested if
m*n is small or density is large.
R = SPRANDN(m,n,density,rc) also has reciprocal condition number
approximately equal to rc. R is constructed from a sum of
matrices of rank one.
If rc is a vector of length lr <= min(m,n), then R has
rc as its first lr singular values, all others are zero.
In this case, R is generated by random plane rotations
applied to a diagonal matrix with the given singular values
It has a great deal of topological and algebraic structure.
See also sprand, sprandsym.
Overloaded methods:
distributed/sprandn
codistributor2dbc/sprandn
codistributor1d/sprandn
codistributed/sprandn
Reference page in Help browser
doc sprandn
<sprandsym> - Sparse random symmetric matrix.
SPRANDSYM Sparse random symmetric matrix.
R = SPRANDSYM(S) is a symmetric random matrix whose lower triangle
and diagonal have the same structure as S. The elements are
normally distributed, with mean 0 and variance 1.
R = SPRANDSYM(n,density) is a symmetric random, n-by-n, sparse
matrix with approximately density*n*n nonzeros; each entry is
the sum of one or more normally distributed random samples.
R = SPRANDSYM(n,density,rc) also has a reciprocal condition number
equal to rc. The distribution of entries is
nonuniform; it is roughly symmetric about 0; all are in [-1,1].
If rc is a VECTOR of length n, then R has eigenvalues rc.
Thus, if rc is a positive (nonnegative) vector then R will
be positive (nonnegative) definite. In either case, R is
generated by random Jacobi rotations applied to a diagonal
matrix with the given eigenvalues or condition number. It has
a great deal of topological and algebraic structure.
R = SPRANDSYM(n, density, rc, kind) is positive definite.
If kind = 1, R is generated by random Jacobi rotation of
a positive definite diagonal matrix.
R has the desired condition number exactly.
If kind = 2, R is a shifted sum of outer products.
R has the desired condition number only
approximately, but has less structure.
R = SPRANDSYM(S,[],rc,3) has the same structure as the MATRIX S
and approximate condition number 1/rc.
See also sprandn, sprand.
Reference page in Help browser
doc sprandsym
<spdiags> - Sparse matrix formed from diagonals.
SPDIAGS Sparse matrix formed from diagonals.
SPDIAGS, which generalizes the function "diag", deals with three
matrices, in various combinations, as both input and output.
[B,d] = SPDIAGS(A) extracts all nonzero diagonals from the m-by-n
matrix A. B is a min(m,n)-by-p matrix whose columns are the p
nonzero diagonals of A. d is a vector of length p whose integer
components specify the diagonals in A.
B = SPDIAGS(A,d) extracts the diagonals specified by d.
A = SPDIAGS(B,d,A) replaces the diagonals of A specified by d with
the columns of B. The output is sparse.
A = SPDIAGS(B,d,m,n) creates an m-by-n sparse matrix from the
columns of B and places them along the diagonals specified by d.
Roughly, A, B and d are related by
for k = 1:p
B(:,k) = diag(A,d(k))
end
Example: These commands generate a sparse tridiagonal representation
of the classic second difference operator on n points.
e = ones(n,1);
A = spdiags([e -2*e e], -1:1, n, n)
Some elements of B, corresponding to positions "outside" of A, are
not actually used. They are not referenced when B is an input and
are set to zero when B is an output. If a column of B is longer than
the diagonal it's representing, elements of super-diagonals of A
correspond to the lower part of the column of B, while elements of
sub-diagonals of A correspond to the upper part of the column of B.
Example: This uses the top of the first column of B for the second
sub-diagonal and the bottom of the third column of B for the first
super-diagonal.
B = repmat((1:n)',1,3);
S = spdiags(B,[-2 0 1],n,n);
See also diag, speye.
Reference page in Help browser
doc spdiags
Full to sparse conversion
<sparse> - Create sparse matrix.
SPARSE Create sparse matrix.
S = SPARSE(X) converts a sparse or full matrix to sparse form by squeezing
out any zero elements.
S = sparse(i,j,s,m,n,nzmax) uses vectors i, j, and s to generate an m-by-n
sparse matrix such that S(i(k),j(k)) = s(k), with space allocated for nzmax
nonzeros. Vectors i, j, and s are all the same length. Any elements of s
that are zero are ignored, along with the corresponding values of i and
j. Any elements of s that have duplicate values of i and j are added
together.To simplify this six-argument call, you can pass scalars for the
argument s and one of the arguments i or j.in which case they are expanded
so that i, j, and s all have the same length.
The simplifications of the six-argument call are:
S = SPARSE(i,j,s,m,n) where nzmax = length(s).
S = SPARSE(i,j,s) where m = max(i) and n = max(j).
S = SPARSE(m,n) abbreviates SPARSE([],[],[],m,n,0). This
generates the ultimate sparse matrix, an m-by-n all zero matrix.
The argument s and one of the arguments i or j may be scalars,