Exemplo n.º 1
0
 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));
 }
Exemplo n.º 2
0
 private static Intersection getIntersection(
     TriangleObject obj, DecompositionSolver solver, Vector3D p, Vector3D pc, double[] params) {
   RealVector constants = new ArrayRealVector(params, false);
   RealVector solution = solver.solve(constants);
   double alpfa = solution.getEntry(0);
   double beta = solution.getEntry(1);
   boolean match = false;
   if (alpfa >= 0 && beta >= 0 && alpfa + beta <= 1.0) {
     match = true;
   } else {
     match = false;
   }
   final Intersection intersection = new Intersection(match);
   intersection.setObject(obj);
   intersection.setP(p);
   return intersection;
 }