本文整理匯總了Java中org.ejml.factory.SingularMatrixException類的典型用法代碼示例。如果您正苦於以下問題:Java SingularMatrixException類的具體用法?Java SingularMatrixException怎麽用?Java SingularMatrixException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SingularMatrixException類屬於org.ejml.factory包,在下文中一共展示了SingularMatrixException類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getCrossXY
import org.ejml.factory.SingularMatrixException; //導入依賴的package包/類
public static List<Double> getCrossXY(double a1, double b1, double a2, double b2) {
// maximum line: y = a1 * x + b1
// minimum line: y = a2 * x + b2
try {
final SimpleMatrix A = new SimpleMatrix(2, 2);
A.set(0, 0, a1);
A.set(1, 0, a2);
A.set(0, 1, -1);
A.set(1, 1, -1);
final SimpleMatrix b = new SimpleMatrix(2, 1);
b.set(0, 0, -b1);
b.set(1, 0, -b2);
final SimpleMatrix x = A.solve(b);
final ArrayList<Double> result = new ArrayList<>();
result.add(x.get(0, 0));
result.add(x.get(1, 0));
return result;
} catch (SingularMatrixException sme) {
return Arrays.asList(new Double[] { Double.NaN, Double.NaN });
}
}
示例2: calculateSignalWithMatrix
import org.ejml.factory.SingularMatrixException; //導入依賴的package包/類
private void calculateSignalWithMatrix(Day day) throws BadSignalException {
try {
final SimpleMatrix A = new SimpleMatrix(2, 2);
A.set(0, 0, sumXX);
A.set(1, 0, sumX);
A.set(0, 1, sumX);
A.set(1, 1, y.size());
final SimpleMatrix b = new SimpleMatrix(2, 1);
b.set(0, 0, sumXY);
b.set(1, 0, sumY);
final SimpleMatrix x = A.solve(b);
final ListOfDoubleSignal signal = new ListOfDoubleSignal();
signal.add(x.get(1, 0));
signal.add(x.get(0, 0));
addSignal(day.getDate(), signal);
} catch (SingularMatrixException sme) {
setParallelXsignal(day);
}
}
示例3: calculateSignal
import org.ejml.factory.SingularMatrixException; //導入依賴的package包/類
private void calculateSignal(Day day) throws BadSignalException {
double sumXXXX = 0.0;
double sumXXX = 0.0;
double sumXX = 0.0;
double sumXXY = 0.0;
double sumX = 0.0;
double sumXY = 0.0;
double sumY = 0.0;
double xV = Math.max(0.0, currentX - N + 1);
for (Double yV : y) {
sumXXXX += Math.pow(xV, 4);
sumXXX += Math.pow(xV, 3);
sumXX += Math.pow(xV, 2);
sumX += Math.pow(xV, 1);
sumXXY += Math.pow(xV, 2) * yV;
sumXY += xV * yV;
sumY += yV;
xV += 1;
}
try {
final SimpleMatrix A = new SimpleMatrix(3, 3);
A.set(0, 0, sumXXXX);
A.set(0, 1, sumXXX);
A.set(0, 2, sumXX);
A.set(1, 0, sumXXX);
A.set(1, 1, sumXX);
A.set(1, 2, sumX);
A.set(2, 0, sumXX);
A.set(2, 1, sumX);
A.set(2, 2, y.size());
final SimpleMatrix b = new SimpleMatrix(3, 1);
b.set(0, 0, sumXXY);
b.set(1, 0, sumXY);
b.set(2, 0, sumY);
final SimpleMatrix x = A.solve(b);
final ListOfDoubleSignal signal = new ListOfDoubleSignal();
signal.add(x.get(2, 0));
signal.add(x.get(1, 0));
signal.add(x.get(0, 0));
addSignal(day.getDate(), signal);
} catch (SingularMatrixException sme) {
setParallelXsignal(day);
}
}