<commit_before>// ---------------------------------------------------------------------
// $Id$
//
// Copyright (C) 2000 - 2013 by the deal.II authors
//
// This file is part of the deal.II library.
//
// The deal.II library is free software; you can use it, redistribute
// it, and/or modify it under the terms of the GNU Lesser General
// Public License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// The full text of the license can be found in the file LICENSE at
// the top level of the deal.II distribution.
//
// ---------------------------------------------------------------------

#ifndef __deal2__block_sparse_matrix_h
#define __deal2__block_sparse_matrix_h


#include <deal.II/base/config.h>
#include <deal.II/base/table.h>
#include <deal.II/lac/block_matrix_base.h>
#include <deal.II/lac/block_vector.h>
#include <deal.II/lac/sparse_matrix.h>
#include <deal.II/lac/block_sparsity_pattern.h>
#include <deal.II/lac/exceptions.h>

#include <cmath>

DEAL_II_NAMESPACE_OPEN


/*! @addtogroup Matrix1
 *@{
 */


/**
 * Blocked sparse matrix based on the SparseMatrix class. This class
 * implements the functions that are specific to the SparseMatrix base objects
 * for a blocked sparse matrix, and leaves the actual work relaying most of
 * the calls to the individual blocks to the functions implemented in the base
 * class. See there also for a description of when this class is useful.
 *
 * @see @ref GlossBlockLA "Block (linear algebra)"
 * @author <NAME>, 2000, 2004
 */
template <typename number>
class BlockSparseMatrix : public BlockMatrixBase<SparseMatrix<number> >
{
public:
  /**
   * Typedef the base class for simpler
   * access to its own typedefs.
   */
  typedef BlockMatrixBase<SparseMatrix<number> > BaseClass;

  /**
   * Typedef the type of the underlying
   * matrix.
   */
  typedef typename BaseClass::BlockType  BlockType;

  /**
   * Import the typedefs from the base
   * class.
   */
  typedef typename BaseClass::value_type      value_type;
  typedef typename BaseClass::pointer         pointer;
  typedef typename BaseClass::const_pointer   const_pointer;
  typedef typename BaseClass::reference       reference;
  typedef typename BaseClass::const_reference const_reference;
  typedef typename BaseClass::size_type       size_type;
  typedef typename BaseClass::iterator        iterator;
  typedef typename BaseClass::const_iterator  const_iterator;

  /**
   * @name Constructors and initalization
   */
//@{
  /**
   * Constructor; initializes the
   * matrix to be empty, without
   * any structure, i.e.  the
   * matrix is not usable at
   * all. This constructor is
   * therefore only useful for
   * matrices which are members of
   * a class. All other matrices
   * should be created at a point
   * in the data flow where all
   * necessary information is
   * available.
   *
   * You have to initialize the
   * matrix before usage with
   * reinit(BlockSparsityPattern). The
   * number of blocks per row and
   * column are then determined by
   * that function.
   */
  BlockSparseMatrix ();

  /**
   * Constructor. Takes the given
   * matrix sparsity structure to
   * represent the sparsity pattern
   * of this matrix. You can change
   * the sparsity pattern later on
   * by calling the reinit()
   * function.
   *
   * This constructor initializes
   * all sub-matrices with the
   * sub-sparsity pattern within
   * the argument.
   *
   * You have to make sure that the
   * lifetime of the sparsity
   * structure is at least as long
   * as that of this matrix or as
   * long as reinit() is not called
   * with a new sparsity structure.
   */
  BlockSparseMatrix (const BlockSparsityPattern &sparsity);

  /**
   * Destructor.
   */
  virtual ~BlockSparseMatrix ();



  /**
   * Pseudo copy operator only copying
   * empty objects. The sizes of the block
   * matrices need to be the same.
   */
  BlockSparseMatrix &
  operator = (const BlockSparseMatrix &);

  /**
   * This operator assigns a scalar to a
   * matrix. Since this does usually not
   * make much sense (should we set all
   * matrix entries to this value? Only
   * the nonzero entries of the sparsity
   * pattern?), this operation is only
   * allowed if the actual value to be
   * assigned is zero. This operator only
   * exists to allow for the obvious
   * notation <tt>matrix=0</tt>, which
   * sets all elements of the matrix to
   * zero, but keep the sparsity pattern
   * previously used.
   */
  BlockSparseMatrix &
  operator = (const double d);

  /**
   * Release all memory and return
   * to a state just like after
   * having called the default
   * constructor. It also forgets
   * the sparsity pattern it was
   * previously tied to.
   *
   * This calls SparseMatrix::clear on all
   * sub-matrices and then resets this
   * object to have no blocks at all.
   */
  void clear ();

  /**
   * Reinitialize the sparse matrix
   * with the given sparsity
   * pattern. The latter tells the
   * matrix how many nonzero
   * elements there need to be
   * reserved.
   *
   * Basically, this function only
   * calls SparseMatrix::reinit() of the
   * sub-matrices with the block
   * sparsity patterns of the
   * parameter.
   *
   * The elements of the matrix are
   * set to zero by this function.
   */
  virtual void reinit (const BlockSparsityPattern &sparsity);
//@}

  /**
   * @name Information on the matrix
   */
//@{
  /**
   * Return whether the object is
   * empty. It is empty if either
   * both dimensions are zero or no
   * BlockSparsityPattern is
   * associated.
   */
  bool empty () const;

  /**
   * Return the number of entries
   * in a specific row.
   */
  size_type get_row_length (const size_type row) const;<commit_msg>Add a note.<commit_after>// ---------------------------------------------------------------------
// $Id$
//
// Copyright (C) 2000 - 2013 by the deal.II authors
//
// This file is part of the deal.II library.
//
// The deal.II library is free software; you can use it, redistribute
// it, and/or modify it under the terms of the GNU Lesser General
// Public License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// The full text of the license can be found in the file LICENSE at
// the top level of the deal.II distribution.
//
// ---------------------------------------------------------------------

#ifndef __deal2__block_sparse_matrix_h
#define __deal2__block_sparse_matrix_h


#include <deal.II/base/config.h>
#include <deal.II/base/table.h>
#include <deal.II/lac/block_matrix_base.h>
#include <deal.II/lac/block_vector.h>
#include <deal.II/lac/sparse_matrix.h>
#include <deal.II/lac/block_sparsity_pattern.h>
#include <deal.II/lac/exceptions.h>

#include <cmath>

DEAL_II_NAMESPACE_OPEN


/*! @addtogroup Matrix1
 *@{
 */


/**
 * Blocked sparse matrix based on the SparseMatrix class. This class
 * implements the functions that are specific to the SparseMatrix base objects
 * for a blocked sparse matrix, and leaves the actual work relaying most of
 * the calls to the individual blocks to the functions implemented in the base
 * class. See there also for a description of when this class is useful.
 *
 * @see @ref GlossBlockLA "Block (linear algebra)"
 * @author <NAME>, 2000, 2004
 */
template <typename number>
class BlockSparseMatrix : public BlockMatrixBase<SparseMatrix<number> >
{
public:
  /**
   * Typedef the base class for simpler
   * access to its own typedefs.
   */
  typedef BlockMatrixBase<SparseMatrix<number> > BaseClass;

  /**
   * Typedef the type of the underlying
   * matrix.
   */
  typedef typename BaseClass::BlockType  BlockType;

  /**
   * Import the typedefs from the base
   * class.
   */
  typedef typename BaseClass::value_type      value_type;
  typedef typename BaseClass::pointer         pointer;
  typedef typename BaseClass::const_pointer   const_pointer;
  typedef typename BaseClass::reference       reference;
  typedef typename BaseClass::const_reference const_reference;
  typedef typename BaseClass::size_type       size_type;
  typedef typename BaseClass::iterator        iterator;
  typedef typename BaseClass::const_iterator  const_iterator;

  /**
   * @name Constructors and initalization
   */
//@{
  /**
   * Constructor; initializes the
   * matrix to be empty, without
   * any structure, i.e.  the
   * matrix is not usable at
   * all. This constructor is
   * therefore only useful for
   * matrices which are members of
   * a class. All other matrices
   * should be created at a point
   * in the data flow where all
   * necessary information is
   * available.
   *
   * You have to initialize the
   * matrix before usage with
   * reinit(BlockSparsityPattern). The
   * number of blocks per row and
   * column are then determined by
   * that function.
   */
  BlockSparseMatrix ();

  /**
   * Constructor. Takes the given
   * matrix sparsity structure to
   * represent the sparsity pattern
   * of this matrix. You can change
   * the sparsity pattern later on
   * by calling the reinit()
   * function.
   *
   * This constructor initializes
   * all sub-matrices with the
   * sub-sparsity pattern within
   * the argument.
   *
   * You have to make sure that the
   * lifetime of the sparsity
   * structure is at least as long
   * as that of this matrix or as
   * long as reinit() is not called
   * with a new sparsity structure.
   */
  BlockSparseMatrix (const BlockSparsityPattern &sparsity);

  /**
   * Destructor.
   */
  virtual ~BlockSparseMatrix ();



  /**
   * Pseudo copy operator only copying
   * empty objects. The sizes of the block
   * matrices need to be the same.
   */
  BlockSparseMatrix &
  operator = (const BlockSparseMatrix &);

  /**
   * This operator assigns a scalar to a
   * matrix. Since this does usually not
   * make much sense (should we set all
   * matrix entries to this value? Only
   * the nonzero entries of the sparsity
   * pattern?), this operation is only
   * allowed if the actual value to be
   * assigned is zero. This operator only
   * exists to allow for the obvious
   * notation <tt>matrix=0</tt>, which
   * sets all elements of the matrix to
   * zero, but keep the sparsity pattern
   * previously used.
   */
  BlockSparseMatrix &
  operator = (const double d);

  /**
   * Release all memory and return
   * to a state just like after
   * having called the default
   * constructor. It also forgets
   * the sparsity pattern it was
   * previously tied to.
   *
   * This calls SparseMatrix::clear on all
   * sub-matrices and then resets this
   * object to have no blocks at all.
   */
  void clear ();

  /**
   * Reinitialize the sparse matrix
   * with the given sparsity
   * pattern. The latter tells the
   * matrix how many nonzero
   * elements there need to be
   * reserved.
   *
   * Basically, this function only
   * calls SparseMatrix::reinit() of the
   * sub-matrices with the block
   * sparsity patterns of the
   * parameter.
   *
   * You have to make sure that the lifetime of the sparsity structure is at
   * least as long as that of this matrix or as long as reinit(const
   * SparsityPattern &) is not called with a new sparsity structure.
   *
   * The elements of the matrix are set to zero by this function.
   */
  virtual void reinit (const BlockSparsityPattern &sparsity);
//@}

  /**
   * @name Information on the matrix
   */
//@{
  /**
   * Return whether the object is
   * empty. It is empty if either
   * both dimensions are zero or no
   * BlockSparsityPattern is
   * associated.
   */
  bool empty () const;

  /**
   * Return the number of entries
   * in a specific row.
   */
  size_type get_row_length (const size_type row) const;
{'fraction_non_alphanumeric': 0.10266836086404066, 'fraction_numerical': 0.0037272342227869545, 'mean_word_length': 2.6801745635910224, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 35, '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': '4816861', 'n_tokens_mistral': 3469, 'n_tokens_neox': 3311, 'n_words': 1355}