Naive_Natural2511
Naive_Natural2511

Reputation: 717

How to take transpose of a big.matrix object?

How to take transpose of a big.matrix object?

I have a 8000 x 8000 big.matrix object and I need to perform transpose and multiplication. How to do it?

b <- as.big.matrix(basis)

bTransb <- t(b) %*% b

This gives me the following error

Error in t.default(b) : argument is not a matrix

I have imported bigalgebra library. Still not working.

Upvotes: 0

Views: 668

Answers (1)

F. Priv&#233;
F. Priv&#233;

Reputation: 11728

I'm not sure with {bigmemory}, but you can do it with {bigstatsr} (disclaimer: I'm the author), which uses a similar format.

# Sample data
a <- matrix(0, 8000, 8000); a[] <- rnorm(length(a))
# devtools::install_github("privefl/bigstatsr")
library(bigstatsr)
b <- as_FBM(a)
class(b)
btrans <- big_crossprodSelf(b)
dim(btrans)
class(btrans)
# Verification
all.equal(btrans[], crossprod(b[]))

Upvotes: 1

Related Questions