home *** CD-ROM | disk | FTP | other *** search
- function f = spfun(fun,s)
- %SPFUN Apply a function only to the nonzero entries.
- % F = SPFUN('fun',S) evaluates fun(s) on the nonzero elements of S.
- % e.g. F = SPFUN('exp',S) has the same sparsity pattern as S
- % (except for underflow), whereas EXP(S) has 1's where S has 0's.
-
- % Copyright (c) 1984-93 by The MathWorks, Inc.
-
- [i,j,x] = find(s);
- f = eval( [ 'sparse(i,j,' fun '(x))' ] );
-
-