# SCM Repository

[matrix] Annotation of /pkg/Matrix/man/symmpart.Rd
 [matrix] / pkg / Matrix / man / symmpart.Rd

# Annotation of /pkg/Matrix/man/symmpart.Rd

 1 : maechler 2112 \name{symmpart} 2 : \title{Symmetric Part and Skew(symmetric) Part of a Matrix} 3 : %% Hmm, want the generic and methods all in this file ... 4 : %% \docType{methods} 5 : \alias{symmpart} 6 : \alias{skewpart} 7 : % 8 : \alias{symmpart-methods} 9 : \alias{skewpart-methods} 10 : \alias{symmpart,Matrix-method} 11 : \alias{skewpart,Matrix-method} 12 : \alias{symmpart,diagonalMatrix-method} 13 : \alias{skewpart,diagonalMatrix-method} 14 : \alias{symmpart,ddenseMatrix-method} 15 : \alias{skewpart,ddenseMatrix-method} 16 : \alias{symmpart,denseMatrix-method} 17 : \alias{skewpart,denseMatrix-method} 18 : \alias{symmpart,symmetricMatrix-method} 19 : \alias{skewpart,symmetricMatrix-method} 20 : \alias{symmpart,matrix-method} 21 : \alias{skewpart,matrix-method} 22 : % 23 : \description{ 24 : mmaechler 2638 \code{symmpart(x)} computes the symmetric part \code{(x + t(x))/2} and 25 : \code{skewpart(x)} the 26 : skew symmetric part \code{(x - t(x))/2} of a square matrix \code{x}, 27 : more efficiently for specific Matrix classes. 28 : 29 : maechler 2112 Note that \code{x == symmpart(x) + skewpart(x)} for all square 30 : mmaechler 2526 matrices -- apart from extraneous \code{\link{NA}} values in the RHS. 31 : maechler 2112 } 32 : \usage{ 33 : symmpart(x) 34 : skewpart(x) 35 : } 36 : \arguments{ 37 : \item{x}{a \emph{square} matrix; either \dQuote{traditional} of class 38 : \code{"matrix"}, or typically, inheriting from the 39 : \code{\linkS4class{Matrix}} class.} 40 : } 41 : mmaechler 2638 \details{ 42 : These are generic functions with several methods for different matrix 43 : classes, use e.g., \code{\link{showMethods}(symmpart)} to see them. 44 : mmaechler 3020 45 : If the row and column names differ, the result will use the column 46 : names unless they are (partly) \code{NULL} where the row names are 47 : non-\code{NULL} (see also the examples). 48 : mmaechler 2638 } 49 : maechler 2112 \value{ 50 : \code{symmpart()} returns a symmetric matrix, inheriting from 51 : \code{\linkS4class{symmetricMatrix}} iff \code{x} inherited from 52 : \code{Matrix}. 53 : 54 : \code{skewpart()} returns a skew-symmetric matrix, 55 : typically of the same class as \code{x} (or the closest 56 : \dQuote{general} one, see \code{\linkS4class{generalMatrix}}). 57 : } 58 : mmaechler 3020 \seealso{ 59 : \code{\link{isSymmetric}}.} 60 : maechler 2112 \examples{ 61 : m <- Matrix(1:4, 2,2) 62 : symmpart(m) 63 : skewpart(m) 64 : 65 : stopifnot(all(m == symmpart(m) + skewpart(m))) 66 : mmaechler 2638 67 : mmaechler 3020 dn <- dimnames(m) <- list(row = c("r1", "r2"), col = c("var.1", "var.2")) 68 : stopifnot(all(m == symmpart(m) + skewpart(m))) 69 : colnames(m) <- NULL 70 : stopifnot(all(m == symmpart(m) + skewpart(m))) 71 : dimnames(m) <- unname(dn) 72 : stopifnot(all(m == symmpart(m) + skewpart(m))) 73 : 74 : 75 : mmaechler 2638 ## investigate the current methods: 76 : showMethods(skewpart, include = TRUE) 77 : maechler 2112 } 78 : \keyword{array} 79 : \keyword{arith}