# SCM Repository

[matrix] Annotation of /pkg/R/dtpMatrix.R
 [matrix] / pkg / R / dtpMatrix.R

# Annotation of /pkg/R/dtpMatrix.R

 1 : bates 597 #### Triangular Packed Matrices -- Coercion and Methods 2 : 3 : setAs("dtpMatrix", "dtrMatrix", 4 : function(from) .Call("dtpMatrix_as_dtrMatrix", from) ) 5 : 6 : setAs("dtpMatrix", "dgeMatrix", 7 : function(from) as(as(from, "dtrMatrix"), "dgeMatrix")) 8 : 9 : setAs("dtpMatrix", "matrix", 10 : function(from) as(as(from, "dtrMatrix"), "matrix")) 11 : 12 : maechler 609 13 : bates 597 setMethod("%*%", signature(x = "dtpMatrix", y = "dgeMatrix"), 14 : function(x, y) .Call("dtpMatrix_dgeMatrix_mm", x, y)) 15 : maechler 609 setMethod("%*%", signature(x = "dgeMatrix", y = "dtpMatrix"), 16 : function(x, y) callGeneric(x, as(y, "dgeMatrix"))) 17 : bates 597 18 : bates 603 setMethod("%*%", signature(x = "dtpMatrix", y = "matrix"), 19 : function(x, y) .Call("dtpMatrix_matrix_mm", x, y)) 20 : maechler 609 ## extending to vector RHS 21 : setMethod("%*%", signature(x = "dtpMatrix", y = "numeric"), 22 : function(x, y) callGeneric(x, as.matrix(y))) 23 : ## the other way around 24 : setMethod("%*%", signature(x = "numeric", y = "dtpMatrix"), 25 : function(x, y) callGeneric(as(as.matrix(x), "dgeMatrix"), y)) 26 : bates 603 27 : bates 597 setMethod("determinant", signature(x = "dtpMatrix", logarithm = "missing"), 28 : function(x, logarithm, ...) determinant(x, TRUE)) 29 : 30 : setMethod("diag", signature(x = "dtpMatrix"), 31 : maechler 609 function(x = 1, nrow, ncol = n) .Call("dtpMatrix_getDiag", x), 32 : bates 597 valueClass = "numeric") 33 : maechler 609 34 : bates 597 setMethod("determinant", signature(x = "dtpMatrix", logarithm = "logical"), 35 : function(x, logarithm, ...) { 36 : dg <- diag(x) 37 : if (logarithm) { 38 : modulus <- sum(log(abs(dg))) 39 : sgn <- prod(sign(dg)) 40 : } else { 41 : modulus <- prod(dg) 42 : sgn <- sign(modulus) 43 : modulus <- abs(modulus) 44 : } 45 : attr(modulus, "logarithm") <- logarithm 46 : val <- list(modulus = modulus, sign = sgn) 47 : class(val) <- "det" 48 : val 49 : }) 50 : 51 : setMethod("norm", signature(x = "dtpMatrix", type = "character"), 52 : function(x, type, ...) 53 : .Call("dtpMatrix_norm", x, type), 54 : valueClass = "numeric") 55 : 56 : setMethod("norm", signature(x = "dtpMatrix", type = "missing"), 57 : function(x, type, ...) 58 : .Call("dtpMatrix_norm", x, "O"), 59 : valueClass = "numeric") 60 : 61 : setMethod("rcond", signature(x = "dtpMatrix", type = "character"), 62 : function(x, type, ...) 63 : .Call("dtpMatrix_rcond", x, type), 64 : valueClass = "numeric") 65 : 66 : setMethod("rcond", signature(x = "dtpMatrix", type = "missing"), 67 : function(x, type, ...) 68 : .Call("dtpMatrix_rcond", x, "O"), 69 : valueClass = "numeric") 70 : 71 : setMethod("solve", signature(a = "dtpMatrix", b="missing"), 72 : function(a, b, ...) 73 : .Call("dtpMatrix_solve", a), 74 : valueClass = "dtpMatrix") 75 : 76 : setMethod("solve", signature(a = "dtpMatrix", b="matrix"), 77 : function(a, b, ...) 78 : .Call("dtpMatrix_matrix_solve", a, b), 79 : valueClass = "matrix") 80 : 81 : setMethod("t", signature(x = "dtpMatrix"), 82 : function(x) as(t(as(x, "dtrMatrix")), "dtpMatrix"), 83 : valueClass = "dtpMatrix") 84 : ###