From: guido Date: Fri, 30 May 2003 19:19:46 +0000 (+0000) Subject: instantiate for float matrices X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4d15233214afa8c12fcce43e5b30b2b0bf2e744a;p=dealii-svn.git instantiate for float matrices git-svn-id: https://svn.dealii.org/trunk@7692 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/lac/source/filtered_matrix.cc b/deal.II/lac/source/filtered_matrix.cc index 6923ccafec..82eeb008be 100644 --- a/deal.II/lac/source/filtered_matrix.cc +++ b/deal.II/lac/source/filtered_matrix.cc @@ -1,4 +1,4 @@ -//---------------------------- filtered_matrix.cc --------------------------- +//--------------------------------------------------------------------------- // $Id$ // Version: $Name$ // @@ -9,135 +9,32 @@ // to the file deal.II/doc/license.html for the text and // further information on this license. // -//---------------------------- filtered_matrix.cc --------------------------- +//--------------------------------------------------------------------------- #include +//TODO: Maybe split in several files? -template <> -void -FilteredMatrix,Vector >:: -get_column_entries (const unsigned int index, - std::vector &column_entries, - const bool matrix_is_symmetric) const -{ - // depending on whether the matrix - // can be assumed symmetric or not, - // either use a fast or a slow - // algorithm - if (matrix_is_symmetric == true) - // ok, matrix is symmetric. we - // may determine the matrix - // entries in this column by - // looking at the matrix entries - // in this row which is - // significantly faster since we - // can traverse them linearly and - // do not have to check each row - // for the possible existence of - // a matrix entry - { - const unsigned int * - col_nums = &(matrix->get_sparsity_pattern().get_column_numbers() - [matrix->get_sparsity_pattern().get_rowstart_indices()[index]]); - const unsigned int - row_length = matrix->get_sparsity_pattern().row_length(index); +#define TYPEMAT double +#define TYPEVEC double +#include "filtered_matrix.in.h" - for (unsigned int i=0; i,Vector >; +template class FilteredMatrix,BlockVector >; - // if not diagonal entry, - // add to list - if (c != index) - column_entries.push_back (std::make_pair(c, (*matrix)(c,index))); - }; - } - else - { - // otherwise check each row for - // occurrence of an entry in - // this column - for (unsigned int row=0; rowget_sparsity_pattern()(row,index); - if (global_index != SparsityPattern::invalid_entry) - column_entries.push_back (std::make_pair(row, - (*matrix)(row,index))); - }; - }; -} +#undef TYPEVEC +#undef TYPEMAT -template <> -void -FilteredMatrix,BlockVector >:: -get_column_entries (const unsigned int /*index*/, - std::vector &/*column_entries*/, - const bool /*matrix_is_symmetric*/) const -{ - // presently not implemented, but - // should be fairly simple to do - Assert (false, ExcNotImplemented()); -} +#define TYPEMAT float +#define TYPEVEC float +#include "filtered_matrix.in.h" +template class FilteredMatrix,Vector >; +template class FilteredMatrix,BlockVector >; +#undef TYPEVEC +#undef TYPEMAT - -template <> -void -FilteredMatrix,Vector >:: -allocate_tmp_vector () -{ - Threads::ThreadMutex::ScopedLock lock (tmp_mutex); - tmp_vector.reinit (matrix->n(), true); -} - - - -template <> -void -FilteredMatrix,Vector >:: -allocate_tmp_vector () -{ - Threads::ThreadMutex::ScopedLock lock (tmp_mutex); - tmp_vector.reinit (matrix->n(), true); -} - - - -template <> -void -FilteredMatrix,BlockVector >:: -allocate_tmp_vector () -{ - std::vector block_sizes (matrix->n_block_rows()); - for (unsigned int i=0; iblock(i,i).n(); - - Threads::ThreadMutex::ScopedLock lock (tmp_mutex); - tmp_vector.reinit (block_sizes, true); -} - - - -template <> -void -FilteredMatrix,BlockVector >:: -allocate_tmp_vector () -{ - std::vector block_sizes (matrix->n_block_rows()); - for (unsigned int i=0; iblock(i,i).n(); - - Threads::ThreadMutex::ScopedLock lock (tmp_mutex); - tmp_vector.reinit (block_sizes, true); -} - - -template class FilteredMatrix,Vector >; -template class FilteredMatrix,BlockVector >; diff --git a/deal.II/lac/source/filtered_matrix.in.h b/deal.II/lac/source/filtered_matrix.in.h new file mode 100644 index 0000000000..70d10e2887 --- /dev/null +++ b/deal.II/lac/source/filtered_matrix.in.h @@ -0,0 +1,117 @@ +//--------------------------------------------------------------------------- +// $Id$ +// Version: $Name$ +// +// Copyright (C) 2001, 2002, 2003 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. +// +//--------------------------------------------------------------------------- + + +// File included by driver file fitered_matrix.?.cc +// There, TYPEMAT and TYPEVEC must be set to the number types + + +//TODO: Check if this cannot be implemented with iterators +// and applied to SparseMatrixEZ + +template <> +void +FilteredMatrix,Vector >:: +get_column_entries (const unsigned int index, + std::vector &column_entries, + const bool matrix_is_symmetric) const +{ + // depending on whether the matrix + // can be assumed symmetric or not, + // either use a fast or a slow + // algorithm + if (matrix_is_symmetric == true) + // ok, matrix is symmetric. we + // may determine the matrix + // entries in this column by + // looking at the matrix entries + // in this row which is + // significantly faster since we + // can traverse them linearly and + // do not have to check each row + // for the possible existence of + // a matrix entry + { + const unsigned int * + col_nums = &(matrix->get_sparsity_pattern().get_column_numbers() + [matrix->get_sparsity_pattern().get_rowstart_indices()[index]]); + const unsigned int + row_length = matrix->get_sparsity_pattern().row_length(index); + + for (unsigned int i=0; iget_sparsity_pattern()(row,index); + if (global_index != SparsityPattern::invalid_entry) + column_entries.push_back (std::make_pair(row, + (*matrix)(row,index))); + }; + }; +} + + + +template <> +void +FilteredMatrix,BlockVector >:: +get_column_entries (const unsigned int /*index*/, + std::vector &/*column_entries*/, + const bool /*matrix_is_symmetric*/) const +{ + // presently not implemented, but + // should be fairly simple to do + Assert (false, ExcNotImplemented()); +} + + + + +template <> +void +FilteredMatrix,Vector >:: +allocate_tmp_vector () +{ + Threads::ThreadMutex::ScopedLock lock (tmp_mutex); + tmp_vector.reinit (matrix->n(), true); +} + + + +template <> +void +FilteredMatrix,BlockVector >:: +allocate_tmp_vector () +{ + std::vector block_sizes (matrix->n_block_rows()); + for (unsigned int i=0; iblock(i,i).n(); + + Threads::ThreadMutex::ScopedLock lock (tmp_mutex); + tmp_vector.reinit (block_sizes, true); +}