SciDoubleArray.java

Go to the documentation of this file.
00001 package javasci ;
00002 /********************************************************************************************************/
00003 /* Allan CORNET */
00004 /* INRIA 2005 */
00005 /********************************************************************************************************/
00006 public class SciDoubleArray implements java.io.Serializable  
00007 {
00008 /********************************************************************************************************/
00009   private double [] x ;
00010   
00011   private int m, n;
00012   /* m number of rows */
00013   /* n number of colons */
00014   
00015   private String name; 
00016 /********************************************************************************************************/
00017   private static native void Initialize();
00022   private native int getRowFromScilab(String name);
00029   private native int getColFromScilab(String name);
00036   public native boolean Job(String job);
00041   public native void Get();
00046   public native void Send();
00051   public native double GetElement(int indr, int indc);
00063 /********************************************************************************************************/  
00064   static 
00065   {
00066     System.loadLibrary("javasci");
00067     Initialize();
00068   }
00069 /********************************************************************************************************/  
00070   public SciDoubleArray(String name,SciDoubleArray Obj) 
00071   {
00072     this.name = name;
00073     this.m = Obj.getRow() ;
00074     this.n = Obj.getCol();
00075     this.x = new double[m*n];
00076    
00077     this.x =Obj.getData() ;
00078     Send();
00079   }
00080 /********************************************************************************************************/  
00081   public SciDoubleArray(String name,int r,int c) 
00082   {
00083     this.m = r ;
00084     this.n = c ;
00085     this.x = new double[r*c];
00086     this.name = name;
00087     
00088     if ( (Scilab.TypeVar(name) == 1) & 
00089          (getRowFromScilab(name) == r) & 
00090          (getColFromScilab(name) == c) )
00091     {
00092                 Get();
00093     }
00094     else
00095     {
00096         for ( int i = 0 ; i < r*c ; i++)x[i]=0;
00097         Send();
00098     }
00099   }
00100  /********************************************************************************************************/  
00101   public SciDoubleArray(String name,int r,int c,double [] x )
00102   {
00103     if ( r*c != x.length) 
00104     {
00105      throw new BadDataArgumentException("Bad Matrix call, size of third argument is wrong");
00106     }
00107     this.m = r ;
00108     this.n = c;
00109     this.x = x;
00110     this.name = name;
00111     Send();
00112   }
00113 /********************************************************************************************************/
00114   public int getRow() 
00115   {
00116    return m;
00117   }
00118 /********************************************************************************************************/  
00119   public int getCol() 
00120   {
00121    return n;
00122   }
00123 /********************************************************************************************************/  
00124   public String getName()
00125   {
00126    return name;
00127   }
00128 /********************************************************************************************************/  
00129   public double[] getData() 
00130   {
00131    Get();
00132    return x;
00133   }
00134 /********************************************************************************************************/  
00135   public void disp() 
00136   {
00137         Get();
00138     System.out.println("Matrix "+ getName() +"=");
00139     Job( "disp(" + getName() +");");
00140   }
00141 }
00142 /********************************************************************************************************/

Generated on Sun Mar 4 15:03:58 2007 for Scilab [trunk] by  doxygen 1.5.1