Diagonal matrix. More...

#include <diagonal.hh>

Inheritance diagram for concepts::DiagonalMatrix< F >:
concepts::Matrix< F >

Public Types

typedef Cmplxtype< F >::type c_type
 Complex type of data type. More...
 
typedef _Matrix_iterator< F, const F &, const F * > const_iterator
 
typedef std::conditional< std::is_same< typename Realtype< F >::type, F >::value, typename Realtype< F >::type, typename Cmplxtype< F >::type >::type d_type
 Data type, depending if F is real or complex. More...
 
typedef _Matrix_iterator< F, F &, F * > iterator
 
typedef Realtype< F >::type r_type
 Real type of data type. More...
 
typedef F value_type
 

Public Member Functions

virtual void add (const uint i, const uint j, const F value, const bool use_threshold=false, const Real threshold_value=1e-8)
 Addition operator Add the value to the entry (i,j) if not zero (for use_threshold = false), or if the absolute avlue is bigger than the threshold_value (for use_threshold = true) More...
 
template<class H , class I >
void addInto (Matrix< H > &dest, const I fact)
 This matrix is added to the given matrix dest. More...
 
iterator begin (uint r=0)
 Iterator over the elements, standing at position (r,0). More...
 
const_iterator begin (uint r=0) const
 Constant iterator over the elements, standing at position (r,0) More...
 
 DiagonalMatrix (const Matrix< F > &matrix)
 Constructor. More...
 
template<class G >
 DiagonalMatrix (const Space< G > &spc)
 Constructor. Creates a diagonal matrix with all entries set to 0. More...
 
template<class G >
 DiagonalMatrix (const Space< G > &spc, const Array< F > entries)
 Constructor. More...
 
 DiagonalMatrix (uint dim=0)
 
iterator end ()
 Iterator, standing behind last element. More...
 
const_iterator end () const
 Constant iterator, standing behind last element. More...
 
const uint nofCols () const
 Number of columns. More...
 
const uint nofRows () const
 Number of rows. More...
 
 operator F* ()
 Returns a pointer to the diagonal data (array) More...
 
virtual void operator() (const Function< c_type > &fncY, Function< c_type > &fncX)
 
virtual void operator() (const Function< r_type > &fncY, Function< F > &fncX)
 Computes fncX = A(fncY) where A is this matrix. More...
 
virtual F & operator() (const uint i, const uint j)
 Returns and allows access to entry with indices i and j. More...
 
virtual F operator() (const uint i, const uint j) const
 Returns entry with indices i and j. More...
 
DiagonalMatrix< F > & operator+= (const Matrix< F > &d)
 Addition operator. More...
 
DiagonalMatrix< F > & operator= (F c)
 Assignement operator. More...
 
virtual bool operator== (const Matrix< F > &otherMat) const
 
void resize (uint n)
 
virtual void set (const uint i, const uint j, const F value, const bool use_threshold=false, const Real threshold_value=1e-8)
 Affectation operator Affet the value to the entry (i,j) if not zero (for use_threshold = false), or if the absolute value is bigger than the threshold_value (for use_threshold = true) More...
 
virtual void transpMult (const Vector< c_type > &fncY, Vector< c_type > &fncX)
 
virtual void transpMult (const Vector< r_type > &fncY, Vector< F > &fncX)
 Computes fncX = AT fncY where A is this matrix. More...
 
void zeros ()
 Fills the matrix diagonals with zeros. More...
 
virtual ~DiagonalMatrix ()
 

Static Public Member Functions

template<class G >
static void assembly (Matrix< F > &dest, const BilinearForm< F, G > &bf, const ElementPairList< G > &pairs)
 Assembly operator for dest using the bilinear form bf. More...
 
template<class G >
static void assembly (Matrix< F > &dest, const Sequence< ElementWithCell< G > * > seq, const BilinearForm< F, G > &bf, const Real threshold=0.0)
 Assembly operator for dest using the bilinear form bf. More...
 
template<class G >
static void assembly (Matrix< F > &dest, const Sequence< ElementWithCell< G > * > seqX, const Space< G > &spcY, const BilinearForm< F, G > &bf, const Real threshold=0.0)
 Assembly operator for dest using the bilinear form bf. More...
 
template<class G >
static void assembly (Matrix< F > &dest, const Space< G > &spc, const BilinearForm< F, G > &bf, const Real threshold=0.0)
 Assembly operator for dest using the bilinear form bf. More...
 
template<class G >
static void assembly (Matrix< F > &dest, const Space< G > &spc, const Sequence< bool > &seq, const BilinearForm< F, G > &bf, const Real threshold=0.0)
 Assembly operator for dest using the bilinear form bf on space spc. More...
 
template<class G >
static void assembly (Matrix< F > &dest, const Space< G > &spcX, const Space< G > &spcY, const BilinearForm< F, G > &bf, const Real threshold=0.0, const bool single=false)
 Assembly operator for dest using the bilinear form bf. More...
 
template<class G >
static void assembly (Matrix< F > &dest, const Space< G > &spcX, const Space< G > &spcY, const Sequence< bool > &seq, const BilinearForm< F, G > &bf, const Real threshold=0.0, const bool single=false)
 Assembly operator for dest using the bilinear form bf. More...
 
template<class G >
static void assembly (Matrix< F > &dest, Scan< Element< G > > *sc, const BilinearForm< F, G > &bf, const Real threshold=0.0)
 Assembly operator for dest using the bilinear form bf. More...
 

Protected Member Functions

virtual std::ostream & info (std::ostream &os) const
 

Private Member Functions

template<typename H , typename I >
void apply_ (const Function< H > &fncY, Function< I > &fncX)
 
template<typename H , typename I >
void applyT_ (const Vector< H > &fncY, Vector< I > &fncX)
 

Private Attributes

dummy_
 Dummy entry for the access to the off diagonal entries. More...
 
Array< F > entries_
 Diagonal entries of the matrix. More...
 

Timing Interface

These functions are used to get timings from class internal computations.

The values are stored in a user defined concepts::InOutParameters structure in different arrays (see setTimings). These arrays can be grouped into a table for easier postprocessing with

table.addMap(concepts::ResultsTable::DOUBLE, "jacobian", output);
table.addMap(concepts::ResultsTable::DOUBLE, "whole_sumfact", output);
std::ofstream ofs("table.gnuplot");
ofs << std::setprecision(20);
static InOutParameterstimings_
 Place to store timing values. More...
 
static uint timeCntr_
 Counter for timing table. More...
 
static void setTimings (InOutParameters *timings)
 Sets the class to store the timing values in. More...
 
static bool timings ()
 Returns true if the class is able to do timings. More...
 

Detailed Description

template<typename F>
class concepts::DiagonalMatrix< F >

Diagonal matrix.

A diagonal matrix must be square. Any access to off diagonal entries does not lead to an error but is simply discarded.

Author
Philipp Frauenfelder, 2002
See also
DiagonalSolver
Examples
hpFEM2d-simple.cc, and hpFEM2d.cc.

Definition at line 24 of file diagonal.hh.

Member Typedef Documentation

◆ c_type

template<typename F >
typedef Cmplxtype<F>::type concepts::DiagonalMatrix< F >::c_type

Complex type of data type.

Definition at line 29 of file diagonal.hh.

◆ const_iterator

template<class F >
typedef _Matrix_iterator<F, const F&, const F*> concepts::Matrix< F >::const_iterator
inherited

Definition at line 51 of file matrix.hh.

◆ d_type

template<typename F >
typedef std::conditional<std::is_same<typename Realtype<F>::type, F>::value , typename Realtype<F>::type, typename Cmplxtype<F>::type >::type concepts::DiagonalMatrix< F >::d_type

Data type, depending if F is real or complex.

Definition at line 32 of file diagonal.hh.

◆ iterator

template<class F >
typedef _Matrix_iterator<F, F&, F*> concepts::Matrix< F >::iterator
inherited

Definition at line 50 of file matrix.hh.

◆ r_type

template<typename F >
typedef Realtype<F>::type concepts::DiagonalMatrix< F >::r_type

Real type of data type.

Definition at line 27 of file diagonal.hh.

◆ value_type

template<class F >
typedef F concepts::Matrix< F >::value_type
inherited

Definition at line 41 of file matrix.hh.

Constructor & Destructor Documentation

◆ DiagonalMatrix() [1/4]

template<typename F >
template<class G >
concepts::DiagonalMatrix< F >::DiagonalMatrix ( const Space< G > &  spc)

Constructor. Creates a diagonal matrix with all entries set to 0.

◆ DiagonalMatrix() [2/4]

template<typename F >
concepts::DiagonalMatrix< F >::DiagonalMatrix ( uint  dim = 0)

◆ DiagonalMatrix() [3/4]

template<typename F >
template<class G >
concepts::DiagonalMatrix< F >::DiagonalMatrix ( const Space< G > &  spc,
const Array< F >  entries 
)

Constructor.

Creates a diagonal matrix with entries on the diagonal.

◆ DiagonalMatrix() [4/4]

template<typename F >
concepts::DiagonalMatrix< F >::DiagonalMatrix ( const Matrix< F > &  matrix)

Constructor.

Creates a diagonal matrix by taking the diagonal of matrix.

◆ ~DiagonalMatrix()

template<typename F >
virtual concepts::DiagonalMatrix< F >::~DiagonalMatrix ( )
virtual

Member Function Documentation

◆ add()

template<class F >
virtual void concepts::Matrix< F >::add ( const uint  i,
const uint  j,
const F  value,
const bool  use_threshold = false,
const Real  threshold_value = 1e-8 
)
virtualinherited

Addition operator Add the value to the entry (i,j) if not zero (for use_threshold = false), or if the absolute avlue is bigger than the threshold_value (for use_threshold = true)

◆ addInto()

template<typename F >
template<class H , class I >
void concepts::DiagonalMatrix< F >::addInto ( Matrix< H > &  dest,
const I  fact 
)

This matrix is added to the given matrix dest.

Parameters
destMatrix into which this matrix should be added.
factFactor by which this matrix should be multiplied.

Definition at line 127 of file diagonal.hh.

◆ apply_()

template<typename F >
template<typename H , typename I >
void concepts::DiagonalMatrix< F >::apply_ ( const Function< H > &  fncY,
Function< I > &  fncX 
)
private

Definition at line 99 of file diagonal.hh.

◆ applyT_()

template<typename F >
template<typename H , typename I >
void concepts::DiagonalMatrix< F >::applyT_ ( const Vector< H > &  fncY,
Vector< I > &  fncX 
)
private

Definition at line 116 of file diagonal.hh.

◆ assembly() [1/8]

template<class F >
template<class G >
static void concepts::Matrix< F >::assembly ( Matrix< F > &  dest,
const BilinearForm< F, G > &  bf,
const ElementPairList< G > &  pairs 
)
staticinherited

Assembly operator for dest using the bilinear form bf.

This assembly operator uses the element pairs taken from pairs. For every two elements found in a ElementPair in pairs, the bilinear form is evaluated and the result assembled into dest.

◆ assembly() [2/8]

template<class F >
template<class G >
static void concepts::Matrix< F >::assembly ( Matrix< F > &  dest,
const Sequence< ElementWithCell< G > * >  seq,
const BilinearForm< F, G > &  bf,
const Real  threshold = 0.0 
)
staticinherited

Assembly operator for dest using the bilinear form bf.

This assembly operator does not compute element matrices for two different elements. The elements are taken from the element sequence seq.

◆ assembly() [3/8]

template<class F >
template<class G >
static void concepts::Matrix< F >::assembly ( Matrix< F > &  dest,
const Sequence< ElementWithCell< G > * >  seqX,
const Space< G > &  spcY,
const BilinearForm< F, G > &  bf,
const Real  threshold = 0.0 
)
staticinherited

Assembly operator for dest using the bilinear form bf.

This assembly operator computes also the element matrices for two different elements. The elements are taken from the element sequence seqX for the test space, and the trial space spcY is fully taken into account.

◆ assembly() [4/8]

template<class F >
template<class G >
static void concepts::Matrix< F >::assembly ( Matrix< F > &  dest,
const Space< G > &  spc,
const BilinearForm< F, G > &  bf,
const Real  threshold = 0.0 
)
staticinherited

Assembly operator for dest using the bilinear form bf.

This assembly operator does not compute element matrices for two different elements. The elements are taken from the space spc.

Examples
linearDG1d.cc.

◆ assembly() [5/8]

template<class F >
template<class G >
static void concepts::Matrix< F >::assembly ( Matrix< F > &  dest,
const Space< G > &  spc,
const Sequence< bool > &  seq,
const BilinearForm< F, G > &  bf,
const Real  threshold = 0.0 
)
staticinherited

Assembly operator for dest using the bilinear form bf on space spc.

This assembly operator does not compute element matrices for two different elements. The elements are computing on the cells that are flagged by seq.

◆ assembly() [6/8]

template<class F >
template<class G >
static void concepts::Matrix< F >::assembly ( Matrix< F > &  dest,
const Space< G > &  spcX,
const Space< G > &  spcY,
const BilinearForm< F, G > &  bf,
const Real  threshold = 0.0,
const bool  single = false 
)
staticinherited

Assembly operator for dest using the bilinear form bf.

This assembly operator computes also the element matrices for two different elements (coming from test space spcX and trial space spcY).

◆ assembly() [7/8]

template<class F >
template<class G >
static void concepts::Matrix< F >::assembly ( Matrix< F > &  dest,
const Space< G > &  spcX,
const Space< G > &  spcY,
const Sequence< bool > &  seq,
const BilinearForm< F, G > &  bf,
const Real  threshold = 0.0,
const bool  single = false 
)
staticinherited

Assembly operator for dest using the bilinear form bf.

This assembly operator computes also the element matrices for two different elements (coming from test space spcX and trial space spcY). The elements are computing on the cells that are flagged by seq.

◆ assembly() [8/8]

template<class F >
template<class G >
static void concepts::Matrix< F >::assembly ( Matrix< F > &  dest,
Scan< Element< G > > *  sc,
const BilinearForm< F, G > &  bf,
const Real  threshold = 0.0 
)
staticinherited

Assembly operator for dest using the bilinear form bf.

This assembly operator does not compute element matrices for two different elements. The elements are taken from the space scanner sc.

◆ begin() [1/2]

template<class F >
iterator concepts::Matrix< F >::begin ( uint  r = 0)
inlineinherited

Iterator over the elements, standing at position (r,0).

Might be implemented differently for derived classes.

Definition at line 64 of file matrix.hh.

◆ begin() [2/2]

template<class F >
const_iterator concepts::Matrix< F >::begin ( uint  r = 0) const
inlineinherited

Constant iterator over the elements, standing at position (r,0)

Might be implemented differently for derived classes.

Definition at line 71 of file matrix.hh.

◆ end() [1/2]

template<class F >
iterator concepts::Matrix< F >::end ( )
inlineinherited

Iterator, standing behind last element.

Definition at line 66 of file matrix.hh.

◆ end() [2/2]

template<class F >
const_iterator concepts::Matrix< F >::end ( ) const
inlineinherited

Constant iterator, standing behind last element.

Definition at line 73 of file matrix.hh.

◆ info()

template<typename F >
virtual std::ostream& concepts::DiagonalMatrix< F >::info ( std::ostream &  os) const
protectedvirtual

◆ nofCols()

template<class F >
const uint concepts::Matrix< F >::nofCols ( ) const
inlineinherited

Number of columns.

Definition at line 58 of file matrix.hh.

◆ nofRows()

template<class F >
const uint concepts::Matrix< F >::nofRows ( ) const
inlineinherited

Number of rows.

Definition at line 56 of file matrix.hh.

◆ operator F*()

template<typename F >
concepts::DiagonalMatrix< F >::operator F* ( )
inline

Returns a pointer to the diagonal data (array)

Definition at line 71 of file diagonal.hh.

◆ operator()() [1/4]

template<typename F >
virtual void concepts::DiagonalMatrix< F >::operator() ( const Function< c_type > &  fncY,
Function< c_type > &  fncX 
)
virtual

Implements concepts::Matrix< F >.

◆ operator()() [2/4]

template<typename F >
virtual void concepts::DiagonalMatrix< F >::operator() ( const Function< r_type > &  fncY,
Function< F > &  fncX 
)
virtual

Computes fncX = A(fncY) where A is this matrix.

Implements concepts::Matrix< F >.

◆ operator()() [3/4]

template<typename F >
virtual F& concepts::DiagonalMatrix< F >::operator() ( const uint  i,
const uint  j 
)
virtual

Returns and allows access to entry with indices i and j.

Implements concepts::Matrix< F >.

◆ operator()() [4/4]

template<typename F >
virtual F concepts::DiagonalMatrix< F >::operator() ( const uint  i,
const uint  j 
) const
virtual

Returns entry with indices i and j.

Implements concepts::Matrix< F >.

◆ operator+=()

template<typename F >
DiagonalMatrix<F>& concepts::DiagonalMatrix< F >::operator+= ( const Matrix< F > &  d)

Addition operator.

◆ operator=()

template<typename F >
DiagonalMatrix<F>& concepts::DiagonalMatrix< F >::operator= ( c)

Assignement operator.

◆ operator==()

template<class F >
virtual bool concepts::Matrix< F >::operator== ( const Matrix< F > &  otherMat) const
inlinevirtualinherited

Definition at line 179 of file matrix.hh.

◆ resize()

template<typename F >
void concepts::DiagonalMatrix< F >::resize ( uint  n)

◆ set()

template<class F >
virtual void concepts::Matrix< F >::set ( const uint  i,
const uint  j,
const F  value,
const bool  use_threshold = false,
const Real  threshold_value = 1e-8 
)
virtualinherited

Affectation operator Affet the value to the entry (i,j) if not zero (for use_threshold = false), or if the absolute value is bigger than the threshold_value (for use_threshold = true)

◆ setTimings()

template<class F >
static void concepts::Matrix< F >::setTimings ( InOutParameters timings)
staticinherited

Sets the class to store the timing values in.

Additionally, the timeCntr_ is reset to 0. This counter is used to fill in the values into the arrays listed below in subsequent calls. The following timings are taken and stored in timings:

  • evaluation of bilinear form in bilinear_form
  • application of T matrix in tmatrix_apply
  • assembling into global matrix in global_assembly

◆ timings()

template<class F >
static bool concepts::Matrix< F >::timings ( )
staticinherited

Returns true if the class is able to do timings.

The ability to do timings depends on a compiler switch in matrix.cc file.

◆ transpMult() [1/2]

template<typename F >
virtual void concepts::DiagonalMatrix< F >::transpMult ( const Vector< c_type > &  fncY,
Vector< c_type > &  fncX 
)
virtual

Implements concepts::Matrix< F >.

◆ transpMult() [2/2]

template<typename F >
virtual void concepts::DiagonalMatrix< F >::transpMult ( const Vector< r_type > &  fncY,
Vector< F > &  fncX 
)
virtual

Computes fncX = AT fncY where A is this matrix.

Implements concepts::Matrix< F >.

◆ zeros()

template<typename F >
void concepts::DiagonalMatrix< F >::zeros ( )
inline

Fills the matrix diagonals with zeros.

Definition at line 68 of file diagonal.hh.

Member Data Documentation

◆ dummy_

template<typename F >
F concepts::DiagonalMatrix< F >::dummy_
private

Dummy entry for the access to the off diagonal entries.

Definition at line 88 of file diagonal.hh.

◆ entries_

template<typename F >
Array<F> concepts::DiagonalMatrix< F >::entries_
private

Diagonal entries of the matrix.

Definition at line 86 of file diagonal.hh.

◆ timeCntr_

template<class F >
uint concepts::Matrix< F >::timeCntr_
staticprivateinherited

Counter for timing table.

Definition at line 236 of file matrix.hh.

◆ timings_

template<class F >
InOutParameters* concepts::Matrix< F >::timings_
staticprivateinherited

Place to store timing values.

Definition at line 234 of file matrix.hh.


The documentation for this class was generated from the following file:
void addMap(enum mapTypes type, const char *name, const InOutParameters &holder)
Organizes the results in the hashes from InOutParameters in a nice table.
Definition: resultsTable.hh:23
void print(std::ostream &os) const
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich