% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/demomat.R
\name{demomat}
\alias{demomat}
\title{Set up a matrix whose elements consist of row and col numbers.}
\usage{
demomat(
  nr,
  nc,
  n3 = 0,
  root = NULL,
  vec = 0,
  shape = NULL,
  nodiag = 0,
  supermat = 0,
  list = 0,
  fullsymb = 0,
  mul = NULL,
  mul3 = NULL,
  rnroot = "r",
  cnroot = "c",
  anroot = "a"
)
}
\arguments{
\item{nr}{# of rows of the matrix to be generated
or a vector consisting of the # of rows of each submatrix.}

\item{nc}{# of columns of the matrix to be generated
or a vector consisting of the # of columns of each submatrix.}

\item{n3}{# of the 3d dimension or 0, if any}

\item{root}{The root character of the elements of the symbolic matrix. \cr
If this is present, a character matrix/array will be created.}

\item{vec}{= 1 to drop the redundant subscript.}

\item{shape}{Shape of the resulting matrix: \cr
"sym", "symU", "symL", "diag", "uppert", "lowert"}

\item{nodiag}{= 1 to set the diagonal elements to 0 when either
"upper" or "lower" is specified}

\item{supermat}{= 1 to create horizontally stacked array\cr
= 2 to create vertically stacked array\cr
= 0 othereize}

\item{list}{= 1 to return the array as list when n3 > 2.}

\item{fullsymb}{= 1 to make the result a fully symbolic matrix}

\item{mul}{See below.}

\item{mul3}{See below.}

\item{rnroot}{root of the row names}

\item{cnroot}{root of the column names}

\item{anroot}{root of the third dimension names}
}
\value{
A matrix or an array. \cr
Note that even with vec=1 option, thre result is a matrix. \cr
Use c() to convert it to a vector.
}
\description{
This can create either symbolic or numeric matrix.
}
\details{
The i,j elements of a matrix will be named as mul*i + j\cr
 The i,j,k elements of an array will be named as mul3*(mul*i + j) + k\cr
 \cr
 When a supermatrix is generated, SMdim attributes will be set \cr
 where SMdim	is a list of the form \cr
 (nrows=nr, ncols=nc, rownames=rn, colnames=cn, anames=an) \cr
 where \cr
  nr is a vector consisting of the number of rows of each submatrix, \cr
  nc is a vector consisting of the number of columns of each submatrix \cr
  rn is a vector consisting of the supplemental row names \cr
  cn is a vector consisting of the supplemental column names \cr
  an is a vector consisting of the names associated with the 3rd dim.\cr
  '
}
\examples{
demomat( 11,3 ) # numeric matrix
demomat( 11,3,root="a" ) # symbolic matrix
demomat( 4,1,root="a", vec=1 ) # symbolic matrix

demomat( 4,3,2 ) # numeric array
demomat( 4,3,2, supermat=1 ) # numeric supermatrix (horizontally stacked)
demomat( 4,3,2, supermat=2 ) # numeric supermatrix (vertically stacked)

# Below two creates almost identical super matrices.
demomat( 4,3,2, root="a", supermat=1 )
demomat( 4,c(3,3), root="a" )

# 2 x 2 partitioned matrix
A=demomat( c(4,3),c(3,2), root="a" )
Printb(A)

# various shape
demomat(3,3,root="a", shape="sym")
demomat(3,3,root="a", shape="diag")
demomat(3,3,root="a", shape="lowert")

# fully symbolic matrix
demomat(4,4, root="S", fullsymb=1)
demomat(4,4, root="S", shape="sym", fullsymb=1)

}
