Classes | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes

MatrixOut Class Reference
[Graphical output]

Inheritance diagram for MatrixOut:
Inheritance graph
[legend]

List of all members.

Classes

struct  Options

Public Member Functions

virtual ~MatrixOut ()
template<class Matrix >
void build_patches (const Matrix &matrix, const std::string &name, const Options options=Options(false, 1, false))

Private Types

typedef ::DataOutBase::Patch< 2, 2 > Patch

Private Member Functions

virtual const std::vector
< Patch > & 
get_patches () const
virtual std::vector< std::string > get_dataset_names () const

Static Private Member Functions

template<typename number >
static double get_element (const SparseMatrix< number > &matrix, const unsigned int i, const unsigned int j)
template<typename number >
static double get_element (const BlockSparseMatrix< number > &matrix, const unsigned int i, const unsigned int j)
template<class Matrix >
static double get_element (const Matrix &matrix, const unsigned int i, const unsigned int j)
template<class Matrix >
static double get_gridpoint_value (const Matrix &matrix, const unsigned int i, const unsigned int j, const Options &options)

Private Attributes

std::vector< Patchpatches
std::string name

Detailed Description

Output a matrix in graphical form using the generic format independent output routines of the base class. The matrix is converted into a list of patches on a 2d domain where the height is given by the elements of the matrix. The functions of the base class can then write this "mountain representation" of the matrix in a variety of graphical output formats. The coordinates of the matrix output are that the columns run with increasing x-axis, as usual, starting from zero, while the rows run into the negative y-axis, also starting from zero. Note that due to some internal restrictions, this class can only output one matrix at a time, i.e. it can not take advantage of the multiple dataset capabilities of the base class.

A typical usage of this class would be as follows:

 *    FullMatrix<double> M;
 *    ...                // fill matrix M with some values
 *
 *                       // now write out M:
 *    MatrixOut matrix_out;
 *    std::ofstream out ("M.gnuplot");
 *    matrix_out.build_patches (M, "M");
 *    matrix_out.write_gnuplot (out);
 * 

Of course, you can as well choose a different graphical output format. Also, this class supports any matrix, not only of type FullMatrix, as long as it satisfies a number of requirements, stated with the member functions of this class.

The generation of patches through the build_patches() function can be modified by giving it an object holding certain flags. See the documentation of the members of the Options class for a description of these flags.

Internals

To avoid a compiler error in Sun's Forte compiler, we derive privately from DataOutBase. Since the base class DataOutInterface does so as well, this does no harm, but calms the compiler which is suspecting an access control conflict otherwise. Testcase here:

 *    template <typename T> class V {};
 *    
 *    struct B1 { 
 *        template <int dim> struct X { 
 *    	int i[dim]; 
 *        };
 *    };
 *    
 *    struct B2 : private B1 {}; 
 *    
 *    struct D : public B2, private B1 {
 *        ~D () {};
 *        typedef B1::X<2> X;
 *        V<X> x;
 *    }; 
 *    
 *    D d;
 * 
Author:
Wolfgang Bangerth, 2001

Definition at line 88 of file matrix_out.h.


Member Typedef Documentation

typedef ::DataOutBase::Patch<2,2> MatrixOut::Patch [private]

Abbreviate the somewhat lengthy name for the DataOutBase::Patch class.

Note that we have to indicate the global scope in front of DataOutBase, since otherwise the C++ rules specify that this here indicates the DataOutBase base class of this class. Since that is a private base class, we cannot access its members, and so access to the local Patch type would be forbidden.

Definition at line 212 of file matrix_out.h.


Constructor & Destructor Documentation

virtual MatrixOut::~MatrixOut (  ) [virtual]

Destructor. Declared in order to make it virtual.


Member Function Documentation

template<class Matrix >
void MatrixOut::build_patches ( const Matrix &  matrix,
const std::string &  name,
const Options  options = Options(false, 1, false) 
)

Generate a list of patches from the given matrix and use the given string as the name of the data set upon writing to a file. Once patches have been built, you can use the functions of the base class to write the data into a files, using one of the supported output formats.

You may give a structure holding various options. See the description of the fields of this structure for more information.

Note that this function requires that we can extract elements of the matrix, which is done using the get_element() function declared below. By adding specializations, you can extend this class to other matrix classes which are not presently supported. Furthermore, we need to be able to extract the size of the matrix, for which we assume that the matrix type offers member functions m() and n(), which return the number of rows and columns, respectively.

Definition at line 380 of file matrix_out.h.

References MatrixOut::Options::block_size, MatrixOut::Options::discontinuous, get_gridpoint_value(), name, and patches.

virtual const std::vector<Patch>& MatrixOut::get_patches (  ) const [private, virtual]

Function by which the base class's functions get to know what patches they shall write to a file.

Implements DataOutInterface< 2, 2 >.

virtual std::vector<std::string> MatrixOut::get_dataset_names (  ) const [private, virtual]

Virtual function through which the names of data sets are obtained by the output functions of the base class.

Implements DataOutInterface< 2, 2 >.

template<typename number >
double MatrixOut::get_element ( const SparseMatrix< number > &  matrix,
const unsigned int  i,
const unsigned int  j 
) [inline, static, private]

Return the element with given indices of a sparse matrix.

Definition at line 306 of file matrix_out.h.

References SparseMatrix< number >::el().

Referenced by get_gridpoint_value().

template<typename number >
double MatrixOut::get_element ( const BlockSparseMatrix< number > &  matrix,
const unsigned int  i,
const unsigned int  j 
) [inline, static, private]

Return the element with given indices of a block sparse matrix.

Definition at line 319 of file matrix_out.h.

References BlockMatrixBase< SparseMatrix< number > >::el().

template<class Matrix >
double MatrixOut::get_element ( const Matrix &  matrix,
const unsigned int  i,
const unsigned int  j 
) [inline, static, private]

Return the element with given indices from any matrix type for which no specialization of this function was declared above. This will call operator() on the matrix.

Definition at line 332 of file matrix_out.h.

References LAPACKSupport::matrix.

template<class Matrix >
double MatrixOut::get_gridpoint_value ( const Matrix &  matrix,
const unsigned int  i,
const unsigned int  j,
const Options options 
) [inline, static, private]

Get the value of the matrix at gridpoint (i,j). Depending on the given flags, this can mean different things, for example if only absolute values shall be shown then the absolute value of the matrix entry is taken. If the block size is larger than one, then an average of several matrix entries is taken.

Definition at line 344 of file matrix_out.h.

References MatrixOut::Options::block_size, get_element(), and MatrixOut::Options::show_absolute_values.

Referenced by build_patches().


Member Data Documentation

std::vector<Patch> MatrixOut::patches [private]

This is a list of patches that is created each time build_patches() is called. These patches are used in the output routines of the base classes.

Definition at line 222 of file matrix_out.h.

Referenced by build_patches().

std::string MatrixOut::name [private]

Name of the matrix to be written.

Definition at line 228 of file matrix_out.h.

Referenced by build_patches().


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

deal.II documentation generated on Fri Feb 3 2012 06:04:09 by doxygen 1.7.2