pMatrix-class(Matrix)
pMatrix-class()所属R语言包:Matrix
Permutation matrices
置换矩阵
译者:生物统计家园网 机器人LoveR
描述----------Description----------
The "pMatrix" class is the class of permutation
"pMatrix"类是置换类
类的对象----------Objects from the Class----------
Objects can be created by calls of the form new("pMatrix", ...) or by coercion from an integer permutation vector, see below.
可以通过电话的形式创建对象new("pMatrix", ...)或胁迫整数置换向量,见下文。
插槽----------Slots----------
perm: An integer, 1-based permutation vector, i.e. an integer vector of length Dim[1] whose elements form a
perm:一个整数,1基于置换向量,即长度Dim[1]整数向量,其元素组成一个
Dim: Object of class "integer". The dimensions of the matrix which must be a two-element vector of equal,
Dim类"integer"的对象。矩阵的尺寸必须是平等的两个元素的向量,
Dimnames: list of length two; each component containing NULL or a character vector length
Dimnames:长度为二的名单;每个组件包含NULL或一个character向量的长度
延伸----------Extends----------
Class "sparseMatrix" and "generalMatrix", directly.
类"sparseMatrix"和"generalMatrix",直接。
方法----------Methods----------
%*% signature(x = "matrix", y = "pMatrix") and other
%*%signature(x = "matrix", y = "pMatrix")和其他
coerce signature(from = "integer", to = "pMatrix"): This is enables typical "pMatrix" construction, given
要挟signature(from = "integer", to = "pMatrix"):这是使典型的"pMatrix"建设,给予
coerce signature(from = "numeric", to = "pMatrix"): a user convenience, to allow as(perm, "pMatrix") for
要挟signature(from = "numeric", to = "pMatrix"):方便用户,让as(perm, "pMatrix")
coerce signature(from = "pMatrix", to = "matrix"): coercion to a traditional FALSE/TRUE matrix of mode logical. (in earlier version of Matrix, it resulted in a 0/1-integer matrix; logical makes slightly more sense, corresponding better to the “natural” sparseMatrix counterpart,
强制signature(from = "pMatrix", to = "matrix"):强迫传统FALSE /真matrixmodelogical。 (在早期版本的Matrix,它导致在0/1-integer矩阵;logical稍微更有意义,更好地对应“自然”sparseMatrix的对口,
coerce signature(from = "pMatrix", to = "ngTMatrix"):
强制signature(from = "pMatrix", to = "ngTMatrix"):
determinant signature(x = "pMatrix", logarithm="logical"): Since permutation matrices are orthogonal, the determinant must be +1 or -1. In fact, it is exactly the sign of the
行列式signature(x = "pMatrix", logarithm="logical"):由于置换矩阵是正交的,行列式必须是+1或-1。事实上,正是标志
solve signature(a = "pMatrix", b = "missing"): return
解决signature(a = "pMatrix", b = "missing"):返回
t signature(x = "pMatrix"): return the transpose of the permuation matrix (which is also the inverse of the
Tsignature(x = "pMatrix"):返回的permuation矩阵的转置(这也是逆
注意----------Note----------
The inverse of the typical "pMatrix" constructor, P <- as(ip, "pMatrix") is simply ip <- P@perm.
逆的典型"pMatrix"构造,P <- as(ip, "pMatrix")的只是ip <- P@perm。
Subsetting (“indexing”, including, diag) "pMatrix" objects treats themas nonzero-pattern matrices, i.e., as "ngTMatrix" such that non-matrix subsetting result in logical vectors. Sub-assignment (M[i,j] <- v) is not sensible and hence an error for these permutation matrices.
子集(“索引”,包括diag)"pMatrix"等非矩阵子集在"ngTMatrix"向量的结果logical对象对待themas非零模式矩阵,即。小组分配(M[i,j] <- v)是不理智的,因此这些置换矩阵的错误。
举例----------Examples----------
(pm1 <- as(as.integer(c(2,3,1)), "pMatrix"))
t(pm1) # is the same as[是一样的]
solve(pm1)
pm1 %*% t(pm1) # check that the transpose is the inverse[检查的转逆]
stopifnot(all(diag(3) == as(pm1 %*% t(pm1), "matrix")),
is.logical(as(pm1, "matrix")))
set.seed(11)
## random permutation matrix :[#随机置换矩阵:]
(p10 <- as(sample(10),"pMatrix"))
## Permute rows / columns of a numeric matrix :[#表,改变行/列数字矩阵:]
(mm <- round(array(rnorm(3 * 3), c(3, 3)), 2))
mm %*% pm1
pm1 %*% mm
try(as(as.integer(c(3,3,1)), "pMatrix"))# Error: not a permutation[错误:不是一个置换]
as(pm1, "ngTMatrix")
p10[1:7, 1:4] # gives an "ngTMatrix" (most economic!)[给“ngTMatrix”(最经济!)]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|