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

Operation with complex numbers

Source code of Scilab function

function x=t5(a,b)
x=a+%i*b

Translation Procedure

-->lt5=list();
-->lt5(1)=list('1','m1','n1',0);
-->lt5(2)=list('1','m1','n1',0);

-->// show the initial data
-->printspecs(t5,lt5)
type and dimension of input parameters
---------------------------------------
| variable number | fortran type       |# rows     |# columns    |
|1                   |double precision |m1         |n1           |
|2                   |double precision |m1         |n1           |
-->//translate
-->txt=sci2for(t5,'t5',lt5);
Generated Fortran code
       subroutine t5(a,b,x_r,x_i,m1,n1)
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,n1
c      x(_r,_i)   : double precision variable of size m1,n1
c      m1         : integer variable
c      n1         : integer variable
c      work  : working array :
c              m1*n1+m1*n1
c!
       double precision a(m1,n1),b(m1,n1),x_r(m1,n1),x_i(m1,n1),work(*)
       integer m1,n1
c
       iw0 = 1
c
       iw1 = iw0+m1*n1
       call dcopy(m1*n1,b,1,work(iw-1),1)
       call dcopy(m1*n1,b,1,work(iw0),1)
       call dscal(m1*n1,0.0d0,work(iw-1),1)
       call dscal(m1*n1,1.0d0,work(iw0),1)
       call dcopy(m1*n1,a,1,x_r,1)
       call dadd(m1*n1,work(iw-1),1,x_r,1)
       call dcopy(m1*n1,work(iw0),1,x_i,1)
c
       return
c
       end


Scilab group