diff options
author | Shashank | 2017-05-29 12:40:26 +0530 |
---|---|---|
committer | Shashank | 2017-05-29 12:40:26 +0530 |
commit | 0345245e860375a32c9a437c4a9d9cae807134e9 (patch) | |
tree | ad51ecbfa7bcd3cc5f09834f1bb8c08feaa526a4 /modules/intersci/examples | |
download | scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.gz scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.tar.bz2 scilab_for_xcos_on_cloud-0345245e860375a32c9a437c4a9d9cae807134e9.zip |
CMSCOPE changed
Diffstat (limited to 'modules/intersci/examples')
60 files changed, 3289 insertions, 0 deletions
diff --git a/modules/intersci/examples/Makefile b/modules/intersci/examples/Makefile new file mode 100755 index 000000000..e696f81ff --- /dev/null +++ b/modules/intersci/examples/Makefile @@ -0,0 +1,149 @@ +SHELL = /bin/sh + +SCIDIR=../.. +INTERSCI = $(SCIDIR)/bin/intersci + +include ../../Makefile.incl + +all:: info + +info: + @echo "Type \"make /tmp/pgm.o\" to compile pgm program" + @echo "Type \"make objs\" to compile all test programs" + +OBJS= /tmp/ex1c.o /tmp/ex2f.o /tmp/ex4f.o /tmp/ex5f.o /tmp/ex6c.o \ + /tmp/ex7f.o /tmp/ex8c.o /tmp/ex9f.o /tmp/ex10f.o /tmp/ex11c.o \ + /tmp/ex12c.o /tmp/ex13c.o /tmp/ex14c.o /tmp/ex15c.o /tmp/ex16c.o + +IOBJS= /tmp/ex1fi.o /tmp/ex2fi.o /tmp/ex3fi.o /tmp/ex4fi.o /tmp/ex5fi.o \ + /tmp/ex6fi.o /tmp/ex7fi.o /tmp/ex8fi.o /tmp/ex9fi.o \ + /tmp/ex10fi.o /tmp/ex11fi.o /tmp/ex12fi.o /tmp/ex13fi.o \ + /tmp/ex14fi.o /tmp/ex15fi.o /tmp/ex16fi.o + +objs : $(OBJS) $(IOBJS) + +CFLAGS = $(CC_OPTIONS) $(CC_PICFLAGS) -I$(SCIDIR)/routines +FFLAGS = $(FC_OPTIONS) $(FC_PICFLAGS) -I$(SCIDIR)/routines + +/tmp/ex1fi.o: ex1fi.desc + $(INTERSCI) ex1fi ; ./sedprov ex1fi + $(FC) $(FFLAGS) -c ex1fi.f -o /tmp/ex1fi.o + +/tmp/ex1c.o: ex1c.c + $(CC) $(CFLAGS) -c ex1c.c -o /tmp/ex1c.o + +/tmp/ex2fi.o: ex2fi.desc + $(INTERSCI) ex2fi ; ./sedprov ex2fi + $(FC) $(FFLAGS) -c ex2fi.f -o /tmp/ex2fi.o + +/tmp/ex2f.o: ex2f.f + $(FC) $(FFLAGS) -c ex2f.f -o /tmp/ex2f.o + +/tmp/ex3fi.o: ex3fi.desc + $(INTERSCI) ex3fi ; ./sedprov ex3fi + $(FC) $(FFLAGS) -c ex3fi.f -o /tmp/ex3fi.o + +/tmp/ex4fi.o: ex4fi.desc + $(INTERSCI) ex4fi ; ./sedprov ex4fi + $(FC) $(FFLAGS) -c ex4fi.f -o /tmp/ex4fi.o + +/tmp/ex4f.o: ex4f.f + $(FC) $(FFLAGS) -c ex4f.f -o /tmp/ex4f.o + +/tmp/ex5fi.o: ex5fi.desc + $(INTERSCI) ex5fi ; ./sedprov ex5fi + $(FC) $(FFLAGS) -c ex5fi.f -o /tmp/ex5fi.o + +/tmp/ex5f.o: ex5f.f + $(FC) $(FFLAGS) -c ex5f.f -o /tmp/ex5f.o + +/tmp/ex6fi.o: ex6fi.desc + $(INTERSCI) ex6fi ; ./sedprov ex6fi + $(FC) $(FFLAGS) -c ex6fi.f -o /tmp/ex6fi.o + +/tmp/ex6c.o: ex6c.c + $(CC) $(CFLAGS) -c ex6c.c -o /tmp/ex6c.o + +/tmp/ex7fi.o: ex7fi.desc + $(INTERSCI) ex7fi ; ./sedprov ex7fi + $(FC) $(FFLAGS) -c ex7fi.f -o /tmp/ex7fi.o + +/tmp/ex7f.o: ex7f.f + $(FC) $(FFLAGS) -c ex7f.f -o /tmp/ex7f.o + +/tmp/ex8fi.o: ex8fi.desc + $(INTERSCI) ex8fi ; ./sedprov ex8fi + $(FC) $(FFLAGS) -c ex8fi.f -o /tmp/ex8fi.o + +/tmp/ex8c.o: ex8c.c + $(CC) $(CFLAGS) -c ex8c.c -o /tmp/ex8c.o + +/tmp/ex9fi.o: ex9fi.desc + $(INTERSCI) ex9fi ; ./sedprov ex9fi + $(FC) $(FFLAGS) -c ex9fi.f -o /tmp/ex9fi.o + +/tmp/ex9f.o: ex9f.f + $(FC) $(FFLAGS) -c ex9f.f -o /tmp/ex9f.o + +/tmp/ex10fi.o: ex10fi.desc + $(INTERSCI) ex10fi ; ./sedprov ex10fi + $(FC) $(FFLAGS) -c ex10fi.f -o /tmp/ex10fi.o + +/tmp/ex10f.o: ex10f.f + $(FC) $(FFLAGS) -c ex10f.f -o /tmp/ex10f.o + +/tmp/ex11fi.o: ex11fi.desc + $(INTERSCI) ex11fi ; ./sedprov ex11fi + $(FC) $(FFLAGS) -c ex11fi.f -o /tmp/ex11fi.o + +/tmp/ex11c.o: ex11c.c + $(CC) $(CFLAGS) -c ex11c.c -o /tmp/ex11c.o + +/tmp/ex12fi.o: ex12fi.desc + $(INTERSCI) ex12fi ; ./sedprov ex12fi + $(FC) $(FFLAGS) -c ex12fi.f -o /tmp/ex12fi.o + +/tmp/ex12c.o: ex12c.c + $(CC) $(CFLAGS) -c ex12c.c -o /tmp/ex12c.o + +/tmp/ex13fi.o: ex13fi.desc + $(INTERSCI) ex13fi ; ./sedprov ex13fi + $(FC) $(FFLAGS) -c ex13fi.f -o /tmp/ex13fi.o + +/tmp/ex13c.o: ex13c.c + $(CC) $(CFLAGS) -c ex13c.c -o /tmp/ex13c.o + +/tmp/ex14fi.o: ex14fi.desc + $(INTERSCI) ex14fi ; ./sedprov ex14fi + $(FC) $(FFLAGS) -c ex14fi.f -o /tmp/ex14fi.o + +/tmp/ex14c.o: ex14c.c + $(CC) $(CFLAGS) -c ex14c.c -o /tmp/ex14c.o + + +/tmp/ex15fi.o: ex15fi.desc + $(INTERSCI) ex15fi ; ./sedprov ex15fi + $(FC) $(FFLAGS) -c ex15fi.f -o /tmp/ex15fi.o + +/tmp/ex15c.o: ex15c.c + $(CC) $(CFLAGS) -c ex15c.c -o /tmp/ex15c.o + +/tmp/ex16fi.o: ex16fi.desc + $(INTERSCI) ex16fi ; ./sedprov ex16fi + $(FC) $(FFLAGS) -c ex16fi.f -o /tmp/ex16fi.o + +/tmp/ex16c.o: ex16c.c + $(CC) $(CFLAGS) -c ex16c.c -o /tmp/ex16c.o + +tests : Makefile + @$(RM) zallfi.desc + @cat *.desc > zallfi + @mv zallfi zallfi.desc + @$(INTERSCI) zallfi > /dev/null ; ./sedprov zallfi + @$(SCIDIR)/util/scidem $(SCIDIR) zall.sce zallfi.dia + +distclean:: clean + +clean :: + @$(RM) ex*fi.f ex*fi.sce ex*fi.tmp zallfi zallfi.desc zallfi.sce zallfi.f zallfi.o zallfi.dia + @$(RM) $(OBJS) $(IOBJS) diff --git a/modules/intersci/examples/Makefile.mak b/modules/intersci/examples/Makefile.mak new file mode 100755 index 000000000..b26165e79 --- /dev/null +++ b/modules/intersci/examples/Makefile.mak @@ -0,0 +1,253 @@ +SHELL = /bin/sh + +SCIDIR=../../.. +SCIDIR1=..\..\.. + +DUMPEXTS="$(SCIDIR1)\bin\dumpexts" +SCIIMPLIB=$(SCIDIR)/bin/LibScilab.lib +INTERSCI="$(SCIDIR1)\modules\intersci\bin\intersci" +F2C="$(SCIDIR1)\bin\f2c.exe" + +include ../../dynamic_link/src/scripts/Makefile.incl.mak + +FFLAGS = $(FC_OPTIONS) -DFORDLL INCLUDES=-I"$(SCIDIR)\libs\MALLOC\includes" -I"$(SCIDIR)\modules\core\includes" -I"$(SCIDIR)/libs/f2c" -I"$(SCIDIR)/modules/mexlib/includes" +CFLAGS = $(CC_OPTIONS) -DFORDLL INCLUDES=-I"$(SCIDIR)\libs\MALLOC\includes" -I"$(SCIDIR)\modules\core\includes" -I"$(SCIDIR)/libs/f2c" -I"$(SCIDIR)/modules/mexlib/includes" + +all:: info + +info: + @echo Type "nmake /f Makefile.mak dlls" to compile all programs + @echo Type "nmake /f Makefile.mak pgm.dll" to compile pgm program + +DLLS= ex1.dll ex2.dll ex3.dll ex4.dll ex5.dll ex6.dll \ + ex7.dll ex8.dll ex9.dll ex10.dll ex11.dll ex12.dll \ + ex13.dll ex14.dll ex15.dll ex16.dll + +dlls : $(DLLS) + +ex1.dll : ex1fi.obj ex1c.obj + @echo Creation of dll $(DLL) and import lib + @$(DUMPEXTS) -o "$*.def" "$*.dll" $** + @$(LINKER) $(LINKER_FLAGS) $** $(SCIIMPLIB) $(SCILAB_LIBS) /nologo /dll /out:"$*.dll" /implib:"$*.lib" /def:"$*.def" + +ex1fi.obj : ex1fi.desc + @$(INTERSCI) $* + @$(F2C) $*.f + @$(CC) $(CFLAGS) $*.c + @del $*.c + +ex2.dll : ex2fi.obj ex2f.obj + @echo Creation of dll $(DLL) and import lib + @$(DUMPEXTS) -o "$*.def" "$*.dll" $** + @$(LINKER) $(LINKER_FLAGS) $** $(SCIIMPLIB) $(SCILAB_LIBS) /nologo /dll /out:"$*.dll" /implib:"$*.lib" /def:"$*.def" + +ex2fi.obj : ex2fi.desc + @$(INTERSCI) $* + @$(F2C) $*.f + @$(CC) $(CFLAGS) $*.c + @del $*.c + +ex3.dll : ex3fi.obj + @echo Creation of dll $(DLL) and import lib + @$(DUMPEXTS) -o "$*.def" "$*.dll" $** + @$(LINKER) $(LINKER_FLAGS) $** $(SCIIMPLIB) $(SCILAB_LIBS) /nologo /dll /out:"$*.dll" /implib:"$*.lib" /def:"$*.def" + +ex3fi.obj : ex3fi.desc + @$(INTERSCI) $* + @$(F2C) $*.f + @$(CC) $(CFLAGS) $*.c + @del $*.c + +ex4.dll : ex4fi.obj ex4f.obj + @echo Creation of dll $(DLL) and import lib + @$(DUMPEXTS) -o "$*.def" "$*.dll" $** + @$(LINKER) $(LINKER_FLAGS) $** $(SCIIMPLIB) $(SCILAB_LIBS) /nologo /dll /out:"$*.dll" /implib:"$*.lib" /def:"$*.def" + +ex4fi.obj : ex4fi.desc + @$(INTERSCI) $* + @$(F2C) $*.f + @$(CC) $(CFLAGS) $*.c + @del $*.c + +ex5.dll : ex5fi.obj ex5f.obj + @echo Creation of dll $(DLL) and import lib + @$(DUMPEXTS) -o "$*.def" "$*.dll" $** + @$(LINKER) $(LINKER_FLAGS) $** $(SCIIMPLIB) $(SCILAB_LIBS) /nologo /dll /out:"$*.dll" /implib:"$*.lib" /def:"$*.def" + +ex5fi.obj : ex5fi.desc + @$(INTERSCI) $* + @$(F2C) $*.f + @$(CC) $(CFLAGS) $*.c + @del $*.c + + +ex6.dll : ex6fi.obj ex6c.obj + @echo Creation of dll $(DLL) and import lib + @$(DUMPEXTS) -o "$*.def" "$*.dll" $** + @$(LINKER) $(LINKER_FLAGS) $** $(SCIIMPLIB) $(SCILAB_LIBS) /nologo /dll /out:"$*.dll" /implib:"$*.lib" /def:"$*.def" + +ex6fi.obj : ex6fi.desc + @$(INTERSCI) $* + @$(F2C) $*.f + @$(CC) $(CFLAGS) $*.c + @del $*.c + +ex7.dll : ex7fi.obj ex7f.obj + @echo Creation of dll $(DLL) and import lib + @$(DUMPEXTS) -o "$*.def" "$*.dll" $** + @$(LINKER) $(LINKER_FLAGS) $** $(SCIIMPLIB) $(SCILAB_LIBS) /nologo /dll /out:"$*.dll" /implib:"$*.lib" /def:"$*.def" + +ex7fi.obj : ex7fi.desc + @$(INTERSCI) $* + @$(F2C) $*.f + @$(CC) $(CFLAGS) $*.c + @del $*.c + +ex8.dll : ex8fi.obj ex8c.obj + @echo Creation of dll $(DLL) and import lib + @$(DUMPEXTS) -o "$*.def" "$*.dll" $** + @$(LINKER) $(LINKER_FLAGS) $** $(SCIIMPLIB) $(SCILAB_LIBS) /nologo /dll /out:"$*.dll" /implib:"$*.lib" /def:"$*.def" + +ex8fi.obj : ex8fi.desc + @$(INTERSCI) $* + @$(F2C) $*.f + @$(CC) $(CFLAGS) $*.c + @del $*.c + +ex9.dll : ex9fi.obj ex9f.obj + @echo Creation of dll $(DLL) and import lib + @$(DUMPEXTS) -o "$*.def" "$*.dll" $** + @$(LINKER) $(LINKER_FLAGS) $** $(SCIIMPLIB) $(SCILAB_LIBS) /nologo /dll /out:"$*.dll" /implib:"$*.lib" /def:"$*.def" + +ex9fi.obj : ex9fi.desc + @$(INTERSCI) $* + @$(F2C) $*.f + @$(CC) $(CFLAGS) $*.c + @del $*.c + + +ex10.dll : ex10fi.obj ex10f.obj + @echo Creation of dll $(DLL) and import lib + @$(DUMPEXTS) -o "$*.def" "$*.dll" $** + @$(LINKER) $(LINKER_FLAGS) $** $(SCIIMPLIB) $(SCILAB_LIBS) /nologo /dll /out:"$*.dll" /implib:"$*.lib" /def:"$*.def" + +ex10fi.obj : ex10fi.desc + @$(INTERSCI) $* + @$(F2C) $*.f + @$(CC) $(CFLAGS) $*.c + @del $*.c + + +ex11.dll : ex11fi.obj ex11c.obj + @echo Creation of dll $(DLL) and import lib + @$(DUMPEXTS) -o "$*.def" "$*.dll" $** + @$(LINKER) $(LINKER_FLAGS) $** $(SCIIMPLIB) $(SCILAB_LIBS) /nologo /dll /out:"$*.dll" /implib:"$*.lib" /def:"$*.def" + +ex11fi.obj : ex11fi.desc + @$(INTERSCI) $* + @$(F2C) $*.f + @$(CC) $(CFLAGS) $*.c + @del $*.c + +ex12.dll : ex12fi.obj ex12c.obj + @echo Creation of dll $(DLL) and import lib + @$(DUMPEXTS) -o "$*.def" "$*.dll" $** + @$(LINKER) $(LINKER_FLAGS) $** $(SCIIMPLIB) $(SCILAB_LIBS) /nologo /dll /out:"$*.dll" /implib:"$*.lib" /def:"$*.def" + +ex12fi.obj : ex12fi.desc + @$(INTERSCI) $* + @$(F2C) $*.f + @$(CC) $(CFLAGS) $*.c + @del $*.c + +ex13.dll : ex13fi.obj ex13c.obj + @echo Creation of dll $(DLL) and import lib + @$(DUMPEXTS) -o "$*.def" "$*.dll" $** + @$(LINKER) $(LINKER_FLAGS) $** $(SCIIMPLIB) $(SCILAB_LIBS) /nologo /dll /out:"$*.dll" /implib:"$*.lib" /def:"$*.def" + +ex13fi.obj : ex13fi.desc + @$(INTERSCI) $* + @$(F2C) $*.f + @$(CC) $(CFLAGS) $*.c + @del $*.c + +ex14.dll : ex14fi.obj ex14c.obj + @echo Creation of dll $(DLL) and import lib + @$(DUMPEXTS) -o "$*.def" "$*.dll" $** + @$(LINKER) $(LINKER_FLAGS) $** $(SCIIMPLIB) $(SCILAB_LIBS) /nologo /dll /out:"$*.dll" /implib:"$*.lib" /def:"$*.def" + +ex14fi.obj : ex14fi.desc + @$(INTERSCI) $* + @$(F2C) $*.f + @$(CC) $(CFLAGS) $*.c + @del $*.c + +ex15.dll : ex15fi.obj ex15c.obj + @echo Creation of dll $(DLL) and import lib + @$(DUMPEXTS) -o "$*.def" "$*.dll" $** + @$(LINKER) $(LINKER_FLAGS) $** $(SCIIMPLIB) $(SCILAB_LIBS) /nologo /dll /out:"$*.dll" /implib:"$*.lib" /def:"$*.def" + +ex15fi.obj : ex15fi.desc + @$(INTERSCI) $* + @$(F2C) $*.f + @$(CC) $(CFLAGS) $*.c + @del $*.c + + +ex16.dll : ex16fi.obj ex16c.obj + @echo Creation of dll $(DLL) and import lib + @$(DUMPEXTS) -o "$*.def" "$*.dll" $** + @$(LINKER) $(LINKER_FLAGS) $** $(SCIIMPLIB) $(SCILAB_LIBS) /nologo /dll /out:"$*.dll" /implib:"$*.lib" /def:"$*.def" + +ex16fi.obj : ex16fi.desc + @$(INTERSCI) $* + @$(F2C) $*.f + @$(CC) $(CFLAGS) $*.c + @del $*.c + +clean:: + + +distclean :: + @del *.obj + @del *.dll + @del *.lib + @del *.pdk + @del *.pdb + @del *.ilk + @del *.def + @del *.exp + +#------------------------------------------------------------ + +OBJS=ex1c.obj ex2f.obj ex4f.obj ex5f.obj ex6c.obj ex7f.obj ex8c.obj \ + ex9f.obj ex10f.obj ex11c.obj ex12c.obj ex13c.obj ex14c.obj \ + ex15c.obj ex16c.obj + +zallfi.dll : zallfi.obj $(OBJS) + @echo Creation of dll $(DLL) and import lib + @$(DUMPEXTS) -o "$*.def" "$*.dll" $** + @$(LINKER) $(LINKER_FLAGS) $** $(SCIIMPLIB) $(SCILAB_LIBS) /nologo /dll /out:"$*.dll" /implib:"$*.lib" /def:"$*.def" + +zallfi.obj : zallfi.desc + @$(INTERSCI) $* + @$(F2C) $*.f + @$(CC) $(CFLAGS) $*.c + @del $*.c + +zallfi.desc : + @del zallfi.desc + copy *.desc zallfi.desc + +tests : zallfi.desc zallfi.obj + "$(SCIDIR1)\bin\scilex.exe" -f zall.sce + +distclean:: clean + +clean :: + @del zallfi + @del zallfi.sce + @del zallfi.f + @del zallfi.obj + @del zallfi.dia + diff --git a/modules/intersci/examples/README.txt b/modules/intersci/examples/README.txt new file mode 100755 index 000000000..7d93e6648 --- /dev/null +++ b/modules/intersci/examples/README.txt @@ -0,0 +1,29 @@ +Example of use of intersci. +Interfacing C and Fortran programs with Scilab. + +ex*.sce : Scilab script to execute the corresponding demo +ex*fi.desc : intersci descriptor file +ex*fi-l.list : intersci descriptor for list arguments +ex*c.c : C function to be interfaced +ex*f.f : Fortran function to be interfaced + +ex1* : simple example with vectors +ex2* : example with scilab vectors and type conversion to real +ex3* : example with vectors and a Scilab internal function +ex4* : example with a list +ex5* : example with Scilab string and matrices +ex6* : two examples with scilab matrices of string +ex7* : a simple example with Scilab string +ex8* : an example with a C dynamically allocated array of int +ex9* : an example with optional arguments +ex10*: a simple example with lists +ex11*: an example with complex matrices +ex12*: an example with a user external type +ex13*: an example with size conversion on output +ex14*: a set of examples with sparse matrices. testing all possible + cases. +ex15*: a set of examples with standard matrices. testing all possible + cases. +ex16*: a set of examples with boolean matrices. testing all possible + cases. + diff --git a/modules/intersci/examples/ex1.sce b/modules/intersci/examples/ex1.sce new file mode 100755 index 000000000..d72dd2b27 --- /dev/null +++ b/modules/intersci/examples/ex1.sce @@ -0,0 +1,24 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +//ex1 example +//1-Creating interface source file +// from ex1fi.desc file by call to intersci (see Makefile) +// Making object files +files=G_make(["/tmp/ex1fi.o","/tmp/ex1c.o"],"ex1.dll"); +//2-Link object files .o with addinter +//addinter(files,'intex1',intex1_funs); +exec("ex1fi.sce"); +//Run Scilab functions: +a=[1,2,3];b=[4,5,6]; +c=ext1c(a,b); +if norm(c-(a+b)) > %eps then pause,end + + diff --git a/modules/intersci/examples/ex10.sce b/modules/intersci/examples/ex10.sce new file mode 100755 index 000000000..6e0f4afc5 --- /dev/null +++ b/modules/intersci/examples/ex10.sce @@ -0,0 +1,32 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +//1-Creating interface source file (matusr.f) +// from ex10fi.desc file by call to intersci +// Making object files +// Interface file '/tmp/ex10fi.o' +// User's files '/tmp/ex10f.o'; +// +files=G_make(["/tmp/ex10fi.o","/tmp/ex10f.o"],"ex10.dll"); +//2-Link object files .o with addinter +//addinter(files,'ex10fi',matusr_funs); +exec("ex10fi.sce"); +//Test Scilab functions: +// calc1: 3 matrix input variables and at most 3 output variables of +// types double, real, int +l=calc10(list(1,[2,3],[1,2;3,4])); +if norm(l(1)-2) > %eps then pause,end +if norm(l(2)-([2,3]+[1,2])) > %eps then pause,end +if norm(l(3)-([1,2;3,4]+[1,3;2,4])) > %eps then pause,end + + + + + diff --git a/modules/intersci/examples/ex10f.f b/modules/intersci/examples/ex10f.f new file mode 100755 index 000000000..a01d8e528 --- /dev/null +++ b/modules/intersci/examples/ex10f.f @@ -0,0 +1,33 @@ +c Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +c Copyright (C) ????-2008 - INRIA +c +c This file must be used under the terms of the CeCILL. +c This source file is licensed as described in the file COPYING, which +c you should have received as part of this distribution. The terms +c are also available at +c http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + subroutine fcalc10(ii,m1,n1,db,m2,n2,rea,m3,n3) + integer ii(*) + double precision db(*) + real rea(*) + do 10 i=1,m1*n1 + ii(i) =i + ii(i) + 10 continue + do 20 i=1,m2*n2 + db(i) = dble(i) + db(i) + 20 continue + do 30 i=1,m3*n3 + rea(i) = real(i) + rea(i) + 30 continue + return + end + + + + + + + + + + diff --git a/modules/intersci/examples/ex10fi-l.list b/modules/intersci/examples/ex10fi-l.list new file mode 100755 index 000000000..dc2850322 --- /dev/null +++ b/modules/intersci/examples/ex10fi-l.list @@ -0,0 +1,10 @@ +1 a +a matrix ma na +****************************** +2 b +b matrix mb nb +****************************** +3 c +c matrix mc nc +****************************** + diff --git a/modules/intersci/examples/ex10fi.desc b/modules/intersci/examples/ex10fi.desc new file mode 100755 index 000000000..ee68aba02 --- /dev/null +++ b/modules/intersci/examples/ex10fi.desc @@ -0,0 +1,10 @@ +calc10 ll +ll list ex10fi-l + +fcalc10 a(ll) ma(ll) na(ll) b(ll) mb(ll) nb(ll) c(ll) mc(ll) nc(ll) +a(ll) integer +b(ll) double +c(ll) real + +out list a(ll) b(ll) c(ll) +****************************** diff --git a/modules/intersci/examples/ex11.sce b/modules/intersci/examples/ex11.sce new file mode 100755 index 000000000..1aa17190f --- /dev/null +++ b/modules/intersci/examples/ex11.sce @@ -0,0 +1,27 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +//ex11 example +//1-Creating interface source file +// from ex11fi.desc file by call to intersci +// Making object files +// Interface file '/tmp/ex11fi.o' +// User's files '/tmp/ex11c.o'; +files=G_make(["/tmp/ex11fi.o","/tmp/ex11c.o"],"ex11.dll"); +//2-Link object files .o with addinter +//addinter(files,'intex11',intex1_funs); +exec("ex11fi.sce"); +//Run Scilab functions: +a=[1,2,3]+%i*[4,5,6]; +b=ext11c(a); +if norm(b-([4,5,6]+%i*[1,2,3])) > %eps then pause,end + + + diff --git a/modules/intersci/examples/ex11c.c b/modules/intersci/examples/ex11c.c new file mode 100755 index 000000000..911f6491b --- /dev/null +++ b/modules/intersci/examples/ex11c.c @@ -0,0 +1,44 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) ????-2008 - INRIA + * Copyright (C) 2008-2008 - INRIA - Bruno JOFRET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + + +#include "../../routines/machine.h" + +/******************************************* + * complex matrices + * are transmited as ar,ai,itra + * real part, imaginary part and a descriptor flag + * the descriptor flag is 1 for a complex matrix 0 if the + * matrix is real valued + *******************************************/ + +int F2C(ext11c)(double *ar, double *ai, int *itra, + double *br, double *bi, int *itrb, int *m, int *n) +{ + int k; + for (k = 0; k < *n * (*m); ++k) + { + if ( *itra == 1) + { + br[k] = ai[k]; + } + else + { + br[k] = 0.0; + } + bi[k] = ar[k]; + } + *itrb = 1; + return(0); +} + diff --git a/modules/intersci/examples/ex11fi.desc b/modules/intersci/examples/ex11fi.desc new file mode 100755 index 000000000..45fbbd05f --- /dev/null +++ b/modules/intersci/examples/ex11fi.desc @@ -0,0 +1,12 @@ +ext11c a +a imatrix m n it +b imatrix m n it + +ext11c a b m n +m integer +n integer +a double +b double + +out sequence b +*********************** diff --git a/modules/intersci/examples/ex12.sce b/modules/intersci/examples/ex12.sce new file mode 100755 index 000000000..d67a50036 --- /dev/null +++ b/modules/intersci/examples/ex12.sce @@ -0,0 +1,27 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +//ex12 example +//1-Creating interface source file +// Making object files +// Interface file '/tmp/ex12fi.o' +// User's files '/tmp/ex12c.o'; +files=G_make(["/tmp/ex12fi.o","/tmp/ex12c.o"],"ex12.dll"); +//2-Link object files .o with addinter +//addinter(files,'intex12',intex1_funs); +exec("ex12fi.sce"); +//Run Scilab functions: +b=ccalc12(); + +if norm(b-(0:9)) > %eps then pause,end + + + + diff --git a/modules/intersci/examples/ex12c.c b/modules/intersci/examples/ex12c.c new file mode 100755 index 000000000..72b025213 --- /dev/null +++ b/modules/intersci/examples/ex12c.c @@ -0,0 +1,79 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) ????-2008 - INRIA + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + + +#include "../../routines/machine.h" + +/******************************************* + * External type for intersci + * creating a new external type + * ccalc12 : the wrapped function which returns a handler + * to a dynamically allocated object + * ccalc12f : function for the wrapper which <<converts>> + * Array to Scilab data + *******************************************/ + +typedef struct array +{ + int m, n; + double *val; +} Array ; + +C2F(ccalc12) ( a, m, n, err) +Array **a; +int *m, *n, *err ; +{ + int i; + *a = ( Array *) malloc( sizeof(Array)); + if ( *a == (Array *) 0) + { + *err = 1; + sciprint("No more space\n"); + } + *m = (*a)->m = 1; + *n = (*a)->n = 10; + (*a)->val = (double *) malloc( (unsigned) (*m) * (*n) * sizeof(double)); + if ( (*a)->val == (double *) 0 ) + { + *err = 1; + sciprint("No more space\n"); + } + *err = 0; + for ( i = 0 ; i < (*m) * (*n) ; i++) + { + (*a)->val[i] = i ; + } +} + + +C2F(ccalc12f)(n, ip, op) +int *n; +Array **ip; +double *op; +{ + int i; + if ( *n > 0 ) + { + for (i = 0; i < *n; i++) + { + op[i] = (*ip)->val[i]; + } + free((char *)(*ip)->val); + free((char *)(*ip)); + } +} + + + + + + diff --git a/modules/intersci/examples/ex12fi.desc b/modules/intersci/examples/ex12fi.desc new file mode 100755 index 000000000..96717f340 --- /dev/null +++ b/modules/intersci/examples/ex12fi.desc @@ -0,0 +1,10 @@ +ccalc12 +a matrix m n + +ccalc12 a m n err +a ccalc12f +m integer +n integer + +out sequence a +*********************** diff --git a/modules/intersci/examples/ex13.sce b/modules/intersci/examples/ex13.sce new file mode 100755 index 000000000..776e08536 --- /dev/null +++ b/modules/intersci/examples/ex13.sce @@ -0,0 +1,26 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +//ex13 example +//1-Creating interface source file +// Making object files +// Interface file '/tmp/ex13fi.o' +// User's files '/tmp/ex13c.o' +files=G_make(["/tmp/ex13fi.o","/tmp/ex13c.o"],"ex13.dll"); +//2-Link object files .o with addinter +//addinter(files,'intex13',intex1_funs); +exec("ex13fi.sce"); +//Run Scilab functions: +a=rand(2,3); +b=ext13c(a); +if norm(b- matrix(2*a,3,2)) > %eps then pause,end + + + diff --git a/modules/intersci/examples/ex13c.c b/modules/intersci/examples/ex13c.c new file mode 100755 index 000000000..5a94af608 --- /dev/null +++ b/modules/intersci/examples/ex13c.c @@ -0,0 +1,30 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) ????-2008 - INRIA + * Copyright (C) 2008-2008 - INRIA - Bruno JOFRET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + + +#include "../../routines/machine.h" + +/******************************************* + * simple example + *******************************************/ + +int F2C(ext13c)( double *ar, int *m, int *n) +{ + int k; + for (k = 0; k < *n * (*m); ++k) + { + ar[k] = 2 * ar[k]; + } + return(0); +} + diff --git a/modules/intersci/examples/ex13fi.desc b/modules/intersci/examples/ex13fi.desc new file mode 100755 index 000000000..7226c023d --- /dev/null +++ b/modules/intersci/examples/ex13fi.desc @@ -0,0 +1,12 @@ +ext13c a +a matrix m n +o matrix n m + +ext13c a m n +m integer +n integer +a double + +out sequence o +o a +*********************** diff --git a/modules/intersci/examples/ex14.sce b/modules/intersci/examples/ex14.sce new file mode 100755 index 000000000..f3a000ff8 --- /dev/null +++ b/modules/intersci/examples/ex14.sce @@ -0,0 +1,100 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +//ex14 example +//1-Creating interface source file +// from ex14fi.desc file by call to intersci +// Making object files +// Interface file '/tmp/ex14fi.o'; +// User's files '/tmp/ex14c.o' +files=G_make(["/tmp/ex14fi.o","/tmp/ex14c.o";],"ex14.dll"); +//2-Link object files .o with addinter +//addinter(files,'intex14',intex1_funs); +exec("ex14fi.sce"); +//Run Scilab functions: +a=[0,0,1.23;0,2.32,0;3.45,0,0]; +ai=[0,0,9;0,6,0;7,0,0]; +spa=sparse(a); +spai=sparse(a+%i*ai); +// simple sparse argument + +b=spt1(spa); +if norm(full(b- spa)) > %eps then pause,end + +b=spt1(spai); +if norm(full(b- spai)) > %eps then pause,end + +// sparse argument + conversion to int + +b=spt2(spa); +if norm(full(b- int(spa))) > %eps then pause,end + +b=spt2(spai); +if norm(full(b- int(spai))) > %eps then pause,end + +// sparse and return a sparse in a list + +b=spt3(spa); +if norm(full(b(1)- spa)) > %eps then pause,end + +b=spt3(spai); +if norm(full(b(1)- spai)) > %eps then pause,end + +// new sparse in intersci + +b=spt4(spa); +if norm(full(b- 2*spa)) > %eps then pause,end + +b=spt4(spai); +if norm(full(b- 2*spai)) > %eps then pause,end + +// new sparse + conversion to int + +b=spt5(spa); +if norm(full(b- int(2*spa))) > %eps then pause,end + +b=spt5(spai); +if norm(full(b- int(2*spai))) > %eps then pause,end + +// new sparse returned in a list + +b=spt6(spa); +if norm(full(b(1)- 2*spa)) > %eps then pause,end + +b=spt6(spai); +if norm(full(b(1)- 2*spai)) > %eps then pause,end + +// list argument with a sparse + +b=spt7(list(spa)); +if norm(full(b- spa)) > %eps then pause,end + +b=spt7(list(spai)); +if norm(full(b- spai)) > %eps then pause,end + +// list argument + conversion + +b=spt8(list(spa)); +if norm(full(b- int(spa))) > %eps then pause,end + +b=spt8(list(spai)); +if norm(full(b- int(spai))) > %eps then pause,end + +// list argument + list output + +b=spt9(list(spa)); +if norm(full(b(1)- spa)) > %eps then pause,end + +b=spt9(list(spai)); +if norm(full(b(1)- spai)) > %eps then pause,end + +b=spt10(spa); +if norm(full(b- 2*spa)) > %eps then pause,end + diff --git a/modules/intersci/examples/ex14c.c b/modules/intersci/examples/ex14c.c new file mode 100755 index 000000000..566640867 --- /dev/null +++ b/modules/intersci/examples/ex14c.c @@ -0,0 +1,225 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) ????-2008 - INRIA + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + + +#include "stack-c.h" + +/******************************************* + * simple example with sparse matrix + * Display of a + *******************************************/ + +int F2C(ext14ca)(it, m, n, nel, mnel, icol, ar, ai) +int *n, *m, *it, *nel, *mnel, *icol; +double *ar, *ai; +{ + int i, iof = 0, j; + for ( i = 0; i < *m ; i++) + { + sciprint("Row %d, %d non zero elements\n", i + 1, mnel[i]); + for ( j = 0; j < mnel[i]; j++) + { + if (*it == 1) + sciprint("(%d,%d) -> %f +i%f\n", i + 1, icol[iof + j], + ar[iof + j], ai[iof + j]); + else + sciprint("(%d,%d) -> %f\n", i + 1, icol[iof + j], + ar[iof + j]); + } + iof += mnel[i]; + } + return(0); +} + +/******************************************* + * simple example with sparse matrix + * 2*a copied into b + *******************************************/ + +int F2C(ext14cb)(it1, m1, n1, nel1, mnel1, icol1, ar1, ai1, + it2, m2, n2, nel2, mnel2, icol2, ar2, ai2) +int *n1, *m1, *it1, *nel1, *mnel1, *icol1; +double *ar1, *ai1; +int *it2, *m2, *n2, *nel2, *mnel2, *icol2; +double *ar2, *ai2; +{ + int i, iof = 0, j; + for ( i = 0; i < *m1 ; i++) + { + for ( j = 0; j < mnel1[i]; j++) + { + if (*it1 == 1) + { + ai2[iof + j] = 2 * ai1[iof + j]; + } + ar2[iof + j] = 2 * ar1[iof + j]; + } + iof += mnel1[i]; + } + for ( i = 0 ; i < *m1 ; i++ ) + { + mnel2[i] = mnel1[i]; + } + for ( i = 0 ; i < *nel1 ; i++) + { + icol2[i] = icol1[i] ; + } + return(0); +} + +/******************************************* + * same as ext14ca but ar and ai are integers + *******************************************/ + +int F2C(ext14cc)(it, m, n, nel, mnel, icol, ar, ai) +int *n, *m, *it, *nel, *mnel, *icol; +int *ar, *ai; +{ + int i, iof = 0, j; + for ( i = 0; i < *m ; i++) + { + sciprint("Row %d, %d non zero elements\n", i + 1, mnel[i]); + for ( j = 0; j < mnel[i]; j++) + { + if (*it == 1) + sciprint("(%d,%d) -> %d +i%d\n", i + 1, icol[iof + j], + ar[iof + j], ai[iof + j]); + else + sciprint("(%d,%d) -> %d\n", i + 1, icol[iof + j], + ar[iof + j]); + } + iof += mnel[i]; + } + return(0); +} + + +/******************************************* + * same as ext14cb but ar2 and ai2 are integers + * + *******************************************/ + + +int F2C(ext14cd)(it1, m1, n1, nel1, mnel1, icol1, ar1, ai1, + it2, m2, n2, nel2, mnel2, icol2, ar2, ai2) +int *n1, *m1, *it1, *nel1, *mnel1, *icol1; +double *ar1, *ai1; +int *it2, *m2, *n2, *nel2, *mnel2, *icol2; +int *ar2, *ai2; +{ + int i, iof = 0, j; + for ( i = 0; i < *m1 ; i++) + { + for ( j = 0; j < mnel1[i]; j++) + { + if (*it1 == 1) + { + ai2[iof + j] = 2 * ai1[iof + j]; + } + ar2[iof + j] = 2 * ar1[iof + j]; + } + iof += mnel1[i]; + } + for ( i = 0 ; i < *m1 ; i++ ) + { + mnel2[i] = mnel1[i]; + } + for ( i = 0 ; i < *nel1 ; i++) + { + icol2[i] = icol1[i] ; + } + return(0); +} + + + + +/******************************************* + * Test for intersci with external sparse (spt10 in ex14fi.desc) + * + * a Sparse structure is defined in stack-c.h which can be used + * for storing external Sparse matrices which can be + * copied back to scilab sparse matrices ( by csparsef ) + * + * if x is a Sparse object + * x.m : number of rows of x + * x,n : number of columns of x + * x.nel : number of non zero elements in x + * x.it : 0 or 1 i.e. real or complex matrix + * x.mnel[i],i=0,m-1 number of non zero elements in line i+1 + * + * x.icol[j],j=0,nel-1 : column of (j+1)th non zero element of the matrix + * ( stored by rows ) + * x.xr[j], ..... : real value of the (j+1)th non zero element + * x.xi[j], ..... : if x.it ==1 imaginary value of the (j+1)th + * non zero element + * + * NewSparse can be used to allocate a new Sparse object + * + * The Scilab internal coding is very similar + * and the following function copies a Scilab Sparse (it,m,n,nel,mnel,icol,ar,ai) + * into an allocated Sparse object + * and return the allocated Sparse and its dimensions + * + * + * the routine C2F(csparsef) (file routines/intersci/sparse.c) + * is used for back converstion from Sparse to Scilab sparse and + * and the Sparse object is freed in csparsef + * + *******************************************/ + +#include "../../routines/intersci/libinter.h" + +int F2C(ext14ce)(it, m, n, nel, mnel, icol, ar, ai, x, mx, nx, nelx, itx, err) +int *n, *m, *it, *nel, *mnel, *icol; +double *ar, *ai; +SciSparse **x; +int *mx, *nx, *nelx, *itx; +int *err; +{ + int i, iof = 0, j; + *x = NewSparse(it, m, n, nel); + if ( *x == (SciSparse *) 0) + { + sciprint("No more space\n"); + *err = 1; + return; + } + *mx = *m ; + *nx = *n ; + *nelx = *nel; + *itx = *it; + *err = 0; + for ( i = 0; i < *m ; i++) + { + for ( j = 0; j < mnel[i]; j++) + { + if (*it == 1) + { + (*x)->I[iof + j] = 2 * ai[iof + j]; + } + (*x)->R[iof + j] = 2 * ar[iof + j]; + } + iof += mnel[i]; + } + for ( i = 0 ; i < *m ; i++ ) + { + (*x)->mnel[i] = mnel[i]; + } + for ( i = 0 ; i < *nel ; i++) + { + (*x)->icol[i] = icol[i] ; + } + return(0); +} + + diff --git a/modules/intersci/examples/ex14fi-l.list b/modules/intersci/examples/ex14fi-l.list new file mode 100755 index 000000000..aacf7e6ae --- /dev/null +++ b/modules/intersci/examples/ex14fi-l.list @@ -0,0 +1,3 @@ +1 mat +mat sparse ma na nela ita +****************************** diff --git a/modules/intersci/examples/ex14fi.desc b/modules/intersci/examples/ex14fi.desc new file mode 100755 index 000000000..6b5a04241 --- /dev/null +++ b/modules/intersci/examples/ex14fi.desc @@ -0,0 +1,88 @@ +spt1 a +a sparse ma na nela ita + +ext14ca a +a double + +out sequence a +*********************** +spt2 a +a sparse ma na nela ita + +ext14cc a +a int + +out sequence a +*********************** +spt3 a +a sparse ma na nela ita + +ext14ca a +a double + +out list a +*********************** +spt4 a +a sparse ma na nela ita +b sparse ma na nela ita + +ext14cb a b +a double +b double + +out sequence b +*********************** +spt5 a +a sparse ma na nela ita +b sparse ma na nela ita + +ext14cd a b +a double +b int + +out sequence b +*********************** +spt6 a +a sparse ma na nela ita +b sparse ma na nela ita + +ext14cb a b +a double +b double + +out list b +*********************** +spt7 a +a list ex14fi-l + +ext14ca mat(a) +mat(a) double + +out sequence mat(a) +*********************** +spt8 a +a list ex14fi-l + +ext14cc mat(a) +mat(a) int + +out sequence mat(a) +*********************** +spt9 a +a list ex14fi-l + +ext14ca mat(a) +mat(a) double + +out list mat(a) +*********************** +spt10 a +a sparse ma na nela ita +b sparse mb nb nelb itb + +ext14ce a b mb nb nelb itb err +a double +b csparsef + +out sequence b +*********************** diff --git a/modules/intersci/examples/ex15.sce b/modules/intersci/examples/ex15.sce new file mode 100755 index 000000000..d0cb3cc6b --- /dev/null +++ b/modules/intersci/examples/ex15.sce @@ -0,0 +1,77 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +//ex15 example +//1-Creating interface source file +// Making object files +// Interface file '/tmp/ex15fi.o'; +// User's files '/tmp/ex15c.o'; +files=G_make(["/tmp/ex15fi.o","/tmp/ex15c.o";],"ex15.dll"); +//2-Link object files .o with addinter +//addinter(files,'intex15',intex1_funs); +exec("ex15fi.sce"); +//Run Scilab functions: +a=[0,0,1.23;0,2.32,0;3.45,0,0]; + +// simple matrix argument + +b=mat1(a); +if norm(b- a) > %eps then pause,end + +// matrix argument + conversion to int + +b=mat2(a); +if norm(b- int(a)) > %eps then pause,end + +// matrix and return a matrix in a list + +b=mat3(a); +if norm(b(1)- a) > %eps then pause,end + +// new matrix in intersci + +b=mat4(a); +if norm(b- 2*a) > %eps then pause,end + +// new matrix + conversion to int + +b=mat5(a); +if norm(b- int(2*a)) > %eps then pause,end + +// new matrix returned in a list + +b=mat6(a); +if norm(b(1)- 2*a) > %eps then pause,end + +// list argument with a matrix + +b=mat7(list(a)); +if norm(b- a) > %eps then pause,end + +// list argument + conversion + +b=mat8(list(a)); +if norm(b- int(a)) > %eps then pause,end + +// list argument + list output + +b=mat9(list(a)); +if norm(b(1)- a) > %eps then pause,end + +// cintf + +b=mat10(); +if norm(b'- (0:9)) > %eps then pause,end + +// cintf + list + +b=mat11(); +if norm(b(1)'- (0:9)) > %eps then pause,end + diff --git a/modules/intersci/examples/ex15c.c b/modules/intersci/examples/ex15c.c new file mode 100755 index 000000000..da488c1f2 --- /dev/null +++ b/modules/intersci/examples/ex15c.c @@ -0,0 +1,100 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) ????-2008 - INRIA + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + + +#include "../../routines/machine.h" + +/******************************************* + * simple example with sparse matrix + * Display of a + *******************************************/ + +int F2C(ext15ca)(ar, m, n) +double *ar; +int *n, *m; +{ + +} + +/******************************************* + * simple example with sparse matrix + * 2*a copied into b + *******************************************/ + +int F2C(ext15cb)(ar1, ar2, m, n) +double *ar1, *ar2; +int *m, *n; +{ + int i; + for ( i = 0; i < *m * (*n) ; i++) + { + ar2[i] = 2 * ar1[i]; + } +} + +/******************************************* + * same as ext15ca but ar and ai are integers + *******************************************/ + +int F2C(ext15cc)(ar, m, n) +int *ar, *m, *n; +{ + +} + + +/******************************************* + * same as ext15cb but ar2 and ai2 are integers + * + *******************************************/ + + +int F2C(ext15cd)(ar1, ar2, m, n) +int *ar1, *ar2; +int *m, *n; + +{ + int i; + for ( i = 0; i < *m * (*n) ; i++) + { + ar2[i] = 2 * ar1[i]; + } +} + + + + +/******************************************* + * a is an external + *******************************************/ + + +int F2C(ext15ce)(ar1, m, n, err) +int **ar1; +int *m, *n, *err; +{ + int i; + *n = 1; + *m = 10; + *ar1 = (int *) malloc((unsigned) (*m) * sizeof(int)); + if ( *ar1 == (int*) 0) + { + *err = 1; + sciprint("No more space\n"); + return; + } + *err = 0; + for ( i = 0; i < *m * (*n) ; i++) + { + (*ar1)[i] = i; + } +} diff --git a/modules/intersci/examples/ex15fi-l.list b/modules/intersci/examples/ex15fi-l.list new file mode 100755 index 000000000..e38c272aa --- /dev/null +++ b/modules/intersci/examples/ex15fi-l.list @@ -0,0 +1,3 @@ +1 mat +mat matrix ma na +****************************** diff --git a/modules/intersci/examples/ex15fi.desc b/modules/intersci/examples/ex15fi.desc new file mode 100755 index 000000000..d0e581de6 --- /dev/null +++ b/modules/intersci/examples/ex15fi.desc @@ -0,0 +1,98 @@ +mat1 a +a matrix ma na + +ext15ca a ma na +a double + +out sequence a +*********************** +mat2 a +a matrix ma na + +ext15cc a ma na +a int + +out sequence a +*********************** +mat3 a +a matrix ma na + +ext15ca a ma na +a double + +out list a +*********************** +mat4 a +a matrix ma na +b matrix ma na + +ext15cb a b ma na +a double +b double + +out sequence b +*********************** +mat5 a +a matrix ma na +b matrix ma na + +ext15cd a b ma na +a int +b int + +out sequence b +*********************** +mat6 a +a matrix ma na +b matrix ma na + +ext15cb a b ma na +a double +b double + +out list b +*********************** +mat7 a +a list ex15fi-l + +ext15ca mat(a) ma(a) na(a) +mat(a) double + +out sequence mat(a) +*********************** +mat8 a +a list ex15fi-l + +ext15cc mat(a) ma(a) na(a) +mat(a) int + +out sequence mat(a) +*********************** +mat9 a +a list ex15fi-l + +ext15ca mat(a) ma(a) na(a) +mat(a) double + +out list mat(a) +*********************** +mat10 +a matrix ma na + +ext15ce a ma na err +a cintf +ma int +na int + +out sequence a +*********************** +mat11 +a matrix ma na + +ext15ce a ma na err +a cintf +ma int +na int + +out list a +*********************** diff --git a/modules/intersci/examples/ex15fi.fundef b/modules/intersci/examples/ex15fi.fundef new file mode 100755 index 000000000..160aae9aa --- /dev/null +++ b/modules/intersci/examples/ex15fi.fundef @@ -0,0 +1,12 @@ +#define IN_ex15fi 14 +{"mat1", IN_ex15fi, 1, 3}, +{"mat2", IN_ex15fi, 2, 3}, +{"mat3", IN_ex15fi, 3, 3}, +{"mat4", IN_ex15fi, 4, 3}, +{"mat5", IN_ex15fi, 5, 3}, +{"mat6", IN_ex15fi, 6, 3}, +{"mat7", IN_ex15fi, 7, 3}, +{"mat8", IN_ex15fi, 8, 3}, +{"mat9", IN_ex15fi, 9, 3}, +{"mat10", IN_ex15fi, 10, 3}, +{"mat11", IN_ex15fi, 11, 3}, diff --git a/modules/intersci/examples/ex16.sce b/modules/intersci/examples/ex16.sce new file mode 100755 index 000000000..d3f17a0ba --- /dev/null +++ b/modules/intersci/examples/ex16.sce @@ -0,0 +1,64 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +//ex16 example ( boolean matrices ) +//1-Creating interface source file +// Making object files +// Interface file '/tmp/ex16fi.o'; +// User's files '/tmp/ex16c.o'; +files=G_make(["/tmp/ex16fi.o","/tmp/ex16c.o";],"ex16.dll"); +//2-Link object files .o with addinter +//addinter(files,'intex16',intex1_funs); +exec("ex16fi.sce"); +//Run Scilab functions: +a=[%t,%t;%f,%f]; + +// simple matrix argument + +b=ext16ca(a); +if b<>~a then pause,end + +// matrix and return a matrix in a list + +b=ext16cb(a); +if b(1)<>~a then pause,end + +// new matrix in intersci + +b=ext16cc(a); +if b<>~a then pause,end + +// new matrix returned in a list + +b=ext16cd(a); +if b(1)<>~a then pause,end + +// list argument with a matrix + +b=ext16ce(list(a)) +if b<>~a then pause,end + +// list argument + list output + +b=ext16cf(list(a)) +if b(1)<>~a then pause,end + +// cboolf + +b=ext16cg(); +if b<>[%f,%t;%t,%f;%f,%t] then pause,end + +// cboolf + list + +b=ext16ch(); +if b(1)<>[%f,%t;%t,%f;%f,%t] then pause,end + + + diff --git a/modules/intersci/examples/ex16c.c b/modules/intersci/examples/ex16c.c new file mode 100755 index 000000000..e7eb63d11 --- /dev/null +++ b/modules/intersci/examples/ex16c.c @@ -0,0 +1,74 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) ????-2008 - INRIA + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + + +#include "../../routines/machine.h" + +/******************************************* + * simple example with sparse matrix + * Display of a + *******************************************/ + +int F2C(ext16ca)(ar, m, n) +int *ar; +int *n, *m; +{ + int i; + for ( i = 0; i < (*m) * (*n) ; i++) + { + ar[i] = (ar[i] == 1) ? 0 : 1; + } +} + +/******************************************* + * simple example with sparse matrix + * 2*a copied into b + *******************************************/ + +int F2C(ext16cb)(ar1, ar2, m, n) +int *ar1, *ar2; +int *m, *n; +{ + int i; + for ( i = 0; i < *m * (*n) ; i++) + { + ar2[i] = (ar1[i] == 1) ? 0 : 1; + } +} + + +/******************************************* + * a is an external + *******************************************/ + + +int F2C(ext16ce)(ar1, m, n, err) +int **ar1; +int *m, *n, *err; +{ + int i, j; + *n = 2; + *m = 3; + *ar1 = (int *) malloc((unsigned) (*m) * (*n) * sizeof(int)); + if ( *ar1 == (int*) 0) + { + *err = 1; + sciprint("No more space\n"); + return; + } + *err = 0; + for ( i = 0; i < (*n) ; i++) + for ( j = 0; j < (*m) ; j++) + { + (*ar1)[i + (*n)*j] = i ; + } +} diff --git a/modules/intersci/examples/ex16fi-l.list b/modules/intersci/examples/ex16fi-l.list new file mode 100755 index 000000000..910bfa3cb --- /dev/null +++ b/modules/intersci/examples/ex16fi-l.list @@ -0,0 +1,3 @@ +1 mat +mat bmatrix ma na +****************************** diff --git a/modules/intersci/examples/ex16fi.desc b/modules/intersci/examples/ex16fi.desc new file mode 100755 index 000000000..379ccbdd8 --- /dev/null +++ b/modules/intersci/examples/ex16fi.desc @@ -0,0 +1,72 @@ +ext16ca a +a bmatrix ma na + +ext16ca a ma na +a int + +out sequence a +*********************** +ext16cb a +a bmatrix ma na + +ext16ca a ma na +a int + +out list a +*********************** +ext16cc a +a bmatrix ma na +b bmatrix ma na + +ext16cb a b ma na +a int +b int + +out sequence b +*********************** +ext16cd a +a bmatrix ma na +b bmatrix ma na + +ext16cb a b ma na +a int +b int + +out list b +*********************** +ext16ce a +a list ex16fi-l + +ext16ca mat(a) ma(a) na(a) +mat(a) int + +out sequence mat(a) +*********************** +ext16cf a +a list ex16fi-l + +ext16ca mat(a) ma(a) na(a) +mat(a) int + +out list mat(a) +*********************** +ext16cg +a bmatrix ma na + +ext16ce a ma na err +a cboolf +ma int +na int + +out sequence a +*********************** +ext16ch +a bmatrix ma na + +ext16ce a ma na err +a cboolf +ma int +na int + +out list a +*********************** diff --git a/modules/intersci/examples/ex1c.c b/modules/intersci/examples/ex1c.c new file mode 100755 index 000000000..9ed652c40 --- /dev/null +++ b/modules/intersci/examples/ex1c.c @@ -0,0 +1,26 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) ????-2008 - INRIA + * Copyright (C) 2008-2008 - INRIA - Bruno JOFRET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + + +#include "../../routines/machine.h" + +int F2C(ext1c)(int *n, double *a, double *b, double *c) +{ + int k; + for (k = 0; k < *n; ++k) + { + c[k] = a[k] + b[k]; + } + return(0); +} + diff --git a/modules/intersci/examples/ex1fi.desc b/modules/intersci/examples/ex1fi.desc new file mode 100755 index 000000000..5768a554b --- /dev/null +++ b/modules/intersci/examples/ex1fi.desc @@ -0,0 +1,13 @@ +ext1c a b +a vector m +b vector m +c vector m + +ext1c m a b c +m integer +a double +b double +c double + +out sequence c +*********************** diff --git a/modules/intersci/examples/ex2.sce b/modules/intersci/examples/ex2.sce new file mode 100755 index 000000000..16f81428c --- /dev/null +++ b/modules/intersci/examples/ex2.sce @@ -0,0 +1,28 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +//ex2 example +//1-Creating interface source file +// from intex2.desc file by call to intersci (see Makefile) +// Making object files +// Interface file '/tmp/ex2fi.o' +// User's files ['/tmp/ex2f.o'] +files=G_make(["/tmp/ex2fi.o","/tmp/ex2f.o"],"ex2.dll"); +//2-Link object files .o with addinter +//addinter(files,'intex2',intex2_funs); +exec("ex2fi.sce"); +//Run Scilab functions: +a=1:20;b=1:10; +d=som(a=1:20,b=1:10); +d1=ones(1,10) + a(1:10)+b(1:10); +if norm(d-d1') > %eps then pause,end; + + + diff --git a/modules/intersci/examples/ex2f.f b/modules/intersci/examples/ex2f.f new file mode 100755 index 000000000..3f4644542 --- /dev/null +++ b/modules/intersci/examples/ex2f.f @@ -0,0 +1,18 @@ +c Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +c Copyright (C) ????-2008 - INRIA +c +c This file must be used under the terms of the CeCILL. +c This source file is licensed as described in the file COPYING, which +c you should have received as part of this distribution. The terms +c are also available at +c http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + subroutine fsom(a,n,b,m,c) + real a(*),b(*),c(*) + kk=min(n,m) + do 2 k=1,m + 2 c(k)=1.0 + do 1 k=1,kk + 1 c(k)=c(k)+b(k)+a(k) + end + + diff --git a/modules/intersci/examples/ex2fi.desc b/modules/intersci/examples/ex2fi.desc new file mode 100755 index 000000000..1fdf2bbad --- /dev/null +++ b/modules/intersci/examples/ex2fi.desc @@ -0,0 +1,14 @@ +som a b +a row m +b row n +c column n + +fsom a n b m c +a real +n integer +b real +m integer +c real + +out sequence c +*********************** diff --git a/modules/intersci/examples/ex3.sce b/modules/intersci/examples/ex3.sce new file mode 100755 index 000000000..efef52b48 --- /dev/null +++ b/modules/intersci/examples/ex3.sce @@ -0,0 +1,28 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +//daxpy example +//1-Creating interface source file +// from ex3fi.desc file by call to intersci (see Makefile) +// Making object files +// Interface file '/tmp/ex3fi.o' +// User's files []; +files=G_make(["/tmp/ex3fi.o"],"ex3.dll"); +//2-Link object files .o with addinter +//addinter(files,'daxpy',ex3fi_funs); +exec("ex3fi.sce"); +//Run Scilab functions: +n=3;a=13;incx=2;incy=3;x=1:10;y=2*x; +ynew=scilabdaxpy(n,a,x,incx,y,incy); +y(1:incy:n*incy)=y(1:incy:n*incy)+a*x(1:incx:n*incx); +if norm(ynew-y) > %eps then pause,end + + + diff --git a/modules/intersci/examples/ex3fi.desc b/modules/intersci/examples/ex3fi.desc new file mode 100755 index 000000000..bef16359b --- /dev/null +++ b/modules/intersci/examples/ex3fi.desc @@ -0,0 +1,18 @@ +scilabdaxpy n a x incx y incy +n scalar +a scalar +x vector nx +incx scalar +y vector ny +incy scalar + +daxpy n a x incx y incy +n int +a double +x double +incx int +y double +incy int + +out sequence y +********************* diff --git a/modules/intersci/examples/ex4.sce b/modules/intersci/examples/ex4.sce new file mode 100755 index 000000000..35d0a9072 --- /dev/null +++ b/modules/intersci/examples/ex4.sce @@ -0,0 +1,28 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +//ex4 example +//1-Creating interface source file +// from intex4.desc file by call to intersci (see Makefile) +// Making object files +// Interface file '/tmp/ex4fi.o' +// User's files '/tmp/ex4f.o'; +files=G_make(["/tmp/ex4fi.o","/tmp/ex4f.o"],"ex4.dll"); +//2-Link object files .o with addinter +//addinter(files,'intex4',intex4_funs); +exec("ex4fi.sce"); +//Run Scilab functions: +sys=ssrand(2,2,3,list("co",1)); +n=contrb(sys,0.01) +if n <> 1 then pause,end + + + + diff --git a/modules/intersci/examples/ex4f.f b/modules/intersci/examples/ex4f.f new file mode 100755 index 000000000..18c9f8fab --- /dev/null +++ b/modules/intersci/examples/ex4f.f @@ -0,0 +1,40 @@ +c Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +c Copyright (C) ????-2008 - INRIA +c +c This file must be used under the terms of the CeCILL. +c This source file is licensed as described in the file COPYING, which +c you should have received as part of this distribution. The terms +c are also available at +c http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + subroutine contr(nstate,nin,a,b,icontr,tol) +c computes the order of controllablility of a state-space representation + double precision a(nstate,*),b(nstate,*) + double precision tol + integer nstate,nin,icontr +c + double precision w(200) + integer iw(20) +c + lz=1 + lwrka=lz+nstate*nstate + lwrk1=lwrka+nstate*nin + lwrk2=lwrk1+nin + lw=lwrk2+nin + if(lw.gt.200) then + call erro('Too big system') + return + endif + + lnblk=1 + liwrk=lnblk+nstate + lw=liwrk+nin + if(lw.gt.20) then + call erro('Too big system') + return + endif + + call ssxmc(nstate,nin,a,nstate,b,icontr,indcon,iw(lnblk), + 1 w(lz),w(lwrka), w(lwrk1), w(lwrk2),iw(liwrk), + 2 tol,0) + return + end diff --git a/modules/intersci/examples/ex4fi-l.list b/modules/intersci/examples/ex4fi-l.list new file mode 100755 index 000000000..60eac1e33 --- /dev/null +++ b/modules/intersci/examples/ex4fi-l.list @@ -0,0 +1,24 @@ +1 type +type string 3 +****************************** +2 state matrix +a matrix nstate nstate +****************************** +3 input matrix +b matrix nstate nin +****************************** +4 output matrix +c matrix nout nstate +****************************** +5 direct tranfert matrix +d matrix nout nin +****************************** +6 initial state +x0 column nstate +****************************** +7 time domain +t any +****************************** +8 names +names string 4 +****************************** diff --git a/modules/intersci/examples/ex4fi.desc b/modules/intersci/examples/ex4fi.desc new file mode 100755 index 000000000..d3b93390f --- /dev/null +++ b/modules/intersci/examples/ex4fi.desc @@ -0,0 +1,15 @@ +contrb sys tol +tol scalar +sys list ex4fi-l +icontr scalar + +contr nstate(sys) nin(sys) a(sys) b(sys) icontr tol +a(sys) double +b(sys) double +tol double +nstate(sys) integer +nin(sys) integer +icontr integer + +out sequence icontr +****************************** diff --git a/modules/intersci/examples/ex5.sce b/modules/intersci/examples/ex5.sce new file mode 100755 index 000000000..ff3e91833 --- /dev/null +++ b/modules/intersci/examples/ex5.sce @@ -0,0 +1,26 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +//foobar example +//1-Creating interface source file +// from ex5fi.desc file by call to intersci (see Makefile) +//2-Making object files +// Interface file '/tmp/ex5fi.o' +// User's files '/tmp/ex5f.o'; +files=G_make(["/tmp/ex5fi.o","/tmp/ex5f.o"],"ex5.dll"); +//2-Link object files .o with addinter +//addinter(files,'foobar',ex5fi_funs); +exec("ex5fi.sce"); +//Run Scilab functions: +a=1:5;b=-a;c=ones(3,3); +[a,b,c,d]=foobar("mul",a,b,c) +[a,b,c,d]=foobar("add",a,b,c) + + diff --git a/modules/intersci/examples/ex5f.f b/modules/intersci/examples/ex5f.f new file mode 100755 index 000000000..88dd525a5 --- /dev/null +++ b/modules/intersci/examples/ex5f.f @@ -0,0 +1,61 @@ +c Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +c Copyright (C) ????-2008 - INRIA +c +c This file must be used under the terms of the CeCILL. +c This source file is licensed as described in the file COPYING, which +c you should have received as part of this distribution. The terms +c are also available at +c http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + subroutine foubare2(ch,a,ia,b,ib,c,mc,nc,d,w) +c ----------------------------------------- +c ----------- EXAMPLE ----------------- +c inputs: ch, a,b and c; ia,ib and mc,nc +c ch=character, a=integer, b=real and c=double +c ia,ib and [mc,nc] are the dimensions of a,b and c resp. +c outputs: a,b,c,d +c if ch='mul' a,b and c = 2 * (a,b and c) +c and d of same dimensions as c with +c d(i,j)=(i+j)*c(i,j) +c if ch='add' a,b and c = 2 + (a,b and c) +c d(i,j)=(i+j)+c(i,j) +c w is a working array of size [mc,nc] +c ------------------------------------------- + character*(*) ch + integer a(*) + real b(*) + double precision c(mc,*),d(mc,*),w(mc,*) + if(ch(1:3).eq.'mul') then + do 1 k=1,ia + a(k)=2*a(k) + 1 continue + do 2 k=1,ib + b(k)=2.0*b(k) + 2 continue + do 3 i=1,mc + do 3 j=1,nc + c(i,j)=2.0d0*c(i,j) + 3 continue + do 4 i=1,mc + do 4 j=1,nc + w(i,j)=dble(i+j) + d(i,j)=w(i,j)*c(i,j) + 4 continue + elseif(ch(1:3).eq.'add') then + do 10 k=1,ia + a(k)=2+a(k) + 10 continue + do 20 k=1,ib + b(k)=2.0+b(k) + 20 continue + do 30 i=1,mc + do 30 j=1,nc + c(i,j)=2.0d0+c(i,j) + 30 continue + do 40 i=1,mc + do 40 j=1,nc + w(i,j)=dble(i+j) + d(i,j)=w(i,j)+c(i,j) + 40 continue + endif + end + diff --git a/modules/intersci/examples/ex5fi.desc b/modules/intersci/examples/ex5fi.desc new file mode 100755 index 000000000..54453ee13 --- /dev/null +++ b/modules/intersci/examples/ex5fi.desc @@ -0,0 +1,22 @@ +foobar ch a b c +ch string nch +a vector ma +b row mb +c matrix mc nc +d matrix mc nc +w matrix mc nc + +foubare2 ch a ma b mb c mc nc d w +ch char +a int +ma int +b real +mb int +c double +mc int +nc int +d double +w double + +out sequence a b c d +*************************** diff --git a/modules/intersci/examples/ex6.sce b/modules/intersci/examples/ex6.sce new file mode 100755 index 000000000..11f51cacd --- /dev/null +++ b/modules/intersci/examples/ex6.sce @@ -0,0 +1,37 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +//1-Creating interface source file +// from ex6fi.desc file by call to intersci (see Makefile) +//2-Making object files +// Interface file '/tmp/ex6fi.o' +// User's files '/tmp/ex6c.o'; +files=G_make(["/tmp/ex6fi.o","/tmp/ex6c.o"],"ex6.dll"); +//2-Link object files .o with addinter +//addinter(files,'ex6fi',matusr_funs); +exec("ex6fi.sce"); +//Test Scilab functions: + +//calc4: input: matrix of character string +// output: matrix of character string (C function ccalc4) +w=["this" "is"; "naw" "gaad"] +rep=calc6a(w); +if rep<>["this" "is"; "now" "good"] then pause,end; + +//calc5: creation of a character string matrix. +a=calc6b(); +a1="char "; a1=matrix(a1(ones(1,6))+string(0:5),3,2); +if a<>a1 then pause,end + + + + + + diff --git a/modules/intersci/examples/ex6c.c b/modules/intersci/examples/ex6c.c new file mode 100755 index 000000000..7d2acfee1 --- /dev/null +++ b/modules/intersci/examples/ex6c.c @@ -0,0 +1,80 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) ????-2008 - INRIA + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +#include "../../routines/machine.h" +#include <stdlib.h> + +/************************************************************* + * Example of a dynamically allocated array of character created here. + * Its size is sent back as an output. + * It is converted into Scilab variable in the interface program. + * The allocated array is freed. + * the Scilab variable is of type stringmat and is not in the argument list of the scilab + * function. The Fortran type is Cstringv + *************************************************************/ + +C2F(ccalc6b)(a, m, n, err) +char ***a; +int *m, *n, *err; +{ + int i, nstring; + *m = 3; + *n = 2; + nstring = (*m) * (*n); + *a = (char **) malloc((unsigned) (nstring * sizeof(char *))); + if ( *a == 0) + { + sciprint("No more space\n"); + *err = 1; + return; + } + for ( i = 0 ; i < nstring ; i++) + { + (*a)[i] = (char *) malloc ((8) * sizeof(char)); + sprintf((*a)[i], "char %d", i); + *err = 0; + } +} + + +/************************************************************* + * This example shows how a Scilab argument of type stringmat + * (which is in the calling list of the Scilab function ) + * is transmited to a C program. + * a is a stringmat Scilab argument and a Cstringv Fortran argument + * a is allocated in the interface + *************************************************************/ + +C2F(ccalc6a)(a, m, n) +char ***a; +int *m, *n; +{ + int i, j; + for ( i = 0 ; i < *m * (*n) ; i++) + { + char *loc = (*a)[i]; + for ( j = 0 ; j < strlen(loc); j++) + if ( loc[j] == 'a' ) + { + loc[j] = 'o'; + } + } +} + + + + + + + + + diff --git a/modules/intersci/examples/ex6fi.desc b/modules/intersci/examples/ex6fi.desc new file mode 100755 index 000000000..e994e95da --- /dev/null +++ b/modules/intersci/examples/ex6fi.desc @@ -0,0 +1,16 @@ +calc6a a +a stringmat m n + +ccalc6a a m n +a Cstringv + +out sequence a +*********************** +calc6b +a stringmat m n + +ccalc6b a m n err +a Cstringv + +out sequence a +*********************** diff --git a/modules/intersci/examples/ex7.sce b/modules/intersci/examples/ex7.sce new file mode 100755 index 000000000..3d8d2734c --- /dev/null +++ b/modules/intersci/examples/ex7.sce @@ -0,0 +1,25 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +//ex7 example +//1-Creating interface source file +// from ex7fi.desc file by call to intersci +// Making object files +// Interface file '/tmp/ex7fi.o' +// User's files '/tmp/ex7f.o'; +files=G_make(["/tmp/ex7fi.o","/tmp/ex7f.o"],"ex7.dll"); +//2-Link object files .o with addinter +//addinter(files,'intex7',intex1_funs); +exec("ex7fi.sce"); +//Run Scilab functions: +if calc("one")<>1 then pause,end +if calc("two")<>2 then pause,end +if calc("other")<>-1 then pause,end + diff --git a/modules/intersci/examples/ex7f.f b/modules/intersci/examples/ex7f.f new file mode 100755 index 000000000..2688e3cf6 --- /dev/null +++ b/modules/intersci/examples/ex7f.f @@ -0,0 +1,21 @@ +c Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +c Copyright (C) ????-2008 - INRIA +c +c This file must be used under the terms of the CeCILL. +c This source file is licensed as described in the file COPYING, which +c you should have received as part of this distribution. The terms +c are also available at +c http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + subroutine fcalc(str,a) + character*(*) str + integer a +c + if (str.eq.'one') then + a=1 + elseif (str.eq.'two') then + a=2 + else + a=-1 + endif + end + diff --git a/modules/intersci/examples/ex7fi.desc b/modules/intersci/examples/ex7fi.desc new file mode 100755 index 000000000..fb6d4e6bc --- /dev/null +++ b/modules/intersci/examples/ex7fi.desc @@ -0,0 +1,10 @@ +calc str +str string l +a scalar + +fcalc str a +str char +a integer + +out sequence a +*********************** diff --git a/modules/intersci/examples/ex8.sce b/modules/intersci/examples/ex8.sce new file mode 100755 index 000000000..07e3de367 --- /dev/null +++ b/modules/intersci/examples/ex8.sce @@ -0,0 +1,30 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +//1-Creating interface source file (matusr.f) +// from ex8fi.desc file by call to intersci +// Making object files +// Interface file '/tmp/ex8fi.o' +// User's files '/tmp/ex8c.o'; +files=G_make(["/tmp/ex8fi.o","/tmp/ex8c.o"],"ex8.dll"); +//2-Link object files .o with addinter +//addinter(files,'ex8fi',matusr_funs); +exec("ex8fi.sce"); +//Test Scilab functions: + +//calc8: matrix of integer type created by C function (malloc and free). +a=calc8(); +if norm(a - matrix(0:14,3,5)) > %eps then pause,end + + + + + + diff --git a/modules/intersci/examples/ex8c.c b/modules/intersci/examples/ex8c.c new file mode 100755 index 000000000..1a4e0276e --- /dev/null +++ b/modules/intersci/examples/ex8c.c @@ -0,0 +1,40 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) ????-2008 - INRIA + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +#include "../../routines/machine.h" +#include <stdlib.h> + +/************************************************************* + * Example of an int array created by C code + * converted to output Scilab variable by cintf + *************************************************************/ + +C2F(ccalc8) ( a, m, n, err) +int **a, *m, *n, *err ; +{ + int i ; + *n = 5 ; + *m = 3 ; + *a = ( int *) malloc( (unsigned) (*m) * (*n) * sizeof(int)); + if ( *a == (int *) 0 ) + { + *err = 1; + sciprint("No more space\n"); + } + *err = 0; + for ( i = 0 ; i < (*m) * (*n) ; i++) + { + (*a)[i] = i ; + } +} + + diff --git a/modules/intersci/examples/ex8fi.desc b/modules/intersci/examples/ex8fi.desc new file mode 100755 index 000000000..0ebb9cc27 --- /dev/null +++ b/modules/intersci/examples/ex8fi.desc @@ -0,0 +1,10 @@ +calc8 +a matrix m n + +ccalc8 a m n err +a cintf +m integer +n integer + +out sequence a +*********************** diff --git a/modules/intersci/examples/ex9.sce b/modules/intersci/examples/ex9.sce new file mode 100755 index 000000000..687ba17bf --- /dev/null +++ b/modules/intersci/examples/ex9.sce @@ -0,0 +1,36 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +//1-Creating interface source file (matusr.f) +// from ex9fi.desc file by call to intersci +// Making object files +// Interface file '/tmp/ex9fi.o' +// User's files '/tmp/ex9f.o'; +files=G_make(["/tmp/ex9fi.o","/tmp/ex9f.o"],"ex9.dll"); +//2-Link object files .o with addinter +//addinter(files,'ex9fi',matusr_funs); +exec("ex9fi.sce"); +//Test Scilab functions: +//calc7: function with two optional values, a string and a scilab variable. +bb=33; //scilab optional variable +[a,b,c,d]=calc9(10); +if c<>"toto" then pause,end +if norm(d-[2,4,6,8])> %eps then pause,end +if b<>bb then pause,end + + + + + + + + + + diff --git a/modules/intersci/examples/ex9c.c b/modules/intersci/examples/ex9c.c new file mode 100755 index 000000000..c1f9807c9 --- /dev/null +++ b/modules/intersci/examples/ex9c.c @@ -0,0 +1,34 @@ +/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) ????-2008 - INRIA + * Copyright (C) 2008-2008 - INRIA - Bruno JOFRET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + * + */ + +#include "../../routines/machine.h" +#include <stdlib.h> + +/************************************************************* + Example of an int array created by C code + converted to output Scilab variable by cintf +*************************************************************/ + +C2F(ccalc3) (int **a, int *m, int *n) +{ + int i ; + *n = 5 ; + *m = 3 ; + *a = ( int *) malloc( (unsigned) (*m) * (*n) * sizeof(int)); + for ( i = 0 ; i < (*m) * (*n) ; i++) + { + (*a)[i] = i ; + } +} + + diff --git a/modules/intersci/examples/ex9f.f b/modules/intersci/examples/ex9f.f new file mode 100755 index 000000000..da9cdfffd --- /dev/null +++ b/modules/intersci/examples/ex9f.f @@ -0,0 +1,21 @@ +c Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +c Copyright (C) ????-2008 - INRIA +c +c This file must be used under the terms of the CeCILL. +c This source file is licensed as described in the file COPYING, which +c you should have received as part of this distribution. The terms +c are also available at +c http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + subroutine fcalc9(a,b,c,lc,d,nd) + integer a(*),d(*) + double precision b(*) + character c*(*) + do 10 i=1,nd + d(i)=2*d(i) + 10 continue + do 20 i=1,lc + if (c(i:i).eq.'u') c(i:i)='o' + 20 continue + return + end diff --git a/modules/intersci/examples/ex9fi-l.list b/modules/intersci/examples/ex9fi-l.list new file mode 100755 index 000000000..56a2b2b95 --- /dev/null +++ b/modules/intersci/examples/ex9fi-l.list @@ -0,0 +1,9 @@ +1 a +a matrix ma na +****************************** +2 b +b matrix mb nb +****************************** +3 c +c matrix mc nc +****************************** diff --git a/modules/intersci/examples/ex9fi.desc b/modules/intersci/examples/ex9fi.desc new file mode 100755 index 000000000..c36f73499 --- /dev/null +++ b/modules/intersci/examples/ex9fi.desc @@ -0,0 +1,14 @@ +calc9 a {b bb} [c tutu] [d (4)/1,2,3,4/] +a scalar +b scalar +c string l +d matrix 1 l1 + +fcalc9 a b c l d l1 +a integer +b double +c char +d integer + +out sequence a b c d +*********************** diff --git a/modules/intersci/examples/zall.sce b/modules/intersci/examples/zall.sce new file mode 100755 index 000000000..0ae0f30d7 --- /dev/null +++ b/modules/intersci/examples/zall.sce @@ -0,0 +1,237 @@ +// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +// Copyright (C) ????-2008 - INRIA +// +// This file must be used under the terms of the CeCILL. +// This source file is licensed as described in the file COPYING, which +// you should have received as part of this distribution. The terms +// are also available at +// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt + + +// Making object files +// Interface file +ifile="zallfi.o"; +ufiles=["/tmp/ex1c.o","/tmp/ex2f.o","/tmp/ex4f.o","/tmp/ex5f.o","/tmp/ex6c.o","/tmp/ex7f.o","/tmp/ex8c.o","/tmp/ex9f.o","/tmp/ex10f.o","/tmp/ex11c.o","/tmp/ex12c.o","/tmp/ex13c.o","/tmp/ex14c.o","/tmp/ex15c.o","/tmp/ex16c.o"]; +files=G_make([ifile,ufiles],"zallfi.dll"); +//2-Link object files .o with addinter +//addinter(files,'intex1',intex1_funs); +exec("zallfi.sce"); +//Run Scilab functions: +a=[1,2,3];b=[4,5,6]; +c=ext1c(a,b); +if norm(c-(a+b)) > %eps then pause,end + + +//Run Scilab functions: +a=1:20;b=1:10; +d=som(a=1:20,b=1:10); +d1=ones(1,10) + a(1:10)+b(1:10); +if norm(d-d1') > %eps then pause,end; + + + +//Run Scilab functions: +n=3;a=13;incx=2;incy=3;x=1:10;y=2*x; +ynew=scilabdaxpy(n,a,x,incx,y,incy); +y(1:incy:n*incy)=y(1:incy:n*incy)+a*x(1:incx:n*incx); +if norm(ynew-y) > %eps then pause,end + +//Run Scilab functions: +sys=ssrand(2,2,3,list("co",1)); +n=contrb(sys,0.01) +if n <> 1 then pause,end + +//Run Scilab functions: +a=1:5;b=-a;c=ones(3,3); +[a,b,c,d]=foobar("mul",a,b,c) +[a,b,c,d]=foobar("add",a,b,c) + + +w=["this" "is"; "naw" "gaad"] +rep=calc6a(w); +if rep<>["this" "is"; "now" "good"] then pause,end; + +//calc5: creation of a character string matrix. +a=calc6b(); +a1="char "; a1=matrix(a1(ones(1,6))+string(0:5),3,2); +if a<>a1 then pause,end + +//Run Scilab functions: +if calc("one")<>1 then pause,end +if calc("two")<>2 then pause,end +if calc("other")<>-1 then pause,end + + +//calc8: matrix of integer type created by C function (malloc and free). +a=calc8(); +if norm(a - matrix(0:14,3,5)) > %eps then pause,end + +//calc7: function with two optional values, a string and a scilab variable. +bb=33; //scilab optional variable +[a,b,c,d]=calc9(10); +if c<>"toto" then pause,end +if norm(d-[2,4,6,8])> %eps then pause,end +if b<>bb then pause,end + +//Test Scilab functions: +// calc1: 3 matrix input variables and at most 3 output variables of +// types double, real, int +l=calc10(list(1,[2,3],[1,2;3,4])); +if norm(l(1)-2) > %eps then pause,end +if norm(l(2)-([2,3]+[1,2])) > %eps then pause,end +if norm(l(3)-([1,2;3,4]+[1,3;2,4])) > %eps then pause,end + +//Run Scilab functions: +a=[1,2,3]+%i*[4,5,6]; +b=ext11c(a); +if norm(b-([4,5,6]+%i*[1,2,3])) > %eps then pause,end + + +//Run Scilab functions: +b=ccalc12(); +if norm(b-(0:9)) > %eps then pause,end + +//Run Scilab functions: +a=rand(2,3); +b=ext13c(a); +if norm(b- matrix(2*a,3,2)) > %eps then pause,end + +//Run Scilab functions: +a=[0,0,1.23;0,2.32,0;3.45,0,0]; +ai=[0,0,9;0,6,0;7,0,0]; +spa=sparse(a); +spai=sparse(a+%i*ai); +// simple sparse argument + +b=spt1(spa); +if norm(full(b- spa)) > %eps then pause,end + +b=spt1(spai); +if norm(full(b- spai)) > %eps then pause,end + +// sparse argument + conversion to int + +b=spt2(spa); +if norm(full(b- int(spa))) > %eps then pause,end + +b=spt2(spai); +if norm(full(b- int(spai))) > %eps then pause,end + +// sparse and return a sparse in a list + +b=spt3(spa); +if norm(full(b(1)- spa)) > %eps then pause,end + +b=spt3(spai); +if norm(full(b(1)- spai)) > %eps then pause,end + +// new sparse in intersci + +b=spt4(spa); +if norm(full(b- 2*spa)) > %eps then pause,end + +b=spt4(spai); +if norm(full(b- 2*spai)) > %eps then pause,end + +// new sparse + conversion to int + +b=spt5(spa); +if norm(full(b- int(2*spa))) > %eps then pause,end + +b=spt5(spai); +if norm(full(b- int(2*spai))) > %eps then pause,end + +// new sparse returned in a list + +b=spt6(spa); +if norm(full(b(1)- 2*spa)) > %eps then pause,end + +b=spt6(spai); +if norm(full(b(1)- 2*spai)) > %eps then pause,end + +// list argument with a sparse + +b=spt7(list(spa)); +if norm(full(b- spa)) > %eps then pause,end + +b=spt7(list(spai)); +if norm(full(b- spai)) > %eps then pause,end + +// list argument + conversion + +b=spt8(list(spa)); +if norm(full(b- int(spa))) > %eps then pause,end + +b=spt8(list(spai)); +if norm(full(b- int(spai))) > %eps then pause,end + +// list argument + list output + +b=spt9(list(spa)); +if norm(full(b(1)- spa)) > %eps then pause,end + +b=spt9(list(spai)); +if norm(full(b(1)- spai)) > %eps then pause,end + +b=spt10(spa); +if norm(full(b- 2*spa)) > %eps then pause,end + + +//Run Scilab functions: +a=[0,0,1.23;0,2.32,0;3.45,0,0]; + +// simple matrix argument + +b=mat1(a); +if norm(b- a) > %eps then pause,end + +// matrix argument + conversion to int + +b=mat2(a); +if norm(b- int(a)) > %eps then pause,end + +// matrix and return a matrix in a list + +b=mat3(a); +if norm(b(1)- a) > %eps then pause,end + +// new matrix in intersci + +b=mat4(a); +if norm(b- 2*a) > %eps then pause,end + +// new matrix + conversion to int + +b=mat5(a); +if norm(b- int(2*a)) > %eps then pause,end + +// new matrix returned in a list + +b=mat6(a); +if norm(b(1)- 2*a) > %eps then pause,end + +// list argument with a matrix + +b=mat7(list(a)); +if norm(b- a) > %eps then pause,end + +// list argument + conversion + +b=mat8(list(a)); +if norm(b- int(a)) > %eps then pause,end + +// list argument + list output + +b=mat9(list(a)); +if norm(b(1)- a) > %eps then pause,end + +// cintf + +b=mat10(); +if norm(b'- (0:9)) > %eps then pause,end + +// cintf + list + +b=mat11(); +if norm(b(1)'- (0:9)) > %eps then pause,end + diff --git a/modules/intersci/examples/zallfi.dia.ref b/modules/intersci/examples/zallfi.dia.ref new file mode 100755 index 000000000..8dbdf7551 --- /dev/null +++ b/modules/intersci/examples/zallfi.dia.ref @@ -0,0 +1,582 @@ + +// Making object files + +// Interface file + +ifile='zallfi.o'; + +ufiles=['/tmp/ex1c.o','/tmp/ex2f.o','/tmp/ex4f.o','/tmp/ex5f.o','/tmp/ex6c.o','/tmp/ex7f.o','/tmp/ex8c.o','/tmp/ex9f.o','/tmp/ex10f.o','/tmp/ex11c.o','/tmp/ex12c.o','/tmp/ex13c.o','/tmp/ex14c.o','/tmp/ex15c.o','/tmp/ex16c.o']; + +files=G_make([ifile,ufiles],'zallfi.dll'); + +//2-Link object files0.o with addinter + +//addinter(files,'intex1',intex1_funs); + + zallfi_funs = + +!calc10 ! +! ! +!ext11c ! +! ! +!ccalc12 ! +! ! +!ext13c ! +! ! +!spt1 ! +! ! +!spt2 ! +! ! +!spt3 ! +! ! +!spt4 ! +! ! +!spt5 ! +! ! +!spt6 ! +! ! +!spt7 ! +! ! +!spt8 ! +! ! +!spt9 ! +! ! +!spt10 ! +! ! +!mat1 ! +! ! +!mat2 ! +! ! +!mat3 ! +! ! +!mat4 ! +! ! +!mat5 ! +! ! +!mat6 ! +! ! +!mat7 ! +! ! +!mat8 ! +! ! +!mat9 ! +! ! +!mat10 ! +! ! +!mat11 ! +! ! +!ext16ca ! +! ! +!ext16cb ! +! ! +!ext16cc ! +! ! +!ext16cd ! +! ! +!ext16ce ! +! ! +!ext16cf ! +! ! +!ext16cg ! +! ! +!ext16ch ! +! ! +!ext1c ! +! ! +!som ! +! ! +!scilabdaxpy ! +! ! +!contrb ! +! ! +!foobar ! +! ! +!calc6a ! +! ! +!calc6b ! +! ! +!calc ! +! ! +!calc8 ! +! ! +!calc9 ! +shared archive loaded + +//Run Scilab functions: + +a=[1,2,3];b=[4,5,6]; + +c=ext1c(a,b); + +if norm(c-(a+b)) > %eps then bugmes();quit;end + + + +//Run Scilab functions: + +a=1:20;b=1:10; + +d=som(a=1:20,b=1:10); + +d1=ones(1,10) + a(1:10)+b(1:10); + +if norm(d-d1') > %eps then bugmes();quit;end; + + + + +//Run Scilab functions: + +n=3;a=13;incx=2;incy=3;x=1:10;y=2*x; + +ynew=scilabdaxpy(n,a,x,incx,y,incy); + +y(1:incy:n*incy)=y(1:incy:n*incy)+a*x(1:incx:n*incx); + +if norm(ynew-y) > %eps then bugmes();quit;end + + +//Run Scilab functions: + +sys=ssrand(2,2,3,list('co',1)); + +n=contrb(sys,0.01) + n = + + 1. + +if n <> 1 then bugmes();quit;end + + +//Run Scilab functions: + +a=1:5;b=-a;c=ones(3,3); + +[a,b,c,d]=foobar('mul',a,b,c) + d = + + 4. 6. 8. + 6. 8. 10. + 8. 10. 12. + c = + + 2. 2. 2. + 2. 2. 2. + 2. 2. 2. + b = + + - 2. - 4. - 6. - 8. - 10. + a = + + 2. 4. 6. 8. 10. + +[a,b,c,d]=foobar('add',a,b,c) + d = + + 6. 7. 8. + 7. 8. 9. + 8. 9. 10. + c = + + 4. 4. 4. + 4. 4. 4. + 4. 4. 4. + b = + + 0. - 2. - 4. - 6. - 8. + a = + + 4. 6. 8. 10. 12. + + + +w=['this' 'is'; 'naw' 'gaad'] + w = + +!this is ! +! ! +!naw gaad ! + +rep=calc6a(w); + +if rep<>['this' 'is'; 'now' 'good'] then bugmes();quit;end; + + +//calc5: creation of a character string matrix. + +a=calc6b(); + +a1='char '; a1=matrix(a1(ones(1,6))+string(0:5),3,2); + +if a<>a1 then bugmes();quit;end + + +//Run Scilab functions: + +if calc('one')<>1 then bugmes();quit;end + +if calc('two')<>2 then bugmes();quit;end + +if calc('other')<>-1 then bugmes();quit;end + + + +//calc8: matrix of integer type created by C function (malloc and free). + +a=calc8(); + +if norm(a - matrix(0:14,3,5)) > %eps then bugmes();quit;end + + +//calc7: function with two optional values, a string and a scilab variable. + +bb=33; //scilab optional variable + +[a,b,c,d]=calc9(10); + +if c<>'toto' then bugmes();quit;end + +if norm(d-[2,4,6,8])> %eps then bugmes();quit;end + +if b<>bb then bugmes();quit;end + + +//Test Scilab functions: + +// calc1: 3 matrix input variables and at most 3 output variables of + +// types double, real, int + +l=calc10(list(1,[2,3],[1,2;3,4])); + +if norm(l(1)-2) > %eps then bugmes();quit;end + +if norm(l(2)-([2,3]+[1,2])) > %eps then bugmes();quit;end + +if norm(l(3)-([1,2;3,4]+[1,3;2,4])) > %eps then bugmes();quit;end + + +//Run Scilab functions: + +a=[1,2,3]+%i*[4,5,6]; + +b=ext11c(a); + +if norm(b-([4,5,6]+%i*[1,2,3])) > %eps then bugmes();quit;end + + + +//Run Scilab functions: + +b=ccalc12(); + +if norm(b-(0:9)) > %eps then bugmes();quit;end + + +//Run Scilab functions: + +a=rand(2,3); + +b=ext13c(a); + +if norm(b- matrix(2*a,3,2)) > %eps then bugmes();quit;end + + +//Run Scilab functions: + +a=[0,0,1.23;0,2.32,0;3.45,0,0]; + +ai=[0,0,9;0,6,0;7,0,0]; + +spa=sparse(a); + +spai=sparse(a+%i*ai); + +// simple sparse argument + + +b=spt1(spa); +Row 1, 1 non zero elements +(1,3) -> 1.230000 +Row 2, 1 non zero elements +(2,2) -> 2.320000 +Row 3, 1 non zero elements +(3,1) -> 3.450000 + +if norm(full(b- spa)) > %eps then bugmes();quit;end + + +b=spt1(spai); +Row 1, 1 non zero elements +(1,3) -> 1.230000 +i9.000000 +Row 2, 1 non zero elements +(2,2) -> 2.320000 +i6.000000 +Row 3, 1 non zero elements +(3,1) -> 3.450000 +i7.000000 + +if norm(full(b- spai)) > %eps then bugmes();quit;end + + +// sparse argument + conversion to int + + +b=spt2(spa); +Row 1, 1 non zero elements +(1,3) -> 1 +Row 2, 1 non zero elements +(2,2) -> 2 +Row 3, 1 non zero elements +(3,1) -> 3 + +if norm(full(b- int(spa))) > %eps then bugmes();quit;end + + +b=spt2(spai); +Row 1, 1 non zero elements +(1,3) -> 1 +i9 +Row 2, 1 non zero elements +(2,2) -> 2 +i6 +Row 3, 1 non zero elements +(3,1) -> 3 +i7 + +if norm(full(b- int(spai))) > %eps then bugmes();quit;end + + +// sparse and return a sparse in a list + + +b=spt3(spa); +Row 1, 1 non zero elements +(1,3) -> 1.230000 +Row 2, 1 non zero elements +(2,2) -> 2.320000 +Row 3, 1 non zero elements +(3,1) -> 3.450000 + +if norm(full(b(1)- spa)) > %eps then bugmes();quit;end + + +b=spt3(spai); +Row 1, 1 non zero elements +(1,3) -> 1.230000 +i9.000000 +Row 2, 1 non zero elements +(2,2) -> 2.320000 +i6.000000 +Row 3, 1 non zero elements +(3,1) -> 3.450000 +i7.000000 + +if norm(full(b(1)- spai)) > %eps then bugmes();quit;end + + +// new sparse in intersci + + +b=spt4(spa); + +if norm(full(b- 2*spa)) > %eps then bugmes();quit;end + + +b=spt4(spai); + +if norm(full(b- 2*spai)) > %eps then bugmes();quit;end + + +// new sparse + conversion to int + + +b=spt5(spa); + +if norm(full(b- int(2*spa))) > %eps then bugmes();quit;end + + +b=spt5(spai); + +if norm(full(b- int(2*spai))) > %eps then bugmes();quit;end + + +// new sparse returned in a list + + +b=spt6(spa); + +if norm(full(b(1)- 2*spa)) > %eps then bugmes();quit;end + + +b=spt6(spai); + +if norm(full(b(1)- 2*spai)) > %eps then bugmes();quit;end + + +// list argument with a sparse + + +b=spt7(list(spa)); +Row 1, 1 non zero elements +(1,3) -> 1.230000 +Row 2, 1 non zero elements +(2,2) -> 2.320000 +Row 3, 1 non zero elements +(3,1) -> 3.450000 + +if norm(full(b- spa)) > %eps then bugmes();quit;end + + +b=spt7(list(spai)); +Row 1, 1 non zero elements +(1,3) -> 1.230000 +i9.000000 +Row 2, 1 non zero elements +(2,2) -> 2.320000 +i6.000000 +Row 3, 1 non zero elements +(3,1) -> 3.450000 +i7.000000 + +if norm(full(b- spai)) > %eps then bugmes();quit;end + + +// list argument + conversion + + +b=spt8(list(spa)); +Row 1, 1 non zero elements +(1,3) -> 1 +Row 2, 1 non zero elements +(2,2) -> 2 +Row 3, 1 non zero elements +(3,1) -> 3 + +if norm(full(b- int(spa))) > %eps then bugmes();quit;end + + +b=spt8(list(spai)); +Row 1, 1 non zero elements +(1,3) -> 1 +i9 +Row 2, 1 non zero elements +(2,2) -> 2 +i6 +Row 3, 1 non zero elements +(3,1) -> 3 +i7 + +if norm(full(b- int(spai))) > %eps then bugmes();quit;end + + +// list argument + list output + + +b=spt9(list(spa)); +Row 1, 1 non zero elements +(1,3) -> 1.230000 +Row 2, 1 non zero elements +(2,2) -> 2.320000 +Row 3, 1 non zero elements +(3,1) -> 3.450000 + +if norm(full(b(1)- spa)) > %eps then bugmes();quit;end + + +b=spt9(list(spai)); +Row 1, 1 non zero elements +(1,3) -> 1.230000 +i9.000000 +Row 2, 1 non zero elements +(2,2) -> 2.320000 +i6.000000 +Row 3, 1 non zero elements +(3,1) -> 3.450000 +i7.000000 + +if norm(full(b(1)- spai)) > %eps then bugmes();quit;end + + +b=spt10(spa); + +if norm(full(b- 2*spa)) > %eps then bugmes();quit;end + + + +//Run Scilab functions: + +a=[0,0,1.23;0,2.32,0;3.45,0,0]; + + +// simple matrix argument + + +b=mat1(a); + +if norm(b- a) > %eps then bugmes();quit;end + + +// matrix argument + conversion to int + + +b=mat2(a); + +if norm(b- int(a)) > %eps then bugmes();quit;end + + +// matrix and return a matrix in a list + + +b=mat3(a); + +if norm(b(1)- a) > %eps then bugmes();quit;end + + +// new matrix in intersci + + +b=mat4(a); + +if norm(b- 2*a) > %eps then bugmes();quit;end + + +// new matrix + conversion to int + + +b=mat5(a); + +if norm(b- int(2*a)) > %eps then bugmes();quit;end + + +// new matrix returned in a list + + +b=mat6(a); + +if norm(b(1)- 2*a) > %eps then bugmes();quit;end + + +// list argument with a matrix + + +b=mat7(list(a)); + +if norm(b- a) > %eps then bugmes();quit;end + + +// list argument + conversion + + +b=mat8(list(a)); + +if norm(b- int(a)) > %eps then bugmes();quit;end + + +// list argument + list output + + +b=mat9(list(a)); + +if norm(b(1)- a) > %eps then bugmes();quit;end + + +// cintf + + +b=mat10(); + +if norm(b'- (0:9)) > %eps then bugmes();quit;end + + +// cintf + list + + +b=mat11(); + +if norm(b(1)'- (0:9)) > %eps then bugmes();quit;end + + |