|
Ok, I got an idea here. I add and remove elements in the sparse matrix by using indices as for example if ir has 6 non-zero elements and 3 is removed I write
ir(3:5)=ir(4:6)
ir(6)=0
But I start to think, will this idea be slower than vectorized code in MATLAB where I can update a whole column in the matrix by for example
A(:,6)=new_relation
I got a bit curious here, how does MATLAB handle the above if A is sparse?
Is a new A allocated?
Jimmy
"Jimmy Kovarians" <kovarians@gmail.com> wrote in message <heh9p5$7bb$1@fred.mathworks.com>...
> Hehe, ok, thanks.
>
> I just clear out the headache then..
>
> Jimmy
>
> "Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <heh9cf$ccr$1@fred.mathworks.com>...
> > "Jimmy Kovarians" <kovarians@gmail.com> wrote in message <heh7vi$el9$1@fred.mathworks.com>...
> >
> > >
> > > What I want to do now is to add and remove elements from this sparse matrix, but this seem to be quite cumbersome, or have I missed the point here? I cannot see a simple way of doing this without writing a new sparse matrix and declaring ir and jc again. Are there any trix to use here?
> >
> > No trick to use. Welcome to sparse mex programming.
> >
> > Bruno
|