SCM

SCM Repository

[matrix] Annotation of /pkg/man/pMatrix-class.Rd
ViewVC logotype

Annotation of /pkg/man/pMatrix-class.Rd

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1548 - (view) (download) (as text)

1 : bates 638 \name{pMatrix-class}
2 :     \docType{class}
3 :     \alias{pMatrix-class}
4 : maechler 956 \alias{-,pMatrix,missing-method}
5 : bates 638 \alias{\%*\%,matrix,pMatrix-method}
6 :     \alias{\%*\%,pMatrix,matrix-method}
7 : maechler 657 \alias{\%*\%,pMatrix,pMatrix-method}
8 : maechler 953 \alias{\%*\%,Matrix,pMatrix-method}
9 :     \alias{\%*\%,pMatrix,Matrix-method}
10 : bates 638 \alias{coerce,integer,pMatrix-method}
11 : maechler 1407 \alias{coerce,numeric,pMatrix-method}
12 : bates 638 \alias{coerce,pMatrix,matrix-method}
13 : maechler 1548 \alias{coerce,pMatrix,ngTMatrix-method}
14 : maechler 1305 \alias{coerce,pMatrix,TsparseMatrix-method}
15 : bates 638 \alias{solve,pMatrix,missing-method}
16 :     \alias{t,pMatrix-method}
17 :     \title{Permutation matrices}
18 :     \description{The \code{"pMatrix"} class is the class of permutation
19 : maechler 659 matrices, stored as 1-based integer permutation vectors.}
20 : bates 638 \section{Objects from the Class}{
21 :     Objects can be created by calls of the form \code{new("pMatrix", ...)}
22 : maechler 659 or by coercion from an integer permutation vector, see below.
23 : bates 638 }
24 :     \section{Slots}{
25 :     \describe{
26 :     \item{\code{perm}:}{An integer, 1-based permutation vector, i.e.
27 :     an integer vector of length \code{Dim[1]} whose elements form a
28 :     permutation of \code{1:Dim[1]}.}
29 :     \item{\code{Dim}:}{Object of class \code{"integer"}. The dimensions
30 :     of the matrix which must be a two-element vector of equal,
31 :     non-negative integers.}
32 :     \item{\code{Dimnames}:}{list of length two; each component
33 :     containing NULL or a \code{\link{character}} vector length
34 :     equal the corresponding \code{Dim} element.}
35 :     }
36 :     }
37 :     \section{Extends}{
38 : maechler 659 Class \code{"Matrix"}, directly.
39 : bates 638 }
40 :     \section{Methods}{
41 :     \describe{
42 : maechler 657 \item{\%*\%}{\code{signature(x = "matrix", y = "pMatrix")} and other
43 :     signatures (use \code{showMethods("\%*\%", class="pMatrix")}): ... }
44 : maechler 659 \item{coerce}{\code{signature(from = "integer", to = "pMatrix")}:
45 : maechler 1407 This is enables typical \code{"pMatrix"} construction, given
46 : maechler 659 a permutation vector of \code{1:n}, see the first example.}
47 : maechler 1407 \item{coerce}{\code{signature(from = "numeric", to = "pMatrix")}:
48 :     a user convenience, to allow \code{as(perm, "pMatrix")} for
49 :     numeric \code{perm} with integer values.}
50 : bates 638 \item{coerce}{\code{signature(from = "pMatrix", to = "matrix")}: ... }
51 : maechler 1548 \item{coerce}{\code{signature(from = "pMatrix", to = "ngTMatrix")}:
52 :     coercion to sparse logical matrix of class \code{\linkS4class{ngTMatrix}}.}
53 : bates 638 \item{solve}{\code{signature(a = "pMatrix", b = "missing")}: return
54 :     the inverse permutation matrix.}
55 :     \item{t}{\code{signature(x = "pMatrix")}: return the transpose of
56 :     the permuation matrix (which is also the inverse of the
57 :     permutation matrix).}
58 :     }
59 :     }
60 : maechler 1407 \note{
61 :     The inverse of the typical \code{"pMatrix"} constructor,
62 :     \code{P <- as(ip, "pMatrix")} is simply \code{ip <- P@perm}.
63 :     }
64 : bates 638 %\seealso{}
65 :     \examples{
66 :     (pm1 <- as(as.integer(c(2,3,1)), "pMatrix"))
67 : maechler 659 t(pm1) # is the same as
68 : bates 638 solve(pm1)
69 : maechler 659 pm1 \%*\% t(pm1) # check that the transpose is the inverse
70 :     stopifnot(identical(diag(3), as(pm1 \%*\% t(pm1), "matrix")))
71 : maechler 1331
72 :     set.seed(11)
73 :     ## random permutation matrix :
74 :     (p10 <- as(sample(10),"pMatrix"))
75 :    
76 :     ## Permute rows / columns of a numeric matrix :
77 : bates 638 (mm <- round(array(rnorm(3 * 3), c(3, 3)), 2))
78 : bates 650 mm \%*\% pm1
79 :     pm1 \%*\% mm
80 : maechler 659 try(as(as.integer(c(3,3,1)), "pMatrix"))# Error: not a permutation
81 : maechler 868
82 : maechler 1548 as(pm1, "ngTMatrix")
83 :     p10[1:7, 1:4] # gives an "ngTMatrix" (most economic!)
84 : bates 638 }
85 :     \keyword{classes}

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge