In Sparse Matrices is posible condition in "combine"?


#1

sparse(I, J, V[, m, n, combine ])

I must to igore new laue of V of old V is more then 0.

is posible condition in combine ?
e.g: + if V=0 else skip…

Paul


#2

Please do make an effort to post something intelligible. If I decipher correctly, you may want something like

function sparse_new(I, J, V, W)
    _pick(w, v) = w > 0 ? w : v
    sparse(I, J, [_pick(W[i, j], v) for (i, j, v) in zip(I, J, V)])
end

#3
sparse(I, J, V, m, n, (a,b) -> a == 0 ? b : a)

#4

Thanks!

I undestend “a” is existing and “b” is new.

I need:

if b<a -> a-b
if b==a -> a

do it this rule : |
sparse(I, J, V, m, n, (a,b) -> b < a ? a-b)|
Paul;

W dniu 2017-10-29 o 17:46, kristoffer.carlsson pisze:


#5

You havent said what to do when b > a.