summaryrefslogtreecommitdiffstats
path: root/scilab/modules/core
diff options
context:
space:
mode:
authorSylvestre Ledru <sylvestre.ledru@scilab.org>2010-04-16 10:24:27 +0200
committerSylvestre Ledru <sylvestre.ledru@scilab.org>2010-04-16 10:24:27 +0200
commit9340726d0b5ec9b4b911f8b5e4b9a5197f2093cd (patch)
tree2425c6389e97e2749336540acdd861f14d643291 /scilab/modules/core
parentdae9e26f16242cd5c85bd4daa7a462b80f36d2e2 (diff)
parent388a3f48470ad6896f60e24752241687486c9a3e (diff)
downloadscilab-9340726d0b5ec9b4b911f8b5e4b9a5197f2093cd.zip
scilab-9340726d0b5ec9b4b911f8b5e4b9a5197f2093cd.tar.gz
Merge remote branch 'origin/hpc'
Diffstat (limited to 'scilab/modules/core')
-rw-r--r--scilab/modules/core/Makefile.am7
-rw-r--r--scilab/modules/core/Makefile.in97
-rw-r--r--scilab/modules/core/src/cpp/hashtable_core.cpp68
-rw-r--r--scilab/modules/core/src/cpp/namstr.cpp113
-rw-r--r--scilab/modules/core/src/cpp/search_functions.cpp171
-rw-r--r--scilab/modules/core/src/cpp/unrolled_algorithms.hxx226
-rw-r--r--scilab/modules/core/src/fortran/funs.f83
7 files changed, 562 insertions, 203 deletions
diff --git a/scilab/modules/core/Makefile.am b/scilab/modules/core/Makefile.am
index d1ce123..422e9be 100644
--- a/scilab/modules/core/Makefile.am
+++ b/scilab/modules/core/Makefile.am
@@ -87,7 +87,9 @@ src/c/exitCodeValue.c \
87src/c/getversion.c \ 87src/c/getversion.c \
88src/c/dynamic_tclsci.c 88src/c/dynamic_tclsci.c
89 89
90CORE_CPP_SOURCES = src/cpp/hashtable_core.cpp 90CORE_CPP_SOURCES = src/cpp/hashtable_core.cpp \
91src/cpp/namstr.cpp \
92src/cpp/search_functions.cpp
91 93
92if USE_DYNAMIC_STACK 94if USE_DYNAMIC_STACK
93CORE_C_SOURCES += src/c/scimem64.c 95CORE_C_SOURCES += src/c/scimem64.c
@@ -139,7 +141,6 @@ src/fortran/allops.f \
139src/fortran/mname.f \ 141src/fortran/mname.f \
140src/fortran/command.f \ 142src/fortran/command.f \
141src/fortran/ref2val.f \ 143src/fortran/ref2val.f \
142src/fortran/namstr.f \
143src/fortran/stack.f \ 144src/fortran/stack.f \
144src/fortran/isbrk.f \ 145src/fortran/isbrk.f \
145src/fortran/majmin.f \ 146src/fortran/majmin.f \
@@ -299,7 +300,7 @@ libscicore_la_CPPFLAGS = -I$(srcdir)/includes/ \
299 -I$(srcdir)/src/c/ \ 300 -I$(srcdir)/src/c/ \
300 -I$(srcdir)/src/cpp/ \ 301 -I$(srcdir)/src/cpp/ \
301 -I$(top_srcdir)/modules/dynamic_link/includes \ 302 -I$(top_srcdir)/modules/dynamic_link/includes \
302 -I$(top_srcdir)/libs/MALLOC/includes/ 303 -I$(top_srcdir)/libs/MALLOC/includes/
303 304
304# Used by sci_getdebuginfo: 305# Used by sci_getdebuginfo:
305if TCLTK 306if TCLTK
diff --git a/scilab/modules/core/Makefile.in b/scilab/modules/core/Makefile.in
index 13059f4..d201aef 100644
--- a/scilab/modules/core/Makefile.in
+++ b/scilab/modules/core/Makefile.in
@@ -152,7 +152,8 @@ am__libscicore_la_SOURCES_DIST = src/c/inffic.c src/c/cs2st.c \
152 src/c/inittypenames.c src/c/funcprot.c src/c/eqid.c \ 152 src/c/inittypenames.c src/c/funcprot.c src/c/eqid.c \
153 src/c/exitCodeValue.c src/c/getversion.c \ 153 src/c/exitCodeValue.c src/c/getversion.c \
154 src/c/dynamic_tclsci.c src/c/scimem64.c \ 154 src/c/dynamic_tclsci.c src/c/scimem64.c \
155 src/cpp/hashtable_core.cpp src/fortran/clunit.f \ 155 src/cpp/hashtable_core.cpp src/cpp/namstr.cpp \
156 src/cpp/search_functions.cpp src/fortran/clunit.f \
156 src/fortran/getlin.f src/fortran/allowptr.f \ 157 src/fortran/getlin.f src/fortran/allowptr.f \
157 src/fortran/isany.f src/fortran/hmcreate.f src/fortran/nextj.f \ 158 src/fortran/isany.f src/fortran/hmcreate.f src/fortran/nextj.f \
158 src/fortran/setgetmode.f src/fortran/showstack.f \ 159 src/fortran/setgetmode.f src/fortran/showstack.f \
@@ -170,18 +171,17 @@ am__libscicore_la_SOURCES_DIST = src/c/inffic.c src/c/cs2st.c \
170 src/fortran/find.f src/fortran/israt.f src/fortran/setlnb.f \ 171 src/fortran/find.f src/fortran/israt.f src/fortran/setlnb.f \
171 src/fortran/mrknmd.f src/fortran/stackgl.f \ 172 src/fortran/mrknmd.f src/fortran/stackgl.f \
172 src/fortran/allops.f src/fortran/mname.f src/fortran/command.f \ 173 src/fortran/allops.f src/fortran/mname.f src/fortran/command.f \
173 src/fortran/ref2val.f src/fortran/namstr.f src/fortran/stack.f \ 174 src/fortran/ref2val.f src/fortran/stack.f src/fortran/isbrk.f \
174 src/fortran/isbrk.f src/fortran/majmin.f src/fortran/xerbla.f \ 175 src/fortran/majmin.f src/fortran/xerbla.f src/fortran/dtosci.f \
175 src/fortran/dtosci.f src/fortran/bexec.f \ 176 src/fortran/bexec.f src/fortran/varfunptr.f \
176 src/fortran/varfunptr.f src/fortran/getfun.f \ 177 src/fortran/getfun.f src/fortran/savlod.f src/fortran/error.f \
177 src/fortran/savlod.f src/fortran/error.f src/fortran/cvdm.f \ 178 src/fortran/cvdm.f src/fortran/tradsl.f src/fortran/mkindx.f \
178 src/fortran/tradsl.f src/fortran/mkindx.f src/fortran/whatln.f \ 179 src/fortran/whatln.f src/fortran/errmgr.f src/fortran/defmat.f \
179 src/fortran/errmgr.f src/fortran/defmat.f src/fortran/mklist.f \ 180 src/fortran/mklist.f src/fortran/sigbas.f src/fortran/indxg.f \
180 src/fortran/sigbas.f src/fortran/indxg.f src/fortran/matz.f \ 181 src/fortran/matz.f src/fortran/istrue.f src/fortran/inisci.f \
181 src/fortran/istrue.f src/fortran/inisci.f src/fortran/ptover.f \ 182 src/fortran/ptover.f src/fortran/getfunction.f \
182 src/fortran/getfunction.f src/fortran/stackp.f \ 183 src/fortran/stackp.f src/fortran/dbasin.f src/fortran/macro.f \
183 src/fortran/dbasin.f src/fortran/macro.f src/fortran/extlarg.f \ 184 src/fortran/extlarg.f src/fortran/getstr.f src/fortran/cvwm.f \
184 src/fortran/getstr.f src/fortran/cvwm.f \
185 src/fortran/storeglobal.f src/fortran/lst2vars.f \ 185 src/fortran/storeglobal.f src/fortran/lst2vars.f \
186 src/fortran/basnms.f src/fortran/matc.f src/fortran/ptrback.f \ 186 src/fortran/basnms.f src/fortran/matc.f src/fortran/ptrback.f \
187 src/fortran/getch.f src/fortran/ftob.f src/fortran/seteol.f \ 187 src/fortran/getch.f src/fortran/ftob.f src/fortran/seteol.f \
@@ -286,7 +286,8 @@ am__objects_2 = libscicore_la-inffic.lo libscicore_la-cs2st.lo \
286 libscicore_la-eqid.lo libscicore_la-exitCodeValue.lo \ 286 libscicore_la-eqid.lo libscicore_la-exitCodeValue.lo \
287 libscicore_la-getversion.lo libscicore_la-dynamic_tclsci.lo \ 287 libscicore_la-getversion.lo libscicore_la-dynamic_tclsci.lo \
288 $(am__objects_1) 288 $(am__objects_1)
289am__objects_3 = libscicore_la-hashtable_core.lo 289am__objects_3 = libscicore_la-hashtable_core.lo \
290 libscicore_la-namstr.lo libscicore_la-search_functions.lo
290@USE_DYNAMIC_STACK_TRUE@am__objects_4 = relocstack.lo 291@USE_DYNAMIC_STACK_TRUE@am__objects_4 = relocstack.lo
291am__objects_5 = clunit.lo getlin.lo allowptr.lo isany.lo hmcreate.lo \ 292am__objects_5 = clunit.lo getlin.lo allowptr.lo isany.lo hmcreate.lo \
292 nextj.lo setgetmode.lo showstack.lo misops.lo iseye.lo \ 293 nextj.lo setgetmode.lo showstack.lo misops.lo iseye.lo \
@@ -296,16 +297,15 @@ am__objects_5 = clunit.lo getlin.lo allowptr.lo isany.lo hmcreate.lo \
296 intstr.lo createref.lo btof.lo matzs.lo getnum.lo btofm.lo \ 297 intstr.lo createref.lo btof.lo matzs.lo getnum.lo btofm.lo \
297 getsym.lo findequal.lo stackg.lo find.lo israt.lo setlnb.lo \ 298 getsym.lo findequal.lo stackg.lo find.lo israt.lo setlnb.lo \
298 mrknmd.lo stackgl.lo allops.lo mname.lo command.lo ref2val.lo \ 299 mrknmd.lo stackgl.lo allops.lo mname.lo command.lo ref2val.lo \
299 namstr.lo stack.lo isbrk.lo majmin.lo xerbla.lo dtosci.lo \ 300 stack.lo isbrk.lo majmin.lo xerbla.lo dtosci.lo bexec.lo \
300 bexec.lo varfunptr.lo getfun.lo savlod.lo error.lo cvdm.lo \ 301 varfunptr.lo getfun.lo savlod.lo error.lo cvdm.lo tradsl.lo \
301 tradsl.lo mkindx.lo whatln.lo errmgr.lo defmat.lo mklist.lo \ 302 mkindx.lo whatln.lo errmgr.lo defmat.lo mklist.lo sigbas.lo \
302 sigbas.lo indxg.lo matz.lo istrue.lo inisci.lo ptover.lo \ 303 indxg.lo matz.lo istrue.lo inisci.lo ptover.lo getfunction.lo \
303 getfunction.lo stackp.lo dbasin.lo macro.lo extlarg.lo \ 304 stackp.lo dbasin.lo macro.lo extlarg.lo getstr.lo cvwm.lo \
304 getstr.lo cvwm.lo storeglobal.lo lst2vars.lo basnms.lo matc.lo \ 305 storeglobal.lo lst2vars.lo basnms.lo matc.lo ptrback.lo \
305 ptrback.lo getch.lo ftob.lo seteol.lo basin.lo clause.lo \ 306 getch.lo ftob.lo seteol.lo basin.lo clause.lo compcl.lo \
306 compcl.lo termf.lo expsum.lo copyvar.lo putid.lo itosci.lo \ 307 termf.lo expsum.lo copyvar.lo putid.lo itosci.lo stackr2d.lo \
307 stackr2d.lo stacki2d.lo stackc2i.lo isinstring.lo \ 308 stacki2d.lo stackc2i.lo isinstring.lo $(am__objects_4)
308 $(am__objects_4)
309am__objects_6 = libscicore_la-sci_stacksize.lo \ 309am__objects_6 = libscicore_la-sci_stacksize.lo \
310 libscicore_la-sci_resume.lo libscicore_la-sci_mtlb_mode.lo \ 310 libscicore_la-sci_resume.lo libscicore_la-sci_mtlb_mode.lo \
311 libscicore_la-sci_banner.lo libscicore_la-sci_where.lo \ 311 libscicore_la-sci_banner.lo libscicore_la-sci_where.lo \
@@ -656,7 +656,10 @@ CORE_C_SOURCES = src/c/inffic.c src/c/cs2st.c src/c/tmpdir.c \
656 src/c/inittypenames.c src/c/funcprot.c src/c/eqid.c \ 656 src/c/inittypenames.c src/c/funcprot.c src/c/eqid.c \
657 src/c/exitCodeValue.c src/c/getversion.c \ 657 src/c/exitCodeValue.c src/c/getversion.c \
658 src/c/dynamic_tclsci.c $(am__append_1) 658 src/c/dynamic_tclsci.c $(am__append_1)
659CORE_CPP_SOURCES = src/cpp/hashtable_core.cpp 659CORE_CPP_SOURCES = src/cpp/hashtable_core.cpp \
660src/cpp/namstr.cpp \
661src/cpp/search_functions.cpp
662
660CORE_FORTRAN_SOURCES = src/fortran/clunit.f src/fortran/getlin.f \ 663CORE_FORTRAN_SOURCES = src/fortran/clunit.f src/fortran/getlin.f \
661 src/fortran/allowptr.f src/fortran/isany.f \ 664 src/fortran/allowptr.f src/fortran/isany.f \
662 src/fortran/hmcreate.f src/fortran/nextj.f \ 665 src/fortran/hmcreate.f src/fortran/nextj.f \
@@ -675,18 +678,17 @@ CORE_FORTRAN_SOURCES = src/fortran/clunit.f src/fortran/getlin.f \
675 src/fortran/find.f src/fortran/israt.f src/fortran/setlnb.f \ 678 src/fortran/find.f src/fortran/israt.f src/fortran/setlnb.f \
676 src/fortran/mrknmd.f src/fortran/stackgl.f \ 679 src/fortran/mrknmd.f src/fortran/stackgl.f \
677 src/fortran/allops.f src/fortran/mname.f src/fortran/command.f \ 680 src/fortran/allops.f src/fortran/mname.f src/fortran/command.f \
678 src/fortran/ref2val.f src/fortran/namstr.f src/fortran/stack.f \ 681 src/fortran/ref2val.f src/fortran/stack.f src/fortran/isbrk.f \
679 src/fortran/isbrk.f src/fortran/majmin.f src/fortran/xerbla.f \ 682 src/fortran/majmin.f src/fortran/xerbla.f src/fortran/dtosci.f \
680 src/fortran/dtosci.f src/fortran/bexec.f \ 683 src/fortran/bexec.f src/fortran/varfunptr.f \
681 src/fortran/varfunptr.f src/fortran/getfun.f \ 684 src/fortran/getfun.f src/fortran/savlod.f src/fortran/error.f \
682 src/fortran/savlod.f src/fortran/error.f src/fortran/cvdm.f \ 685 src/fortran/cvdm.f src/fortran/tradsl.f src/fortran/mkindx.f \
683 src/fortran/tradsl.f src/fortran/mkindx.f src/fortran/whatln.f \ 686 src/fortran/whatln.f src/fortran/errmgr.f src/fortran/defmat.f \
684 src/fortran/errmgr.f src/fortran/defmat.f src/fortran/mklist.f \ 687 src/fortran/mklist.f src/fortran/sigbas.f src/fortran/indxg.f \
685 src/fortran/sigbas.f src/fortran/indxg.f src/fortran/matz.f \ 688 src/fortran/matz.f src/fortran/istrue.f src/fortran/inisci.f \
686 src/fortran/istrue.f src/fortran/inisci.f src/fortran/ptover.f \ 689 src/fortran/ptover.f src/fortran/getfunction.f \
687 src/fortran/getfunction.f src/fortran/stackp.f \ 690 src/fortran/stackp.f src/fortran/dbasin.f src/fortran/macro.f \
688 src/fortran/dbasin.f src/fortran/macro.f src/fortran/extlarg.f \ 691 src/fortran/extlarg.f src/fortran/getstr.f src/fortran/cvwm.f \
689 src/fortran/getstr.f src/fortran/cvwm.f \
690 src/fortran/storeglobal.f src/fortran/lst2vars.f \ 692 src/fortran/storeglobal.f src/fortran/lst2vars.f \
691 src/fortran/basnms.f src/fortran/matc.f src/fortran/ptrback.f \ 693 src/fortran/basnms.f src/fortran/matc.f src/fortran/ptrback.f \
692 src/fortran/getch.f src/fortran/ftob.f src/fortran/seteol.f \ 694 src/fortran/getch.f src/fortran/ftob.f src/fortran/seteol.f \
@@ -798,7 +800,7 @@ libscicore_la_CPPFLAGS = -I$(srcdir)/includes/ \
798 -I$(srcdir)/src/c/ \ 800 -I$(srcdir)/src/c/ \
799 -I$(srcdir)/src/cpp/ \ 801 -I$(srcdir)/src/cpp/ \
800 -I$(top_srcdir)/modules/dynamic_link/includes \ 802 -I$(top_srcdir)/modules/dynamic_link/includes \
801 -I$(top_srcdir)/libs/MALLOC/includes/ 803 -I$(top_srcdir)/libs/MALLOC/includes/
802 804
803pkglib_LTLIBRARIES = libscicore.la 805pkglib_LTLIBRARIES = libscicore.la
804libscicore_la_LDFLAGS = -version-info $(SCILAB_LIBRARY_VERSION) $(XML_LIBS) 806libscicore_la_LDFLAGS = -version-info $(SCILAB_LIBRARY_VERSION) $(XML_LIBS)
@@ -1048,6 +1050,7 @@ distclean-compile:
1048@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-loadversion.Plo@am__quote@ 1050@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-loadversion.Plo@am__quote@
1049@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-md5.Plo@am__quote@ 1051@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-md5.Plo@am__quote@
1050@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-mode_exec.Plo@am__quote@ 1052@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-mode_exec.Plo@am__quote@
1053@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-namstr.Plo@am__quote@
1051@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-parse.Plo@am__quote@ 1054@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-parse.Plo@am__quote@
1052@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-predef.Plo@am__quote@ 1055@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-predef.Plo@am__quote@
1053@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-readGateway.Plo@am__quote@ 1056@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-readGateway.Plo@am__quote@
@@ -1116,6 +1119,7 @@ distclean-compile:
1116@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-scimem64.Plo@am__quote@ 1119@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-scimem64.Plo@am__quote@
1117@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-sciquit.Plo@am__quote@ 1120@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-sciquit.Plo@am__quote@
1118@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-scirun.Plo@am__quote@ 1121@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-scirun.Plo@am__quote@
1122@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-search_functions.Plo@am__quote@
1119@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-setPrecisionFPU.Plo@am__quote@ 1123@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-setPrecisionFPU.Plo@am__quote@
1120@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-setgetSCIpath.Plo@am__quote@ 1124@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-setgetSCIpath.Plo@am__quote@
1121@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-stack1.Plo@am__quote@ 1125@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libscicore_la-stack1.Plo@am__quote@
@@ -2129,6 +2133,20 @@ libscicore_la-hashtable_core.lo: src/cpp/hashtable_core.cpp
2129@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 2133@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
2130@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscicore_la-hashtable_core.lo `test -f 'src/cpp/hashtable_core.cpp' || echo '$(srcdir)/'`src/cpp/hashtable_core.cpp 2134@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscicore_la-hashtable_core.lo `test -f 'src/cpp/hashtable_core.cpp' || echo '$(srcdir)/'`src/cpp/hashtable_core.cpp
2131 2135
2136libscicore_la-namstr.lo: src/cpp/namstr.cpp
2137@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscicore_la-namstr.lo -MD -MP -MF $(DEPDIR)/libscicore_la-namstr.Tpo -c -o libscicore_la-namstr.lo `test -f 'src/cpp/namstr.cpp' || echo '$(srcdir)/'`src/cpp/namstr.cpp
2138@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/libscicore_la-namstr.Tpo $(DEPDIR)/libscicore_la-namstr.Plo
2139@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/cpp/namstr.cpp' object='libscicore_la-namstr.lo' libtool=yes @AMDEPBACKSLASH@
2140@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
2141@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscicore_la-namstr.lo `test -f 'src/cpp/namstr.cpp' || echo '$(srcdir)/'`src/cpp/namstr.cpp
2142
2143libscicore_la-search_functions.lo: src/cpp/search_functions.cpp
2144@am__fastdepCXX_TRUE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libscicore_la-search_functions.lo -MD -MP -MF $(DEPDIR)/libscicore_la-search_functions.Tpo -c -o libscicore_la-search_functions.lo `test -f 'src/cpp/search_functions.cpp' || echo '$(srcdir)/'`src/cpp/search_functions.cpp
2145@am__fastdepCXX_TRUE@ $(am__mv) $(DEPDIR)/libscicore_la-search_functions.Tpo $(DEPDIR)/libscicore_la-search_functions.Plo
2146@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='src/cpp/search_functions.cpp' object='libscicore_la-search_functions.lo' libtool=yes @AMDEPBACKSLASH@
2147@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
2148@am__fastdepCXX_FALSE@ $(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libscicore_la_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libscicore_la-search_functions.lo `test -f 'src/cpp/search_functions.cpp' || echo '$(srcdir)/'`src/cpp/search_functions.cpp
2149
2132.f.o: 2150.f.o:
2133 $(F77COMPILE) -c -o $@ $< 2151 $(F77COMPILE) -c -o $@ $<
2134 2152
@@ -2276,9 +2294,6 @@ command.lo: src/fortran/command.f
2276ref2val.lo: src/fortran/ref2val.f 2294ref2val.lo: src/fortran/ref2val.f
2277 $(LIBTOOL) --tag=F77 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(F77) $(AM_FFLAGS) $(FFLAGS) -c -o ref2val.lo `test -f 'src/fortran/ref2val.f' || echo '$(srcdir)/'`src/fortran/ref2val.f 2295 $(LIBTOOL) --tag=F77 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(F77) $(AM_FFLAGS) $(FFLAGS) -c -o ref2val.lo `test -f 'src/fortran/ref2val.f' || echo '$(srcdir)/'`src/fortran/ref2val.f
2278 2296
2279namstr.lo: src/fortran/namstr.f
2280 $(LIBTOOL) --tag=F77 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(F77) $(AM_FFLAGS) $(FFLAGS) -c -o namstr.lo `test -f 'src/fortran/namstr.f' || echo '$(srcdir)/'`src/fortran/namstr.f
2281
2282stack.lo: src/fortran/stack.f 2297stack.lo: src/fortran/stack.f
2283 $(LIBTOOL) --tag=F77 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(F77) $(AM_FFLAGS) $(FFLAGS) -c -o stack.lo `test -f 'src/fortran/stack.f' || echo '$(srcdir)/'`src/fortran/stack.f 2298 $(LIBTOOL) --tag=F77 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(F77) $(AM_FFLAGS) $(FFLAGS) -c -o stack.lo `test -f 'src/fortran/stack.f' || echo '$(srcdir)/'`src/fortran/stack.f
2284 2299
diff --git a/scilab/modules/core/src/cpp/hashtable_core.cpp b/scilab/modules/core/src/cpp/hashtable_core.cpp
index 6a44257..ae7cd75 100644
--- a/scilab/modules/core/src/cpp/hashtable_core.cpp
+++ b/scilab/modules/core/src/cpp/hashtable_core.cpp
@@ -33,7 +33,7 @@ extern int C2F(cvname)(int *,char *,int const*, unsigned long int);
33#include <functional> 33#include <functional>
34#include <cstring> // for std::memset 34#include <cstring> // for std::memset
35#include "partition.hxx" // for scilab::core::partition_point_n 35#include "partition.hxx" // for scilab::core::partition_point_n
36#include "unrolled_algorithms.hxx" //for scilab::core::eq_n less_n copy_n 36#include "unrolled_algorithms.hxx" //for eq_n less_n copy_n
37/*----------------------------------------------------------------------------*/ 37/*----------------------------------------------------------------------------*/
38#define MAXLENGHTFUNCTIONNAME 32 /* 24 in fact in scilab +1 for '\0' round to nearest multiple of 8*/ 38#define MAXLENGHTFUNCTIONNAME 32 /* 24 in fact in scilab +1 for '\0' round to nearest multiple of 8*/
39/*----------------------------------------------------------------------------*/ 39/*----------------------------------------------------------------------------*/
@@ -42,18 +42,18 @@ using namespace scilab::core;
42namespace { 42namespace {
43 struct entry 43 struct entry
44 { 44 {
45 entry() 45 entry()
46 { 46 {
47 std::memset(key, 0, sizeof(key)+sizeof(data)+1); // no alignement issues, init ints to 0 and namefunction to "" 47 std::memset(key, 0, sizeof(key)+sizeof(data)+1); // no alignement issues, init ints to 0 and namefunction to ""
48 } 48 }
49 entry(int d, char const* name): data(d) 49 entry(int d, char const* name): data(d)
50 { 50 {
51 int const zero(0); 51 int const zero(0);
52 if(name) 52 if(name)
53 { 53 {
54 strncpy(namefunction, name, MAXLENGHTFUNCTIONNAME); 54 strncpy(namefunction, name, MAXLENGHTFUNCTIONNAME);
55 } 55 }
56 else 56 else
57 { 57 {
58 namefunction[0]= '\0'; // "" name 58 namefunction[0]= '\0'; // "" name
59 } 59 }
@@ -76,14 +76,14 @@ namespace {
76 * (could be removed with boost:: or C++0x lambdas ) 76 * (could be removed with boost:: or C++0x lambdas )
77 * 77 *
78 */ 78 */
79 struct key_less_than : std::unary_function<entry const&, bool> 79 struct key_less_than : std::unary_function<entry const&, bool>
80 { 80 {
81 key_less_than(int const* const k): key(k) {} 81 key_less_than(int const* const k): key(k) {}
82 bool operator()(entry const& e) const { return less_n<nsiz>(key, e.key);} 82 bool operator()(entry const& e) const { return less_n<nsiz>(key, e.key);}
83 int const* const key; 83 int const* const key;
84 }; 84 };
85 85
86 struct not_less_than_key : std::unary_function<entry const&, bool> 86 struct not_less_than_key : std::unary_function<entry const&, bool>
87 { 87 {
88 not_less_than_key(int const* const k): key(k) {} 88 not_less_than_key(int const* const k): key(k) {}
89 bool operator()(entry const& e) const { return !less_n<nsiz>(e.key, key);} 89 bool operator()(entry const& e) const { return !less_n<nsiz>(e.key, key);}
@@ -91,7 +91,7 @@ namespace {
91 }; 91 };
92 92
93 93
94 struct equal_data 94 struct equal_data
95 { 95 {
96 equal_data(int const d) : data(d) {} 96 equal_data(int const d) : data(d) {}
97 bool operator()(entry const& e) const { return e.data == data ; } 97 bool operator()(entry const& e) const { return e.data == data ; }
@@ -103,16 +103,16 @@ namespace {
103* preallocate memory for DEFAULT_ELEMENTFUNCTIONLIST entries in table 103* preallocate memory for DEFAULT_ELEMENTFUNCTIONLIST entries in table
104*/ 104*/
105/*----------------------------------------------------------------------------*/ 105/*----------------------------------------------------------------------------*/
106BOOL create_hashtable_scilab_functions(void) 106BOOL create_hashtable_scilab_functions(void)
107{ 107{
108 try 108 try
109 { 109 {
110 table_t tmp(0); 110 table_t tmp(0);
111 tmp.reserve( DEFAULT_ELEMENTFUNCTIONLIST ); 111 tmp.reserve( DEFAULT_ELEMENTFUNCTIONLIST );
112 table.swap(tmp); 112 table.swap(tmp);
113 return TRUE; 113 return TRUE;
114 } 114 }
115 catch( std::bad_alloc& e) 115 catch( std::bad_alloc& e)
116 { 116 {
117 return FALSE; 117 return FALSE;
118 } 118 }
@@ -123,7 +123,7 @@ BOOL create_hashtable_scilab_functions(void)
123* free memory for table 123* free memory for table
124*/ 124*/
125/*----------------------------------------------------------------------------*/ 125/*----------------------------------------------------------------------------*/
126void destroy_hashtable_scilab_functions() 126void destroy_hashtable_scilab_functions()
127{ 127{
128 table_t tmp(0); // swap trick needed because resize() does *not* release memory 128 table_t tmp(0); // swap trick needed because resize() does *not* release memory
129 table.swap(tmp); 129 table.swap(tmp);
@@ -133,7 +133,7 @@ static BOOL doFindFunction(int *key,char *name, int *scilab_funptr)
133{ 133{
134 int tmp[nsiz]; 134 int tmp[nsiz];
135 int const* keyToSearch= key; 135 int const* keyToSearch= key;
136 if (name) 136 if (name)
137 { 137 {
138 /* faster than a strcmp */ 138 /* faster than a strcmp */
139 int job = 0; /* convert name to id */ 139 int job = 0; /* convert name to id */
@@ -142,12 +142,12 @@ static BOOL doFindFunction(int *key,char *name, int *scilab_funptr)
142 } 142 }
143 // find lower bound : first elt not < 143 // find lower bound : first elt not <
144 table_t::const_iterator i= partition_point_n(table.begin(), table.size(), not_less_than_key(keyToSearch)); 144 table_t::const_iterator i= partition_point_n(table.begin(), table.size(), not_less_than_key(keyToSearch));
145 if(i != table.end() && eq_n<nsiz>(keyToSearch, i->key)) 145 if(i != table.end() && eq_n<nsiz>(keyToSearch, i->key))
146 { 146 {
147 *scilab_funptr = i->data; 147 *scilab_funptr = i->data;
148 return TRUE; 148 return TRUE;
149 } 149 }
150 else 150 else
151 { 151 {
152 return FALSE; 152 return FALSE;
153 } 153 }
@@ -158,12 +158,12 @@ static BOOL doBackSearchFunction(int *key, int *scilab_funptr)
158{ 158{
159 table_t::const_iterator i= std::find_if(table.begin(), table.end() 159 table_t::const_iterator i= std::find_if(table.begin(), table.end()
160 , equal_data(*scilab_funptr)); 160 , equal_data(*scilab_funptr));
161 if( i != table.end()) 161 if( i != table.end())
162 { 162 {
163 copy_n<nsiz>(i->key, key); 163 copy_n<nsiz>(i->key, key);
164 return TRUE; 164 return TRUE;
165 } 165 }
166 else 166 else
167 { 167 {
168 return FALSE; 168 return FALSE;
169 } 169 }
@@ -171,13 +171,13 @@ static BOOL doBackSearchFunction(int *key, int *scilab_funptr)
171/*----------------------------------------------------------------------------*/ 171/*----------------------------------------------------------------------------*/
172static BOOL doEnterFunction(int *key,char *name, int *scilab_funptr) 172static BOOL doEnterFunction(int *key,char *name, int *scilab_funptr)
173{ 173{
174 if(table.size() < MAXELEMENTFUNCTIONLIST) 174 if(table.size() < MAXELEMENTFUNCTIONLIST)
175 { 175 {
176 entry tmp(*scilab_funptr, name); 176 entry tmp(*scilab_funptr, name);
177 // insert before upper bound : first elt such that key<elt 177 // insert before upper bound : first elt such that key<elt
178 table.insert(partition_point_n(table.begin(), table.size() 178 table.insert(partition_point_n(table.begin(), table.size()
179 , key_less_than(tmp.key)), tmp); 179 , key_less_than(tmp.key)), tmp);
180 if(table.size() > hashtable_core_maxFilled) 180 if(table.size() > hashtable_core_maxFilled)
181 { 181 {
182 hashtable_core_maxFilled = table.size(); 182 hashtable_core_maxFilled = table.size();
183 } 183 }
@@ -194,14 +194,14 @@ static BOOL doDeleteFunction(int *key, int *scilab_funptr)
194 , not_less_than_key(key)) 194 , not_less_than_key(key))
195 , table.end(), equal_data(*scilab_funptr))); 195 , table.end(), equal_data(*scilab_funptr)));
196 196
197 if( i != table.end() ) 197 if( i != table.end() )
198 { 198 {
199 // entry found -> erase it 199 // entry found -> erase it
200 table.erase(i); 200 table.erase(i);
201 return TRUE; 201 return TRUE;
202 } 202 }
203 else 203 else
204 { 204 {
205 // not found 205 // not found
206 return FALSE; 206 return FALSE;
207 } 207 }
@@ -234,24 +234,24 @@ struct has_namefunction : std::unary_function<entry const&, bool> {
234 234
235struct copy_name : std::unary_function<entry const&, char**> { 235struct copy_name : std::unary_function<entry const&, char**> {
236 copy_name(char** n): names(n) { } 236 copy_name(char** n): names(n) { }
237 char** operator()(entry const& e) 237 char** operator()(entry const& e)
238 { 238 {
239 if(e.namefunction[0] != '\0') 239 if(e.namefunction[0] != '\0')
240 { 240 {
241 *names = strdup(e.namefunction); 241 *names = strdup(e.namefunction);
242 ++names; 242 ++names;
243 } 243 }
244 return names; 244 return names;
245 } 245 }
246 246
247 char** names; 247 char** names;
248}; 248};
249/*----------------------------------------------------------------------------*/ 249/*----------------------------------------------------------------------------*/
250char **GetFunctionsList(int *sizeList) 250char **GetFunctionsList(int *sizeList)
251{ 251{
252 *sizeList= std::count_if(table.begin(), table.end(), has_namefunction()); 252 *sizeList= std::count_if(table.begin(), table.end(), has_namefunction());
253 char **ListFunctions = static_cast<char**>(MALLOC(sizeof(char*)*(*sizeList))); 253 char **ListFunctions = static_cast<char**>(MALLOC(sizeof(char*)*(*sizeList)));
254 if ( ListFunctions ) 254 if ( ListFunctions )
255 { 255 {
256 std::for_each(table.begin(), table.end(), copy_name(ListFunctions)); 256 std::for_each(table.begin(), table.end(), copy_name(ListFunctions));
257 } 257 }
@@ -265,7 +265,7 @@ struct equal_name : std::unary_function<entry const&, bool>
265 char const* const name; 265 char const* const name;
266}; 266};
267/*----------------------------------------------------------------------------*/ 267/*----------------------------------------------------------------------------*/
268BOOL ExistFunction(char *name) 268BOOL ExistFunction(char *name)
269{ 269{
270 return (std::find_if(table.begin(), table.end(), equal_name(name)) == table.end()) ? FALSE : TRUE ; 270 return (std::find_if(table.begin(), table.end(), equal_name(name)) == table.end()) ? FALSE : TRUE ;
271} 271}
diff --git a/scilab/modules/core/src/cpp/namstr.cpp b/scilab/modules/core/src/cpp/namstr.cpp
new file mode 100644
index 0000000..3dba511
--- /dev/null
+++ b/scilab/modules/core/src/cpp/namstr.cpp
@@ -0,0 +1,113 @@
1/*
2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2010 - DIGITEO - Bernard HUGUENEY
4 *
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10 *
11 */
12#include "machine.h" /* C2F */
13#include "stack-def.h" /* nsiz, nlgh */
14
15extern "C"
16{
17 void C2F(namstr)(int* id, int* str, int* n, char* job);
18}
19
20namespace
21{
22 int const blank=40; /* a scilab encoded blank character: used for padding id when name has < nsiz*6 characters*/
23/* constant below are used for fast padding 1->4 blanks at once */
24 int const one_blank= (blank<<24);
25 int const two_blanks= one_blank + (blank<<16);
26 int const three_blanks= two_blanks + (blank<<8);
27 int const four_blanks= three_blanks + blank;
28}
29
30/*
31 * convert id (array of nsiz ints) <-> str (array of n <= nlgh=4*nsiz ints)
32 * each element of str is stored in 8 bits of an id. The reming bytes (after n)
33 * are filled with blanks.
34 *
35 *
36 * @param id contains the id of nsiz ints
37 * @param str contains the string of nlgh ints
38 * @param n contains the address of the (int) length of the string input for str->id, output for id->str
39 * @param job 0 => str->id, id-> str otherwise
40 *
41 * TODO: now that function search has been ported to C++, should expose a saner API that would not require strlen call nor a job arg.
42 */
43void C2F(namstr)(int* id,int* str, int* n, char* job)
44{
45 if (*job) /* id -> str */
46 {
47
48 unsigned int i1(0); /* starting character from constructed str when processing an int from id */
49
50 for (unsigned int j= 0; j != nsiz; ++j, i1 += 4) /* processing id[j] into str[i1...ii+4] */
51 {
52 int id_j(id[j]);/* caching id[j] because we could not tell the compiler that id and str do not alias */
53 for (unsigned int i(i1); i!=i1+4; ++i, id_j >>= 8)/* processing each byte from id[j] into an int in str*/
54 {
55 /* extracting the *signed* lower byte: & 0x80 tests the 7th bit (sign bit of the byte)
56 * |0xffffff00 : lower <0, byte & 0xff : lower >0 byte */
57 int ch((id_j & 0x80) ? (id_j |0xffffff00) : (id_j & 0xff));
58 if (ch == blank)/* we encounter a blank -> end of string. */
59 {
60 *n = i;
61 return;
62 }
63 id_j += 128;/* propagate sign bit to upper bits */
64 str[i]= ch;
65 }
66 }
67
68 *n= nlgh;/* no blank encountered str length is nlgh= nsiz*8 */
69
70 }
71 else
72 { /* str -> id */
73 /* n (<= nsiz*4 = nlgh) int in str packed into id */
74 unsigned int j;
75 /* a full id contains 4 ints from str, so we have *n/4 full ids the remaing are padded with blanks */
76 unsigned const int full_ids((*n)/4);
77
78 for (j= 0; j!=full_ids; ++j)
79 { /* str int are signed bytes in fact, we pack them using shifts */
80 id[j]= str[4*j+0] +(str[4*j+1]<<8)+(str[4*j+2]<<16)+(str[4*j+3]<<24);
81 }
82 if (j!= nsiz)/* we had < nsiz int in str : padd with blank chars */
83 {
84 switch ((*n ) & 0x3) /* pad partial id int according modulo 4= nb of remaining ints in str */
85 {
86 case 3: /* three remaining ints and one blank */
87 {
88 id[j]= one_blank + (str[4*j+2] << 16) + (str[4*j+1] << 8) + str[4*j + 0];
89 ++j;
90 break;
91 }
92 case 2: /* two remaining ints and two blanks */
93 {
94 id[j]= two_blanks + (str[4*j+1]<<8) + str[4*j+0];
95 ++j;
96 break;
97 }
98 case 1:/* one remaining int and three blanks*/
99 {
100 id[j]= three_blanks + str[4*j+0];
101 ++j;
102 break;
103 }
104 }
105
106 for (;j != nsiz; ++j) /* pad empty ints in id with four blanks at once */
107 {
108 id[j]= four_blanks;
109 }
110 }
111 }
112 return;
113}
diff --git a/scilab/modules/core/src/cpp/search_functions.cpp b/scilab/modules/core/src/cpp/search_functions.cpp
new file mode 100644
index 0000000..7fa7b6f
--- /dev/null
+++ b/scilab/modules/core/src/cpp/search_functions.cpp
@@ -0,0 +1,171 @@
1/*
2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2010 - DIGITEO - Bernard HUGUENEY
4 *
5 * This file must be used under the terms of the CeCILL.
6 * This source file is licensed as described in the file COPYING, which
7 * you should have received as part of this distribution. The terms
8 * are also available at
9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10 *
11 */
12
13#include <cstdlib>
14#include <algorithm>
15#include "unrolled_algorithms.hxx"
16extern "C" {
17#include "stack-c.h"
18#include "stack-def.h" /* C2F(basbrk) */
19#include "intmacr2tree.h" /*#define idstk(x,y) (C2F(vstk).idstk+(x-1)+(y-1)*nsiz) */
20
21 void C2F(siflibs)(int* id, int* k_ptr, int* istr, int* lbibn, int* nbibn, int* ilp, int* nn, int* should_return);
22 void C2F(sivars)(int* id, int* should_return);
23 void C2F(namstr)(int* id, int* str, int* n, char const* job);
24}
25
26
27/*
28 * These are C++ reimplementations of some (as few as possible) code from funs.f
29 * The goal was to improve speed with :
30 * 1°) avoiding a call to namstr_ when only the first (two) caracters where needed
31 * 2°) allowing the compiler to replace eqid() calls with inlined faster C++ implementation of eq_n<nsiz>
32 */
33
34namespace
35{
36 char const f_true = 1;
37 char const f_false = 0;
38 int const percent = 56;
39 int const nclas = 29;
40 char const from_id = 1;
41
42 /* directly convert from id to upper char */
43 int upper_char(int id)
44 {
45 /* scilab character encoding is using signed bytes packed into an int.
46 * testing for the 7th bit with & 0x80 gives us the sign
47 * & 0xff extracts the byte if positive,
48 * |0xffffff00 extracts the byte if negative (assuming two's complement negative numbers representations)
49 * abs() takes the upper value in scilab character encoding.
50 */
51 return std::abs((int)((id & 0x80) ? (id |0xffffff00) : (id & 0xff)));
52 }
53
54 /* gives the discriminating char (either first of second if first=percent) */
55 int id_char(int const* id)
56 {
57 int ch(upper_char(*id));
58 if (ch == percent)
59 {
60 return upper_char((*id)>>8);
61 }
62 return ch;
63 }
64}
65/* search for an id in the libraries
66 * as we reimplement part of Fortran function, we now use a 'bool' (for Fortran) should_return to tell calling
67 * function that it should return at once.
68 * other variables are lifted straight from Fortran code.
69 */
70void C2F(siflibs)(int* id, int* k_ptr, int* istr, int* lbibn_ptr, int* nbibn_ptr, int* ilp_ptr, int* nn_ptr, int* should_return)
71{
72
73 static int const* const lstk_ptr = (int*)C2F(vstk).lstk-1;
74 static int const* const istk_ptr = ((int*)C2F(stack).Stk)-1;
75 int k, ilp, nbibn, lbibn;
76
77 *should_return= f_false;
78
79 for (k= Bot; k < C2F(vstk).isiz; ++k)
80 {
81 int il = iadr(lstk_ptr[k]);
82 int ip;
83
84 if (istk_ptr[il] == sci_lib)
85 {
86 nbibn = istk_ptr[il+1];
87 lbibn = il+2;
88 il += nbibn+2;
89 ilp = il+1;
90 ip = std::max(1, id_char(id)-9);
91 if (ip <= nclas)
92 {
93
94 int n = istk_ptr[ilp+ip] -istk_ptr[ilp+ip-1];
95 if (n != 0)
96 {
97 int iln= ilp+nclas+1+(istk_ptr[ilp+ip-1]-1)*nsiz;
98
99 for (int i = 1; i<=n; ++i, iln+= nsiz)
100 {
101 if (eq_n<nsiz>(id, istk_ptr+iln))
102 { /* 39 */
103 if ((Fin == -1) || (Fin == -3))
104 {
105 C2F(com).fun= k;
106 Fin= i;
107 *should_return= f_true;
108 return;
109 }
110
111 Fin= i;
112 if (C2F(errgst).err1 != 0)
113 {
114 C2F(com).fun= Fin= 0;
115 *should_return= f_true;
116 return;
117 }
118
119 C2F(namstr)(id,istr, nn_ptr, &from_id);
120 *k_ptr= k;
121 *lbibn_ptr= lbibn;
122 *nbibn_ptr= nbibn;
123 *ilp_ptr= ilp;
124 *should_return= f_false;
125 return;
126 }
127 }
128 }
129
130 }
131
132 }
133
134 }
135 C2F(com).fun= Fin= 0;
136 *should_return= f_true;
137 return;
138}
139
140/* search for an id in vars, also lifted from Fortran code in funs.f */
141void C2F(sivars)(int* id, int* should_return)
142{
143 int* const lstk_ptr = (int*)C2F(vstk).lstk-1;
144
145 int k;
146 /* idstk(x,y) (C2F(vstk).idstk+(x-1)+(y-1)*nsiz) */
147 int* id_addr=C2F(vstk).idstk;
148 for (*should_return= f_false, k= Bot, id_addr+=(k-1)*nsiz;
149 k <= C2F(vstk).isiz && !eq_n<nsiz>(id_addr, id);
150 ++k, id_addr+=nsiz)
151 {
152 }
153
154 if (k <= C2F(vstk).isiz)
155 {/* eq_id */
156 int il=lstk_ptr[k];/* iadr() */
157 il<<=1;
158 ++il;
159
160 if ((*istk(il) != sci_u_function) && (*istk(il) != sci_c_function))
161 {
162 C2F(com).fun= Fin= 0;
163 *should_return= f_true;
164 }
165
166 C2F(com).fun= -1;
167 Fin= k;
168 *should_return= f_true;
169 }
170 return; /* *should_return= f_false; */
171}
diff --git a/scilab/modules/core/src/cpp/unrolled_algorithms.hxx b/scilab/modules/core/src/cpp/unrolled_algorithms.hxx
index f2ef6c1..43ec12e 100644
--- a/scilab/modules/core/src/cpp/unrolled_algorithms.hxx
+++ b/scilab/modules/core/src/cpp/unrolled_algorithms.hxx
@@ -1,69 +1,173 @@
1/* 1/*
2* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3* Copyright (C) 2010 - DIGITEO - Bernard HUGUENEY 3 * Copyright (C) 2010 - DIGITEO - Bernard HUGUENEY
4* 4 *
5* This file must be used under the terms of the CeCILL. 5 * This file must be used under the terms of the CeCILL.
6* This source file is licensed as described in the file COPYING, which 6 * This source file is licensed as described in the file COPYING, which
7* you should have received as part of this distribution. The terms 7 * you should have received as part of this distribution. The terms
8* are also available at 8 * are also available at
9* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt 9 * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10* 10 *
11*/ 11 */
12/*-----------------------------------------------------------------------------------*/ 12/*-----------------------------------------------------------------------------------*/
13#ifndef UNROLLED_ALGORITHMS_HXX 13#ifndef UNROLLED_ALGORITHMS_HXX
14#define UNROLLED_ALGORITHMS_HXX 14#define UNROLLED_ALGORITHMS_HXX
15 15
16namespace scilab { 16namespace {
17 namespace core { 17 /*
18 /* 18 * generic template unrolling for small vectors
19 * generic template unrolling for small vectors 19 */
20 */ 20
21 21/**
22 template<typename It1, typename It2, int N> struct eq_n_t { 22 * C++ does not allow function template partial specialization so eq_n<> delegates to work to a eq_n_t<> struct
23 bool operator()(It1 i1, It2 i2) const { 23 * which implements the function in operator().
24 return (*i1 == *i2) && eq_n_t<It1, It2, N-1>()(++i1, ++i2) ; 24 *
25 } 25 * @param i1 : iterator to the beginning of the first sequence
26 }; 26 * @param i2 : iterator to the beginning of the second sequence
27 template<typename It1, typename It2> struct eq_n_t<It1, It2, 0> { 27 * @return true iff *i1 == *i2 &&...&& *(i1+N-1) == *(i2+N-1)
28 bool operator()(It1 i1, It2 i2) const { 28 */
29 return true ; 29 template<typename It1, typename It2, int N> struct eq_n_t
30 } 30 {
31 }; 31 bool operator()(It1 i1, It2 i2) const /* generic recursive implementation */
32 template<int N, typename It1, typename It2> bool eq_n(It1 i1, It2 i2) { 32 {
33 return eq_n_t<It1, It2, N>()(i1, i2); 33 return (*i1 == *i2) && eq_n_t<It1, It2, N-1>()(++i1, ++i2) ;
34 } 34 }
35 35 };
36 template<typename It1, typename It2, int N> struct less_n_t { 36 template<typename It1, typename It2> struct eq_n_t<It1, It2, 0> {
37 bool operator()(It1 i1, It2 i2) const { 37 bool operator()(It1 i1, It2 i2) const /* partial specialization for N=0 */
38 return (*i1<*i2) ? true : ( (*i1>*i2) ? false : less_n_t<It1, It2, N-1>()(++i1, ++i2)); 38 {
39 } 39 return true ;
40 }; 40 }
41 template<typename It1, typename It2> struct less_n_t<It1, It2, 0> { 41 };
42 bool operator()(It1 i1, It2 i2) const { 42/**
43 return false ; 43 * Compares two sequences for equality when the size in know at compile time.
44 } 44 * Uses template metaprogramming to ensure loop unrolling.
45 }; 45 *
46 46 * @param i1 : iterator to the beginning of the first sequence
47 template<int N, typename It1, typename It2> bool less_n(It1 i1, It2 i2) { 47 * @param i2 : iterator to the beginning of the second sequence
48 return less_n_t<It1, It2, N>()(i1, i2); 48 * @return true iff *i1 == *i2 &&...&& *(i1+N-1) == *(i2+N-1)
49 } 49 */
50 50 template<int N, typename It1, typename It2> bool eq_n(It1 i1, It2 i2)
51 template<typename In, typename Out, int N> struct copy_n_t { 51 {
52 Out operator()(In in, Out out) const { 52 return eq_n_t<It1, It2, N>()(i1, i2);
53 *out= *in; 53 }
54 return copy_n_t<In, Out, N-1>()(++in, ++out); 54
55 } 55/**
56 }; 56 * ensure most efficient inlining irrespectively of optimization compiler options for ids of nsiz=6 ints
57 template<typename In, typename Out> struct copy_n_t<In, Out, 0> { 57 *
58 Out operator()(In, Out out) const { 58 * we make all the (4) combinations of (const or not) arguments.
59 return out; 59 *
60 } 60 * @param i1 : int* beginning of the first int[6]
61 }; 61 * @param i2 : int* beginning of the second int[6]
62 template<int N, typename In, typename Out> Out copy_n(In in, Out out) { 62 * @return true iff *i1 == *i2 &&...&& *(i1+5) == *(i2+5)
63 return copy_n_t<In, Out, N>()(in, out); 63 */
64 } 64 template<> bool eq_n<6,int const*, int const*>(int const* id1, int const* id2)
65 65 {
66 } 66 return (id1[0]==id2[0]) && (id1[1]==id2[1]) && (id1[2]==id2[2]) && (id1[3]==id2[3]) && (id1[4]==id2[4]) && (id1[5]==id2[5]);
67 }
68
69/**
70 * See above.
71 */
72 template<> bool eq_n<6,int const*, int*>(int const* id1, int* id2)
73 {
74 return (id1[0]==id2[0]) && (id1[1]==id2[1]) && (id1[2]==id2[2]) && (id1[3]==id2[3]) && (id1[4]==id2[4]) && (id1[5]==id2[5]);
75 }
76
77/**
78 * See above.
79 */
80 template<> bool eq_n<6,int*, int const*>(int* id1, int const* id2)
81 {
82 return (id1[0]==id2[0]) && (id1[1]==id2[1]) && (id1[2]==id2[2]) && (id1[3]==id2[3]) && (id1[4]==id2[4]) && (id1[5]==id2[5]);
83 }
84
85
86/**
87 * See above.
88 */
89 template<> bool eq_n<6,int*, int*>(int* id1, int* id2)
90 {
91 return (id1[0]==id2[0]) && (id1[1]==id2[1]) && (id1[2]==id2[2]) && (id1[3]==id2[3]) && (id1[4]==id2[4]) && (id1[5]==id2[5]);
92 }
93
94/**
95 * C++ does not allow function template partial specialization so less_n<> delegates to work to a less_n_t<> struct
96 * which implements the function in operator().
97 *
98 * @param i1 : iterator to the beginning of the first sequence
99 * @param i2 : iterator to the beginning of the second sequence
100 * @return true iff [i1...i1+N[ < [i2...i2+N[ in lexicographical order
101 */
102
103 template<typename It1, typename It2, int N> struct less_n_t
104 {
105 bool operator()(It1 i1, It2 i2) const /*/ generic recursive case */
106 {
107 return (*i1<*i2) ? true : ( (*i1>*i2) ? false : less_n_t<It1, It2, N-1>()(++i1, ++i2));
108 }
109 };
110
111 template<typename It1, typename It2> struct less_n_t<It1, It2, 0>
112 {
113 bool operator()(It1 i1, It2 i2) const /* special case for empty sequences */
114 {
115 return false ;
116 }
117 };
118
119/**
120 * Compares two sequences for lexicographical order when the size in know at compile time.
121 * Uses template metaprogramming to ensure loop unrolling.
122 *
123 * @param i1 : iterator to the beginning of the first sequence
124 * @param i2 : iterator to the beginning of the second sequence
125 * @return true iff [i1...i1+N[ < [i2...i2+N[ in lexicographical order
126 */
127 template<int N, typename It1, typename It2> bool less_n(It1 i1, It2 i2)
128 {
129 return less_n_t<It1, It2, N>()(i1, i2);
130 }
131
132/**
133 * C++ does not allow function template partial specialization so copy_n<> delegates the work to a copy_n_t<> struct
134 * which implements the function in operator().
135 *
136 * @param i1 : iterator to the beginning of the first sequence
137 * @param i2 : iterator to the beginning of the second sequence
138 * @return i1+N
139 */
140
141 template<typename In, typename Out, int N> struct copy_n_t
142 {
143 Out operator()(In in, Out out) const /* generic case for N>0 */
144 {
145 *out= *in;
146 return copy_n_t<In, Out, N-1>()(++in, ++out);
147 }
148 };
149
150 template<typename In, typename Out> struct copy_n_t<In, Out, 0>
151 {
152 Out operator()(In, Out out) const /* special case for empty sequences */
153 {
154 return out;
155 }
156 };
157
158/**
159 * Copy one sequence to another when the size in know at compile time.
160 * Uses template metaprogramming to ensure loop unrolling.
161 *
162 * @param i1 : iterator to the beginning of the input sequence
163 * @param i2 : iterator to the beginning of the output sequence
164 * @return in+N
165 */
166 template<int N, typename In, typename Out> Out copy_n(In in, Out out)
167 {
168 return copy_n_t<In, Out, N>()(in, out);
169 }
170
67} 171}
68#endif 172#endif
69/*-----------------------------------------------------------------------------------*/ 173/*-----------------------------------------------------------------------------------*/
diff --git a/scilab/modules/core/src/fortran/funs.f b/scilab/modules/core/src/fortran/funs.f
index 137d960..e979568 100644
--- a/scilab/modules/core/src/fortran/funs.f
+++ b/scilab/modules/core/src/fortran/funs.f
@@ -1,10 +1,10 @@
1c Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 1c Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
2c Copyright (C) INRIA 2c Copyright (C) INRIA
3c 3c
4c This file must be used under the terms of the CeCILL. 4c This file must be used under the terms of the CeCILL.
5c This source file is licensed as described in the file COPYING, which 5c This source file is licensed as described in the file COPYING, which
6c you should have received as part of this distribution. The terms 6c you should have received as part of this distribution. The terms
7c are also available at 7c are also available at
8c http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt 8c http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
9 9
10 subroutine funs(id) 10 subroutine funs(id)
@@ -15,18 +15,19 @@ c ====================================================================
15 parameter (nz1=nsiz-1,nz2=nsiz-2) 15 parameter (nz1=nsiz-1,nz2=nsiz-2)
16 integer id(nsiz),istr(nlgh) 16 integer id(nsiz),istr(nlgh)
17c 17c
18 logical eqid,cresmat 18 logical cresmat
19 integer srhs,percen,fptr,slhs,r 19 integer srhs,percen,fptr,slhs,r
20 integer iadr 20 integer iadr
21 logical toreturn
21 data nclas/29/,percen/56/ 22 data nclas/29/,percen/56/
22c 23c
23 iadr(l)=l+l-1 24 iadr(l)=l+l-1
24c 25c
25c look only in scilab code function libraries 26c look only in scilab code function libraries
26 if(fin.eq.-3) goto 35 27 if(fin.eq.-3) goto 35
27 if(fin.eq.-4) goto 30 28 if(fin.eq.-4) goto 30
28c 29c
29c 30c
30 if (comp(1).ne.0) then 31 if (comp(1).ne.0) then
31c if compilation mode skip primitive functions 32c if compilation mode skip primitive functions
32 fin=0 33 fin=0
@@ -45,66 +46,24 @@ c look for name in primitive functions
45 fin = mod(fptr,1000) 46 fin = mod(fptr,1000)
46 endif 47 endif
47 return 48 return
48c 49c
49c is a scilab code function already loaded in the variables stack 50c is a scilab code function already loaded in the variables stack
50 30 k=bot-1 51 30 call sivars(id, toreturn)
51 31 k=k+1 52 if(toreturn) then
52 if(k.gt.isiz) goto 35
53 if(.not.eqid(idstk(1,k),id)) goto 31
54 il=iadr(lstk(k))
55c modif 1.3 SS
56 if(istk(il).ne.11.and.istk(il).ne.13) then
57 fin=0
58 fun=0
59 return 53 return
60 endif 54 endif
61 fin=k 55c
62 fun=-1
63 return
64c
65c look in scilab code function libraries 56c look in scilab code function libraries
66 35 k=bot-1 57 35 call siflibs(id, k, istr, lbibn, nbibn, ilp, nn, toreturn)
67 36 k=k+1 58 if(toreturn) then
68 if(k.ge.isiz) then
69 fin=0
70 fun=0
71 return 59 return
72 endif 60 endif
73 il=iadr(lstk(k)) 61c
74 if(istk(il).ne.14) goto 36 62c
75 nbibn=istk(il+1) 63
76 lbibn=il+2 64c
77 il=lbibn+nbibn
78 ilp=il+1
79 call namstr(id,istr,nn,1)
80 ip=abs(istr(1))
81 if(ip.eq.percen) ip=abs(istr(2))
82 ip=max(1,ip-9)
83 if(ip.gt.nclas) goto 36
84 n=istk(ilp+ip)-istk(ilp+ip-1)
85 if(n.eq.0) goto 36
86 iln=ilp+nclas+1+(istk(ilp+ip-1)-1)*nsiz
87 do 37 l=1,n
88 if(eqid(id,istk(iln))) goto 39
89 iln=iln+nsiz
90 37 continue
91 goto 36
92c
93c
94 39 if(fin.ne.-1.and.fin.ne.-3) goto 40
95 fun=k
96 fin=l
97 return
98c
99 40 fin=l
100 if(err1.ne.0) then
101 fun=0
102 fin=0
103 return
104 endif
105c
106c load it in the variables stack 65c load it in the variables stack
107 66
108c create a variable with the bin file path 67c create a variable with the bin file path
109 n=nbibn 68 n=nbibn
110c get name and its length 69c get name and its length
@@ -115,7 +74,7 @@ c get name and its length
115c path 74c path
116 call icopy(nbibn,istk(lbibn),1,istk(ilp),1) 75 call icopy(nbibn,istk(lbibn),1,istk(ilp),1)
117c name 76c name
118 call icopy(nn,istr,1,istk(ilp+nbibn),1) 77 call icopy(nn,istr,1,istk(ilp+nbibn),1)
119c extension 78c extension
120 call cvstr(4,istk(ilp+nbibn+nn),'.bin',0) 79 call cvstr(4,istk(ilp+nbibn+nn),'.bin',0)
121c load variables stored in the given file 80c load variables stored in the given file
@@ -157,7 +116,3 @@ c . requested varible not loaded
157 return 116 return
158c 117c
159 end 118 end
160
161
162
163