/** {@inheritDoc} */ public double getLInfDistance(RealVector v) throws IllegalArgumentException { checkVectorDimensions(v.getDimension()); if (v instanceof OpenMapRealVector) { return getLInfDistance((OpenMapRealVector) v); } return getLInfDistance(v.getData()); }
/** {@inheritDoc} */ public OpenMapRealVector add(RealVector v) throws IllegalArgumentException { checkVectorDimensions(v.getDimension()); if (v instanceof OpenMapRealVector) { return add((OpenMapRealVector) v); } return add(v.getData()); }
/** {@inheritDoc} */ public RealVector solve(RealVector b) throws IllegalArgumentException, InvalidMatrixException { try { return solve((RealVectorImpl) b); } catch (ClassCastException cce) { final int m = lTData.length; if (b.getDimension() != m) { throw MathRuntimeException.createIllegalArgumentException( "vector length mismatch: got {0} but expected {1}", b.getDimension(), m); } final double[] x = b.getData(); // Solve LY = b for (int j = 0; j < m; j++) { final double[] lJ = lTData[j]; x[j] /= lJ[j]; final double xJ = x[j]; for (int i = j + 1; i < m; i++) { x[i] -= xJ * lJ[i]; } } // Solve LTX = Y for (int j = m - 1; j >= 0; j--) { x[j] /= lTData[j][j]; final double xJ = x[j]; for (int i = 0; i < j; i++) { x[i] -= xJ * lTData[i][j]; } } return new RealVectorImpl(x, false); } }
public static void main(String[] args) { RealMatrix coefficients2 = new Array2DRowRealMatrix( new double[][] { {0.0D, 1.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D}, {0.0D, 0.0D, 0.857D, 0.0D, 0.054D, 0.018D, 0.0D, 0.071D, 0.0D, 0.0D, 0.0D}, {0.0D, 0.0D, 0.0D, 1.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D}, {0.0D, 0.0D, 0.857D, 0.0D, 0.054D, 0.018D, 0.0D, 0.071D, 0.0D, 0.0D, 0.0D}, {0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 1.0D, 0.0D, 0.0D, 0.0D, 0.0D}, {0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 1.0D, 0.0D, 0.0D, 0.0D, 0.0D}, {0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 1.0D, 0.0D, 0.0D}, {0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.6D, 0.4D}, {0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 1.0D}, {0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 1.0D, 0.0D, 0.0D, 1.0D}, {0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D} }, false); for (int i = 0; i < 11; i++) { coefficients2.setEntry(i, i, -1d); } coefficients2 = coefficients2.transpose(); DecompositionSolver solver = new LUDecompositionImpl(coefficients2).getSolver(); System.out.println("1 method my Value :"); RealVector constants = new ArrayRealVector(new double[] {-1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, false); RealVector solution = solver.solve(constants); double[] data = solution.getData(); DecimalFormat df = new DecimalFormat(); df.setRoundingMode(RoundingMode.DOWN); System.out.println("Корни уравнения:"); for (double dd : data) { System.out.print(df.format(dd) + " "); } System.out.println(); System.out.println( "Среднее число процессорных операций, выполняемых при одном прогоне алгоритма: " + operationsByProcess(data, arr)); System.out.println("Среднее число обращений к файлам:"); for (int i = 1; i < 4; i++) { System.out.println(" Файл " + i + " : " + fileMiddleRequest(data, arr, i)); } System.out.println("Среднее количество информации передаваемой при одном обращении к файлам:"); for (int i = 1; i < 4; i++) { System.out.println(" Файл " + i + " : " + bitsPerFileTransfer(data, arr, i)); } System.out.println( "Сумма среднего числа обращений к основным операторам: " + operatorExecute(data, arr)); System.out.println("Средняя трудоемкость этапа: " + middleWork(data, arr)); }
/** {@inheritDoc} */ public OpenMapRealVector append(RealVector v) { if (v instanceof OpenMapRealVector) { return append((OpenMapRealVector) v); } return append(v.getData()); }
/** {@inheritDoc} */ public void setSubVector(int index, RealVector v) throws MatrixIndexException { checkIndex(index); checkIndex(index + v.getDimension() - 1); setSubVector(index, v.getData()); }