*** empty log message ***
Serge Steer [Thu, 26 Apr 2001 15:09:10 +0000 (15:09 +0000)]
16 files changed:
scilab/config/Makefile.aix
scilab/macros/elem/Makefile
scilab/macros/mtlb/%cell_e.sci [new file with mode: 0755]
scilab/macros/mtlb/%cell_p.sci [new file with mode: 0755]
scilab/macros/mtlb/%cell_size.sci [new file with mode: 0755]
scilab/macros/mtlb/%s_i_cell.sci [new file with mode: 0755]
scilab/macros/mtlb/%struct_p.sci [new file with mode: 0755]
scilab/macros/mtlb/Makefile
scilab/macros/mtlb/cell.sci [new file with mode: 0644]
scilab/macros/mtlb/struct.sci
scilab/macros/optim/karmarkar.sci
scilab/macros/signal/chepol.sci
scilab/macros/util/Makefile
scilab/macros/util/sci2excel.sci [new file with mode: 0644]
scilab/routines/system/macro.f
scilab/routines/system/stackp.f

index acc9a58..e4b2e6e 100755 (executable)
@@ -1,4 +1,3 @@
-# Generated automatically from Makefile.aix.in by configure.
 # Copyright INRIA
 LLD = ld -bh:4 -T512 -H512 -o /tmp/scilex-1 -bnodelcsect /lib/crt0.o
 LLD1 = ld -bh:4 -T512 -H512 -o $@ -bnodelcsect -bE:bin/scilex.exp /lib/crt0.o
@@ -15,7 +14,7 @@ bin/scilex: scilex-lib
                $(RM) /tmp/scilex-1;\
                $(LLD) $(DEFAULTS) $(LIBR) $(LD_LDFLAGS) $(TCLTK_LIBS) \
                        $(XLIBS) $(TERMCAPLIB) $(LLDLF);\
-               (echo "#!$(SCIDIR)/bin/scilex"; /usr/bin/nm -B -gp /tmp/scilex-1\
+               (echo "#!$(SCIDIR)/bin/scilex"; $(NM) -gp /tmp/scilex-1\
                        | sed -n -e '/.* T \./s///p' -e '/.* [DB] /s///p' \
                        | sort -u) > bin/scilex.exp ;\
                $(RM) /tmp/scilex-1 ;\
index e665072..8da9f27 100644 (file)
@@ -23,6 +23,7 @@ MACROS = acos.sci acosm.sci acosh.sci acoshm.sci asin.sci asinm.sci \
        speye.sci spzeros.sci sprand.sci spones.sci \
        intsplin.sci inttrap.sci GLoad.sci \
        isinf.sci isnan.sci median.sci mean.sci st_deviation.sci\
-       lex_sort.sci unique.sci union.sci setdiff.sci intersect.sci
+       lex_sort.sci unique.sci union.sci setdiff.sci intersect.sci \
+       isempty.sci
 
 include ../Make.lib
diff --git a/scilab/macros/mtlb/%cell_e.sci b/scilab/macros/mtlb/%cell_e.sci
new file mode 100755 (executable)
index 0000000..6afcd6f
--- /dev/null
@@ -0,0 +1,54 @@
+function M=%cell_e(varargin)
+// Copyright INRIA
+//extract an sub_cell
+[lhs,rhs]=argn(0)
+M=varargin(rhs)
+dims=M('dims')
+//v=M('entries')(:)
+
+
+if rhs-1>size(dims,'*') then
+  error('Too many subscripts')
+end
+dims1=[]
+I=0
+
+for k=rhs-1:-1:1
+  ik=varargin(k)
+  if type(ik)==2 |type(ik)==129 then // size implicit subscript $...
+    ik=horner(ik,dims(k)) // explicit subscript
+  elseif type(ik)==4 then // boolean subscript
+    ik=find(ik)
+  elseif mini(size(ik))<0 then // :
+    if rhs==2 then
+      M=M('entries')(:)
+      return
+    end
+    ik=1:dims(k)
+    if k==rhs-1 then
+      if k<size(dims,'*') then
+       ik=1:prod(dims(k:$))
+      end
+    end
+  end
+  dims1=[size(ik,'*');dims1]
+  if size(ik,'*')>1 then
+    ik=ik(:)
+    if size(I,'*')>1 then
+      I=(dims(k)*I).*.ones(ik)+ones(I).*.(ik-1)
+    else
+      I=dims(k)*I+ik-1
+    end
+  else
+    I=dims(k)*I+ik-1
+  end
+end
+//
+//dims1(max(find(dims1>1))+1:$)=[]
+//while  dims1($)==1 then dims1($)=[],end
+
+v=list()
+for k=1:size(I,'*'),v(k)=M('entries')(I(k)+1),end
+M=mlist(['cell','dims','entries'],dims1,v)
+
+endfunction
diff --git a/scilab/macros/mtlb/%cell_p.sci b/scilab/macros/mtlb/%cell_p.sci
new file mode 100755 (executable)
index 0000000..281990e
--- /dev/null
@@ -0,0 +1,20 @@
+function %cell_p(c)
+str=[]
+val=c.entries
+dims=c.dims;  
+for k=1:size(val)
+ sz=size(val(k))
+ tp=typeof(val(k))
+ if prod(sz)==0 then 
+   str(k)='[]'
+ else
+   str(k)='['+strcat(string(sz),'x')+' '+tp+']'
+ end
+end
+if size(dims,'*')>2 then
+  str=hypermat(dims,str)
+else
+  str=matrix(str,dims(1),-1)
+end
+disp(str)
+endfunction
diff --git a/scilab/macros/mtlb/%cell_size.sci b/scilab/macros/mtlb/%cell_size.sci
new file mode 100755 (executable)
index 0000000..94e59d2
--- /dev/null
@@ -0,0 +1,9 @@
+function varargout=%cell_size(c)
+sz=matrix(c.dims,1,-1)
+if argn(1)==1 then 
+  varargout=list(sz)
+else
+  varargout=list()
+  for k=1:argn(1),varargout(k)=sz(k),end
+end
+endfunction
diff --git a/scilab/macros/mtlb/%s_i_cell.sci b/scilab/macros/mtlb/%s_i_cell.sci
new file mode 100755 (executable)
index 0000000..ee422d9
--- /dev/null
@@ -0,0 +1,94 @@
+function M=%s_i_cell(varargin)
+// Copyright INRIA
+//insertion of a matrix in an hypermatrix
+[lhs,rhs]=argn(0)
+M=varargin(rhs)
+N=varargin(rhs-1)//inserted matrix
+dims=M('dims')(:);
+
+v=M('entries');
+
+ndims=rhs-2
+nd=size(dims,'*')
+if ndims>nd then dims(nd+1:ndims)=0;end  
+del=prod(dims)==0;count=[]
+dims1=[]
+I=0;I1=0
+for k=ndims:-1:1
+  ik=varargin(k)//the kth subscript
+  if type(ik)==2 |type(ik)==129 then // size implicit subscript $...
+    ik=horner(ik,dims(k)) // explicit subscript
+    dims1(k,1)=max(max(ik),dims(k))
+  elseif type(ik)==4 then // boolean subscript
+    ik=find(ik)
+    dims1(k,1)=max(max(ik),dims(k))
+  elseif mini(size(ik))<0 then // :
+    ik=1:dims(k)
+    dims1(k,1)=max(max(ik),dims(k))
+    if k==ndims then
+      if k<nd then
+       ik=1:prod(dims(k:$))
+       dims1(k:nd,1)=dims(k:nd)
+      end
+    end
+  else
+    dims1(k,1)=max(max(ik),dims(k))
+  end
+  if size(ik,'*')>1 then
+    ik=ik(:)
+    if size(I,'*')>1 then
+      I=(dims1(k)*I).*.ones(ik)+ones(I).*.(ik-1)
+    else
+      I=dims1(k)*I+ik-1
+    end
+  else
+    I=dims1(k)*I+ik-1
+  end
+  if del then
+    if or(ik<>(1:dims1(k))') then
+      count=[count k]
+      nk=size(ik,'*')
+    end
+  end
+end
+if del then
+  for iw=size(I,'*'):-1:1
+    v(I(iw)+1)=null();
+  end
+else
+  if or(dims1>dims) then
+    I1=0
+    for k=size(dims1,'*'):-1:1
+      ik1=(1:dims(k))'
+      if ik1<>[] then
+       if dims1(k)>1 then
+         if size(I1,'*')>1 then
+           I1=(dims1(k)*I1).*.ones(ik1)+ones(I1).*.(ik1-1)
+         else
+           I1=dims1(k)*I1+ik1-1
+         end
+       else
+         I1=dims1(k)*I1+ik1-1
+       end
+      end
+    end
+    v1=list();for iw=1:prod(dims1),v1(iw)=[],end
+    for iw=1:size(I1,'*')
+      v1(I1(iw)+1)=v(iw);
+    end
+    v=v1
+  end
+  v(I+1)=N
+end
+
+if del then
+  if size(count,'*')>1 then
+    error('A null assignment can have only one non-colon index')
+  end
+  dims1(count)=dims1(count)-nk
+end
+
+while  dims1($)==1 then dims1($)=[],end
+M=mlist(['cell','dims','entries'],dims1,v)
+
+endfunction
diff --git a/scilab/macros/mtlb/%struct_p.sci b/scilab/macros/mtlb/%struct_p.sci
new file mode 100755 (executable)
index 0000000..a7d2d6d
--- /dev/null
@@ -0,0 +1,16 @@
+function %struct_p(s)
+f=getfield(1,s)
+ll=lines()
+for k=2:size(f,'*')
+  var=f(k)
+  value=s(var)
+  str=sci2exp(value,ll(1))
+  txt='   '+var+': '
+  if size(str,'*')==1 then
+    txt=txt+str
+  else
+    tp=typeof(value)
+    txt=txt+'['+strcat(string(size(value)),'x')+' '+tp+']'
+  end
+  write(%io(2),txt,'(a)')
+end
index e85193b..3250c4e 100644 (file)
@@ -32,7 +32,8 @@ MTLB = mtlb.sci mtlb_e.sci mtlb_i.sci mtlb_is.sci mtlb_eval.sci \
 
 M5 = mtlb_cell.sci struct.sci  \
        %s_i_struct.sci %b_i_struct.sci %i_i_struct.sci %sp_i_struct.sci \
-       %c_i_struct.sci    %s_i_struct.sci
+       %c_i_struct.sci %s_i_struct.sci %struct_p.sci\
+        %cell_e.sci %cell_p.sci %cell_size.sci %s_i_cell.sci cell.sci 
 
 
 MACROS =$(MTLB) $(M5)
diff --git a/scilab/macros/mtlb/cell.sci b/scilab/macros/mtlb/cell.sci
new file mode 100644 (file)
index 0000000..769d7cf
--- /dev/null
@@ -0,0 +1,5 @@
+function c=cell(varargin)
+  dims=[] ;for k=1:size(varargin),dims(k)=varargin(k),end
+  val=list() ;for k=1:prod(dims),val(k)=[],end
+  c=mlist(['cell','dims','entries'],dims,val)
+endfunction
index 6c91029..c055c24 100644 (file)
@@ -1,2 +1,15 @@
-function s=struct()
-s=mlist('struct')
+function %struct_p(s)
+f=getfield(1,s)
+ll=lines()
+for k=2:size(f,'*')
+  var=f(k)
+  value=f(var)
+  str=sci2exp(value,ll(1))
+  txt='   '+var+': '
+  if size(str,'*')==1 then
+    txt=txt+str
+  else
+    tp=typeof(value)
+    txt=txt+'['+strcat(string(size(value)),'x')+' '+tp+']'
+  end
+end
index 1935ddc..b50ee4b 100644 (file)
@@ -32,7 +32,7 @@ count=0
 while test>eps&count<=maxiter
     count=count+1;
 //    ax=a*diag(x1);
-    ax=a.*(ones(size(a),1)*x1');
+    ax=a.*(ones(size(a,1),1)*x1');
     xc=x1.*c;
     y=ax'\xc;
 //    y=(ax*ax')\(ax*xc)
@@ -45,3 +45,4 @@ while test>eps&count<=maxiter
     crit=tc*x1;
     write(%io(2),[count,crit,test],'(f3.0,3x,e10.3,3x,e10.3)')
 end
+  
index af9993e..5f6159e 100644 (file)
@@ -1,5 +1,5 @@
-function [Tn]=chepol(n,var)
-//Recursive implementation of Chebychev polynomial
+function Tn=chepol(n,var)
+//Chebychev polynomial
 //  n   :Polynomial order
 //  var :Polynomial variable (character string)
 //  Tn  :Polynomial in var
@@ -7,18 +7,17 @@ function [Tn]=chepol(n,var)
 //!
 //Author F.D.
 // Copyright INRIA
-T1=poly(0,var);
-T0=1+0*T1;
-if n==0 then,
-      Tn=T0,
-      return,
-end,
-if n==1 then,
-      Tn=T1,
-      return,
-end,
-if n>1 then,
-      Tn=2*poly(0,var)*chepol(n-1,var)-chepol(n-2,var),
+if n==0 then
+  Tn=poly(1,var,'coeff'),
+elseif n==1 then
+  Tn=poly(0,var);
+else
+  T0=poly(1,var,'coeff');
+  T1=poly(0,var)
+  for k=2:n
+    Tn=2*poly(0,var)*T1-T0
+    [T1,T0]=(Tn,T1);
+  end
 end
     
 
index d86e568..ecd7c24 100644 (file)
@@ -46,6 +46,6 @@ MACROS = sysconv.sci readc_.sci lin.sci halt.sci bloc2exp.sci \
        get_absolute_file_path.sci get_function_path.sci\
        %c_mclose.sci mputl.sci dispfiles.sci fun2string.sci %cblock_p.sci\
        profile.sci get_profile.sci showprofile.sci plotprofile.sci \
-       ilib_for_link.sci ilib_unix_soname.sci scitest.sci
+       ilib_for_link.sci ilib_unix_soname.sci scitest.sci sci2excel.sci
 
 include ../Make.lib
diff --git a/scilab/macros/util/sci2excel.sci b/scilab/macros/util/sci2excel.sci
new file mode 100644 (file)
index 0000000..89b4460
--- /dev/null
@@ -0,0 +1,20 @@
+function sci2excel(var,fname,sep,dec)
+// var : a matrix of numbers or a matrix of strings
+// fname : a character string, the path of the file to create
+// sep   : the column separator mark, a tab by default
+// dec   : the decimal mark . or ,
+// Example
+// a=rand(3,5);
+// sci2excel(a,'/tmp/foo.txt',sep=',')
+if exists('sep','local')==0 then sep=code2str(-40),end
+if exists('dec','local')==0 then dec=',',end
+if dec<>['.',','] then error('decimal mark must be ''.'' or '','''),end
+if type(var)==1 then
+  var=string(var)
+  if dec<>'.' then var =strsubst(var,'.',','),end
+end
+t=var(:,1)
+for k=2:size(var,2)
+  t=t+sep+var(:,k)
+end
+mputl(t,fname)
index a3db534..ded29a9 100644 (file)
@@ -196,6 +196,8 @@ c     and not 0
          endif
       endif
 c     
+      ids(6,pt)=toperr
+
       toperr=top
       if(istk(ilk).eq.13) then
          lct(8)=1
@@ -217,13 +219,14 @@ c
 c     fin de l'execution d'une macro
 c-----------------------------------
 c     handle errcatch
-      if(errct.ne.0.and.errpt.ge.pt.and.rstk(pt-1).ne.903) then
+      exec=rstk(pt-1).eq.909.or.rstk(pt-1).eq.903
+      if(errct.ne.0.and.errpt.ge.pt.and..not.exec) then
          errct=0
          errpt=0
          err1=0
          err2=0
       endif
-      exec=rstk(pt-1).eq.909.or.rstk(pt-1).eq.903
+
 c     restaure  pointers
       k = lpt(1) - (13+nsiz)
       ilk=lin(k+6)
@@ -237,6 +240,8 @@ c
       lhs=ids(2,pt)
       lct(4)=pstk(pt)
       vargout=ids(4,pt).eq.1
+      toperr=ids(6,pt)
+
 c     
       if(comp(1).ne.0) then
          comp(2)=comp(1)
index c72778f..8132b39 100644 (file)
@@ -140,7 +140,7 @@ c     .        it not the same
  19            call  putid(ids(1,pt+1),id)
                if(macprt.eq.2) then  
                   call error(111)
-                  if(err.gt.0) return
+                  return
                elseif(macprt.eq.1) then  
                   call msgs(42,vt)
                endif
@@ -196,7 +196,7 @@ c     create new variable
             if(macprt.eq.2) then
                call putid(ids(1,pt+1),id)
                call  error(111)
-               if(err.gt.0) return
+               return
             elseif(macprt.eq.1) then
                call putid(ids(1,pt+1),id)
                call msgs(42,vt)