| Line 59... |
Line 59... |
| 59 |
This is enables typical \code{"pMatrix"} construction, given
|
59 |
This is enables typical \code{"pMatrix"} construction, given
|
| 60 |
a permutation vector of \code{1:n}, see the first example.}
|
60 |
a permutation vector of \code{1:n}, see the first example.}
|
| 61 |
\item{coerce}{\code{signature(from = "numeric", to = "pMatrix")}:
|
61 |
\item{coerce}{\code{signature(from = "numeric", to = "pMatrix")}:
|
| 62 |
a user convenience, to allow \code{as(perm, "pMatrix")} for
|
62 |
a user convenience, to allow \code{as(perm, "pMatrix")} for
|
| 63 |
numeric \code{perm} with integer values.}
|
63 |
numeric \code{perm} with integer values.}
|
| 64 |
\item{coerce}{\code{signature(from = "pMatrix", to = "matrix")}: ... }
|
64 |
\item{coerce}{\code{signature(from = "pMatrix", to = "matrix")}:
|
| - |
|
65 |
coercion to a traditional 0/1 \code{\link{matrix}} of
|
| - |
|
66 |
\code{\link{mode}} \code{integer}.}
|
| 65 |
\item{coerce}{\code{signature(from = "pMatrix", to = "ngTMatrix")}:
|
67 |
\item{coerce}{\code{signature(from = "pMatrix", to = "ngTMatrix")}:
|
| 66 |
coercion to sparse logical matrix of class \code{\linkS4class{ngTMatrix}}.}
|
68 |
coercion to sparse logical matrix of class \code{\linkS4class{ngTMatrix}}.}
|
| 67 |
\item{solve}{\code{signature(a = "pMatrix", b = "missing")}: return
|
69 |
\item{solve}{\code{signature(a = "pMatrix", b = "missing")}: return
|
| 68 |
the inverse permutation matrix.}
|
70 |
the inverse permutation matrix.}
|
| 69 |
\item{t}{\code{signature(x = "pMatrix")}: return the transpose of
|
71 |
\item{t}{\code{signature(x = "pMatrix")}: return the transpose of
|
| Line 85... |
Line 87... |
| 85 |
\examples{
|
87 |
\examples{
|
| 86 |
(pm1 <- as(as.integer(c(2,3,1)), "pMatrix"))
|
88 |
(pm1 <- as(as.integer(c(2,3,1)), "pMatrix"))
|
| 87 |
t(pm1) # is the same as
|
89 |
t(pm1) # is the same as
|
| 88 |
solve(pm1)
|
90 |
solve(pm1)
|
| 89 |
pm1 \%*\% t(pm1) # check that the transpose is the inverse
|
91 |
pm1 \%*\% t(pm1) # check that the transpose is the inverse
|
| 90 |
stopifnot(identical(diag(3), as(pm1 \%*\% t(pm1), "matrix")))
|
92 |
stopifnot(all.equal(diag(3), as(pm1 \%*\% t(pm1), "matrix")),
|
| - |
|
93 |
is.integer(as(pm1, "matrix")))
|
| 91 |
|
94 |
|
| 92 |
set.seed(11)
|
95 |
set.seed(11)
|
| 93 |
## random permutation matrix :
|
96 |
## random permutation matrix :
|
| 94 |
(p10 <- as(sample(10),"pMatrix"))
|
97 |
(p10 <- as(sample(10),"pMatrix"))
|
| 95 |
|
98 |
|