Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
victorlei committed Oct 20, 2014
1 parent 4f23702 commit ca48c9c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 12 deletions.
17 changes: 15 additions & 2 deletions smop/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,22 @@ PYTHON = python
FLAGS = -X interp1.m,interpn.m,nargchk.m,nargoutchk.m,profexplore.m,profshow.m,quadgk.m,quadl.m
V = 2.7
ALL = \*.m
GENERAL = accumarray.py accumdim.py bicubic.py bincoeff.py\
bitcmp.py bitget.py bitset.py blkdiag.py cart2pol.py cart2sph.py\
cell2mat.py celldisp.py chop.py circshift.py common_size.py cplxpair.py\
cumtrapz.py curl.py dblquad.py deal.py del2.py display.py divergence.py\
fieldnames.py flipdim.py fliplr.py flipud.py gradient.py idivide.py\
int2str.py interp1.py interp2.py interp3.py interpft.py interpn.py\
isa.py iscolumn.py isdir.py isequal.py isequaln.py isrow.py isscalar.py\
issquare.py isvector.py loadobj.py logspace.py methods.py nargchk.py\
narginchk.py nargoutchk.py nextpow2.py nthargout.py num2str.py pol2cart.py\
polyarea.py postpad.py prepad.py profexplore.py profile.py profshow.py\
quadgk.py quadl.py quadv.py randi.py rat.py repmat.py rot90.py rotdim.py\
saveobj.py shiftdim.py shift.py sortrows.py sph2cart.py structfun.py\
subsindex.py trapz.py triplequad.py

general: accumarray.py accumdim.py bicubic.py bincoeff.py bitcmp.py bitget.py bitset.py blkdiag.py cart2pol.py cart2sph.py cell2mat.py celldisp.py chop.py circshift.py common_size.py cplxpair.py cumtrapz.py curl.py dblquad.py deal.py del2.py display.py divergence.py fieldnames.py flipdim.py fliplr.py flipud.py gradient.py idivide.py int2str.py interp1.py interp2.py interp3.py interpft.py interpn.py isa.py iscolumn.py isdir.py isequal.py isequaln.py isrow.py isscalar.py issquare.py isvector.py loadobj.py logspace.py methods.py nargchk.py narginchk.py nargoutchk.py nextpow2.py nthargout.py num2str.py pol2cart.py polyarea.py postpad.py prepad.py profexplore.py profile.py profshow.py quadgk.py quadl.py quadv.py randi.py rat.py repmat.py rot90.py rotdim.py saveobj.py shiftdim.py shift.py sortrows.py sph2cart.py structfun.py subsindex.py trapz.py triplequad.py
all: mybench.py runtime.py
$(PYTHON) -c "import mybench ; mybench.mybench()"

go_so: solver.so
$(PYTHON) go.py
Expand All @@ -31,7 +45,6 @@ solver.py: solver.m r8_random.m
check:
$(PYTHON) runtime.py
$(PYTHON) test_runtime.py

$(PYTHON) test_matlabarray.py
$(PYTHON) test_sparsearray.py
$(PYTHON) test_lexer.py
Expand Down
8 changes: 4 additions & 4 deletions smop/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def _backend(self,level=0):

@extend(node.string)
def _backend(self,level=0):
return "char(%s)" % repr(self.value)
return "char('%s')" % (self.value)

@extend(node.number)
def _backend(self,level=0):
Expand Down Expand Up @@ -301,15 +301,15 @@ def _backend(self,level=0):
except exec execfile exit False file filter finally float for format from
frozenset getattr global globals hasattr hash help hex id if import __import__
in input int intern is isinstance issubclass iter lambda len license list
locals long map max memoryview min next None not not NotImplemented object oct
locals long map memoryview next None not not NotImplemented object oct
open or ord pass pow print property quit raise range raw_input reduce reload
repr return reversed round set setattr slice sorted staticmethod str sum super
True try tuple type unichr unicode vars while with xrange yield zip
True try tuple type unichr unicode vars while with xrange yield zip struct
""".split())

@extend(node.ident)
def _backend(self,level=0):
return self.name #if self.name not in reserved else "_"+self.name
return self.name if self.name not in reserved else self.name+'_'

@extend(node.stmt_list)
def _backend(self,level=0):
Expand Down
2 changes: 1 addition & 1 deletion smop/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import lexer,parse,resolve,backend,options,node,graphviz
import networkx as nx
import readline
from runtime import *
#from runtime import *
#from version import __version__
__version__ = version.__version__

Expand Down
6 changes: 3 additions & 3 deletions smop/mybench.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@

%create output file
moVersio = strrep(version(),' ','_');
outFileName = ['results_',moVersio,'.txt'];
outFileName = "foo.txt" %['results_',moVersio,'.txt'];
fid = fopen(outFileName,'w');

if NORMALIZE_TIMES
Expand Down Expand Up @@ -119,9 +119,9 @@
fprintf(1,'%d ',ii);
if IS_OCTAVE, fflush(stdout); end

tic();
t0=tic();
mytests{i}.test(x);
t1=toc();
t1=toc(t0);

if isfield(mytests{i}, 'goldResult') && NORMALIZE_TIMES == true
goldResult = mytests{i}.goldResult;
Expand Down
6 changes: 4 additions & 2 deletions smop/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ def __str__(self):
return "\n".join("".join(s) for s in self)
raise NotImplementedError

class struct(object):
class struct_(object):
def __init__(self,*args):
for i in range(0,len(args),2):
setattr(self,str(args[i]),args[i+1])
Expand Down Expand Up @@ -491,7 +491,9 @@ def fflush(fp):
fp.flush()

def fprintf(fp,fmt,*args):
print str(fmt) % tuple(str(a) if isinstance(a,char) else a for a in args)
if not isinstance(fp,file):
fp = stdout
fp.write(str(fmt) % tuple(str(a) if isinstance(a,char) else a for a in args))

def fullfile(*args):
return os.path.join(*args)
Expand Down

0 comments on commit ca48c9c

Please sign in to comment.