No BSD License
-
adsmax(f, x, stopit, savit, P...
ADSMAX Alternating directions method for direct search optimization.
-
augment(A, alpha)
AUGMENT Augmented system matrix.
-
cholp(A, piv)
CHOLP Cholesky factorization with pivoting of a positive semidefinite matrix.
-
chop(x, t)
-
cod(A, tol)
COD Complete orthogonal decomposition.
-
cpltaxes(z)
CPLTAXES Determine suitable AXIS for plot of complex vector.
-
dual(x, p)
-
fv(B, nk, thmax, noplot)
-
gep(A, piv)
GEP Gaussian elimination with pivoting: none, complete, partial or rook.
-
gersh(A, noplot)
-
gfpp(T, c)
GFPP Matrix giving maximal growth factor for Gaussian elim. with pivoting.
-
gj(A, b, piv)
-
gqr(A, B, partial)
GQR Generalized QR factorization.
-
gs_c(A)
GS_C Classical Gram-Schmidt QR factorization.
-
gs_m(A)
GS_M Modified Gram-Schmidt QR factorization.
-
ldlt_skew(A)
LDLT_SKEW Block LDL^T factorization for a skew-symmetric matrix.
-
ldlt_symm(A, piv)
LDLT_SYMM Block LDL^T factorization for a symmetric indefinite matrix.
-
ldlt_sytr(A)
LDLT_SYTR Block LDL^T factorization for a symmetric tridiagonal matrix.
-
lse(A, b, B, d, method)
LSE Solve the equality constrained least squares problem.
-
makejcf(n, e, m, X)
MAKEJCF A matrix with specified Jordan canonical form.
-
matrix(k, n)
MATRIX Test matrices accessed by number.
-
matsignt(T)
MATSIGNT Matrix sign function of a triangular matrix.
-
mdsmax(fun, x, stopit, savit,...
MDSMAX Multidirectional search method for direct search optimization.
-
nmsmax(fun, x, stopit, savit,...
NMSMAX Nelder-Mead simplex method for direct search optimization.
-
pnorm(A, p, tol, prnt)
-
poldec(A)
POLDEC Polar decomposition.
-
ps(A, m, tol, rl, marksize)
-
pscont(A, k, npts, ax, levels...
PSCONT Contours and colour pictures of pseudospectra.
-
rootm(A,p)
-
rschur(n, mu, x, y)
RSCHUR An upper quasi-triangular matrix.
-
see(A, k)
-
seqcheb(n, k)
SEQCHEB Sequence of points related to Chebyshev polynomials.
-
seqm(a, b, n)
SEQM Multiplicative sequence.
-
show(x)
SHOW Display signs of matrix elements.
-
signm(A)
SIGNM Matrix sign decomposition.
-
skewpart(A)
SKEWPART Skew-symmetric (skew-Hermitian) part.
-
sparsify(A, p)
SPARSIFY Randomly set matrix elements to zero.
-
strassen(A, B, nmin)
STRASSEN Strassen's fast matrix multiplication algorithm.
-
strassenw(A, B, nmin)
STRASSENW Strassen's fast matrix multiplication algorithm (Winograd variant).
-
sub(A, i, j)
-
symmpart(A)
SYMMPART Symmetric (Hermitian) part.
-
trap2tri(L)
TRAP2TRI Unitary reduction of trapezoidal matrix to triangular form.
-
treshape(x,unit)
TRESHAPE Reshape vector to or from (unit) triangular matrix.
-
vand(m, p)
VAND Vandermonde matrix.
-
vecperm(m, n)
VECPERM Vec-permutation matrix.
-
Contents.m
-
mctdemo.m
-
readme.m
-
View all files
from
The Matrix Computation Toolbox
by Nick Higham
A collection of M-files for carrying out various numerical linear algebra tasks.
|
| treshape(x,unit)
|
function T = treshape(x,unit)
%TRESHAPE Reshape vector to or from (unit) triangular matrix.
% TRESHAPE(X) returns a square upper triangular matrix whose
% elements are taken columnwise from the matrix X.
% TRESHAPE(X,1) returns a UNIT upper triangular matrix, and
% the 1s should not be specified in X.
% An error results if X does not have a number of elements of the form
% N*(N+1)/2 (or N less than this in the unit triangular case).
% X = TRESHAPE(R,2) is the inverse operation to R = TRESHAPE(X).
% X = TRESHAPE(R,3) is the inverse operation to R = TRESHAPE(X,1).
if nargin == 1, unit = 0; end
[p,q] = size(x);
if unit < 2 % Convert vector x to upper triangular R.
m = p*q;
n = round( (-1 + sqrt(1+8*m))/2 );
if n*(n+1)/2 ~= m
error('Matrix must have a ''triangular'' number of elements.')
end
if unit == 1
n = n+1;
end
x = x(:);
T = unit*eye(n);
i = 1;
for j = 1+unit:n
T(1:j-unit,j) = x(i:i+j-1-unit);
i = i+j-unit;
end
elseif unit >= 2 % Convert upper triangular R to vector x.
T = x;
if p ~= q, error('Must pass square matrix'), end
unit = unit - 2;
n = p*(p+1)/2 - unit*p;
x = zeros(n,1);
i = 1;
for j = 1+unit:p
x(i:i+j-1-unit) = T(1:j-unit,j);
i = i+j-unit;
end
T = x;
end
|
|
Contact us at files@mathworks.com