next up previous
Next: Call of simple primitives Up: Scilab to Fortran translator Previous: Matrix concatenation

Concatenations and inversions

Source code of Scilab function:

function x=t3(a,b,c,d)
x=[a;c]/[a b;c d]*3.5

Translation procedure

-->lt3=list();
-->lt3(1)=list('1','m1','n1');
-->lt3(2)=list('1','m1','n2');
-->lt3(3)=list('1','m2','n1');
-->lt3(4)=list('1','m2','n2');

-->// show the initial data
-->printspecs(t3,lt3)
type and dimension of input parameters
---------------------------------------
| variable number    | fortran type    |# rows     |# columns  |
|1                   |double precision |m1         |n1           |
|2                   |double precision |m1         |n2           |
|3                   |double precision |m2         |n1           |
|4                   |double precision |m2         |n2           |
-->//translate
-->txt=sci2for(t3,'t3',lt3);
Generated Fortran code
       subroutine t3(a,b,c,d,x,m1,n1,n2,m2,work,iwork,ierr)
c!
c automatic translation
c
c!     calling sequence
c      ----------------
c
c      a          : double precision variable of size m1,n1
c      b          : double precision variable of size m1,n2
c      c          : double precision variable of size m2,n1
c      d          : double precision variable of size m2,n2
c      x          : double precision variable of size m1+m2,n1
c      m1         : integer variable
c      n1         : integer variable
c      n2         : integer variable
c      m2         : integer variable
c      work  : working array :
c              (m1+m2)*n1+(m1+m2)*(n1+n2)+(m1+m2)*(n1+n2)+(m1+m2)*(m1+m2
c              )+m1+m2
c      iwork : working array :
c              m1+m2
c      ierr : error
c             0 :  correct run
c             1 : singular work(iw0) matrix
c!
       double precision a(m1,n1),b(m1,n2),c(m2,n1),d(m2,n2),x(m1+m2,n1),
     & work(*)
       integer m1,n1,n2,m2,iwork(*)
c
       iw0 = 1
       iiw0 = 1
c
       iw0 = iw+(m1+m2)*n1-1
       call dmcopy(a,n1,work(iw-1+1),m1+m2,n1,m1)
       call dmcopy(c,n1,work(iw-1+m1+1),m1+m2,n1,m2)
       iw1 = iw0+(m1+m2)*(n1+n2)
       call dmcopy(a,n1,work(iw0+1),m1+m2,n1,m1)
       call dmcopy(b,n2,work(iw0+n1*(m1+m2)+1),m1+m2,n2,m1)
       call dmcopy(c,n1,work(iw0+m1+1),m1+m2,n1,m2)
       call dmcopy(d,n2,work(iw0+n1*(m1+m2)+m1+1),m1+m2,n2,m2)
       iw2 = iw1+(m1+m2)*(n1+n2)
       iw3 = iw2+(m1+m2)*(m1+m2)
       iw4 = iw3+m1+m2
       call dcopy((m1+m2)*(n1+n2),work(iw0),1,work(iw2),1)
       call dgefa(work(iw2),m1+m2,n1+n2,iwork(iiw-1),ierr)
       if(ierr.ne.0) then
          ierr=1
          return
       endif
       call dgesl(work(iw2),m1+m2,n1+n2,iwork(iiw-1),work(iw1),0)
       call dcopy((m1+m2)*n1,work(iw1),1,x,1)
       call dscal((m1+m2)*n1,3.5,x,1)
c
       return
c
       end


Scilab group