From: Paul K. <pki...@us...> - 2003-12-14 00:50:48
|
On Dec 13, 2003, at 1:48 PM, Andy Adler wrote: > On Sat, 13 Dec 2003, Paul Kienzle wrote: > >> It would be a little more convincing if other operators didn't >> convert to full as necessary, like + and /. I haven't checked >> functions like cos/sin though. > > I didn't think + converted to full. "/" will, though. I didn't > think it was used enough to bother implementing. > > All the advanced functions (sin/cos etc.) will convert to full. > > For cos it doesn't make sense to have a sparse implementation > since cos(0)=1. ie. the matrix will become filled with ones. > > For sin, sinh, tan, erf, abs, conj, floor, round, ceil, fix, > tanh, sign, asin, asinh, atan, sqrt (any more?) > in which func(0)= 0, I could write a template that does > the function on each non-sparse element. Then we could define > sp_func for each, which could dispatch for sparse operands. > > Is this worth the work? These are easy enough to add as scripts: function x = spfn(fn,y) [i,j,v,m,n]=spfind(y); x = sparse(i,j,feval(fn,v),m,n); end Or if they want ease of use: ## PKG_ADD: dispatch('sin','spsin','sparse'); ## PKG_ADD: dispatch('sin','spsin','complex_sparse'); function x=spsin(y), x=spfn('sin',y); end |