Java 类中的 RealMatrix 对象
看来我不能在我的类中使用这个 Apache Commons Math 库,因为当我尝试在我的构造函数中使用 RealMatrix 时,我在 matrixSim 上得到了意外的标记,如下所示:
class vecGenUn
{
double[][] prevMat;
RealMatrix matrixSim; //this is problematic
int dataDim;
int rowDim;
double simVecMean;
double simVecSD;
double simVecUn;
double sum;
vecGenUn (double[][] tempPM)
{
prevMat = tempSM;
matrixSim = new Array2DRowRealMatrix(prevMat); //and possibly this
dataDim = new int matrixSim.getColumnDimension();
rowDim = new int matrixSim.getRowDimension();
simVecMean = new double[dataDim];
simVecSD = new double[dataDim];
simVecUn = new double[dataDim];
sum = new Sum();
}
public void vecGen()
{
for (int i = 0; i < dataDim; i++)
{
simVecMean[i] = sum.evaluate(matrixSim.getColumn(i), 0, rowDim)/rowDim
}
}
}
现在方法尚未实现,但如何使用 RealMatrix 数据类型当我需要它用于所有 Appache 数学库方法时,但我还需要根据创建此类实例时提供的值(双精度数组)来构造它。
It seems that I can`t use this Apache Commons Math library in my class because I get unexpected token on matrixSim when I try to use RealMatrix in my consructor like this:
class vecGenUn
{
double[][] prevMat;
RealMatrix matrixSim; //this is problematic
int dataDim;
int rowDim;
double simVecMean;
double simVecSD;
double simVecUn;
double sum;
vecGenUn (double[][] tempPM)
{
prevMat = tempSM;
matrixSim = new Array2DRowRealMatrix(prevMat); //and possibly this
dataDim = new int matrixSim.getColumnDimension();
rowDim = new int matrixSim.getRowDimension();
simVecMean = new double[dataDim];
simVecSD = new double[dataDim];
simVecUn = new double[dataDim];
sum = new Sum();
}
public void vecGen()
{
for (int i = 0; i < dataDim; i++)
{
simVecMean[i] = sum.evaluate(matrixSim.getColumn(i), 0, rowDim)/rowDim
}
}
}
Now methods are yet to be implemented but how do I use RealMatrix data type here when I need it for all Appache math library methods but also I need to construct it from values (double array) supplied when creating this class instance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在提供的代码中,您遇到了与 Apache Commons Math 无关的各种编译器错误。在尝试确定该库是否有问题之前修复这些问题。
更正意见内嵌标有(*):
In the code provided, you have all sorts of compiler errors unrelated to Apache Commons Math. Fix those before trying to determine if you have problems with that library.
Correction comments are in-line marked with (*):