https://github.com/cran/slam
Raw File
Tip revision: a2eb9cb8cac25421beb6ba64ef71b28d3f1e0335 authored by Kurt Hornik on 07 January 2014, 00:00:00 UTC
version 0.1-31
Tip revision: a2eb9cb
matrix.Rout.save

R version 2.10.1 Patched (2009-12-21 r50815)
Copyright (C) 2009 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> 
> library("slam")
> 
> s <- simple_triplet_diag_matrix(1, nrow = 3)
> 
> identical(as.matrix(s) * Inf, as.matrix(s * Inf))
[1] TRUE
> identical(as.matrix(s) *  NA, as.matrix(s *  NA_real_))
[1] TRUE
> 
> identical(as.matrix(s) * c(Inf, NA, 0), as.matrix(s * c(Inf, NA, 0)))
[1] TRUE
> 
> x1 <- matrix(c(1, Inf, 0, 1), nrow = 2)
> x2 <- matrix(c(1, 0,  NA, 1), nrow = 2)
> 
> identical(x1 * x2, as.matrix(as.simple_triplet_matrix(x1) * x2))
[1] TRUE
> identical(x1 * x2, as.matrix(as.simple_triplet_matrix(x1) *
+                              as.simple_triplet_matrix(x2)))
[1] TRUE
> 
> x <- matrix(1, nrow = 3, ncol = 3)
> identical(x * as.matrix(s), as.matrix(s * as.simple_triplet_matrix(x)))
[1] TRUE
> identical(x / as.matrix(s), as.matrix(as.simple_triplet_matrix(x) / s))
[1] TRUE
> 
> identical(x * as.matrix(s), as.matrix(s * x))
[1] TRUE
> identical(x / as.matrix(s), as.matrix(x / s))
[1] TRUE
> 
> ###
> 
back to top