Ejemplo n.º 1
0
 /**
  * testing main method
  *
  * @param args
  */
 public static void main(String[] args) {
   DoubleMatrix m = new DoubleMatrix(2, 3);
   m.setCell(0, 0, 2.0);
   m.setCell(0, 1, 1.0);
   m.setCell(0, 2, 32.0);
   m.setCell(1, 0, 1.0);
   m.setCell(1, 2, 9.0);
   GaussElim g = new GaussElim(m);
   g.run();
   g.mMat.print(System.out);
   System.out.println("all basic " + g.allBasicVariables());
   System.out.println("consistent " + g.isConsistent());
 }
Ejemplo n.º 2
0
  /** @return list of vectors spanning the solution set */
  public ArrayList<DoubleMatrix> getSolutionVectors() {
    ArrayList<DoubleMatrix> vecs = new ArrayList<DoubleMatrix>();

    for (int cCol = mPivots[0]; cCol < mMat.getColumns() - 1; ++cCol) {
      DoubleMatrix vec = new DoubleMatrix(mMat.getRows(), 1);
      for (int cRow = 0; cRow < mMat.getRows(); ++cRow) {
        if (mPivots[cRow] < cCol && !mMat.getCell(cRow, cCol).equals(0)) {
          double coeff = mMat.getCell(cRow, cCol);
          for (int cDim = 0; cDim < mMat.getRows(); ++cDim)
            vec.setCell(cDim, 0, vec.getCell(cDim, 0) + coeff * mOrig.getCell(cRow, cCol));
        }
      }
      if (!vec.equals(new DoubleMatrix(mMat.getRows(), 1))) vecs.add(vec);
    }

    return vecs;
  }
Ejemplo n.º 3
0
 /** @return the vector which translates the subspace of the solution set */
 public DoubleMatrix getTranslationVector() {
   DoubleMatrix trans = new DoubleMatrix(mMat.getRows(), 1);
   for (int cRow = 0; cRow < mMat.getRows(); ++cRow)
     trans.setCell(cRow, 0, mMat.getCell(cRow, mMat.getColumns() - 1));
   return trans;
 }