/usr/include/deal.II/lac/block_sparse_matrix.templates.h is in libdeal.ii-dev 6.3.1-1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | //---------------------------------------------------------------------------
// $Id: block_sparse_matrix.templates.h 20586 2010-02-13 01:20:33Z bangerth $
// Version: $Name$
//
// Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2009 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.
//
//---------------------------------------------------------------------------
#ifndef __deal2__block_sparse_matrix_templates_h
#define __deal2__block_sparse_matrix_templates_h
#include <base/config.h>
#include <base/memory_consumption.h>
#include <lac/block_sparse_matrix.h>
DEAL_II_NAMESPACE_OPEN
template <typename number>
BlockSparseMatrix<number>::BlockSparseMatrix ()
{}
template <typename number>
BlockSparseMatrix<number>::
BlockSparseMatrix (const BlockSparsityPattern &sparsity)
{
reinit (sparsity);
}
template <typename number>
BlockSparseMatrix<number>::~BlockSparseMatrix ()
{
// delete previous content of
// the subobjects array
clear ();
sparsity_pattern = 0;
}
template <typename number>
BlockSparseMatrix<number> &
BlockSparseMatrix<number>::
operator = (const BlockSparseMatrix<number> &m)
{
Assert (this->row_block_indices == m.row_block_indices,
ExcBlockDimensionMismatch());
Assert (this->column_block_indices == m.column_block_indices,
ExcBlockDimensionMismatch());
// this operator does not do
// anything except than checking
// whether the base objects want to
// do something
for (unsigned int r=0; r<this->n_block_rows(); ++r)
for (unsigned int c=0; c<this->n_block_cols(); ++c)
this->block(r,c) = m.block(r,c);
return *this;
}
template <typename number>
void
BlockSparseMatrix<number>::clear ()
{
BlockMatrixBase<SparseMatrix<number> >::clear();
sparsity_pattern = 0;
}
template <typename number>
void
BlockSparseMatrix<number>::
reinit (const BlockSparsityPattern &sparsity)
{
// first delete previous content of
// the subobjects array and delete
// the table completely
clear ();
// then associate new sparsity
// pattern and resize
sparsity_pattern = &sparsity;
this->row_block_indices = sparsity.row_indices;
this->column_block_indices = sparsity.column_indices;
this->sub_objects.reinit (sparsity.n_block_rows(),
sparsity.n_block_cols());
// and reinitialize the blocks
for (unsigned int r=0; r<this->n_block_rows(); ++r)
for (unsigned int c=0; c<this->n_block_cols(); ++c)
{
BlockType *p = new SparseMatrix<number>();
p->reinit (sparsity.block(r,c));
this->sub_objects[r][c] = p;
}
}
template <typename number>
bool
BlockSparseMatrix<number>::empty () const
{
for (unsigned int r=0; r<this->n_block_rows(); ++r)
for (unsigned int c=0; c<this->n_block_cols(); ++c)
if (this->block(r,c).empty () == false)
return false;
return true;
}
template <typename number>
unsigned int
BlockSparseMatrix<number>::n_nonzero_elements () const
{
return sparsity_pattern->n_nonzero_elements ();
}
template <typename number>
unsigned int
BlockSparseMatrix<number>::n_actually_nonzero_elements (const double threshold) const
{
unsigned int count = 0;
for (unsigned int i=0; i<this->n_block_rows(); ++i)
for (unsigned int j=0; j<this->n_block_cols(); ++j)
count += this->sub_objects[i][j]->n_actually_nonzero_elements (threshold);
return count;
}
template <typename number>
const BlockSparsityPattern &
BlockSparseMatrix<number>::get_sparsity_pattern () const
{
return *sparsity_pattern;
}
template <typename number>
void
BlockSparseMatrix<number>::
print_formatted (std::ostream &out,
const unsigned int precision,
const bool scientific,
const unsigned int width,
const char *zero_string,
const double denominator) const
{
for (unsigned int r=0;r<this->n_block_rows();++r)
for (unsigned int c=0;c<this->n_block_cols();++c)
{
out << "Component (" << r << "," << c << ")" << std::endl;
this->block(r,c).print_formatted (out, precision, scientific,
width, zero_string, denominator);
}
}
template <typename number>
unsigned int
BlockSparseMatrix<number>::memory_consumption () const
{
unsigned int mem = sizeof(*this);
mem += MemoryConsumption::memory_consumption (this->sub_objects);
for (unsigned int r=0; r<this->n_block_rows(); ++r)
for (unsigned int c=0; c<this->n_block_cols(); ++c)
mem += MemoryConsumption::memory_consumption(*this->sub_objects[r][c]);
return mem;
}
DEAL_II_NAMESPACE_CLOSE
#endif // ifdef block_sparse_matrix_templates_h
|