/usr/include/deal.II/lac/block_sparse_matrix.templates.h is in libdeal.ii-dev 8.1.0-6ubuntu1.
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 201 202 203 204 205 206 207 208 209 210 211 212 213 | // ---------------------------------------------------------------------
// $Id: block_sparse_matrix.templates.h 30036 2013-07-18 16:55:32Z maier $
//
// Copyright (C) 2000 - 2013 by the deal.II authors
//
// This file is part of the deal.II library.
//
// The deal.II library is free software; you can use it, redistribute
// it, and/or modify it under the terms of the GNU Lesser General
// Public License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// The full text of the license can be found in the file LICENSE at
// the top level of the deal.II distribution.
//
// ---------------------------------------------------------------------
#ifndef __deal2__block_sparse_matrix_templates_h
#define __deal2__block_sparse_matrix_templates_h
#include <deal.II/base/config.h>
#include <deal.II/base/memory_consumption.h>
#include <deal.II/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 (size_type r=0; r<this->n_block_rows(); ++r)
for (size_type 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 (size_type r=0; r<this->n_block_rows(); ++r)
for (size_type 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 (size_type r=0; r<this->n_block_rows(); ++r)
for (size_type c=0; c<this->n_block_cols(); ++c)
if (this->block(r,c).empty () == false)
return false;
return true;
}
template <typename number>
typename BlockSparseMatrix<number>::size_type
BlockSparseMatrix<number>::get_row_length (const size_type row) const
{
return sparsity_pattern->row_length(row);
}
template <typename number>
typename BlockSparseMatrix<number>::size_type
BlockSparseMatrix<number>::n_nonzero_elements () const
{
return sparsity_pattern->n_nonzero_elements ();
}
template <typename number>
typename BlockSparseMatrix<number>::size_type
BlockSparseMatrix<number>::n_actually_nonzero_elements (const double threshold) const
{
size_type count = 0;
for (size_type i=0; i<this->n_block_rows(); ++i)
for (size_type 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 (size_type r=0; r<this->n_block_rows(); ++r)
for (size_type 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>
std::size_t
BlockSparseMatrix<number>::memory_consumption () const
{
std::size_t mem = sizeof(*this);
mem += MemoryConsumption::memory_consumption (this->sub_objects);
for (size_type r=0; r<this->n_block_rows(); ++r)
for (size_type 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
|