Hi Robin --
Robin Hankin wrote:
> Hi
>
> I deal with long vectors almost all of whose elements are zero.
> Typically, the length will be ~5e7 with ~100 nonzero elements.
>
> I want to deal with these objects using a sort of sparse
> vector.
>
> The problem is that I want to be able to 'add' two
> "Robin" == Robin Hankin
> on Tue, 08 Sep 2009 14:58:49 +0100 writes:
Robin> Hi guys
Robin> thanks for this, it works fine, but I'm not sure the Matrix package
does
Robin> what I want:
>> a = sparseMatrix(i=c(20, 30, 10), j=rep(1, 3), x=c(2.2, 3.3,
4.4))
Hi guys
thanks for this, it works fine, but I'm not sure the Matrix package does
what I want:
> a = sparseMatrix(i=c(20, 30, 10), j=rep(1, 3), x=c(2.2, 3.3,
4.4))
Error in asMethod(object) :
Cholmod error 'out of memory' at file:../Core/cholmod_memory.c, line 148
Surely an efficien
library(Matrix)
a = sparseMatrix(i=c(20, 30, 1), j=rep(1, 3), x=c(2.2, 3.3,
4.4))
b = sparseMatrix(i=c(3, 30), j=rep(1, 2), x=c(0.1, 0.1), dims=dim(a))
theSum = a+b
summary(theSum)
hth,
b
On Sep 8, 2009, at 10:19 AM, Henrique Dallazuanna wrote:
Try this:
abMerge <- merge(a, b, by
On 08-Sep-09 13:06:28, Robin Hankin wrote:
> Hi
> I deal with long vectors almost all of whose elements are zero.
> Typically, the length will be ~5e7 with ~100 nonzero elements.
>
> I want to deal with these objects using a sort of sparse
> vector.
>
> The problem is that I want to be able to 'a
Hi,
On Sep 8, 2009, at 9:06 AM, Robin Hankin wrote:
Hi
I deal with long vectors almost all of whose elements are zero.
Typically, the length will be ~5e7 with ~100 nonzero elements.
I want to deal with these objects using a sort of sparse
vector.
Would using sparse matrices (from the Matrix
Try this:
abMerge <- merge(a, b, by = 'index', all = TRUE)
list(index = abMerge$index, val = rowSums(abMerge[,2:3], na.rm = TRUE))
On Tue, Sep 8, 2009 at 10:06 AM, Robin Hankin wrote:
> Hi
>
> I deal with long vectors almost all of whose elements are zero.
> Typically, the length will be ~5e7 w
one simple way could be:
sparse.vec <- function (..., fun = sum) {
lis <- list(...)
values <- unlist(lapply(lis, "[[", "value"))
inds <- factor(unlist(lapply(lis, "[[", "index")))
out <- tapply(values, inds, FUN = fun)
list(index = as.numeric(levels(inds)), values = out)
}
a
Hi
I deal with long vectors almost all of whose elements are zero.
Typically, the length will be ~5e7 with ~100 nonzero elements.
I want to deal with these objects using a sort of sparse
vector.
The problem is that I want to be able to 'add' two such
vectors.
Toy problem follows. Suppose I
9 matches
Mail list logo