Skip to content

Commit

Permalink
Same results w targets go_m go_py go_so
Browse files Browse the repository at this point in the history
  • Loading branch information
victorlei committed Oct 4, 2014
1 parent 52c0fcf commit ac16a91
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
15 changes: 8 additions & 7 deletions smop/Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
FLAGS=

timer_so: solver.so
rm -f solver.py solver.pyc
go_so: solver.so
python go.py

timer_py: solver.py
rm -f solver.so
go_py: solver.py
python go.py

go_m: solver.m
octave -q go.m

clean:
rm -f a.* *.pyc
rm -f a.* *.pyc solver.so solver.py

solver.py: solver.m r8_random.m
python main.py $^ -o $@
Expand All @@ -20,12 +21,12 @@ check:
python test_matlabarray.py $(FLAGS)
python test_sparsearray.py $(FLAGS)
python test_lexer.py $(FLAGS)
python main.py solver.m r8_random.m && python go.py | tail
python main.py solver.m r8_random.m -o solver.py && python go.py
#python main.py fastsolver.m && python go.py

%.c: %.pyx
cython -a $^

%.so: %.c
gcc -I /usr/include/python2.7 -O2 -shared -o $@ $^
gcc -Wno-cpp -I /usr/include/python2.7 -O2 -shared -o $@ $^

2 changes: 1 addition & 1 deletion smop/go.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@
mv = solver(ai,af,0);
toc

%disp(mv);
disp(size(mv));
8 changes: 6 additions & 2 deletions smop/go.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from runtime import *

def main():
ai = matlabarray(zeros_(10,10,dtype=int))
ai = matlabarray(zeros_(10,10,dtype=int),dtype=int)
af = copy_(ai)

ai[1,1]=2
Expand All @@ -23,8 +23,12 @@ def main():
mv = a.solver_(ai,af,0)
t1 = time.clock()
print t1-t0
print mv.shape

if __name__ == '__main__':
#main()
main()
"""
cProfile.runctx('main()',globals(),locals(),"Profile.prof")
s = pstats.Stats("Profile.prof")
s.strip_dirs().sort_stats("time").print_stats()
"""
6 changes: 3 additions & 3 deletions smop/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class matlabarray(np.ndarray):
matlabarray([], shape=(0, 0), dtype=float64)
"""

def __new__(cls,a=[],dtype="float64"):
def __new__(cls,a=[],dtype=None):
obj = np.array(a,
dtype=dtype,
copy=False,
Expand Down Expand Up @@ -380,7 +380,7 @@ def arange_(start,stop,step=1,**kwargs):
"""
>>> a=arange_(1,10) # 1:10
>>> size_(a)
matlabarray([[ 1., 10.]])
matlabarray([[ 1, 10]])
"""
return matlabarray(np.arange(start,
stop+1,
Expand Down Expand Up @@ -551,7 +551,7 @@ def rows_(a):
def size_(a, b=0, nargout=1):
"""
>>> size_(zeros_(3,3)) + 1
matlabarray([[ 4., 4.]])
matlabarray([[4, 4]])
"""
s = np.asarray(a).shape
if s is ():
Expand Down

0 comments on commit ac16a91

Please sign in to comment.