Poster of Linux kernelThe best gift for a Linux geek
DenseSubMatrix

DenseSubMatrix

Section: C Library Functions (3) Updated: Thu Apr 7 2011
Local index Up
 

NAME

DenseSubMatrix -  

SYNOPSIS


#include <dense_submatrix.h>

Inherits DenseMatrixBase< T >.  

Public Member Functions


virtual void zero ()=0

virtual T el (const unsigned int i, const unsigned int j) const =0

virtual T & el (const unsigned int i, const unsigned int j)=0

virtual void left_multiply (const DenseMatrixBase< T > &M2)=0

virtual void right_multiply (const DenseMatrixBase< T > &M3)=0

unsigned int m () const

unsigned int n () const

void print (std::ostream &os) const

void print_scientific (std::ostream &os) const

template<typename T2 , typename T3 > boostcopy::enable_if_c< ScalarTraits< T2 >::value, void >::type add (const T2 factor, const DenseMatrixBase< T3 > &mat)
 

Protected Member Functions


void multiply (DenseMatrixBase< T > &M1, const DenseMatrixBase< T > &M2, const DenseMatrixBase< T > &M3)

void condense (const unsigned int i, const unsigned int j, const T val, DenseVectorBase< T > &rhs)
 

Protected Attributes


unsigned int _m

unsigned int _n
 

Friends


std::ostream & operator<< (std::ostream &os, const DenseMatrixBase< T > &m)
 

Detailed Description

 

template<typename T> class DenseSubMatrix< T >

Defines a dense submatrix for use in Finite Element-type computations. Useful for storing element stiffness matrices before summation into a global matrix, particularly when you have systems of equations.

Author:

Benjamin S. Kirk, 2003

Definition at line 46 of file dense_submatrix.h.  

Member Function Documentation

 

template<typename T > template<typename T2 , typename T3 > boostcopy::enable_if_c< ScalarTraits< T2 >::value, void >::type DenseMatrixBase< T >::add (const T2factor, const DenseMatrixBase< T3 > &mat) [inline, inherited]Adds factor to every element in the matrix. This should only work if T += T2 * T3 is valid C++ and if T2 is scalar. Return type is void

Definition at line 183 of file dense_matrix_base.h.

References DenseMatrixBase< T >::el(), DenseMatrixBase< T >::m(), and DenseMatrixBase< T >::n().

{
  libmesh_assert (this->m() == mat.m());
  libmesh_assert (this->n() == mat.n());

  for (unsigned int j=0; j<this->n(); j++)
    for (unsigned int i=0; i<this->m(); i++)
      this->el(i,j) += factor*mat.el(i,j);
}
 

template<typename T> void DenseMatrixBase< T >::condense (const unsigned inti, const unsigned intj, const Tval, DenseVectorBase< T > &rhs) [protected, inherited]Condense-out the (i,j) entry of the matrix, forcing it to take on the value val. This is useful in numerical simulations for applying boundary conditions. Preserves the symmetry of the matrix.

Definition at line 57 of file dense_matrix_base.C.

References DenseVectorBase< T >::el(), and DenseVectorBase< T >::size().

{
  libmesh_assert (this->_m == rhs.size());
  libmesh_assert (iv == jv);


  // move the known value into the RHS
  // and zero the column
  for (unsigned int i=0; i<this->m(); i++)
    {
      rhs.el(i) -= this->el(i,jv)*val;
      this->el(i,jv) = 0.;
    }

  // zero the row
  for (unsigned int j=0; j<this->n(); j++)
    this->el(iv,j) = 0.;

  this->el(iv,jv) = 1.;
  rhs.el(iv) = val;
  
}
 

template<typename T> virtual T DenseMatrixBase< T >::el (const unsigned inti, const unsigned intj) const [pure virtual, inherited]Returns:

the (i,j) element of the matrix. Since internal data representations may differ, you must redefine this function.

Implemented in DenseMatrix< T >, and DenseMatrix< Number >.

Referenced by DenseMatrixBase< T >::add(), and DenseMatrixBase< T >::multiply().  

template<typename T> virtual T& DenseMatrixBase< T >::el (const unsigned inti, const unsigned intj) [pure virtual, inherited]Returns:

the (i,j) element of the matrix as a writeable reference. Since internal data representations may differ, you must redefine this function.

Implemented in DenseMatrix< T >, and DenseMatrix< Number >.  

template<typename T> virtual void DenseMatrixBase< T >::left_multiply (const DenseMatrixBase< T > &M2) [pure virtual, inherited]Performs the operation: (*this) <- M2 * (*this)

Implemented in DenseMatrix< T >, and DenseMatrix< Number >.  

template<typename T> unsigned int DenseMatrixBase< T >::m () const [inline, inherited]Returns:

the row-dimension of the matrix.

Definition at line 98 of file dense_matrix_base.h.

Referenced by DenseMatrix< T >::_multiply_blas(), DenseMatrixBase< T >::add(), EpetraMatrix< T >::add_matrix(), PetscMatrix< T >::add_matrix(), LaspackMatrix< T >::add_matrix(), DofMap::build_constraint_matrix(), DofMap::constrain_element_dyad_matrix(), DofMap::constrain_element_matrix(), DofMap::constrain_element_matrix_and_vector(), DofMap::constrain_element_vector(), DofMap::extract_local_vector(), DenseMatrix< T >::get_transpose(), DenseMatrix< T >::left_multiply(), DenseMatrix< T >::left_multiply_transpose(), DofMap::max_constraint_error(), DenseMatrixBase< T >::multiply(), PatchRecoveryErrorEstimator::EstimateError::operator()(), DenseMatrix< T >::right_multiply(), and DenseMatrix< T >::right_multiply_transpose().

{ return _m; }
 

template<typename T> void DenseMatrixBase< T >::multiply (DenseMatrixBase< T > &M1, const DenseMatrixBase< T > &M2, const DenseMatrixBase< T > &M3) [protected, inherited]Performs the computation M1 = M2 * M3 where: M1 = (m x n) M2 = (m x p) M3 = (p x n)

Definition at line 30 of file dense_matrix_base.C.

References DenseMatrixBase< T >::el(), DenseMatrixBase< T >::m(), and DenseMatrixBase< T >::n().

{
  // Assertions to make sure we have been
  // passed matrices of the correct dimension.
  libmesh_assert (M1.m() == M2.m());
  libmesh_assert (M1.n() == M3.n());
  libmesh_assert (M2.n() == M3.m());
          
  const unsigned int m_s = M2.m();
  const unsigned int p_s = M2.n(); 
  const unsigned int n_s = M1.n();
  
  // Do it this way because there is a
  // decent chance (at least for constraint matrices)
  // that M3(k,j) = 0. when right-multiplying.
  for (unsigned int k=0; k<p_s; k++)
    for (unsigned int j=0; j<n_s; j++)
      if (M3.el(k,j) != 0.)
        for (unsigned int i=0; i<m_s; i++)
          M1.el(i,j) += M2.el(i,k) * M3.el(k,j);                  
}
 

template<typename T> unsigned int DenseMatrixBase< T >::n () const [inline, inherited]Returns:

the column-dimension of the matrix.

Definition at line 103 of file dense_matrix_base.h.

Referenced by DenseMatrix< T >::_multiply_blas(), DenseMatrixBase< T >::add(), EpetraMatrix< T >::add_matrix(), PetscMatrix< T >::add_matrix(), LaspackMatrix< T >::add_matrix(), DofMap::build_constraint_matrix(), DofMap::constrain_element_dyad_matrix(), DofMap::constrain_element_matrix(), DofMap::constrain_element_matrix_and_vector(), DofMap::constrain_element_vector(), DofMap::extract_local_vector(), DenseMatrix< T >::get_transpose(), DenseMatrix< T >::left_multiply(), DenseMatrix< T >::left_multiply_transpose(), DofMap::max_constraint_error(), DenseMatrixBase< T >::multiply(), PatchRecoveryErrorEstimator::EstimateError::operator()(), DenseMatrix< T >::right_multiply(), and DenseMatrix< T >::right_multiply_transpose().

{ return _n; }
 

template<typename T > void DenseMatrixBase< T >::print (std::ostream &os) const [inherited]Pretty-print the matrix to stdout.

Definition at line 127 of file dense_matrix_base.C.

{  
  for (unsigned int i=0; i<this->m(); i++)
    {
      for (unsigned int j=0; j<this->n(); j++)
        os << std::setw(8)
           << this->el(i,j) << ' ';

      os << std::endl;
    }

  return;
}
 

template<typename T > void DenseMatrixBase< T >::print_scientific (std::ostream &os) const [inherited]Prints the matrix entries with more decimal places in scientific notation.

Definition at line 85 of file dense_matrix_base.C.

{
#ifndef LIBMESH_BROKEN_IOSTREAM
  
  // save the initial format flags
  std::ios_base::fmtflags os_flags = os.flags();
  
  // Print the matrix entries.
  for (unsigned int i=0; i<this->m(); i++)
    {
      for (unsigned int j=0; j<this->n(); j++)
        os << std::setw(15)
           << std::scientific
           << std::setprecision(8)
           << this->el(i,j) << ' ';

      os << std::endl;
    }
  
  // reset the original format flags
  os.flags(os_flags);

#else
  
  // Print the matrix entries.
  for (unsigned int i=0; i<this->m(); i++)
    {
      for (unsigned int j=0; j<this->n(); j++)  
        os << std::setprecision(8)
           << this->el(i,j)
           << ' ';
      
      os << std::endl;
    }
  
  
#endif
}
 

template<typename T> virtual void DenseMatrixBase< T >::right_multiply (const DenseMatrixBase< T > &M3) [pure virtual, inherited]Performs the operation: (*this) <- (*this) * M3

Implemented in DenseMatrix< T >, and DenseMatrix< Number >.  

template<typename T> virtual void DenseMatrixBase< T >::zero () [pure virtual, inherited]Set every element in the matrix to 0. You must redefine what you mean by zeroing the matrix since it depends on how your values are stored.

Implemented in DenseMatrix< T >, and DenseMatrix< Number >.  

Friends And Related Function Documentation

 

template<typename T> std::ostream& operator<< (std::ostream &os, const DenseMatrixBase< T > &m) [friend, inherited]Formatted print as above but allows you to do DenseMatrix K; std::cout << K << std::endl;

Definition at line 115 of file dense_matrix_base.h.

  {
    m.print(os);
    return os;
  }
 

Member Data Documentation

 

template<typename T> unsigned int DenseMatrixBase< T >::_m [protected, inherited]The row dimension.

Definition at line 164 of file dense_matrix_base.h.

Referenced by DenseMatrixBase< Number >::m(), DenseMatrix< T >::operator=(), and DenseMatrix< T >::swap().  

template<typename T> unsigned int DenseMatrixBase< T >::_n [protected, inherited]The column dimension.

Definition at line 169 of file dense_matrix_base.h.

Referenced by DenseMatrixBase< Number >::n(), DenseMatrix< T >::operator=(), and DenseMatrix< T >::swap().

 

Author

Generated automatically by Doxygen for libMesh from the source code.


 

Index

NAME
SYNOPSIS
Public Member Functions
Protected Member Functions
Protected Attributes
Friends
Detailed Description
template<typename T> class DenseSubMatrix< T >
Member Function Documentation
template<typename T > template<typename T2 , typename T3 > boostcopy::enable_if_c< ScalarTraits< T2 >::value, void >::type DenseMatrixBase< T >::add (const T2factor, const DenseMatrixBase< T3 > &mat) [inline, inherited]Adds factor to every element in the matrix. This should only work if T += T2 * T3 is valid C++ and if T2 is scalar. Return type is void
template<typename T> void DenseMatrixBase< T >::condense (const unsigned inti, const unsigned intj, const Tval, DenseVectorBase< T > &rhs) [protected, inherited]Condense-out the (i,j) entry of the matrix, forcing it to take on the value val. This is useful in numerical simulations for applying boundary conditions. Preserves the symmetry of the matrix.
template<typename T> virtual T DenseMatrixBase< T >::el (const unsigned inti, const unsigned intj) const [pure virtual, inherited]Returns:
template<typename T> virtual T& DenseMatrixBase< T >::el (const unsigned inti, const unsigned intj) [pure virtual, inherited]Returns:
template<typename T> virtual void DenseMatrixBase< T >::left_multiply (const DenseMatrixBase< T > &M2) [pure virtual, inherited]Performs the operation: (*this) <- M2 * (*this)
template<typename T> unsigned int DenseMatrixBase< T >::m () const [inline, inherited]Returns:
template<typename T> void DenseMatrixBase< T >::multiply (DenseMatrixBase< T > &M1, const DenseMatrixBase< T > &M2, const DenseMatrixBase< T > &M3) [protected, inherited]Performs the computation M1 = M2 * M3 where: M1 = (m x n) M2 = (m x p) M3 = (p x n)
template<typename T> unsigned int DenseMatrixBase< T >::n () const [inline, inherited]Returns:
template<typename T > void DenseMatrixBase< T >::print (std::ostream &os) const [inherited]Pretty-print the matrix to stdout.
template<typename T > void DenseMatrixBase< T >::print_scientific (std::ostream &os) const [inherited]Prints the matrix entries with more decimal places in scientific notation.
template<typename T> virtual void DenseMatrixBase< T >::right_multiply (const DenseMatrixBase< T > &M3) [pure virtual, inherited]Performs the operation: (*this) <- (*this) * M3
template<typename T> virtual void DenseMatrixBase< T >::zero () [pure virtual, inherited]Set every element in the matrix to 0. You must redefine what you mean by zeroing the matrix since it depends on how your values are stored.
Friends And Related Function Documentation
template<typename T> std::ostream& operator<< (std::ostream &os, const DenseMatrixBase< T > &m) [friend, inherited]Formatted print as above but allows you to do DenseMatrix K; std::cout << K << std::endl;
Member Data Documentation
template<typename T> unsigned int DenseMatrixBase< T >::_m [protected, inherited]The row dimension.
template<typename T> unsigned int DenseMatrixBase< T >::_n [protected, inherited]The column dimension.
Author

This document was created by man2html, using the manual pages.
Time: 21:44:51 GMT, April 16, 2011