【发布时间】:2013-05-18 20:33:19
【问题描述】:
我对 Java 还是很陌生,我面临一个问题,我相信它可以很容易地掌握。
我正在生成一个链接到 Apache - Commons Math 库的项目。
在项目中,我使用了很多 RealMatrix 对象。我有一个方法如下
public static RealMatrix DistCalc(RealMatrix YCoord, RealMatrix ZCoord){
RealMatrix Distance = new Array2DRowRealMatrix(YCoord.getRowDimension(),ZCoord.getRowDimension());
for(int ii = 0; ii < YCoord.getRowDimension(); ii++){
for(int jj = 0; jj < ZCoord.getRowDimension(); jj++){
Distance.setEntry(ii,jj,Math.sqrt((YCoord.getEntry(ii, 0) - YCoord.getEntry(jj, 0))*(YCoord.getEntry(ii, 0) - YCoord.getEntry(jj, 0)) + (ZCoord.getEntry(jj, 0) - ZCoord.getEntry(ii, 0))*(ZCoord.getEntry(jj, 0) - ZCoord.getEntry(ii, 0))));
}
}
return Distance;
}
另一个生成某个Complex矩阵,
// Define the random phase for the u- component
public static Complex[][] RandPhi(int N, int nFFT){
Complex[][] nn_u = new Complex[N][nFFT];
for(int ii = 0; ii < N; ii++){
for(int jj = 0; jj < nFFT; jj++){
nn_u[ii][jj] = new Complex(Math.cos(new Random().nextDouble()*2*Math.PI),Math.sin(new Random().nextDouble()*2*Math.PI));
}
}
return nn_u;
}
现在,我想将RealMatrix 距离与Complex矩阵nn_u逐列相乘:最后我应该得出一个@ 987654328@矩阵。
你介意解释一下吗?
【问题讨论】:
标签: java eclipse apache-commons