Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
victorlei committed Oct 24, 2014
1 parent 190c084 commit 9a72ab7
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 8 deletions.
1 change: 0 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions smop/Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
# 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

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
Expand Down Expand Up @@ -43,7 +47,7 @@ check:
test:
find $(SCRIPTS) -name $(ALL) | xargs python main.py $(FLAGS)

%.c: %.pyx
%.c: %.py
$(CYTHON) $^

%.so: %.c
Expand Down
2 changes: 1 addition & 1 deletion smop/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
13 changes: 12 additions & 1 deletion smop/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion smop/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down

0 comments on commit 9a72ab7

Please sign in to comment.