r - 大代数R中的大矩阵运算
问题描述
我想将两个大矩阵相乘并将按列函数应用于生成的矩阵。鉴于我没有足够的内存来分配这些对象,我尝试了bigalgebra
允许计算一些矩阵运算的包,但不是这里需要的。
我的脚本如下所示:
library(bigalgebra)
X <- as.big.matrix( matrix(rnorm(265225*360), nrow = 265225, ncol = 360) )
Y <- as.big.matrix( matrix(rnorm(360*10000), nrow = 360, ncol = 265225) )
Z <- X %*% Y # Z is a big.matrix object
apply(Z, 2, function(x) sqrt(sum(x^2)))
# > Error: in as.vector(data) : no method for coercing this s4 to class to a vector
apply(as.matrix(Z), 2, function(x) sqrt(sum(x^2)))
# > Error: cannot allocate vector of size 19.5 Gb
我该如何处理这个对象?而且,有没有更好/更快的方法来达到相同的结果?
解决方案
推荐阅读
- c# - 如何暂停hangfire的工作?在特定时间之间
- java - java重命名zip / gz文件的内容而不膨胀
- sql - 计算重复信息对的数量
- java - 如何在java项目中使用省略库
- angular - 加载 Angular7 应用程序需要很长时间
- nginx - 我的 nginx 配置可以在没有默认服务器的情况下工作吗
- deep-learning - 如何手动计算像 ResNet 这样的 CNN 的后向传递中的 FLOPS 数?
- apache - 有没有办法在同一台机器上同时运行 Apache 和 IIS
- python - 如何在多级字典中查找值
- apache - RewriteOptions InheritBefore 的 Htaccess 问题