The R Project SVN R-packages

Rev

Rev 3876 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3876 Rev 4109
Line 8... Line 8...
8
\description{
8
\description{
9
  Construct a Matrix of a class that inherits from \code{Matrix}.
9
  Construct a Matrix of a class that inherits from \code{Matrix}.
10
}
10
}
11
\arguments{
11
\arguments{
12
  \item{data}{an optional numeric data vector or matrix.}
12
  \item{data}{an optional numeric data vector or matrix.}
13
  \item{nrow}{the desired number of rows}
13
  \item{nrow}{when \code{data} is not a matrix, the desired number of rows}
14
  \item{ncol}{the desired number of columns}
14
  \item{ncol}{when \code{data} is not a matrix, the desired number of columns}
15
  \item{byrow}{logical.  If \code{FALSE} (the default) the matrix is
15
  \item{byrow}{logical.  If \code{FALSE} (the default) the matrix is
16
    filled by columns, otherwise the matrix is filled by rows.}
16
    filled by columns, otherwise the matrix is filled by rows.}
17
  \item{dimnames}{a \code{\link{dimnames}} attribute for the matrix: a
17
  \item{dimnames}{a \code{\link{dimnames}} attribute for the matrix: a
18
    \code{list} of two character components.  They are set if not
18
    \code{list} of two character components.  They are set if not
19
    \code{\link{NULL}} (as per default).}
19
    \code{\link{NULL}} (as per default).}
Line 23... Line 23...
23
  \item{forceCheck}{logical indicating if the checks for structure
23
  \item{forceCheck}{logical indicating if the checks for structure
24
    should even happen when \code{data} is already a \code{"Matrix"}
24
    should even happen when \code{data} is already a \code{"Matrix"}
25
    object.}
25
    object.}
26
}
26
}
27
\value{
27
\value{
-
 
28
  Returns matrix of a class that inherits from \code{"Matrix"}.
28
  Returns an \code{nrow} by \code{ncol} matrix of a class that
29
  Only if \code{data} is not a \code{\link{matrix}} and does not already inherit
-
 
30
  from class \code{\linkS4class{Matrix}} are the arguments
29
  inherits from \code{"Matrix"}.
31
  \code{nrow}, \code{ncol} and \code{byrow} made use of.
30
}
32
}
31
\details{
33
\details{
32
  If either of \code{nrow} or \code{ncol} is not given, an attempt is
34
  If either of \code{nrow} or \code{ncol} is not given, an attempt is
33
  made to infer it from the length of \code{data} and the other
35
  made to infer it from the length of \code{data} and the other
34
  parameter.
36
  parameter.
Line 66... Line 68...
66
Matrix(diag(4) >  0)# -> "ldiMatrix" with diag = "U"
68
Matrix(diag(4) >  0)# -> "ldiMatrix" with diag = "U"
67
Matrix(diag(4) >  0, sparse=TRUE)# -> sparse...
69
Matrix(diag(4) >  0, sparse=TRUE)# -> sparse...
68
Matrix(diag(4) >= 0)# -> "lsyMatrix" (of all 'TRUE')
70
Matrix(diag(4) >= 0)# -> "lsyMatrix" (of all 'TRUE')
69
## triangular
71
## triangular
70
l3 <- upper.tri(matrix(,3,3))
72
l3 <- upper.tri(matrix(,3,3))
71
Matrix(l3)  # -> "ltCMatrix"
73
(M <- Matrix(l3))  # -> "ltCMatrix"
72
Matrix(! l3)# -> "ltrMatrix"
74
Matrix(! l3)# -> "ltrMatrix"
73
as(l3, "CsparseMatrix")
75
as(l3, "CsparseMatrix")
74
 
76
 
75
Matrix(1:9, nrow=3,
77
Matrix(1:9, nrow=3,
76
       dimnames = list(c("a", "b", "c"), c("A", "B", "C")))
78
       dimnames = list(c("a", "b", "c"), c("A", "B", "C")))