00001 import javasci.* ;
00002
00003
00004 class Exemple1 {
00005
00006 public static void main(String[] args) {
00007 int col=4;
00008 int row=2;
00009 int r,c;
00010 double [] b=new double[row*col];
00011
00012 SciDoubleArray a = new SciDoubleArray("A",row,col);
00013 Scilab.Exec("A=[1,2,3,4;5 6 7 8];");
00014 a.Get();
00015 System.out.println("----------------------------------------------------");
00016 a.disp();
00017 System.out.println("----------------------------------------------------");
00018 for(r=1;r<=a.getRow();r++)
00019 {
00020 for(c=1;c<=a.getCol();c++)
00021 {
00022 System.out.print("A("+(r)+","+(c)+")="+a.GetElement(r,c)+" ");
00023 }
00024 System.out.println(" ");
00025 }
00026 System.out.println("----------------------------------------------------");
00027
00028 b=a.getData();
00029
00030 for(r=0;r<row;r++)
00031 {
00032 for(c=0;c<col;c++)
00033 {
00034 System.out.print("b("+r+","+(c)+")="+ b[c*row+r] +" ");
00035 }
00036 System.out.println(" ");
00037 }
00038 System.out.println("----------------------------------------------------");
00039 SciDoubleArray d = new SciDoubleArray("D",1,4,new double [] {1,2,3,4});
00040 SciDoubleArray q = new SciDoubleArray("Q",3,1, new double [] {0,0,0} );
00041
00042 Scilab.Exec("Str='Scilab';");
00043 Scilab.Exec("P=poly(D','x','coeff');");
00044 Scilab.Exec("Q=real(roots(P));");
00045
00046 System.out.println("----------------------------------------------------");
00047
00048 System.out.println("----------------------------------------------------");
00049 Scilab.Exec("disp('Str : '+Str);");
00050 System.out.println("Q ScilabType : "+Scilab.TypeVar("Q"));
00051 System.out.println("Str ScilabType : "+Scilab.TypeVar("Str"));
00052 System.out.println("----------------------------------------------------");
00053 q.Get();
00054 q.disp();
00055 System.out.println("----------------------------------------------------");
00056 Scilab.Finish();
00057 }
00058 }
00059