00001 package javasci ;
00002
00003
00004
00005
00006 public class SciComplexArray implements java.io.Serializable
00007 {
00008
00009 private double [] x ;
00010 private double [] y ;
00011
00012 private int m, n;
00013
00014
00015
00016 private String name;
00017
00018 private static native void Initialize();
00023 private native int getRowFromScilab(String name);
00030 private native int getColFromScilab(String name);
00037 public native boolean Job(String job);
00042 public native void Get();
00047 public native void Send();
00052 public native double GetRealPartElement(int indr,int indc);
00060 public native double GetImaginaryPartElement(int indr,int indc);
00071
00072 static
00073 {
00074 System.loadLibrary("javasci");
00075 Initialize();
00076 }
00077
00078 public SciComplexArray(String name,SciComplexArray Obj)
00079 {
00080 this.name = name;
00081 this.m = Obj.getRow() ;
00082 this.n = Obj.getCol();
00083
00084 this.x = new double[m*n];
00085 this.x =Obj.getRealPartData() ;
00086
00087 this.y = new double[m*n];
00088 this.y =Obj.getImaginaryPartData() ;
00089
00090 Send();
00091 }
00092
00093 public SciComplexArray(String name,int r,int c)
00094 {
00095 this.m = r ;
00096 this.n = c ;
00097 this.x = new double[r*c];
00098 this.y = new double[r*c];
00099 this.name = name;
00100
00101 if ( (Scilab.TypeVar(name) == 1) &
00102 (getRowFromScilab(name) == r) &
00103 (getColFromScilab(name) == c) )
00104 {
00105 Get();
00106 }
00107 else
00108 {
00109 for ( int i = 0 ; i < r*c ; i++)
00110 {
00111 x[i]=0;
00112 y[i]=0;
00113 }
00114 Send();
00115 }
00116 }
00117
00118 public SciComplexArray(String name,int r,int c,double [] x,double [] y )
00119 {
00120 if ( (r*c != x.length) && (r*c != y.length) )
00121 {
00122 throw new BadDataArgumentException("Bad Matrix call, size of third argument is wrong");
00123 }
00124
00125 this.m = r ;
00126 this.n = c;
00127
00128 this.x = x;
00129 this.y = y;
00130
00131 this.name = name;
00132
00133 Send();
00134 }
00135
00136 public int getRow()
00137 {
00138 return m;
00139 }
00140
00141 public int getCol()
00142 {
00143 return n;
00144 }
00145
00146 public String getName()
00147 {
00148 return name;
00149 }
00150
00151 public double[] getRealPartData()
00152 {
00153 Get();
00154 return x;
00155 }
00156
00157 public double[] getImaginaryPartData()
00158 {
00159 Get();
00160 return y;
00161 }
00162
00163 public void disp()
00164 {
00165 Get();
00166 System.out.println("Matrix "+ getName() +"=");
00167 Job( "disp(" + getName() +");");
00168 }
00169 }
00170