Next: dos_windows Up: MacAnova Help File Previous: dim()   Contents

dmat()

Usage:
dmat(n,val), n > 0 integer, val a REAL, CHARACTER or LOGICAL scalar
dmat(vec), vec a REAL, CHARACTER or LOGICAL vector.



Keywords: matrix algebra, variables
                                  Usage
dmat(n,val), where n is a positive integer and val is a scalar
(length(val) = 1), produces an n by n diagonal matrix with val down the
diagonal.

dmat(a) where a is a vector of length n, a n by 1 matrix, or a 1 by n
matrix, produces a n by n diagonal matrix with the elements of a down
the diagonal.

Note: This is a sort of inverse to diag() which extracts the diagonal
elements of a matrix.

                                 Example
Example:
  Cmd> iden5 <- dmat(5,1); iden5 # or dmat(rep(1,5))
  (1,1)           1           0           0           0           0
  (2,1)           0           1           0           0           0
  (3,1)           0           0           1           0           0
  (4,1)           0           0           0           1           0
  (5,1)           0           0           0           0           1

This is the 5 by 5 identity matrix

                            Cross references
See also diag().


Gary Oehlert 2005-08-12