<commit_before>//---------------------------------------------------------------------------
//    $Id$
//
//    Copyright (C) 2003, 2004, 2005, 2006, 2009, 2010, 2011, 2012 by the deal.II authors
//
//    This file is subject to QPL and may not be  distributed
//    without copyright and license information. Please refer
//    to the file deal.II/doc/license.html for the  text  and
//    further information on this license.
//
//---------------------------------------------------------------------------
#ifndef __deal2__mg_matrix_h
#define __deal2__mg_matrix_h

#include <deal.II/lac/vector.h>
#include <deal.II/lac/pointer_matrix.h>
#include <deal.II/lac/sparse_matrix.h>
#include <deal.II/multigrid/mg_base.h>
#include <deal.II/base/mg_level_object.h>
#include <deal.II/base/std_cxx1x/shared_ptr.h>

DEAL_II_NAMESPACE_OPEN

/*!@addtogroup mg */
/*@{*/

namespace mg
{
  /**
   * Multilevel matrix. This matrix stores an MGLevelObject of
   * PointerMatrixBase objects. It implementes the interface defined in
   * MGMatrixBase, so that it can be used as a matrix in Multigrid.
   *
   * @author <NAME>
   * @date 2002, 2010
   */
  template <class VECTOR = Vector<double> >
  class Matrix
    : public MGMatrixBase<VECTOR>
  {
  public:
    /**
     * Default constructor for an
     * empty object.
     */
    Matrix();

    /**
     * Constructor setting up
     * pointers to the matrices in
     * <tt>M</tt> by calling initialize().
     */
    template <class MATRIX>
    Matrix(const MGLevelObject<MATRIX> &M);

    /**
     * Initialize the object such
     * that the level
     * multiplication uses the
     * matrices in <tt>M</tt>
     */
    template <class MATRIX>
    void
    initialize(const MGLevelObject<MATRIX> &M);

    /**
     * Access matrix on a level.
     */
    const PointerMatrixBase<VECTOR> &operator[] (unsigned int level) const;

    virtual void vmult (const unsigned int level, VECTOR &dst, const VECTOR &src) const;
    virtual void vmult_add (const unsigned int level, VECTOR &dst, const VECTOR &src) const;
    virtual void Tvmult (const unsigned int level, VECTOR &dst, const VECTOR &src) const;
    virtual void Tvmult_add (const unsigned int level, VECTOR &dst, const VECTOR &src) const;

    /**
     * Memory used by this object.
     */
    std::size_t memory_consumption () const;
  private:
    MGLevelObject<std_cxx1x::shared_ptr<PointerMatrixBase<VECTOR> > > matrices;
  };

}

/**
 * @deprecated Use the much simpler class mg::Matrix instead.
 * @author <NAME>, 2002
 */
template <class MATRIX = SparseMatrix<double>, class VECTOR = Vector<double> >
class MGMatrix : public MGMatrixBase<VECTOR>
{
public:
  MGMatrix (MGLevelObject<MATRIX> *= 0);
  void set_matrix (MGLevelObject<MATRIX> *M);
  virtual void vmult (const unsigned int level,
                      VECTOR &dst,
                      const VECTOR &src) const;
  virtual void vmult_add (const unsigned int level,
                          VECTOR &dst,
                          const VECTOR &src) const;
  virtual void Tvmult (const unsigned int level,
                       VECTOR &dst,
                       const VECTOR &src) const;
  virtual void Tvmult_add (const unsigned int level,
                           VECTOR &dst,
                           const VECTOR &src) const;
  std::size_t memory_consumption () const;
private:
  SmartPointer<MGLevelObject<MATRIX>,MGMatrix<MATRIX,VECTOR> > matrix;
};


/**
 * Multilevel matrix selecting from block matrices. This class
 * implements the interface defined by MGMatrixBase.  The
 * template parameter @p MATRIX should be a block matrix class like
 * BlockSparseMatrix or @p BlockSparseMatrixEZ. Then, this
 * class stores a pointer to a MGLevelObject of this matrix
 * class. In each @p vmult, the block selected on initialization will
 * be multiplied with the vector provided.
 *
 * @author <NAME>, 2002
 */
template <class MATRIX, typename number>
class MGMatrixSelect : public MGMatrixBase<Vector<number> >
{
public:
  /**
   * Constructor. @p row and
   * @p col are the coordinate of
   * the selected block. The other
   * argument is handed over to the
   * @p SmartPointer constructor.
   */
  MGMatrixSelect (const unsigned int row = 0,
                  const unsigned int col = 0,
                  MGLevelObject<MATRIX> *= 0);

  /**
   * Set the matrix object to be
   * used. The matrix object must
   * exist longer as the
   * @p MGMatrix object, since
   * only a pointer is stored.
   */
  void set_matrix (MGLevelObject<MATRIX> *M);

  /**
   * Select the block for
   * multiplication.
   */
  void select_block (const unsigned int row,
                     const unsigned int col);

  /**
   * Matrix-vector-multiplication on
   * a certain level.
   */<commit_msg>Allow compilation with this file again.<commit_after>//---------------------------------------------------------------------------
//    $Id$
//
//    Copyright (C) 2003, 2004, 2005, 2006, 2009, 2010, 2011, 2012 by the deal.II authors
//
//    This file is subject to QPL and may not be  distributed
//    without copyright and license information. Please refer
//    to the file deal.II/doc/license.html for the  text  and
//    further information on this license.
//
//---------------------------------------------------------------------------
#ifndef __deal2__mg_matrix_h
#define __deal2__mg_matrix_h

#include <deal.II/lac/vector.h>
#include <deal.II/lac/pointer_matrix.h>
#include <deal.II/lac/sparse_matrix.h>
#include <deal.II/multigrid/mg_base.h>
#include <deal.II/base/mg_level_object.h>
#include <deal.II/base/std_cxx1x/shared_ptr.h>

DEAL_II_NAMESPACE_OPEN

/*!@addtogroup mg */
/*@{*/

namespace mg
{
  /**
   * Multilevel matrix. This matrix stores an MGLevelObject of
   * PointerMatrixBase objects. It implementes the interface defined in
   * MGMatrixBase, so that it can be used as a matrix in Multigrid.
   *
   * @author <NAME>
   * @date 2002, 2010
   */
  template <class VECTOR = Vector<double> >
  class Matrix
    : public MGMatrixBase<VECTOR>
  {
  public:
    /**
     * Default constructor for an
     * empty object.
     */
    Matrix();

    /**
     * Constructor setting up
     * pointers to the matrices in
     * <tt>M</tt> by calling initialize().
     */
    template <class MATRIX>
    Matrix(const MGLevelObject<MATRIX> &M);

    /**
     * Initialize the object such
     * that the level
     * multiplication uses the
     * matrices in <tt>M</tt>
     */
    template <class MATRIX>
    void
    initialize(const MGLevelObject<MATRIX> &M);

    /**
     * Access matrix on a level.
     */
    const PointerMatrixBase<VECTOR> &operator[] (unsigned int level) const;

    virtual void vmult (const unsigned int level, VECTOR &dst, const VECTOR &src) const;
    virtual void vmult_add (const unsigned int level, VECTOR &dst, const VECTOR &src) const;
    virtual void Tvmult (const unsigned int level, VECTOR &dst, const VECTOR &src) const;
    virtual void Tvmult_add (const unsigned int level, VECTOR &dst, const VECTOR &src) const;

    /**
     * Memory used by this object.
     */
    std::size_t memory_consumption () const;
  private:
    MGLevelObject<std_cxx1x::shared_ptr<PointerMatrixBase<VECTOR> > > matrices;
  };

}

/**
 * @deprecated Use the much simpler class mg::Matrix instead.
 * @author <NAME>, 2002
 */
template <class MATRIX = SparseMatrix<double>, class VECTOR = Vector<double> >
class MGMatrix : public MGMatrixBase<VECTOR>
{
public:
  MGMatrix (MGLevelObject<MATRIX> *matrix= 0);
  void set_matrix (MGLevelObject<MATRIX> *M);
  virtual void vmult (const unsigned int level,
                      VECTOR &dst,
                      const VECTOR &src) const;
  virtual void vmult_add (const unsigned int level,
                          VECTOR &dst,
                          const VECTOR &src) const;
  virtual void Tvmult (const unsigned int level,
                       VECTOR &dst,
                       const VECTOR &src) const;
  virtual void Tvmult_add (const unsigned int level,
                           VECTOR &dst,
                           const VECTOR &src) const;
  std::size_t memory_consumption () const;
private:
  SmartPointer<MGLevelObject<MATRIX>,MGMatrix<MATRIX,VECTOR> > matrix;
};


/**
 * Multilevel matrix selecting from block matrices. This class
 * implements the interface defined by MGMatrixBase.  The
 * template parameter @p MATRIX should be a block matrix class like
 * BlockSparseMatrix or @p BlockSparseMatrixEZ. Then, this
 * class stores a pointer to a MGLevelObject of this matrix
 * class. In each @p vmult, the block selected on initialization will
 * be multiplied with the vector provided.
 *
 * @author <NAME>, 2002
 */
template <class MATRIX, typename number>
class MGMatrixSelect : public MGMatrixBase<Vector<number> >
{
public:
  /**
   * Constructor. @p row and
   * @p col are the coordinate of
   * the selected block. The other
   * argument is handed over to the
   * @p SmartPointer constructor.
   */
  MGMatrixSelect (const unsigned int row = 0,
                  const unsigned int col = 0,
                  MGLevelObject<MATRIX> *matrix = 0);

  /**
   * Set the matrix object to be
   * used. The matrix object must
   * exist longer as the
   * @p MGMatrix object, since
   * only a pointer is stored.
   */
  void set_matrix (MGLevelObject<MATRIX> *M);

  /**
   * Select the block for
   * multiplication.
   */
  void select_block (const unsigned int row,
                     const unsigned int col);

  /**
   * Matrix-vector-multiplication on
   * a certain level.
   */
{'fraction_non_alphanumeric': 0.12545701452000418, 'fraction_numerical': 0.011699571712106968, 'mean_word_length': 2.380649717514124, 'pattern_counts': {'":': 0, '<': 79, '<?xml version=': 0, '>': 79, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4143720', 'n_tokens_mistral': 3018, 'n_tokens_neox': 2809, 'n_words': 957}