From: arl on 23 Nov 2009 11:01 Hello, I was wondering if anyone knows a solution to divide element- wise two sparse matrices, A./B, but considering only the positions where A is non-zero. I though in using spfun, but it works only with one variable input. Thank you in advance.
From: Anon on 23 Nov 2009 11:34 Hi Arl, what about this? C = A.*spfun(@(x) 1./x,B); Best regards, anon arl <arlourenco(a)gmail.com> wrote in message <f495641d-048f-423d-a618-676f969fa814(a)p36g2000vbn.googlegroups.com>... > Hello, I was wondering if anyone knows a solution to divide element- > wise two sparse matrices, A./B, but considering only the positions > where A is non-zero. > > I though in using spfun, but it works only with one variable input. > > Thank you in advance.
From: Matt on 23 Nov 2009 11:39 arl <arlourenco(a)gmail.com> wrote in message <f495641d-048f-423d-a618-676f969fa814(a)p36g2000vbn.googlegroups.com>... > Hello, I was wondering if anyone knows a solution to divide element- > wise two sparse matrices, A./B, but considering only the positions > where A is non-zero. > > I though in using spfun, but it works only with one variable input. > > Thank you in advance. result=A; idx=logical(A); result(idx)=A(idx)./B(idx);
From: Bruno Luong on 23 Nov 2009 12:14 "Matt " <xys(a)whatever.com> wrote in message <heedra$cuq$1(a)fred.mathworks.com>... > > result=A; > idx=logical(A); > result(idx)=A(idx)./B(idx); CAREFUL!!!! Matlab is known for being BUGGY in doing such indexing with sparse result(idx)=A(idx)./B(idx); >> A=sparse(100000,100000,1) A = (100000,100000) 1 >> B=A B = (100000,100000) 1 >> result=A; >> idx=logical(A); >> result(idx)=A(idx)./B(idx) result = (65408,14101) 1 (100000,100000) 1 %%%%%%%%%%%%%%%%%% This is one of the reason why I wrote this package http://www.mathworks.com/matlabcentral/fileexchange/23488-sparse-sub-access >> [i j]=find(A); >> AB = setsparse(A,i,j,getsparse(B,i,j),@(a,b) a./b) AB = (100000,100000) 1 % Bruno
From: Matt on 23 Nov 2009 13:02 "Bruno Luong" <b.luong(a)fogale.findmycountry> wrote in message <heefss$lcl$1(a)fred.mathworks.com>... > %%%%%%%%%%%%%%%%%% > > This is one of the reason why I wrote this package > http://www.mathworks.com/matlabcentral/fileexchange/23488-sparse-sub-access > > >> [i j]=find(A); > >> AB = setsparse(A,i,j,getsparse(B,i,j),@(a,b) a./b) > > AB = > > (100000,100000) 1 > > % Bruno I didn't realize the extent of the problem. It wonder if one could provide a subclass of @double to interface to this package. That way, we could use the old indexing syntax instead of things like this AB = setsparse(A,i,j,getsparse(B,i,j),@(a,b) a./b)
|
Next
|
Last
Pages: 1 2 3 4 Prev: PCA reconstruction error Next: How to count the number of each intensity value? |