Next: triupper() Up: MacAnova Help File Previous: trilower()   Contents

triunpack()

Usage:
triunpack(vec [, lower:T  or  upper:T]), vec a vector of length p(p+1)/2



Keywords: matrix algebra, variables, combining variables
triunpack(v) creates a symmetric square matrix from vector v which
specifies the upper triangular part of the matrix, including the
diagonal.  The length of v be of the form p*(p+1)/2, that is, it is a
'triangular number' and the dimension of the result is p by p.  For
example, triunpack(run(10)) produces the matrix
             [1   2   4   7]
             [2   3   5   8]
             [4   5   6   9]
             [7   8   9  10]

in which the upper triangle is filled column by column from run(10) and
the lower triangle is filled in symmetrically.

triunpack(v,upper:T) does the same, except the elements below the
diagonal are set to 0.

triunpack(v,lower:T) returns triunpack(v,upper:T)', whose elements above
the diagonal are 0.

When v is a CHARACTER vector, empty strings ("") are used instead of 0's
in filling out the other half.

Example:
  Cmd> triunpack(run(10), upper:T)
and
  Cmd> triunpack(run(10), lower:T)
produce
             [1   2   4   7]          [1   0   0   0]
             [0   3   5   8]          [2   3   0   0]
             [0   0   6   9]   and    [4   5   6   0] , respectively.
             [0   0   0  10]          [7   8   9  10]

See also triupper(), trilower(), qr().


Gary Oehlert 2003-01-15