diff --git a/README.rst b/README.rst index b0534be3..69c203f1 100644 --- a/README.rst +++ b/README.rst @@ -33,7 +33,6 @@ October 23, 2014 == ======== ====== =========== ======= name octave speedboots speedup - == ======== ====== =========== ======= 1 rand 2.58 0.36 0.14 2 randn 2.26 1.04 0.46 diff --git a/smop/Makefile b/smop/Makefile index eacc1ec6..90d8502b 100644 --- a/smop/Makefile +++ b/smop/Makefile @@ -1,5 +1,6 @@ # for py3: make PYTHON=python3 CYTHON="cython -3" V=3.4 +VPATH = $(SCRIPTS)/general:$(SCRIPTS)/specfun OCTAVE = /home/lei/octave-3.8.2 SCRIPTS = $(OCTAVE)/scripts @@ -7,15 +8,18 @@ CYTHON = cython PYTHON = python #FLAGS = -S stft.m,datenum.m -X orderfields.m,legend.m,pack.m,unpack.m,__unimplemented__.m,assert.m,optimset.m #FLAGS = -X interp1.m,interpn.m,nargchk.m,nargoutchk.m,profexplore.m,profshow.m,quadgk.m,quadl.m -FLAGS = -Xquadgk.m,quadl.m,lcm.m,adaptlobstp.m,spline.m,ppval.m +FLAGS = -Xquadgk,quadl,lcm,adaptlobstp,spline,ppval,ellipke V = 2.7 ALL = \*.m all: mybench.py $(PYTHON) -c "import mybench ; mybench.mybench()" -octave.py: - find $(SCRIPTS)/general $(SCRIPTS)/specfun -name \*.m | xargs smop -v -o $@ -r core $(FLAGS) +octave.py: randi.m primes.m + $(PYTHON) main.py $^ -r core -o $@ + +#octave.py: +# find $(SCRIPTS)/general $(SCRIPTS)/specfun -name \*.m | xargs smop -v -o $@ -r core $(FLAGS) go_so: solver.so $(PYTHON) go.py @@ -43,7 +47,7 @@ check: test: find $(SCRIPTS) -name $(ALL) | xargs python main.py $(FLAGS) -%.c: %.pyx +%.c: %.py $(CYTHON) $^ %.so: %.c diff --git a/smop/backend.py b/smop/backend.py index d0de0ac6..f88ef035 100644 --- a/smop/backend.py +++ b/smop/backend.py @@ -45,7 +45,7 @@ def _backend(self,level=0): return " + ".join(a._backend() for a in self.args) else: #import pdb; pdb.set_trace() - return "np.r_[%s]" % self.args[0]._backend() + return "cat(%s)" % self.args[0]._backend() @extend(node.cellarrayref) def _backend(self,level=0): diff --git a/smop/core.py b/smop/core.py index c73a634a..12dbb57a 100644 --- a/smop/core.py +++ b/smop/core.py @@ -6,7 +6,7 @@ import __builtin__ import numpy -from numpy import abs,ceil,floor,sqrt +from numpy import sqrt from numpy.fft import fft2 from numpy.linalg import inv from numpy.linalg import qr as _qr @@ -336,6 +336,9 @@ def __init__(self,*args): for i in range(0,len(args),2): setattr(self,str(args[i]),args[i+1]) +def abs(a): + return numpy.abs(a) + def arange(start,stop,step=1,**kwargs): """ >>> a=arange(1,10) # 1:10 @@ -346,6 +349,11 @@ def arange(start,stop,step=1,**kwargs): stop+1, step, **kwargs).reshape(1,-1),**kwargs) +def cat(*args): + return np.concatenate([matlabarray(a) for a in args],axis=1) + +def ceil(a): + return numpy.ceil(a) def cell(*args): if len(args) == 1: @@ -401,6 +409,9 @@ def find(a,n=None,d=None,nargout=1): matlabarray((j+1).reshape(-1,1))) raise NotImplementedError +def floor(a): + return numpy.floor(a) + def fopen(*args): try: fp = open(*args) diff --git a/smop/main.py b/smop/main.py index eb7fce1e..b8a4b953 100644 --- a/smop/main.py +++ b/smop/main.py @@ -82,7 +82,7 @@ def main(): elif o in ("-d", "--dot"): dot = re.compile(a) elif o in ("-X", "--exclude"): - exclude_list += a.split(",") + exclude_list += [ "%s.m" % b for b in a.split(",")] elif o in ("-v", "--verbose"): options.verbose += 1 elif o in ("-V", "--version"):