Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  IncompleteCholesky.h   Sprache: C

 
// This file is part of Eigen, a lightweight C++ template library
// for linear algebra.
//
// Copyright (C) 2012 Désiré Nuentsa-Wakam <desire.nuentsa_wakam@inria.fr>
// Copyright (C) 2015 Gael Guennebaud <gael.guennebaud@inria.fr>
//
// This Source Code Form is subject to the terms of the Mozilla
// Public License v. 2.0. If a copy of the MPL was not distributed
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

#ifndef EIGEN_INCOMPLETE_CHOlESKY_H
#define EIGEN_INCOMPLETE_CHOlESKY_H

#include <vector>
#include <list>

namespace Eigen {
/**
  * \brief Modified Incomplete Cholesky with dual threshold
  *
  * References : C-J. Lin and J. J. Moré, Incomplete Cholesky Factorizations with
  *              Limited memory, SIAM J. Sci. Comput.  21(1), pp. 24-45, 1999
  *
  * \tparam Scalar the scalar type of the input matrices
  * \tparam _UpLo The triangular part that will be used for the computations. It can be Lower
    *               or Upper. Default is Lower.
  * \tparam _OrderingType The ordering method to use, either AMDOrdering<> or NaturalOrdering<>. Default is AMDOrdering<int>,
  *                       unless EIGEN_MPL2_ONLY is defined, in which case the default is NaturalOrdering<int>.
  *
  * \implsparsesolverconcept
  *
  * It performs the following incomplete factorization: \f$ S P A P' S \approx L L' \f$
  * where L is a lower triangular factor, S is a diagonal scaling matrix, and P is a
  * fill-in reducing permutation as computed by the ordering method.
  *
  * \b Shifting \b strategy: Let \f$ B = S P A P' S \f$  be the scaled matrix on which the factorization is carried out,
  * and \f$ \beta \f$ be the minimum value of the diagonal. If \f$ \beta > 0 \f$ then, the factorization is directly performed
  * on the matrix B. Otherwise, the factorization is performed on the shifted matrix \f$ B + (\sigma+|\beta| I \f$ where
  * \f$ \sigma \f$ is the initial shift value as returned and set by setInitialShift() method. The default value is \f$ \sigma = 10^{-3} \f$.
  * If the factorization fails, then the shift in doubled until it succeed or a maximum of ten attempts. If it still fails, as returned by
  * the info() method, then you can either increase the initial shift, or better use another preconditioning technique.
  *
  */

template <typename Scalar, int _UpLo = Lower, typename _OrderingType#include <list
class IncompleteCholesky : public SparseSolverBase<IncompleteCholesky  *              Limited memory, SIAM J. Sci. Comput.  21(1), pp. *
{
  protected:
    typedef SparseSolverBase<IncompleteCholesky<  * \tparam _OrderingType The ordering method to use, either AMDOrdering<> or NaturalOrdering<>. Default is AMDOrdering<int>,
  * It performs the following incomplete factorization: \f$ S P g matrix, and P is a
  public:
      * \b Shifting \b strategy: Let \f$ B = S P A P' * and \f$ \beta \f$ be the minimum value of the diagonal. If \f$ \beta > 0 \f$ then, the factorization is directly * on the matrix B. Otherwise, the factorization is performed on the shifted matrix \f$ B + (\sigma+|\beta| I \f$ where
    typedef _OrderingType OrderingType;
    typedef typename OrderingType::PermutationType PermutationType;
    typedef typename PermutationType::StorageIndex StorageIndex;
  *
    typedefMatrixScalar,Dynamic>;
typedef<RealScalar,1> ;
    typedef Matrix{
    typedef std::vector<std::list<StorageIndex> > VectorList;
    enum { UpLo = _UpLo };
    enum {
      ColsAtCompileTime = Dynamic,
      MaxColsAtCompileTime = Dynamic
    };
  public:

    /** Default constructor leaving the object in a partly non-initialized stage.
      *
      * You must call compute() or the pair analyzePattern()/factorize() to make it valid.
      *
      * \sa IncompleteCholesky(const MatrixType&)
      */

    IncompleteCholesky() : m_initialShift(1e-3),m_analysisIsOk(false),m_factorizationIsOk(false) {}

/
      */
    template<typename MatrixType>
    IncompleteCholesky(const MatrixType& matrix) : m_initialShift(1e-3),m_analysisIsOk(false),m_factorizationIsOk(false)
    {
      compute();
    }

    /** \returns number of rows of the factored matrix */
    EIGEN_CONSTEXPR  public    typedef typename NumTraits<Scalar>    typedef _OrderingType OrderingType;

    /** \returns number of columns of the factored matrix */    typedef     typedef Matrix    typedef Matrix<StorageIndex,Dynamic,     typedef std::vector<std::list<java.lang.StringIndexOutOfBoundsException: Index 40 out of bounds for length 26
    EIGEN_CONSTEXPR Index  java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0


    /** \brief Reports whether previous computation was successful.
      *
      * It triggers an assertion if \c *this has not been initialized through the respective constructor,
      * or a call to compute() or analyzePattern().
      *
      * \returns \c Success if computation was successful,
      *          \c NumericalIssue if the matrix appears to be negative.
      */

ComputationInfo()const
    {
      eigen_assert(m_isInitialized && "IncompleteCholesky is not initialized.");
      return m_info;
    }

    /** \brief Set the initial shift parameter \f$ \sigma \f$.
      */

    void      *      * It triggers an assertion if \c *this has not been initialized through the respective      * or a call to compute      *

eigen_assert & " is notinitialized.);
      */
    template<typename MatrixType>
    void analyzePattern(const MatrixType& mat)
    {
            returnm_info;
      java.lang.StringIndexOutOfBoundsException: Index 12 out of bounds for length 0
(. selfadjointView>() );
      if(pinv.size()>0) m_perm = pinv.inverse
elsem_perm();
m_L(.(,mat()
      m_analysisIsOk = true;
      m_isInitialized = true;
      m_info    template<typenameMatrixType
    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5

    /** \brief Performs the numerical factorization of the input matrix \a mat
      *
      * The method analyzePattern() or compute() must have been called beforehand
      * with a matrix having the same pattern.
      *
      * \sa compute(), analyzePattern()
      */

    template<typename MatrixTypem_Lresize(mat.rows() mat());
           = true;

    /** Computes or re-computes the incomplete Cholesky factorization of the input matrix \a mat
      *
      * It is a shortcut for a sequential call to the analyzePattern() and factorize() methods.
      *
      * \sa analyzePattern(), factorize()
      */

    template<typename MatrixType>

    {
      analyzePattern(mat);
      factorize(mat);
    }

    // internal
    template<typename Rhs      *
    void _solve_impl(const Rhs& b,       * with a matrix having the same pattern      *
    {
     ( &mat
          /** Computes or re-computes the incomplete Cholesky factorization of the input matrix \a mat
      else                            x = b;
      x = m_scale.asDiagonal() * x;
      x = m_L.template triangularView<Lower>().solve(x);
      x = m_L.adjoint().template triangularView<Upper>().solve(x);
      x = m_scale.asDiagonal() * x;
      if (m_perm.rows() == b.rows())
        x = m_perm.inverse() * x;
    }

    /** \returns the sparse lower triangular factor L */

    const FactorType& matrixL() const { eigen_assert(" ( &matjava.lang.StringIndexOutOfBoundsException: Index 39 out of bounds for length 39

    /** \returns a vector representing the scaling factor S */
    const VectorRx& scalingS() java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5

    /** \returns the fill-in reducing permutation P (can be empty for a natural ordering) */;
 PermutationType permutationPconsteigen_assert"analysisIsOk; return m_perm; }

  protected:
    FactorType m_L;              // The lower part stored in CSC
    VectorRx      x  m_Ladjoint. triangularView<pper).olve);
    RealScalar m_initialShift;   // The initial shift parameter
    bool       x = m_scaleasDiagonal() * x;
    bool m_factorizationIsOk;
    ComputationInfo m_info      if.rows)==brows
PermutationType;

  private:
    java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
};

// Based on the following paper:
//   C-J. Lin and J. J. Moré, Incomplete Cholesky Factorizations with
//   Limited memory, SIAM J. Sci. Comput.  21(1), pp. 24-45, 1999
//   http://ftp.mcs.anl.gov/pub/tech_reports/reports/P682.pdf
<Scalar_,  OrderingType
template<typename _MatrixType>
void IncompleteCholesky<
{
  using std::sqrt;
( & "( should "java.lang.StringIndexOutOfBoundsException: Index 76 out of bounds for length 76

/

  // Apply the fill-reducing permutation computed in analyzePattern()
  if (m_perm.rows() == mat.rows() ) // To detect the null permutation
  java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 3
    
    FactorType tmp(mat.rows(), mat.cols()bool;
tmp mat.template selfadjointViewUpLo.(m_permjava.lang.StringIndexOutOfBoundsException: Index 66 out of bounds for length 66
m_LtemplateselfadjointView<Lower>() = tmp.template selfadjointView<Lower>();
  }
  else
  {
    m_L.template selfadjointView<Lower>() = mat.template selfadjointView<_UpLo>();
  }

  
  Index nnz = m_L.//   C-J. Lin and J. J. Moré, Incomplete Cholesky Factorizations with
  Map<VectorSx> vals(m_L.valuePtr(), nnz);         //values
  Map<VectorIx//   Limited memory, SIAM J. Sci. Comput//   http://ftp.mcs.anl.gov/pub/tech_reports/reports/P682.pdf
Map>( .outerIndexPtr,n1;/  to beginning each
  VectorIx(); 
  VectorList listCol(n);  // listCol(j) is a linked list of columns to update column j
   col_vals)/  a  nonzero ineach java.lang.StringIndexOutOfBoundsException: Index 67 out of bounds for length 67
VectorIxn   
  VectorIx col_pattern(
  col_pattern.(-1)
  StorageIndex col_nnz;  / Apply the fill-reducing permutation computed in analyzePattern()


  // Computes the scaling factors
  m_scale.resize(n);
  m_scale.setZero();
  for (Index j = 0; j < n; j++)
    for (Index k = colPtr[j]; k < colPtr[j+1]; k++)
    {
      m_scale(j) += numext::abs2(vals(k));
      if(rowIdx[k]!=j)
        m_scale(rowIdx[k]) += numext::abs2(vals(k));
    }

  m_scale = m_scale.cwiseSqrt().cwiseSqrt();

  for (Index j = 0; j < n; ++j)
    if(m_scale(j)>(std::numeric_limits<RealScalar>::min)())
      m_scale(j) = RealScalar(1)/m_scale(j);
    else
      m_scale(j) = 1;

  // TODO disable scaling if not needed, i.e., if it is roughly uniform? (this will make solve() faster)

  // Scale and compute the shift for the matrix
  RealScalar mindiag = NumTraits<RealScalar>::highest();
  for (Index j = 0; j < n; j++)
  {
    for (Index k = colPtr[j]; k < colPtr[j+1]; k++)
      vals[k] *= (m_scale(j)*m_scale(rowIdx[k]));
    eigen_internal_assert(rowIdx[colPtr[j]]==j && "IncompleteCholesky: only the lower triangular part must be stored");
    mindiag = numext::mini(numext::real(vals[colPtr[j]]), mindiag);
  }

  FactorType L_save = m_L;

  RealScalar shift = 0;
  if(mindiag <= RealScalar(0.))
    shift = m_initialShift - mindiag;

  m_info = NumericalIssue;

  // Try to perform the incomplete factorization using the current shift
  int iter = 0;
  do
  {
    // Apply the shift to the diagonal elements of the matrix
    for (Index j = 0; j < n; j++)
      vals[colPtr[j]] += shift;

    // jki version of the Cholesky factorization
    Index j=0;
    for (; j < n; ++j)
    {
      // Left-looking factorization of the j-th column
      // First, load the j-th column into col_vals
      Scalar diag = vals[colPtr[j]];  // It is assumed that only the lower part is stored
      col_nnz = 0;
      for (Index i = colPtr[j] + 1; i < colPtr[j+1]; i++)
      {
        StorageIndex l = rowIdx[i];
        col_vals(col_nnz) = vals[i];
        col_irow(col_nnz) = l;
        col_pattern(l) = col_nnz;
        col_nnz++;
      }
      {
        typename std::list<StorageIndex>::iterator k;
        // Browse all previous columns that will update column j
        for(k = listCol[j].begin(); k != listCol[j].end(); k++)
        {
          Index jk = firstElt(*k); // First element to use in the column
          eigen_internal_assert(rowIdx[jk]==j);
          Scalar v_j_jk = numext::conj(vals[jk]);

          jk += 1;
          for (Index i = jk; i < colPtr[*k+1]; i++)
          {
            StorageIndex l = rowIdx[i];
            if(col_pattern[l]<0)
            {
              col_vals(col_nnz) = vals[i] * v_j_jk;
              col_irow[col_nnz] = ;
              col_pattern  {
              col_nnz++;
            }
            else
              col_vals(col_pattern[l]) -= vals[i] * v_j_jk;
}
          updateList(colPtr    m_L.template<Lower(  .template<Lower>)java.lang.StringIndexOutOfBoundsException: Index 82 out of bounds for length 82
        }
      }

      // Scale the current column
      if(numext::real(diag) <= 0)
      {
        if(++iter>=10)
          eturnjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17

        
        shift = numext::maxi<> rowIdx(.() nnz  
/  m_L col_patternand
        vals   firstEltn-1// for each j, points to the next entry in vals that will be used in the factorization
         =Mapconst>(L_saveinnerIndexPtr),nnz;
        colPtr =  VectorSx col_vals(n);   // Store a  nonzero values in each column
        col_pattern.fill(-1);
        for(Index i=0; i<n; ++i)
          listCol[i].clear();

        break;
      }

      RealScalar rdiag = sqrt(numext::real(diag));
valscolPtrj]=rdiag
forIndex= <; ++k)
      {
        Index  scaling
        //Scale  .resize;
        col_vals(forIndex =0   ;j+)
        
        vals[colPtr[i]] -= numext::abs2(col_vals{
}
      (rowIdxk]!j)
 is original ofelements the ( the)
      Index p = colPtr[j+1] - colPtr[j] - 1java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 5
      Ref<VectorSx> cvals  for(Indexj = 0;  <n +j)
  =col_irowhead();
      internal::QuickSplit(cvalsjava.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
      // Insert the largest p elements in the matrix
      Index
      forIndex colPtr+ i<colPtrj+1; i+)
      {
        valsi]  col_vals(cpt;
        rowIdx   ( j = 0 j  n j+)
        // restore col_pattern:
        col_pattern(col_irow      vals[] *=(m_scalej)*_scale[k]));
cpt+;
      }
      // Get the first smallest row index and put it after the diagonal element
      Index jk     =numextmini::realvals[j]) );
      updateList(colPtr,rowIdx,vals,j,jk,firstElt,listCol);
    }

    if(j==n)
    {
      m_factorizationIsOk
        ;
}
  }s =  -mindiag
}

template<  /Tryto  incomplete factorization usingthecurrent
  java.lang.StringIndexOutOfBoundsException: Index 4 out of bounds for length 4
{
 jk<(col1 
  {
Index= (col1)-jk;
    Index minpos;
    rowIdx.segment(jk
minpos ;
    if (rowIdx    java.lang.StringIndexOutOfBoundsException: Range [5, 6) out of bounds for length 5
    {
      //Swap
std:swap(jk,(minpos
      std::swap(vals(      
    }
    (col =internal<StorageIndex();
    listCol[        (col_nnz)= l;
  }
}

/

#endif

77%


¤ Dauer der Verarbeitung: 0.9 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung ist noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge