setAs("dgTMatrix", "dgCMatrix", function(from) .Call("dgTMatrix_to_dgCMatrix", from, PACKAGE = "Matrix") ) setAs("dgTMatrix", "dgeMatrix", function(from) .Call("dgTMatrix_to_dgeMatrix", from, PACKAGE = "Matrix") ) setAs("dgTMatrix", "matrix", function(from) .Call("dgTMatrix_to_matrix", from, PACKAGE = "Matrix") ) setAs("dgeMatrix", "dgTMatrix", function(from) as(as(from, "dgCMatrix"), "dgTMatrix")) ## "[" methods are now in ./Tsparse.R setMethod("crossprod", signature(x = "dgTMatrix", y = "missing"), function(x, y = NULL) .Call("csc_crossprod", as(x, "dgCMatrix"), PACKAGE = "Matrix")) setMethod("crossprod", signature(x = "dgTMatrix", y = "matrix"), function(x, y = NULL) .Call("csc_matrix_crossprod", as(x, "dgCMatrix"), y, PACKAGE = "Matrix")) ##setMethod("crossprod", signature(x = "dgTMatrix", y = "numeric"), ## function(x, y = NULL) ## .Call("csc_matrix_crossprod", as(x, "dgCMatrix"), as.matrix(y), PACKAGE = "Matrix")) setMethod("tcrossprod", signature(x = "dgTMatrix", y = "missing"), function(x, y = NULL) .Call("csc_tcrossprod", as(x, "dgCMatrix"), PACKAGE = "Matrix")) setMethod("image", "dgTMatrix", function(x, xlim = c(-0.5, matdim[2]-0.5), ylim = c(matdim[1]-0.5, -0.5), sub = sprintf("Dimensions: %d x %d", matdim[1], matdim[2]), xlab = "Column", ylab = "Row", cuts = 20, col.regions = grey(seq(from = 0.7, to = 0, length = 100)), ...) { matdim <- x@Dim levelplot(abs(x@x) ~ x@j * x@i, sub = sub, xlab = xlab, ylab = ylab, xlim = xlim, ylim = ylim, col.regions = col.regions, par.settings = list(background = list(col = "transparent")), panel = function(x, y, z, subscripts, at, ..., col.regions) { x <- as.numeric(x[subscripts]) y <- as.numeric(y[subscripts]) numcol <- length(at) - 1 numcol.r <- length(col.regions) col.regions <- if (numcol.r <= numcol) rep(col.regions, length = numcol) else col.regions[floor(1+(1:numcol-1)*(numcol.r-1)/ (numcol-1))] zcol <- rep(NA, length(z)) #numeric(length(z)) for (i in seq(along = col.regions)) zcol[!is.na(x) & !is.na(y) & !is.na(z) & z>=at[i] & z