Commit efc9425e authored by Jeannie Backer's avatar Jeannie Backer
Browse files

Removed unused bool CholeskyUT_NOSQR(); methods from BundleAdjust.

git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/branches/ipce@7037 41f8697f-d340-4b68-9986-7bafba869bb8
parent f05bb3a1
Loading
Loading
Loading
Loading
+0 −187
Original line number Diff line number Diff line
@@ -1811,193 +1811,6 @@ namespace Isis {
  }


  /**
   * Upper triangular, square-root free cholesky.
   *
   */
  bool BundleAdjust::CholeskyUT_NOSQR() {
    int i, j, k;
    double sum, divisor;
    double den;
    double d1, d2;

    int nRows = m_Normals.size1();
//    comment here
//        for (i = 0; i < nRows; i++) {
//          for (j = i; j < nRows; j++) {
//            printf("%lf ",m_Normals(i,j));
//          }
//          printf("\n");
//        }
//    comment here
    for (i = 0; i < nRows; i++) {
//    printf("Cholesky Row %d of %d\n",i+1,nRows);
      sum = 0.0;

      for (j = 0; j < i; j++) {
//      sum += m_Normals(j,i-j) * m_Normals(j,i-j) * m_Normals(j,0);   // old way

        d1 = m_Normals(j, i);
        if (d1 == 0.0)
          continue;
        sum += d1 * d1 * m_Normals(j, j);  // new way
      }

//    m_Normals(i,0) -= sum;                                           // old
      m_Normals(i, i) -= sum;                                          // new

      // check for divide by 0
//    den = m_Normals(i,0);                                            // old
      den = m_Normals(i, i);                                           // new
      if (fabs(den) < 1e-100) {
        return false;
      }

      divisor = 1.0 / den;

      for (j = (i + 1); j < nRows; j++) {
        sum = 0.0;

        for (k = 0; k < i; k++) {
//        sum += m_Normals(k,j-k) * m_Normals(k,i-k) * m_Normals(k,0); // old

          d1 = m_Normals(k, j);
          if (d1 == 0.0)
            continue;

          d2 = m_Normals(k, i);
          if (d2 == 0.0)
            continue;

          sum += d1 * d2 * m_Normals(k, k); // new
        }

//      m_Normals(i,j-i) = (m_Normals(i,j-i) - sum) * divisor;         // old
        m_Normals(i, j)   = (m_Normals(i, j) - sum) * divisor;         // new
      }

      // decompose right-hand side
      sum = 0.0;
      for (k = 0; k < i; k++) {
        d1 = m_nj(k);
        if (d1 == 0.0)
          continue;

        d2 = m_Normals(k, i);
        if (d2 == 0.0)
          continue;

        sum += d1 * d2 * m_Normals(k, k);
      }

      m_nj(i) = (m_nj(i) - sum) * divisor;
    }

    return true;
  }


  /**
   * Backsubstitution for above square-root free cholesky method.
   *
   */
  bool BundleAdjust::CholeskyUT_NOSQR_BackSub(symmetric_matrix<double, upper, column_major> &m,
                                              vector<double> &s,
                                              vector<double> &rhs) {
    int i, j;
    double sum;
    double d1, d2;

    int nRows = m.size1();

    s(nRows - 1) = rhs(nRows - 1);

    for (i = nRows - 2; i >= 0; i--) {
      sum = 0.0;

      for (j = i + 1; j < nRows; j++) {
        d1 = m(i, j);
        if (d1 == 0.0) {
          continue;
        }

        d2 = s(j);
        if (d2 == 0.0) {
          continue;
        }

        sum += d1 * d2;
      }

      s(i) = rhs(i) - sum;
    }

//    std::cout << s << std::endl;

    return true;
  }


  /**
   * Compute inverse of normal equations matrix for above square-root free cholesky method.
   *
   */
  bool BundleAdjust::CholeskyUT_NOSQR_Inverse() {
    int i, j, k;
    double div, sum;
    double colk, tmpkj, tmpkk;

    // create temporary copy, inverse will be stored in m_Normals
    boost::numeric::ublas::symmetric_matrix< double, upper, column_major > tmp = m_Normals;
//    symmetric_matrix<double,lower> tmp = m_Normals;

    // solution vector
    LinearAlgebra::Vector s(m_nRank);

    // initialize column vector
    LinearAlgebra::Vector column(m_nRank);
    column.clear();
    column(0) = 1.0;

    for (i = 0; i < m_nRank; i++) {
      // set current column of identity
      column.clear();
      column(i) = 1.0;

      // factorize current column of identity matrix
      for (j = 0; j < m_nRank; j++) {
        div = 1.0 / tmp(j, j);
        sum = 0.0;

        for (k = 0; k < j; k++) {
          colk = column(k);
          tmpkj = tmp(k, j);
          tmpkk = tmp(k, k);

          if (colk == 0.0 || tmpkj == 0.0 || tmpkk == 0.0)
            continue;

          sum += colk * tmpkj * tmpkk;
        }

        column(j) = (column(j) - sum) * div;
      }

      // back-substitution
      if (!CholeskyUT_NOSQR_BackSub(tmp, s, column))
        return false;

      // store solution in corresponding column of inverse (replacing column in
      // m_Normals)
      for (j = 0; j <= i; j++) {
        m_Normals(j, i) = s(j);
      }
    }

    return true;
  }


  /**
   * Compute inverse of normal equations matrix for CHOLMOD.
   *
+0 −10
Original line number Diff line number Diff line
@@ -352,16 +352,6 @@ namespace Isis {

      bool errorPropagation_CHOLMOD();

      bool CholeskyUT_NOSQR();
      bool CholeskyUT_NOSQR_Inverse();
      bool CholeskyUT_NOSQR_BackSub(
                                    boost::numeric::ublas::symmetric_matrix<
                                        double, 
                                        boost::numeric::ublas::upper,
                                        boost::numeric::ublas::column_major >  &m,
                                    LinearAlgebra::Vector  &s,
                                    LinearAlgebra::Vector  &rhs);

//      bool computePartials_DC(LinearAlgebra::Matrix  &coeff_image,
//                              LinearAlgebra::Matrix  &coeff_point3D,
//                              LinearAlgebra::Vector  &coeff_RHS,