Ignore:
Timestamp:
09/28/12 16:04:47 (12 years ago)
Author:
jschierm
Message:

NEW: New python functions in support of test514.py (which doesn't yet work).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/miscellaneous/MatlabFuncs.py

    r13436 r13482  
    7474                raise TypeError("MatlabFunc.det only implemented for shape (2, 2), not for shape %s." % str(a.shape))
    7575
     76def sparse(ivec,jvec,svec,m=0,n=0,nzmax=0):
     77        import numpy
     78
     79        if not m:
     80                m=numpy.max(ivec)
     81        if not n:
     82                n=numpy.max(jvec)
     83
     84        a=numpy.zeros((m,n))
     85
     86        for i,j,s in zip(ivec.reshape(-1,order='F'),jvec.reshape(-1,order='F'),svec.reshape(-1,order='F')):
     87                a[i-1,j-1]+=s
     88
     89        return a
     90
Note: See TracChangeset for help on using the changeset viewer.