KAINAN source/fe/mapping_q1_eulerian.cc
KAINAN source/fe/mapping_q.cc
KAINAN source/fe/mapping_q_eulerian.cc
-source/grid/grid_generator.cc
-source/grid/grid_in.cc
-source/grid/grid_out.cc
-source/grid/grid_refinement.cc
+BRUNO source/grid/grid_generator.cc
+BRUNO source/grid/grid_in.cc
+BRUNO source/grid/grid_out.cc
+BRUNO source/grid/grid_refinement.cc
source/grid/grid_reordering.cc
source/grid/grid_tools.cc
source/grid/intergrid_map.cc
BRUNO source/lac/precondition_block.cc
BRUNO source/lac/precondition_block_ez.cc
BRUNO source/lac/relaxation_block.cc
-source/lac/slepc_solver.cc
-source/lac/slepc_spectral_transformation.cc
-source/lac/solver.cc
-source/lac/solver_control.cc
-source/lac/sparse_decomposition.cc
-source/lac/sparse_direct.cc
-source/lac/sparse_ilu.cc
-source/lac/sparse_matrix.cc
-source/lac/sparse_matrix_ez.cc
-source/lac/sparse_mic.cc
-source/lac/sparse_vanka.cc
-source/lac/sparsity_pattern.cc
-source/lac/sparsity_tools.cc
+BRUNO source/lac/slepc_solver.cc
+BRUNO source/lac/slepc_spectral_transformation.cc
+BRUNO source/lac/solver.cc
+BRUNO source/lac/solver_control.cc
+BRUNO source/lac/sparse_decomposition.cc
+BRUNO source/lac/sparse_direct.cc
+BRUNO source/lac/sparse_ilu.cc
+BRUNO source/lac/sparse_matrix.cc
+BRUNO source/lac/sparse_matrix_ez.cc
+BRUNO source/lac/sparse_mic.cc
+BRUNO source/lac/sparse_vanka.cc
+BRUNO source/lac/sparsity_pattern.cc
+BRUNO source/lac/sparsity_tools.cc
BRUNO source/lac/swappable_vector.cc
BRUNO source/lac/timestep_control.cc
BRUNO source/lac/tridiagonal_matrix.cc
MARKUS include/deal.II/dofs/block_info.h
TIMO include/deal.II/dofs/dof_accessor.h
TIMO include/deal.II/dofs/dof_accessor.templates.h
-include/deal.II/dofs/dof_constraints.h
+BRUNO include/deal.II/dofs/dof_constraints.h
UWE include/deal.II/dofs/dof_faces.h
MARKUS include/deal.II/dofs/dof_handler.h
TIMO include/deal.II/dofs/dof_handler_policy.h
-include/deal.II/dofs/dof_iterator_selector.h
+BRUNO include/deal.II/dofs/dof_iterator_selector.h
UWE include/deal.II/dofs/dof_levels.h
UWE include/deal.II/dofs/dof_objects.h
HELENE include/deal.II/dofs/dof_renumbering.h
UWE include/deal.II/dofs/dof_tools.h
-include/deal.II/dofs/function_map.h
+BRUNO include/deal.II/dofs/function_map.h
TIMO include/deal.II/dofs/number_cache.h
GK include/deal.II/fe/fe_abf.h
GK include/deal.II/fe/fe_base.h
KAINAN include/deal.II/fe/mapping_q1.h
KAINAN include/deal.II/fe/mapping_q_eulerian.h
KAINAN include/deal.II/fe/mapping_q.h
-include/deal.II/grid/filtered_iterator.h
-include/deal.II/grid/geometry_info.h
-include/deal.II/grid/grid_generator.h
-include/deal.II/grid/grid_in.h
-include/deal.II/grid/grid_out.h
-include/deal.II/grid/grid_refinement.h
+BRUNO include/deal.II/grid/filtered_iterator.h
+BRUNO include/deal.II/grid/geometry_info.h
+BRUNO include/deal.II/grid/grid_generator.h
+BRUNO include/deal.II/grid/grid_in.h
+BRUNO include/deal.II/grid/grid_out.h
+BRUNO include/deal.II/grid/grid_refinement.h
include/deal.II/grid/grid_reordering.h
include/deal.II/grid/grid_reordering_internal.h
include/deal.II/grid/grid_tools.h
BRUNO include/deal.II/lac/relaxation_block.templates.h
BRUNO include/deal.II/lac/schur_matrix.h
BRUNO include/deal.II/lac/shifted_matrix.h
-include/deal.II/lac/slepc_solver.h
-include/deal.II/lac/slepc_spectral_transformation.h
-include/deal.II/lac/solver_bicgstab.h
-include/deal.II/lac/solver_cg.h
-include/deal.II/lac/solver_control.h
-include/deal.II/lac/solver_gmres.h
-include/deal.II/lac/solver.h
-include/deal.II/lac/solver_minres.h
-include/deal.II/lac/solver_qmrs.h
-include/deal.II/lac/solver_relaxation.h
-include/deal.II/lac/solver_richardson.h
-include/deal.II/lac/solver_selector.h
-include/deal.II/lac/sparse_decomposition.h
-include/deal.II/lac/sparse_decomposition.templates.h
-include/deal.II/lac/sparse_direct.h
-include/deal.II/lac/sparse_ilu.h
-include/deal.II/lac/sparse_ilu.templates.h
-include/deal.II/lac/sparse_matrix_ez.h
-include/deal.II/lac/sparse_matrix_ez.templates.h
-include/deal.II/lac/sparse_matrix.h
-include/deal.II/lac/sparse_matrix.templates.h
-include/deal.II/lac/sparse_mic.h
-include/deal.II/lac/sparse_mic.templates.h
-include/deal.II/lac/sparse_vanka.h
-include/deal.II/lac/sparse_vanka.templates.h
-include/deal.II/lac/sparsity_pattern.h
-include/deal.II/lac/sparsity_tools.h
+BRUNO include/deal.II/lac/slepc_solver.h
+BRUNO include/deal.II/lac/slepc_spectral_transformation.h
+BRUNO include/deal.II/lac/solver_bicgstab.h
+BRUNO include/deal.II/lac/solver_cg.h
+BRUNO include/deal.II/lac/solver_control.h
+BRUNO include/deal.II/lac/solver_gmres.h
+BRUNO include/deal.II/lac/solver.h
+BRUNO include/deal.II/lac/solver_minres.h
+BRUNO include/deal.II/lac/solver_qmrs.h
+BRUNO include/deal.II/lac/solver_relaxation.h
+BRUNO include/deal.II/lac/solver_richardson.h
+BRUNO include/deal.II/lac/solver_selector.h
+BRUNO include/deal.II/lac/sparse_decomposition.h
+BRUNO include/deal.II/lac/sparse_decomposition.templates.h
+BRUNO include/deal.II/lac/sparse_direct.h
+BRUNO include/deal.II/lac/sparse_ilu.h
+BRUNO include/deal.II/lac/sparse_ilu.templates.h
+BRUNO include/deal.II/lac/sparse_matrix_ez.h
+BRUNO include/deal.II/lac/sparse_matrix_ez.templates.h
+BRUNO include/deal.II/lac/sparse_matrix.h
+BRUNO include/deal.II/lac/sparse_matrix.templates.h
+BRUNO include/deal.II/lac/sparse_mic.h
+BRUNO include/deal.II/lac/sparse_mic.templates.h
+BRUNO include/deal.II/lac/sparse_vanka.h
+BRUNO include/deal.II/lac/sparse_vanka.templates.h
+BRUNO include/deal.II/lac/sparsity_pattern.h
+BRUNO include/deal.II/lac/sparsity_tools.h
BRUNO include/deal.II/lac/swappable_vector.h
BRUNO include/deal.II/lac/swappable_vector.templates.h
BRUNO include/deal.II/lac/transpose_matrix.h
class GridGenerator
{
public:
+ /**
+ * Declare type for number of cell.
+ */
+ typedef types::global_dof_index size_type;
+
/**
* Initialize the given triangulation with a hypercube (line in 1D, square
* in 2D, etc) consisting of exactly one cell. The hypercube volume is the
static
void
subdivided_parallelepiped (Triangulation<dim> &tria,
- const unsigned int n_subdivisions,
+ const size_type n_subdivisions,
const Point<dim> (&corners) [dim],
const bool colorize = false);
static
void
subdivided_parallelepiped (Triangulation<dim> &tria,
- const unsigned int ( n_subdivisions) [dim],
+ const size_type ( n_subdivisions) [dim],
const Point<dim> (&corners) [dim],
const bool colorize = false);
const Point<dim> ¢er,
const double inner_radius,
const double outer_radius,
- const unsigned int n_cells = 0,
+ const size_type n_cells = 0,
bool colorize = false);
/**
const Point<dim> ¢er,
const double inner_radius,
const double outer_radius,
- const unsigned int n_cells = 0,
+ const size_type n_cells = 0,
const bool colorize = false);
const Point<dim> ¢er,
const double inner_radius,
const double outer_radius,
- const unsigned int n_cells = 0,
+ const size_type n_cells = 0,
const bool colorize = false);
/**
const double length,
const double inner_radius,
const double outer_radius,
- const unsigned int n_radial_cells = 0,
- const unsigned int n_axial_cells = 0);
+ const size_type n_radial_cells = 0,
+ const size_type n_axial_cells = 0);
* @param r The radius of the cylinder bend together as loop.
*/
static void moebius (Triangulation<3,3> &tria,
- const unsigned int n_cells,
+ const size_type n_cells,
const unsigned int n_rotations,
const double R,
const double r);
static
void
extrude_triangulation(const Triangulation<2, 2> & input,
- const unsigned int n_slices,
+ const size_type n_slices,
const double height,
Triangulation<3,3> &result);
*/
template <int dim>
static void laplace_transformation (Triangulation<dim> &tria,
- const std::map<unsigned int,Point<dim> > &new_points);
+ const std::map<size_type,Point<dim> > &new_points);
/**
* Exception
static
void
laplace_solve (const SparseMatrix<double> &S,
- const std::map<unsigned int,double> &m,
+ const std::map<size_type,double> &m,
Vector<double> &u);
};
class SolverBase
{
public:
+ /**
+ * Declare type for container size.
+ */
+ typedef types::global_dof_index size_type;
/**
* Constructor. Takes the MPI communicator over which parallel
solve (const PETScWrappers::MatrixBase &A,
std::vector<double> &kr,
std::vector<OutputVector> &vr,
- const unsigned int n_eigenvectors);
+ const size_type n_eigenvectors);
/**
* Same as above, but here a composite method for solving the
const PETScWrappers::MatrixBase &B,
std::vector<double> &kr,
std::vector<OutputVector> &vr,
- const unsigned int n_eigenvectors);
+ const size_type n_eigenvectors);
/**
* Initialize solver for the linear system $Ax=\lambda x$. (Note:
* SLEPc eigensolver used.
*/
void
- solve (const unsigned int n_eigenvectors, unsigned int *n_converged);
+ solve (const size_type n_eigenvectors, size_type *n_converged);
/**
* Access the solutions for a solved eigenvector problem, pair
* \text{n\_converged}-1$.
*/
void
- get_eigenpair (const unsigned int index,
+ get_eigenpair (const size_type index,
#ifndef PETSC_USE_COMPLEX
double &kr,
#else
SolverBase::solve (const PETScWrappers::MatrixBase &A,
std::vector<double> &kr,
std::vector<OutputVector> &vr,
- const unsigned int n_eigenvectors = 1)
+ const size_type n_eigenvectors = 1)
{
- unsigned int n_converged = 0;
+ size_type n_converged = 0;
// Set the matrices of the problem
set_matrices (A);
vr.resize (n_converged, vr.front());
kr.resize (n_converged);
- for (unsigned int index=0; index<n_converged; ++index)
+ for (size_type index=0; index<n_converged; ++index)
get_eigenpair (index, kr[index], vr[index]);
}
const PETScWrappers::MatrixBase &B,
std::vector<double> &kr,
std::vector<OutputVector> &vr,
- const unsigned int n_eigenvectors = 1)
+ const size_type n_eigenvectors = 1)
{
- unsigned int n_converged = 0;
+ size_type n_converged = 0;
// Set the matrices of the problem
set_matrices (A, B);
vr.resize (n_converged, vr.front());
kr.resize (n_converged);
- for (unsigned int index=0; index<n_converged; ++index)
+ for (size_type index=0; index<n_converged; ++index)
get_eigenpair (index, kr[index], vr[index]);
}
}
class SolverCG : public Solver<VECTOR>
{
public:
+ /**
+ * Declare type for container size.
+ */
+ typedef types::global_dof_index size_type;
+
/**
* Standardized data struct to pipe
* additional data to the solver.
if (additional_data.compute_all_condition_numbers && (diagonal.size()>1))
{
TridiagonalMatrix<double> T(diagonal.size(), true);
- for (unsigned int i=0; i<diagonal.size(); ++i)
+ for (size_type i=0; i<diagonal.size(); ++i)
{
T(i,i) = diagonal[i];
if (i< diagonal.size()-1)
if (do_eigenvalues)
{
TridiagonalMatrix<double> T(diagonal.size(), true);
- for (unsigned int i=0; i<diagonal.size(); ++i)
+ for (size_type i=0; i<diagonal.size(); ++i)
{
T(i,i) = diagonal[i];
if (i< diagonal.size()-1)
T.eigenvalue(T.n()-1)/T.eigenvalue(0) << std::endl;
if (additional_data.compute_eigenvalues)
{
- for (unsigned int i=0; i<T.n(); ++i)
+ for (size_type i=0; i<T.n(); ++i)
deallog << ' ' << T.eigenvalue(i);
deallog << std::endl;
}
SparseLUDecomposition (const SparsityPattern &sparsity) DEAL_II_DEPRECATED;
public:
+ /**
+ * Declare type for container size.
+ */
+ typedef types::global_dof_index size_type;
+
/**
* Destruction. Mark the
* destructor pure to ensure that
* <tt>strengthen_diagonal</tt>'s
* value.
*/
- virtual number get_strengthen_diagonal(const number rowsum, const unsigned int row) const;
+ virtual number get_strengthen_diagonal(const number rowsum, const size_type row) const;
/**
* State flag. If not in
* available after invocation of
* decompose().
*/
- std::vector<const unsigned int *> prebuilt_lower_bound;
+ std::vector<const size_type *> prebuilt_lower_bound;
private:
/**
inline number
SparseLUDecomposition<number>::
get_strengthen_diagonal(const number /*rowsum*/,
- const unsigned int /*row*/) const
+ const size_type /*row*/) const
{
return strengthen_diagonal;
}
{
decomposed = false;
- std::vector<const unsigned int *> tmp;
+ std::vector<const size_type *> tmp;
tmp.swap (prebuilt_lower_bound);
SparseMatrix<number>::clear();
typename SparsityPattern::ExcDiagonalNotOptimized());
decomposed = false;
{
- std::vector<const unsigned int *> tmp;
+ std::vector<const size_type *> tmp;
tmp.swap (prebuilt_lower_bound);
}
SparseMatrix<number>::reinit (*sparsity_pattern_to_use);
typename SparsityPattern::ExcDiagonalNotOptimized());
decomposed = false;
{
- std::vector<const unsigned int *> tmp;
+ std::vector<const size_type *> tmp;
tmp.swap (prebuilt_lower_bound);
}
SparseMatrix<number>::reinit (sparsity);
void
SparseLUDecomposition<number>::prebuild_lower_bound()
{
- const unsigned int *const
+ const size_type *const
column_numbers = this->get_sparsity_pattern().colnums;
const std::size_t *const
rowstart_indices = this->get_sparsity_pattern().rowstart;
- const unsigned int N = this->m();
+ const size_type N = this->m();
prebuilt_lower_bound.resize (N);
- for (unsigned int row=0; row<N; row++)
+ for (size_type row=0; row<N; row++)
{
prebuilt_lower_bound[row]
= Utilities::lower_bound (&column_numbers[rowstart_indices[row]+1],
SparseMatrix<number>::operator= (number(0));
// both allow more and less entries in the new matrix
- for (unsigned int row=0; row<this->m(); ++row)
+ for (size_type row=0; row<this->m(); ++row)
{
typename SparseMatrix<number>::iterator index = this->begin(row);
typename SparseMatrix<somenumber>::const_iterator
void
SparseLUDecomposition<number>::strengthen_diagonal_impl ()
{
- for (unsigned int row=0; row<this->m(); ++row)
+ for (size_type row=0; row<this->m(); ++row)
{
// get the global index of the first
// non-diagonal element in this row
class SparseDirectMA27 : public Subscriptor
{
public:
+ /**
+ * Declare type for container size.
+ */
+ typedef types::global_dof_index size_type;
+
/**
* Constructor. See the
* documentation of this class
* the sparsity pattern on and
* above the diagonal.
*/
- unsigned int n_nonzero_elements;
+ size_type n_nonzero_elements;
/**
* Arrays holding row and column
* indices.
*/
- std::vector<unsigned int> row_numbers;
- std::vector<unsigned int> column_numbers;
+ std::vector<size_type> row_numbers;
+ std::vector<size_type> column_numbers;
/**
* Array to hold the matrix
/**
* Length of the <tt>A</tt> array.
*/
- unsigned int LA;
+ size_type LA;
/**
* Scratch arrays and variables
* letters as is usual in
* Fortran.
*/
- unsigned int LIW;
- std::vector<unsigned int> IW;
- std::vector<unsigned int> IKEEP;
- std::vector<unsigned int> IW1;
+ size_type LIW;
+ std::vector<size_type> IW;
+ std::vector<size_type> IKEEP;
+ std::vector<size_type> IW1;
- unsigned int NSTEPS;
- unsigned int MAXFRT;
+ size_type NSTEPS;
+ size_type MAXFRT;
/**
* Two values that live inside a
* from the Fortran functions to
* the outside world.
*/
- unsigned int NRLNEC;
- unsigned int NIRNEC;
+ size_type NRLNEC;
+ size_type NIRNEC;
/**
* Flag indicating the level of
* with the given args, either
* locally or remote.
*/
- void call_ma27ad (const unsigned int *N,
- const unsigned int *NZ,
- const unsigned int *IRN,
- const unsigned int *ICN,
- unsigned int *IW,
- const unsigned int *LIW,
- unsigned int *IKEEP,
- unsigned int *IW1,
- unsigned int *NSTEPS,
- int *IFLAG);
+ void call_ma27ad (const size_type *N,
+ const size_type *NZ,
+ const size_type *IRN,
+ const size_type *ICN,
+ size_type *IW,
+ const size_type *LIW,
+ size_type *IKEEP,
+ size_type *IW1,
+ size_type *NSTEPS,
+ int *IFLAG);
/**
* Call the respective function
* with the given args, either
* locally or remote.
*/
- void call_ma27bd (const unsigned int *N,
- const unsigned int *NZ,
- const unsigned int *IRN,
- const unsigned int *ICN,
- double *A,
- const unsigned int *LA,
- unsigned int *IW,
- const unsigned int *LIW,
- const unsigned int *IKEEP,
- const unsigned int *NSTEPS,
- unsigned int *MAXFRT,
- unsigned int *IW1,
- int *IFLAG);
+ void call_ma27bd (const size_type *N,
+ const size_type *NZ,
+ const size_type *IRN,
+ const size_type *ICN,
+ double *A,
+ const size_type *LA,
+ size_type *IW,
+ const size_type *LIW,
+ const size_type *IKEEP,
+ const size_type *NSTEPS,
+ size_type *MAXFRT,
+ size_type *IW1,
+ int *IFLAG);
/**
* Call the respective function
* with the given args, either
* locally or remote.
*/
- void call_ma27cd (const unsigned int *N,
- const double *A,
- const unsigned int *LA,
- const unsigned int *IW,
- const unsigned int *LIW,
- const unsigned int *MAXFRT,
- double *RHS,
- const unsigned int *IW1,
- const unsigned int *NSTEPS) const;
+ void call_ma27cd (const size_type *N,
+ const double *A,
+ const size_type *LA,
+ const size_type *IW,
+ const size_type *LIW,
+ const size_type *MAXFRT,
+ double *RHS,
+ const size_type *IW1,
+ const size_type *NSTEPS) const;
/**
* Call the respective function
* with the given args, either
* locally or remote.
*/
- void call_ma27x1 (unsigned int *NRLNEC);
+ void call_ma27x1 (size_type *NRLNEC);
/**
* Call the respective function
* with the given args, either
* locally or remote.
*/
- void call_ma27x2 (unsigned int *NIRNEC);
+ void call_ma27x2 (size_type *NIRNEC);
/**
* Call the respective function
* with the given args, either
* locally or remote.
*/
- void call_ma27x3 (const unsigned int *LP);
+ void call_ma27x3 (const size_type *LP);
};
class SparseDirectMA47 : public Subscriptor
{
public:
+ /**
+ * Declare type for container size.
+ */
+ typedef types::global_dof_index size_type;
+
/**
* Constructor. See the
* documentation of this class
* the sparsity pattern on and
* above the diagonal.
*/
- unsigned int n_nonzero_elements;
+ size_type n_nonzero_elements;
/**
* Control values set by <tt>MA47ID</tt>.
*/
- double CNTL[2];
- unsigned int ICNTL[7];
+ double CNTL[2];
+ size_type ICNTL[7];
/**
* Info field filled by the MA47
* Arrays holding row and column
* indices.
*/
- std::vector<unsigned int> row_numbers;
- std::vector<unsigned int> column_numbers;
+ std::vector<size_type> row_numbers;
+ std::vector<size_type> column_numbers;
/**
* Array to hold the matrix
/**
* Length of the <tt>A</tt> array.
*/
- unsigned int LA;
+ size_type LA;
/**
* Scratch arrays and variables
* letters as is usual in
* Fortran.
*/
- unsigned int LIW;
- std::vector<unsigned int> IW;
- std::vector<unsigned int> KEEP;
- std::vector<unsigned int> IW1;
+ size_type LIW;
+ std::vector<size_type> IW;
+ std::vector<size_type> KEEP;
+ std::vector<size_type> IW1;
/**
* Mutex for synchronising access
* Call the <tt>ma47id</tt> function
* with the given args.
*/
- void call_ma47id (double *CNTL,
- unsigned int *ICNTL);
+ void call_ma47id (double *CNTL,
+ size_type *ICNTL);
/**
* Call the <tt>ma47ad</tt> function
* with the given args.
*/
- void call_ma47ad (const unsigned int *n_rows,
- const unsigned int *n_nonzero_elements,
- unsigned int *row_numbers,
- unsigned int *column_numbers,
- unsigned int *IW,
- const unsigned int *LIW,
- unsigned int *KEEP,
- const unsigned int *ICNTL,
- int *INFO);
+ void call_ma47ad (const size_type *n_rows,
+ const size_type *n_nonzero_elements,
+ size_type *row_numbers,
+ size_type *column_numbers,
+ size_type *IW,
+ const size_type *LIW,
+ size_type *KEEP,
+ const size_type *ICNTL,
+ int *INFO);
/**
* Call the <tt>ma47bd</tt> function
* with the given args.
*/
- void call_ma47bd (const unsigned int *n_rows,
- const unsigned int *n_nonzero_elements,
- const unsigned int *column_numbers,
- double *A,
- const unsigned int *LA,
- unsigned int *IW,
- const unsigned int *LIW,
- const unsigned int *KEEP,
- const double *CNTL,
- const unsigned int *ICNTL,
- unsigned int *IW1,
- int *INFO);
+ void call_ma47bd (const size_type *n_rows,
+ const size_type *n_nonzero_elements,
+ const size_type *column_numbers,
+ double *A,
+ const size_type *LA,
+ size_type *IW,
+ const size_type *LIW,
+ const size_type *KEEP,
+ const double *CNTL,
+ const size_type *ICNTL,
+ size_type *IW1,
+ int *INFO);
/**
* Call the <tt>ma47bd</tt> function
* with the given args.
*/
- void call_ma47cd (const unsigned int *n_rows,
- const double *A,
- const unsigned int *LA,
- const unsigned int *IW,
- const unsigned int *LIW,
- double *rhs_and_solution,
- unsigned int *IW1,
- const unsigned int *ICNTL);
+ void call_ma47cd (const size_type *n_rows,
+ const double *A,
+ const size_type *LA,
+ const size_type *IW,
+ const size_type *LIW,
+ double *rhs_and_solution,
+ size_type *IW1,
+ const size_type *ICNTL);
};
DMUMPS_STRUC_C id;
#endif // DEAL_II_USE_MUMPS
- double *a;
- double *rhs;
- int *irn;
- int *jcn;
- unsigned int n;
- unsigned int nz;
+ double *a;
+ double *rhs;
+ int *irn;
+ int *jcn;
+ types::global_dof_index n;
+ types::global_dof_index nz;
/**
* This function initializes a MUMPS instance
bool initialize_called;
public:
+ /**
+ * Declare type for container size.
+ */
+ typedef types::global_dof_index size_type;
/**
* Constructor
class SparseILU : public SparseLUDecomposition<number>
{
public:
+ /**
+ * Declare type for container size.
+ */
+ typedef types::global_dof_index size_type;
+
/**
* Constructor. Does nothing.
*
// translating in essence the algorithm given at the end of section 10.3.2,
// using the names of variables used there
const SparsityPattern &sparsity = this->get_sparsity_pattern();
- const std::size_t *const ia = sparsity.rowstart;
- const unsigned int *const ja = sparsity.colnums;
+ const std::size_t *const ia = sparsity.rowstart;
+ const size_type *const ja = sparsity.colnums;
number *luval = this->SparseMatrix<number>::val;
- const unsigned int N = this->m();
- unsigned int jrow = 0;
+ const size_type N = this->m();
+ size_type jrow = 0;
- std::vector<unsigned int> iw (N, numbers::invalid_unsigned_int);
+ std::vector<size_type> iw (N, numbers::invalid_unsigned_int);
- for (unsigned int k=0; k<N; ++k)
+ for (size_type k=0; k<N; ++k)
{
- const unsigned int j1 = ia[k],
- j2 = ia[k+1]-1;
+ const size_type j1 = ia[k],
+ j2 = ia[k+1]-1;
- for (unsigned int j=j1; j<=j2; ++j)
+ for (size_type j=j1; j<=j2; ++j)
iw[ja[j]] = j;
// the algorithm in the book works on the elements of row k left of the
// diagonal. however, since we store the diagonal element at the first
// position, start at the element after the diagonal and run as long as
// we don't walk into the right half
- unsigned int j = j1+1;
+ size_type j = j1+1;
// pathological case: the current row of the matrix has only the
// diagonal entry. then we have nothing to do.
luval[j] = t1;
// jj runs from just right of the diagonal to the end of the row
- unsigned int jj = ia[jrow]+1;
+ size_type jj = ia[jrow]+1;
while (ja[jj] < jrow)
++jj;
for (; jj<ia[jrow+1]; ++jj)
{
- const unsigned int jw = iw[ja[jj]];
+ const size_type jw = iw[ja[jj]];
if (jw != numbers::invalid_unsigned_int)
luval[jw] -= t1 * luval[jj];
}
luval[ia[k]] = 1./luval[ia[k]];
- for (unsigned int j=j1; j<=j2; ++j)
+ for (size_type j=j1; j<=j2; ++j)
iw[ja[j]] = numbers::invalid_unsigned_int;
}
}
Assert (dst.size() == src.size(), ExcDimensionMismatch(dst.size(), src.size()));
Assert (dst.size() == this->m(), ExcDimensionMismatch(dst.size(), this->m()));
- const unsigned int N=dst.size();
- const std::size_t *const rowstart_indices
+ const size_type N=dst.size();
+ const std::size_t *const rowstart_indices
= this->get_sparsity_pattern().rowstart;
- const unsigned int *const column_numbers
+ const size_type *const column_numbers
= this->get_sparsity_pattern().colnums;
// solve LUx=b in two steps:
// perform it at the outset of the
// loop
dst = src;
- for (unsigned int row=0; row<N; ++row)
+ for (size_type row=0; row<N; ++row)
{
// get start of this row. skip the
// diagonal element
- const unsigned int *const rowstart = &column_numbers[rowstart_indices[row]+1];
+ const size_type *const rowstart = &column_numbers[rowstart_indices[row]+1];
// find the position where the part
// right of the diagonal starts
- const unsigned int *const first_after_diagonal = this->prebuilt_lower_bound[row];
+ const size_type *const first_after_diagonal = this->prebuilt_lower_bound[row];
somenumber dst_row = dst(row);
const number *luval = this->SparseMatrix<number>::val +
(rowstart - column_numbers);
- for (const unsigned int *col=rowstart; col!=first_after_diagonal; ++col, ++luval)
+ for (const size_type *col=rowstart; col!=first_after_diagonal; ++col, ++luval)
dst_row -= *luval * dst(*col);
dst(row) = dst_row;
}
for (int row=N-1; row>=0; --row)
{
// get end of this row
- const unsigned int *const rowend = &column_numbers[rowstart_indices[row+1]];
+ const size_type *const rowend = &column_numbers[rowstart_indices[row+1]];
// find the position where the part
// right of the diagonal starts
- const unsigned int *const first_after_diagonal = this->prebuilt_lower_bound[row];
+ const size_type *const first_after_diagonal = this->prebuilt_lower_bound[row];
somenumber dst_row = dst(row);
const number *luval = this->SparseMatrix<number>::val +
(first_after_diagonal - column_numbers);
- for (const unsigned int *col=first_after_diagonal; col!=rowend; ++col, ++luval)
+ for (const size_type *col=first_after_diagonal; col!=rowend; ++col, ++luval)
dst_row -= *luval * dst(*col);
// scale by the diagonal element.
Assert (dst.size() == src.size(), ExcDimensionMismatch(dst.size(), src.size()));
Assert (dst.size() == this->m(), ExcDimensionMismatch(dst.size(), this->m()));
- const unsigned int N=dst.size();
- const std::size_t *const rowstart_indices
+ const size_type N=dst.size();
+ const std::size_t *const rowstart_indices
= this->get_sparsity_pattern().rowstart;
- const unsigned int *const column_numbers
+ const size_type *const column_numbers
= this->get_sparsity_pattern().colnums;
// solve (LU)'x=b in two steps:
Vector<somenumber> tmp (N);
dst = src;
- for (unsigned int row=0; row<N; ++row)
+ for (size_type row=0; row<N; ++row)
{
dst(row) -= tmp (row);
// scale by the diagonal element.
dst(row) *= this->diag_element(row);
// get end of this row
- const unsigned int *const rowend = &column_numbers[rowstart_indices[row+1]];
+ const size_type *const rowend = &column_numbers[rowstart_indices[row+1]];
// find the position where the part
// right of the diagonal starts
- const unsigned int *const first_after_diagonal = this->prebuilt_lower_bound[row];
+ const size_type *const first_after_diagonal = this->prebuilt_lower_bound[row];
const somenumber dst_row = dst (row);
const number *luval = this->SparseMatrix<number>::val +
(first_after_diagonal - column_numbers);
- for (const unsigned int *col=first_after_diagonal; col!=rowend; ++col, ++luval)
+ for (const size_type *col=first_after_diagonal; col!=rowend; ++col, ++luval)
tmp(*col) += *luval * dst_row;
}
// get start of this row. skip the
// diagonal element
- const unsigned int *const rowstart = &column_numbers[rowstart_indices[row]+1];
+ const size_type *const rowstart = &column_numbers[rowstart_indices[row]+1];
// find the position where the part
// right of the diagonal starts
- const unsigned int *const first_after_diagonal = this->prebuilt_lower_bound[row];
+ const size_type *const first_after_diagonal = this->prebuilt_lower_bound[row];
const somenumber dst_row = dst (row);
const number *luval = this->SparseMatrix<number>::val +
(rowstart - column_numbers);
- for (const unsigned int *col=rowstart; col!=first_after_diagonal; ++col, ++luval)
+ for (const size_type *col=rowstart; col!=first_after_diagonal; ++col, ++luval)
tmp(*col) += *luval * dst_row;
}
}
*/
namespace SparseMatrixIterators
{
+ /**
+ * Declare type for container size.
+ */
+ typedef types::global_dof_index size_type;
+
// forward declaration
template <typename number, bool Constness>
class Iterator;
* @deprecated This constructor is deprecated. Use the other constructor
* with a global index instead.
*/
- Accessor (MatrixType *matrix,
- const unsigned int row,
- const unsigned int index) DEAL_II_DEPRECATED;
+ Accessor (MatrixType *matrix,
+ const size_type row,
+ const size_type index) DEAL_II_DEPRECATED;
/**
* Constructor.
/**
* Constructor.
*/
- Accessor (MatrixType *matrix,
- const unsigned int row,
- const unsigned int index);
+ Accessor (MatrixType *matrix,
+ const size_type row,
+ const size_type index);
/**
* Constructor.
* @deprecated This constructor is deprecated. Use the other constructor
* with a global index instead.
*/
- Iterator (MatrixType *matrix,
- const unsigned int row,
- const unsigned int index) DEAL_II_DEPRECATED;
+ Iterator (MatrixType *matrix,
+ const size_type row,
+ const size_type index) DEAL_II_DEPRECATED;
/**
* Constructor. Create an iterator into the matrix @p matrix for the given
/**
* Return an iterator that is @p n ahead of the current one.
*/
- Iterator operator + (const unsigned int n) const;
+ Iterator operator + (const size_type n) const;
private:
/**
class SparseMatrix : public virtual Subscriptor
{
public:
+ /**
+ * Declare type for container size.
+ */
+ typedef types::global_dof_index size_type;
+
/**
* Type of matrix entries. In analogy to the STL container classes.
*/
* Return the dimension of the image space. To remember: the matrix is of
* dimension $m \times n$.
*/
- unsigned int m () const;
+ size_type m () const;
/**
* Return the dimension of the range space. To remember: the matrix is of
* dimension $m \times n$.
*/
- unsigned int n () const;
+ size_type n () const;
/**
* Return the number of entries in a specific row.
*/
- unsigned int get_row_length (const unsigned int row) const;
+ size_type get_row_length (const size_type row) const;
/**
* Return the number of nonzero elements of this matrix. Actually, it
* returns the number of entries in the sparsity pattern; if any of the
* entries should happen to be zero, it is counted anyway.
*/
- unsigned int n_nonzero_elements () const;
+ size_type n_nonzero_elements () const;
/**
* Return the number of actually nonzero elements of this matrix. It is
* count all entries of the sparsity pattern but only the ones that are
* nonzero (or whose absolute value is greater than threshold).
*/
- unsigned int n_actually_nonzero_elements (const double threshold = 0.) const;
+ size_type n_actually_nonzero_elements (const double threshold = 0.) const;
/**
* Return a (constant) reference to the underlying sparsity pattern of this
* entry does not exist or if <tt>value</tt> is not a finite number. Still,
* it is allowed to store zero values in non-existent fields.
*/
- void set (const unsigned int i,
- const unsigned int j,
+ void set (const size_type i,
+ const size_type j,
const number value);
/**
* treated.
*/
template <typename number2>
- void set (const std::vector<unsigned int> &indices,
+ void set (const std::vector<size_type> &indices,
const FullMatrix<number2> &full_matrix,
const bool elide_zero_values = false);
* and columns, respectively.
*/
template <typename number2>
- void set (const std::vector<unsigned int> &row_indices,
- const std::vector<unsigned int> &col_indices,
- const FullMatrix<number2> &full_matrix,
- const bool elide_zero_values = false);
+ void set (const std::vector<size_type> &row_indices,
+ const std::vector<size_type> &col_indices,
+ const FullMatrix<number2> &full_matrix,
+ const bool elide_zero_values = false);
/**
* Set several elements in the specified row of the matrix with column
* treated.
*/
template <typename number2>
- void set (const unsigned int row,
- const std::vector<unsigned int> &col_indices,
- const std::vector<number2> &values,
- const bool elide_zero_values = false);
+ void set (const size_type row,
+ const std::vector<size_type> &col_indices,
+ const std::vector<number2> &values,
+ const bool elide_zero_values = false);
/**
* Set several elements to values given by <tt>values</tt> in a given row in
* inserted/replaced.
*/
template <typename number2>
- void set (const unsigned int row,
- const unsigned int n_cols,
- const unsigned int *col_indices,
- const number2 *values,
- const bool elide_zero_values = false);
+ void set (const size_type row,
+ const size_type n_cols,
+ const size_type *col_indices,
+ const number2 *values,
+ const bool elide_zero_values = false);
/**
* Add <tt>value</tt> to the element (<i>i,j</i>). Throws an error if the
* entry does not exist or if <tt>value</tt> is not a finite number. Still,
* it is allowed to store zero values in non-existent fields.
*/
- void add (const unsigned int i,
- const unsigned int j,
+ void add (const size_type i,
+ const size_type j,
const number value);
/**
* i.e., zero values won't be added into the matrix.
*/
template <typename number2>
- void add (const std::vector<unsigned int> &indices,
- const FullMatrix<number2> &full_matrix,
- const bool elide_zero_values = true);
+ void add (const std::vector<size_type> &indices,
+ const FullMatrix<number2> &full_matrix,
+ const bool elide_zero_values = true);
/**
* Same function as before, but now including the possibility to use
* and columns, respectively.
*/
template <typename number2>
- void add (const std::vector<unsigned int> &row_indices,
- const std::vector<unsigned int> &col_indices,
- const FullMatrix<number2> &full_matrix,
- const bool elide_zero_values = true);
+ void add (const std::vector<size_type> &row_indices,
+ const std::vector<size_type> &col_indices,
+ const FullMatrix<number2> &full_matrix,
+ const bool elide_zero_values = true);
/**
* Set several elements in the specified row of the matrix with column
* i.e., zero values won't be added into the matrix.
*/
template <typename number2>
- void add (const unsigned int row,
- const std::vector<unsigned int> &col_indices,
- const std::vector<number2> &values,
- const bool elide_zero_values = true);
+ void add (const size_type row,
+ const std::vector<size_type> &col_indices,
+ const std::vector<number2> &values,
+ const bool elide_zero_values = true);
/**
* Add an array of values given by <tt>values</tt> in the given global
* i.e., zero values won't be added into the matrix.
*/
template <typename number2>
- void add (const unsigned int row,
- const unsigned int n_cols,
- const unsigned int *col_indices,
- const number2 *values,
- const bool elide_zero_values = true,
- const bool col_indices_are_sorted = false);
+ void add (const size_type row,
+ const size_type n_cols,
+ const size_type *col_indices,
+ const number2 *values,
+ const bool elide_zero_values = true,
+ const bool col_indices_are_sorted = false);
/**
* Multiply the entire matrix by a fixed factor.
* classes instead, since they are tailored better to a sparse matrix
* structure.
*/
- number operator () (const unsigned int i,
- const unsigned int j) const;
+ number operator () (const size_type i,
+ const size_type j) const;
/**
* This function is mostly like operator()() in that it returns the value of
* classes instead, since they are tailored better to a sparse matrix
* structure.
*/
- number el (const unsigned int i,
- const unsigned int j) const;
+ number el (const size_type i,
+ const size_type j) const;
/**
* Return the main diagonal element in the <i>i</i>th row. This function
* each row and access therefore does not involve searching for the right
* column number.
*/
- number diag_element (const unsigned int i) const;
+ number diag_element (const size_type i) const;
/**
* Same as above, but return a writeable reference. You're sure you know
* what you do?
*/
- number &diag_element (const unsigned int i);
+ number &diag_element (const size_type i);
/**
* Access to values in internal mode. Returns the value of the
*
* @deprecated Use iterator or const_iterator instead!
*/
- number raw_entry (const unsigned int row,
- const unsigned int index) const DEAL_II_DEPRECATED;
+ number raw_entry (const size_type row,
+ const size_type index) const DEAL_II_DEPRECATED;
/**
* This is for hackers. Get access to the <i>i</i>th element of this
*
* @internal @deprecated Use iterator or const_iterator instead!
*/
- number global_entry (const unsigned int i) const DEAL_II_DEPRECATED;
+ number global_entry (const size_type i) const DEAL_II_DEPRECATED;
/**
* Same as above, but with write access. You certainly know what you do?
*
* @internal @deprecated Use iterator or const_iterator instead!
*/
- number &global_entry (const unsigned int i) DEAL_II_DEPRECATED;
+ number &global_entry (const size_type i) DEAL_II_DEPRECATED;
//@}
/**
*/
template <typename somenumber>
void PSOR (Vector<somenumber> &v,
- const std::vector<unsigned int> &permutation,
- const std::vector<unsigned int> &inverse_permutation,
+ const std::vector<size_type> &permutation,
+ const std::vector<size_type> &inverse_permutation,
const number om = 1.) const;
/**
*/
template <typename somenumber>
void TPSOR (Vector<somenumber> &v,
- const std::vector<unsigned int> &permutation,
- const std::vector<unsigned int> &inverse_permutation,
+ const std::vector<size_type> &permutation,
+ const std::vector<size_type> &inverse_permutation,
const number om = 1.) const;
/**
* Note also the discussion in the general documentation of this class about
* the order in which elements are accessed.
*/
- const_iterator begin (const unsigned int r) const;
+ const_iterator begin (const size_type r) const;
/**
* Final iterator of row <tt>r</tt>. It points to the first element past the
* particular the case if it is the end iterator for the last row of a
* matrix.
*/
- const_iterator end (const unsigned int r) const;
+ const_iterator end (const size_type r) const;
/**
* STL-like iterator with the first entry of row <tt>r</tt>. This is the
* Note the discussion in the general documentation of this class about
* the order in which elements are accessed.
*/
- iterator begin (const unsigned int r);
+ iterator begin (const size_type r);
/**
* Final iterator of row <tt>r</tt>. It points to the first element past the
* particular the case if it is the end iterator for the last row of a
* matrix.
*/
- iterator end (const unsigned int r);
+ iterator end (const size_type r);
//@}
/**
* @name Input/Output
template <typename number>
inline
-unsigned int SparseMatrix<number>::m () const
+typename SparseMatrix<number>::size_type SparseMatrix<number>::m () const
{
Assert (cols != 0, ExcNotInitialized());
return cols->rows;
template <typename number>
inline
-unsigned int SparseMatrix<number>::n () const
+typename SparseMatrix<number>::size_type SparseMatrix<number>::n () const
{
Assert (cols != 0, ExcNotInitialized());
return cols->cols;
template <typename number>
inline
void
-SparseMatrix<number>::set (const unsigned int i,
- const unsigned int j,
+SparseMatrix<number>::set (const size_type i,
+ const size_type j,
const number value)
{
Assert (numbers::is_finite(value), ExcNumberNotFinite());
- const unsigned int index = cols->operator()(i, j);
+ const size_type index = cols->operator()(i, j);
// it is allowed to set elements of the matrix that are not part of the
// sparsity pattern, if the value to which we set it is zero
template <typename number2>
inline
void
-SparseMatrix<number>::set (const std::vector<unsigned int> &indices,
- const FullMatrix<number2> &values,
- const bool elide_zero_values)
+SparseMatrix<number>::set (const std::vector<size_type> &indices,
+ const FullMatrix<number2> &values,
+ const bool elide_zero_values)
{
Assert (indices.size() == values.m(),
ExcDimensionMismatch(indices.size(), values.m()));
Assert (values.m() == values.n(), ExcNotQuadratic());
- for (unsigned int i=0; i<indices.size(); ++i)
+ for (size_type i=0; i<indices.size(); ++i)
set (indices[i], indices.size(), &indices[0], &values(i,0),
elide_zero_values);
}
template <typename number2>
inline
void
-SparseMatrix<number>::set (const std::vector<unsigned int> &row_indices,
- const std::vector<unsigned int> &col_indices,
- const FullMatrix<number2> &values,
- const bool elide_zero_values)
+SparseMatrix<number>::set (const std::vector<size_type> &row_indices,
+ const std::vector<size_type> &col_indices,
+ const FullMatrix<number2> &values,
+ const bool elide_zero_values)
{
Assert (row_indices.size() == values.m(),
ExcDimensionMismatch(row_indices.size(), values.m()));
Assert (col_indices.size() == values.n(),
ExcDimensionMismatch(col_indices.size(), values.n()));
- for (unsigned int i=0; i<row_indices.size(); ++i)
+ for (size_type i=0; i<row_indices.size(); ++i)
set (row_indices[i], col_indices.size(), &col_indices[0], &values(i,0),
elide_zero_values);
}
template <typename number2>
inline
void
-SparseMatrix<number>::set (const unsigned int row,
- const std::vector<unsigned int> &col_indices,
- const std::vector<number2> &values,
- const bool elide_zero_values)
+SparseMatrix<number>::set (const size_type row,
+ const std::vector<size_type> &col_indices,
+ const std::vector<number2> &values,
+ const bool elide_zero_values)
{
Assert (col_indices.size() == values.size(),
ExcDimensionMismatch(col_indices.size(), values.size()));
template <typename number>
inline
void
-SparseMatrix<number>::add (const unsigned int i,
- const unsigned int j,
- const number value)
+SparseMatrix<number>::add (const size_type i,
+ const size_type j,
+ const number value)
{
Assert (numbers::is_finite(value), ExcNumberNotFinite());
if (value == 0)
return;
- const unsigned int index = cols->operator()(i, j);
+ const size_type index = cols->operator()(i, j);
// it is allowed to add elements to the matrix that are not part of the
// sparsity pattern, if the value to which we set it is zero
template <typename number2>
inline
void
-SparseMatrix<number>::add (const std::vector<unsigned int> &indices,
- const FullMatrix<number2> &values,
- const bool elide_zero_values)
+SparseMatrix<number>::add (const std::vector<size_type> &indices,
+ const FullMatrix<number2> &values,
+ const bool elide_zero_values)
{
Assert (indices.size() == values.m(),
ExcDimensionMismatch(indices.size(), values.m()));
Assert (values.m() == values.n(), ExcNotQuadratic());
- for (unsigned int i=0; i<indices.size(); ++i)
+ for (size_type i=0; i<indices.size(); ++i)
add (indices[i], indices.size(), &indices[0], &values(i,0),
elide_zero_values);
}
template <typename number2>
inline
void
-SparseMatrix<number>::add (const std::vector<unsigned int> &row_indices,
- const std::vector<unsigned int> &col_indices,
- const FullMatrix<number2> &values,
- const bool elide_zero_values)
+SparseMatrix<number>::add (const std::vector<size_type> &row_indices,
+ const std::vector<size_type> &col_indices,
+ const FullMatrix<number2> &values,
+ const bool elide_zero_values)
{
Assert (row_indices.size() == values.m(),
ExcDimensionMismatch(row_indices.size(), values.m()));
Assert (col_indices.size() == values.n(),
ExcDimensionMismatch(col_indices.size(), values.n()));
- for (unsigned int i=0; i<row_indices.size(); ++i)
+ for (size_type i=0; i<row_indices.size(); ++i)
add (row_indices[i], col_indices.size(), &col_indices[0], &values(i,0),
elide_zero_values);
}
template <typename number2>
inline
void
-SparseMatrix<number>::add (const unsigned int row,
- const std::vector<unsigned int> &col_indices,
- const std::vector<number2> &values,
- const bool elide_zero_values)
+SparseMatrix<number>::add (const size_type row,
+ const std::vector<size_type> &col_indices,
+ const std::vector<number2> &values,
+ const bool elide_zero_values)
{
Assert (col_indices.size() == values.size(),
ExcDimensionMismatch(col_indices.size(), values.size()));
template <typename number>
inline
-number SparseMatrix<number>::operator () (const unsigned int i,
- const unsigned int j) const
+number SparseMatrix<number>::operator () (const size_type i,
+ const size_type j) const
{
Assert (cols != 0, ExcNotInitialized());
Assert (cols->operator()(i,j) != SparsityPattern::invalid_entry,
template <typename number>
inline
-number SparseMatrix<number>::el (const unsigned int i,
- const unsigned int j) const
+number SparseMatrix<number>::el (const size_type i,
+ const size_type j) const
{
Assert (cols != 0, ExcNotInitialized());
- const unsigned int index = cols->operator()(i,j);
+ const size_type index = cols->operator()(i,j);
if (index != SparsityPattern::invalid_entry)
return val[index];
template <typename number>
inline
-number SparseMatrix<number>::diag_element (const unsigned int i) const
+number SparseMatrix<number>::diag_element (const size_type i) const
{
Assert (cols != 0, ExcNotInitialized());
Assert (m() == n(), ExcNotQuadratic());
template <typename number>
inline
-number &SparseMatrix<number>::diag_element (const unsigned int i)
+number &SparseMatrix<number>::diag_element (const size_type i)
{
Assert (cols != 0, ExcNotInitialized());
Assert (m() == n(), ExcNotQuadratic());
template <typename number>
inline
number
-SparseMatrix<number>::raw_entry (const unsigned int row,
- const unsigned int index) const
+SparseMatrix<number>::raw_entry (const size_type row,
+ const size_type index) const
{
Assert(row<cols->rows, ExcIndexRange(row,0,cols->rows));
Assert(index<cols->row_length(row),
template <typename number>
inline
-number SparseMatrix<number>::global_entry (const unsigned int j) const
+number SparseMatrix<number>::global_entry (const size_type j) const
{
Assert (cols != 0, ExcNotInitialized());
Assert (j < cols->n_nonzero_elements(),
template <typename number>
inline
-number &SparseMatrix<number>::global_entry (const unsigned int j)
+number &SparseMatrix<number>::global_entry (const size_type j)
{
Assert (cols != 0, ExcNotInitialized());
Assert (j < cols->n_nonzero_elements(),
SparseMatrix<number>::copy_from (const ForwardIterator begin,
const ForwardIterator end)
{
- Assert (static_cast<unsigned int>(std::distance (begin, end)) == m(),
+ Assert (static_cast<size_type>(std::distance (begin, end)) == m(),
ExcIteratorRange (std::distance (begin, end), m()));
// for use in the inner loop, we define a typedef to the type of the inner
// iterators
typedef typename std::iterator_traits<ForwardIterator>::value_type::const_iterator inner_iterator;
- unsigned int row=0;
+ size_type row=0;
for (ForwardIterator i=begin; i!=end; ++i, ++row)
{
const inner_iterator end_of_row = i->end();
template <typename number>
inline
Accessor<number,true>::
- Accessor (const MatrixType *matrix,
- const unsigned int row,
- const unsigned int index)
+ Accessor (const MatrixType *matrix,
+ const size_type row,
+ const size_type index)
:
SparsityPatternIterators::Accessor (&matrix->get_sparsity_pattern(),
row, index),
template <typename number>
inline
Accessor<number,false>::
- Accessor (MatrixType *matrix,
- const unsigned int row,
- const unsigned int index)
+ Accessor (MatrixType *matrix,
+ const size_type row,
+ const size_type index)
:
SparsityPatternIterators::Accessor (&matrix->get_sparsity_pattern(),
row, index),
template <typename number, bool Constness>
inline
Iterator<number, Constness>::
- Iterator (MatrixType *matrix,
- const unsigned int r,
- const unsigned int i)
+ Iterator (MatrixType *matrix,
+ const size_type r,
+ const size_type i)
:
accessor(matrix, r, i)
{}
inline
Iterator<number,Constness>
Iterator<number,Constness>::
- operator + (const unsigned int n) const
+ operator + (const size_type n) const
{
Iterator x = *this;
- for (unsigned int i=0; i<n; ++i)
+ for (size_type i=0; i<n; ++i)
++x;
return x;
template <typename number>
inline
typename SparseMatrix<number>::const_iterator
-SparseMatrix<number>::begin (const unsigned int r) const
+SparseMatrix<number>::begin (const size_type r) const
{
Assert (r<m(), ExcIndexRange(r,0,m()));
template <typename number>
inline
typename SparseMatrix<number>::const_iterator
-SparseMatrix<number>::end (const unsigned int r) const
+SparseMatrix<number>::end (const size_type r) const
{
Assert (r<m(), ExcIndexRange(r,0,m()));
template <typename number>
inline
typename SparseMatrix<number>::iterator
-SparseMatrix<number>::begin (const unsigned int r)
+SparseMatrix<number>::begin (const size_type r)
{
Assert (r<m(), ExcIndexRange(r,0,m()));
template <typename number>
inline
typename SparseMatrix<number>::iterator
-SparseMatrix<number>::end (const unsigned int r)
+SparseMatrix<number>::end (const size_type r)
{
Assert (r<m(), ExcIndexRange(r,0,m()));
if (across)
{
- for (unsigned int i=0; i<cols->rows; ++i)
- for (unsigned int j=cols->rowstart[i]; j<cols->rowstart[i+1]; ++j)
+ for (size_type i=0; i<cols->rows; ++i)
+ for (size_type j=cols->rowstart[i]; j<cols->rowstart[i+1]; ++j)
out << ' ' << i << ',' << cols->colnums[j] << ':' << val[j];
out << std::endl;
}
else
- for (unsigned int i=0; i<cols->rows; ++i)
- for (unsigned int j=cols->rowstart[i]; j<cols->rowstart[i+1]; ++j)
+ for (size_type i=0; i<cols->rows; ++i)
+ for (size_type j=cols->rowstart[i]; j<cols->rowstart[i+1]; ++j)
out << "(" << i << "," << cols->colnums[j] << ") " << val[j] << std::endl;
}
Assert (c.n_cols() == id.n(), ExcDimensionMismatch (c.n_cols(), id.n()));
reinit (c);
- for (unsigned int i=0; i<n(); ++i)
+ for (size_type i=0; i<n(); ++i)
this->set(i,i,1.);
}
{
namespace SparseMatrix
{
+ typedef types::global_dof_index size_type;
+
template<typename T>
- void zero_subrange (const unsigned int begin,
- const unsigned int end,
+ void zero_subrange (const size_type begin,
+ const size_type end,
T *dst)
{
std::memset (dst+begin,0,(end-begin)*sizeof(T));
// operator=. The grain size is chosen to reflect the number of rows in
// minimum_parallel_grain_size, weighted by the number of nonzero entries
// per row on average.
- const unsigned int matrix_size = cols->n_nonzero_elements();
- const unsigned int grain_size =
+ const size_type matrix_size = cols->n_nonzero_elements();
+ const size_type grain_size =
internal::SparseMatrix::minimum_parallel_grain_size *
(cols->n_nonzero_elements()+m()) / m();
if (matrix_size>grain_size)
ExcDimensionMismatch (cols->n_cols(), id.n()));
*this = 0;
- for (unsigned int i=0; i<n(); ++i)
+ for (size_type i=0; i<n(); ++i)
this->set(i,i,1.);
return *this;
template <typename number>
-unsigned int
-SparseMatrix<number>::get_row_length (const unsigned int row) const
+typename SparseMatrix<number>::size_type
+SparseMatrix<number>::get_row_length (const size_type row) const
{
Assert (cols != 0, ExcNotInitialized());
return cols->row_length(row);
template <typename number>
-unsigned int
+typename SparseMatrix<number>::size_type
SparseMatrix<number>::n_nonzero_elements () const
{
Assert (cols != 0, ExcNotInitialized());
template <typename number>
-unsigned int
+typename SparseMatrix<number>::size_type
SparseMatrix<number>::n_actually_nonzero_elements (const double threshold) const
{
Assert (cols != 0, ExcNotInitialized());
Assert (threshold >= 0, ExcMessage ("Negative threshold!"));
- unsigned int nnz = 0;
- const unsigned int nnz_alloc = n_nonzero_elements();
- for (unsigned int i=0; i<nnz_alloc; ++i)
+ size_type nnz = 0;
+ const size_type nnz_alloc = n_nonzero_elements();
+ for (size_type i=0; i<nnz_alloc; ++i)
if (std::fabs(val[i]) > threshold)
++nnz;
return nnz;
Assert (cols != 0, ExcNotInitialized());
Assert (cols->rows == cols->cols, ExcNotQuadratic());
- const unsigned int n_rows = m();
- for (unsigned int row=0; row<n_rows; ++row)
+ const size_type n_rows = m();
+ for (size_type row=0; row<n_rows; ++row)
{
// first skip diagonal entry
number *val_ptr = &val[cols->rowstart[row]];
if (m() == n())
++val_ptr;
- const unsigned int *colnum_ptr = &cols->colnums[cols->rowstart[row]+1];
- const number *const val_end_of_row = &val[cols->rowstart[row+1]];
+ const size_type *colnum_ptr = &cols->colnums[cols->rowstart[row]+1];
+ const number *const val_end_of_row = &val[cols->rowstart[row+1]];
// treat lower left triangle
while ((val_ptr != val_end_of_row) && (*colnum_ptr<row))
*this = 0;
// then copy old matrix
- for (unsigned int row=0; row<matrix.m(); ++row)
- for (unsigned int col=0; col<matrix.n(); ++col)
+ for (size_type row=0; row<matrix.m(); ++row)
+ for (size_type col=0; col<matrix.n(); ++col)
if (matrix(row,col) != 0)
set (row, col, matrix(row,col));
}
template <typename number,
typename InVector,
typename OutVector>
- void vmult_on_subrange (const unsigned int begin_row,
- const unsigned int end_row,
- const number *values,
+ void vmult_on_subrange (const size_type begin_row,
+ const size_type end_row,
+ const number *values,
const std::size_t *rowstart,
- const unsigned int *colnums,
- const InVector &src,
- OutVector &dst,
- const bool add)
+ const size_type *colnums,
+ const InVector &src,
+ OutVector &dst,
+ const bool add)
{
- const number *val_ptr = &values[rowstart[begin_row]];
- const unsigned int *colnum_ptr = &colnums[rowstart[begin_row]];
+ const number *val_ptr = &values[rowstart[begin_row]];
+ const size_type *colnum_ptr = &colnums[rowstart[begin_row]];
typename OutVector::iterator dst_ptr = dst.begin() + begin_row;
if (add == false)
- for (unsigned int row=begin_row; row<end_row; ++row)
+ for (size_type row=begin_row; row<end_row; ++row)
{
typename OutVector::value_type s = 0.;
const number *const val_end_of_row = &values[rowstart[row+1]];
*dst_ptr++ = s;
}
else
- for (unsigned int row=begin_row; row<end_row; ++row)
+ for (size_type row=begin_row; row<end_row; ++row)
{
typename OutVector::value_type s = *dst_ptr;
const number *const val_end_of_row = &values[rowstart[row+1]];
template <typename number>
template <typename number2>
void
-SparseMatrix<number>::add (const unsigned int row,
- const unsigned int n_cols,
- const unsigned int *col_indices,
- const number2 *values,
- const bool elide_zero_values,
- const bool col_indices_are_sorted)
+SparseMatrix<number>::add (const size_type row,
+ const size_type n_cols,
+ const size_type *col_indices,
+ const number2 *values,
+ const bool elide_zero_values,
+ const bool col_indices_are_sorted)
{
Assert (cols != 0, ExcNotInitialized());
// check whether the given indices are
// really sorted
#ifdef DEBUG
- for (unsigned int i=1; i<n_cols; ++i)
+ for (size_type i=1; i<n_cols; ++i)
Assert (col_indices[i] > col_indices[i-1],
ExcMessage("List of indices is unsorted or contains duplicates."));
#endif
- const unsigned int *this_cols =
+ const size_type *this_cols =
&cols->colnums[cols->rowstart[row]];
- const unsigned int row_length_1 = cols->row_length(row)-1;
+ const size_type row_length_1 = cols->row_length(row)-1;
number *val_ptr = &val[cols->rowstart[row]];
if (m() == n())
// find diagonal and add it if found
Assert (this_cols[0] == row, ExcInternalError());
- const unsigned int *diag_pos =
+ const size_type *diag_pos =
Utilities::lower_bound (col_indices,
col_indices+n_cols,
row);
- const unsigned int diag = diag_pos - col_indices;
- unsigned int post_diag = diag;
+ const size_type diag = diag_pos - col_indices;
+ size_type post_diag = diag;
if (diag != n_cols && *diag_pos == row)
{
val_ptr[0] += *(values+(diag_pos-col_indices));
}
// add indices before diagonal
- unsigned int counter = 1;
- for (unsigned int i=0; i<diag; ++i)
+ size_type counter = 1;
+ for (size_type i=0; i<diag; ++i)
{
while (this_cols[counter]<col_indices[i] && counter<row_length_1)
++counter;
}
// add indices after diagonal
- for (unsigned int i=post_diag; i<n_cols; ++i)
+ for (size_type i=post_diag; i<n_cols; ++i)
{
while (this_cols[counter]<col_indices[i] && counter<row_length_1)
++counter;
}
else
{
- unsigned int counter = 0;
- for (unsigned int i=0; i<n_cols; ++i)
+ size_type counter = 0;
+ for (size_type i=0; i<n_cols; ++i)
{
while (this_cols[counter]<col_indices[i] && counter<row_length_1)
++counter;
// unsorted case: first, search all the
// indices to find out which values we
// actually need to add.
- const unsigned int *const my_cols = cols->colnums;
- unsigned int index = cols->rowstart[row];
- const unsigned int next_row_index = cols->rowstart[row+1];
+ const size_type *const my_cols = cols->colnums;
+ size_type index = cols->rowstart[row];
+ const size_type next_row_index = cols->rowstart[row+1];
- for (unsigned int j=0; j<n_cols; ++j)
+ for (size_type j=0; j<n_cols; ++j)
{
const number value = values[j];
Assert (numbers::is_finite(value), ExcNumberNotFinite());
template <typename number>
template <typename number2>
void
-SparseMatrix<number>::set (const unsigned int row,
- const unsigned int n_cols,
- const unsigned int *col_indices,
- const number2 *values,
- const bool elide_zero_values)
+SparseMatrix<number>::set (const size_type row,
+ const size_type n_cols,
+ const size_type *col_indices,
+ const number2 *values,
+ const bool elide_zero_values)
{
Assert (cols != 0, ExcNotInitialized());
Assert (row < m(), ExcInvalidIndex1(row));
// First, search all the indices to find
// out which values we actually need to
// set.
- const unsigned int *my_cols = cols->colnums;
+ const size_type *my_cols = cols->colnums;
std::size_t index = cols->rowstart[row], next_index = index;
const std::size_t next_row_index = cols->rowstart[row+1];
if (elide_zero_values == true)
{
- for (unsigned int j=0; j<n_cols; ++j)
+ for (size_type j=0; j<n_cols; ++j)
{
const number value = values[j];
Assert (numbers::is_finite(value), ExcNumberNotFinite());
else
{
// same code as above, but now check for zeros
- for (unsigned int j=0; j<n_cols; ++j)
+ for (size_type j=0; j<n_cols; ++j)
{
const number value = values[j];
Assert (numbers::is_finite(value), ExcNumberNotFinite());
dst = 0;
- for (unsigned int i=0; i<m(); i++)
+ for (size_type i=0; i<m(); i++)
{
- for (unsigned int j=cols->rowstart[i]; j<cols->rowstart[i+1] ; j++)
+ for (size_type j=cols->rowstart[i]; j<cols->rowstart[i+1] ; j++)
{
- const unsigned int p = cols->colnums[j];
+ const size_type p = cols->colnums[j];
dst(p) += val[j] * src(i);
}
}
Assert (!PointerComparison::equal(&src, &dst), ExcSourceEqualsDestination());
- for (unsigned int i=0; i<m(); i++)
- for (unsigned int j=cols->rowstart[i]; j<cols->rowstart[i+1] ; j++)
+ for (size_type i=0; i<m(); i++)
+ for (size_type j=cols->rowstart[i]; j<cols->rowstart[i+1] ; j++)
{
- const unsigned int p = cols->colnums[j];
+ const size_type p = cols->colnums[j];
dst(p) += val[j] * src(i);
}
}
*/
template <typename number,
typename InVector>
- number matrix_norm_sqr_on_subrange (const unsigned int begin_row,
- const unsigned int end_row,
- const number *values,
+ number matrix_norm_sqr_on_subrange (const size_type begin_row,
+ const size_type end_row,
+ const number *values,
const std::size_t *rowstart,
- const unsigned int *colnums,
- const InVector &v)
+ const size_type *colnums,
+ const InVector &v)
{
number norm_sqr=0.;
- for (unsigned int i=begin_row; i<end_row; ++i)
+ for (size_type i=begin_row; i<end_row; ++i)
{
number s = 0;
- for (unsigned int j=rowstart[i]; j<rowstart[i+1] ; j++)
+ for (size_type j=rowstart[i]; j<rowstart[i+1] ; j++)
s += values[j] * v(colnums[j]);
norm_sqr += v(i)*numbers::NumberTraits<number>::conjugate(s);
}
*/
template <typename number,
typename InVector>
- number matrix_scalar_product_on_subrange (const unsigned int begin_row,
- const unsigned int end_row,
- const number *values,
+ number matrix_scalar_product_on_subrange (const size_type begin_row,
+ const size_type end_row,
+ const number *values,
const std::size_t *rowstart,
- const unsigned int *colnums,
- const InVector &u,
- const InVector &v)
+ const size_type *colnums,
+ const InVector &u,
+ const InVector &v)
{
number norm_sqr=0.;
- for (unsigned int i=begin_row; i<end_row; ++i)
+ for (size_type i=begin_row; i<end_row; ++i)
{
number s = 0;
- for (unsigned int j=rowstart[i]; j<rowstart[i+1] ; j++)
+ for (size_type j=rowstart[i]; j<rowstart[i+1] ; j++)
s += values[j] * v(colnums[j]);
norm_sqr += u(i)*numbers::NumberTraits<number>::conjugate(s);
}
// CompressedSimpleSparsityPattern class.
{
CompressedSimpleSparsityPattern csp (m(), B.n());
- for (unsigned int i = 0; i < csp.n_rows(); ++i)
+ for (size_type i = 0; i < csp.n_rows(); ++i)
{
- const unsigned int *rows = &sp_A.colnums[sp_A.rowstart[i]];
- const unsigned int *const end_rows =
+ const size_type *rows = &sp_A.colnums[sp_A.rowstart[i]];
+ const size_type *const end_rows =
&sp_A.colnums[sp_A.rowstart[i+1]];
for (; rows != end_rows; ++rows)
{
- const unsigned int col = *rows;
- unsigned int *new_cols = const_cast<unsigned int *>
+ const size_type col = *rows;
+ size_type *new_cols = const_cast<size_type *>
(&sp_B.colnums[sp_B.rowstart[col]]);
- unsigned int *end_new_cols = const_cast<unsigned int *>
+ size_type *end_new_cols = const_cast<size_type *>
(&sp_B.colnums[sp_B.rowstart[col+1]]);
// if B has a diagonal, need to add that manually. this way,
// create an array that caches some
// elements that are going to be written
// into the new matrix.
- unsigned int max_n_cols_B = 0;
- for (unsigned int i=0; i<B.m(); ++i)
+ size_type max_n_cols_B = 0;
+ for (size_type i=0; i<B.m(); ++i)
max_n_cols_B = std::max (max_n_cols_B, sp_B.row_length(i));
std::vector<numberC> new_entries(max_n_cols_B);
// nested loops. One over the rows of A, for each row we then loop over all
// the columns, and then we need to multiply each element with all the
// elements in that row in B.
- for (unsigned int i=0; i<C.m(); ++i)
+ for (size_type i=0; i<C.m(); ++i)
{
- const unsigned int *rows = &sp_A.colnums[sp_A.rowstart[i]];
- const unsigned int *const end_rows = &sp_A.colnums[sp_A.rowstart[i+1]];
+ const size_type *rows = &sp_A.colnums[sp_A.rowstart[i]];
+ const size_type *const end_rows = &sp_A.colnums[sp_A.rowstart[i+1]];
for (; rows != end_rows; ++rows)
{
const double A_val = val[rows-&sp_A.colnums[sp_A.rowstart[0]]];
- const unsigned int col = *rows;
- const unsigned int *new_cols =
+ const size_type col = *rows;
+ const size_type *new_cols =
(&sp_B.colnums[sp_B.rowstart[col]]);
// special treatment for diagonal
// CompressedSimpleSparsityPattern class.
{
CompressedSimpleSparsityPattern csp (n(), B.n());
- for (unsigned int i = 0; i < sp_A.n_rows(); ++i)
+ for (size_type i = 0; i < sp_A.n_rows(); ++i)
{
- const unsigned int *rows =
+ const size_type *rows =
&sp_A.colnums[sp_A.rowstart[i]];
- const unsigned int *const end_rows =
+ const size_type *const end_rows =
&sp_A.colnums[sp_A.rowstart[i+1]];
// cast away constness to conform with csp.add_entries interface
- unsigned int *new_cols = const_cast<unsigned int *>
+ size_type *new_cols = const_cast<size_type*>
(&sp_B.colnums[sp_B.rowstart[i]]);
- unsigned int *end_new_cols = const_cast<unsigned int *>
+ size_type *end_new_cols = const_cast<size_type*>
(&sp_B.colnums[sp_B.rowstart[i+1]]);
if (sp_B.n_rows() == sp_B.n_cols())
for (; rows != end_rows; ++rows)
{
- const unsigned int row = *rows;
+ const size_type row = *rows;
// if B has a diagonal, need to add that manually. this way,
// we maintain sortedness.
// create an array that caches some
// elements that are going to be written
// into the new matrix.
- unsigned int max_n_cols_B = 0;
- for (unsigned int i=0; i<B.m(); ++i)
+ size_type max_n_cols_B = 0;
+ for (size_type i=0; i<B.m(); ++i)
max_n_cols_B = std::max (max_n_cols_B, sp_B.row_length(i));
std::vector<numberC> new_entries(max_n_cols_B);
// nested loops. One over the rows of A, for each row we then loop over all
// the columns, and then we need to multiply each element with all the
// elements in that row in B.
- for (unsigned int i=0; i<m(); ++i)
+ for (size_type i=0; i<m(); ++i)
{
- const unsigned int *rows = &sp_A.colnums[sp_A.rowstart[i]];
- const unsigned int *const end_rows = &sp_A.colnums[sp_A.rowstart[i+1]];
- const unsigned int *new_cols = &sp_B.colnums[sp_B.rowstart[i]];
+ const size_type *rows = &sp_A.colnums[sp_A.rowstart[i]];
+ const size_type *const end_rows = &sp_A.colnums[sp_A.rowstart[i+1]];
+ const size_type *new_cols = &sp_B.colnums[sp_B.rowstart[i]];
if (sp_B.n_rows() == sp_B.n_cols())
++new_cols;
for (; rows != end_rows; ++rows)
{
- const unsigned int row = *rows;
+ const size_type row = *rows;
const double A_val = val[rows-&sp_A.colnums[sp_A.rowstart[0]]];
// special treatment for diagonal
Assert (val != 0, ExcNotInitialized());
Vector<real_type> column_sums(n());
- const unsigned int n_rows = m();
- for (unsigned int row=0; row<n_rows; ++row)
- for (unsigned int j=cols->rowstart[row]; j<cols->rowstart[row+1] ; ++j)
+ const size_type n_rows = m();
+ for (size_type row=0; row<n_rows; ++row)
+ for (size_type j=cols->rowstart[row]; j<cols->rowstart[row+1] ; ++j)
column_sums(cols->colnums[j]) += numbers::NumberTraits<number>::abs(val[j]);
return column_sums.linfty_norm();
const number *val_ptr = &val[cols->rowstart[0]];
real_type max=0;
- const unsigned int n_rows = m();
- for (unsigned int row=0; row<n_rows; ++row)
+ const size_type n_rows = m();
+ for (size_type row=0; row<n_rows; ++row)
{
real_type sum = 0;
const number *const val_end_of_row = &val[cols->rowstart[row+1]];
// sparsity pattern, without taking any
// reference to rows or columns
real_type norm_sqr = 0;
- const unsigned int n_rows = m();
+ const size_type n_rows = m();
for (const number *ptr = &val[0];
ptr != &val[cols->rowstart[n_rows]]; ++ptr)
norm_sqr += numbers::NumberTraits<number>::abs_square(*ptr);
template <typename number,
typename InVector,
typename OutVector>
- number residual_sqr_on_subrange (const unsigned int begin_row,
- const unsigned int end_row,
- const number *values,
+ number residual_sqr_on_subrange (const size_type begin_row,
+ const size_type end_row,
+ const number *values,
const std::size_t *rowstart,
- const unsigned int *colnums,
- const InVector &u,
- const InVector &b,
- OutVector &dst)
+ const size_type *colnums,
+ const InVector &u,
+ const InVector &b,
+ OutVector &dst)
{
number norm_sqr=0.;
- for (unsigned int i=begin_row; i<end_row; ++i)
+ for (size_type i=begin_row; i<end_row; ++i)
{
number s = b(i);
- for (unsigned int j=rowstart[i]; j<rowstart[i+1] ; j++)
+ for (size_type j=rowstart[i]; j<rowstart[i+1] ; j++)
s -= values[j] * u(colnums[j]);
dst(i) = s;
norm_sqr += s*numbers::NumberTraits<number>::conjugate(s);
AssertDimension (dst.size(), n());
AssertDimension (src.size(), n());
- const unsigned int n = src.size();
- somenumber *dst_ptr = dst.begin();
- const somenumber *src_ptr = src.begin();
+ const size_type n = src.size();
+ somenumber *dst_ptr = dst.begin();
+ const somenumber *src_ptr = src.begin();
const std::size_t *rowstart_ptr = &cols->rowstart[0];
// optimize the following loop for
// rowstart[i]. and we do have a
// square matrix by above assertion
if (om != 1.)
- for (unsigned int i=0; i<n; ++i, ++dst_ptr, ++src_ptr, ++rowstart_ptr)
+ for (size_type i=0; i<n; ++i, ++dst_ptr, ++src_ptr, ++rowstart_ptr)
*dst_ptr = om * *src_ptr / val[*rowstart_ptr];
else
- for (unsigned int i=0; i<n; ++i, ++dst_ptr, ++src_ptr, ++rowstart_ptr)
+ for (size_type i=0; i<n; ++i, ++dst_ptr, ++src_ptr, ++rowstart_ptr)
*dst_ptr = *src_ptr / val[*rowstart_ptr];
}
AssertDimension (dst.size(), n());
AssertDimension (src.size(), n());
- const unsigned int n = src.size();
- const std::size_t *rowstart_ptr = &cols->rowstart[0];
- somenumber *dst_ptr = &dst(0);
+ const size_type n = src.size();
+ const std::size_t *rowstart_ptr = &cols->rowstart[0];
+ somenumber *dst_ptr = &dst(0);
// case when we have stored the position
// just right of the diagonal (then we
ExcDimensionMismatch (pos_right_of_diagonal.size(), dst.size()));
// forward sweep
- for (unsigned int row=0; row<n; ++row, ++dst_ptr, ++rowstart_ptr)
+ for (size_type row=0; row<n; ++row, ++dst_ptr, ++rowstart_ptr)
{
*dst_ptr = src(row);
const std::size_t first_right_of_diagonal_index =
Assert (first_right_of_diagonal_index <= *(rowstart_ptr+1),
ExcInternalError());
number s = 0;
- for (unsigned int j=(*rowstart_ptr)+1; j<first_right_of_diagonal_index; ++j)
+ for (size_type j=(*rowstart_ptr)+1; j<first_right_of_diagonal_index; ++j)
s += val[j] * dst(cols->colnums[j]);
// divide by diagonal element
dst_ptr = &dst(n-1);
for (int row=n-1; row>=0; --row, --rowstart_ptr, --dst_ptr)
{
- const unsigned int end_row = *(rowstart_ptr+1);
- const unsigned int first_right_of_diagonal_index
+ const size_type end_row = *(rowstart_ptr+1);
+ const size_type first_right_of_diagonal_index
= pos_right_of_diagonal[row];
number s = 0;
- for (unsigned int j=first_right_of_diagonal_index; j<end_row; ++j)
+ for (size_type j=first_right_of_diagonal_index; j<end_row; ++j)
s += val[j] * dst(cols->colnums[j]);
*dst_ptr -= s * om;
// of the first element right of the
// diagonal manually for each sweep.
// forward sweep
- for (unsigned int row=0; row<n; ++row, ++dst_ptr, ++rowstart_ptr)
+ for (size_type row=0; row<n; ++row, ++dst_ptr, ++rowstart_ptr)
{
*dst_ptr = src(row);
// find the first element in this line
// note: the first entry in each
// line denotes the diagonal element,
// which we need not check.
- const unsigned int first_right_of_diagonal_index
+ const size_type first_right_of_diagonal_index
= (Utilities::lower_bound (&cols->colnums[*rowstart_ptr+1],
&cols->colnums[*(rowstart_ptr+1)],
row)
&cols->colnums[0]);
number s = 0;
- for (unsigned int j=(*rowstart_ptr)+1; j<first_right_of_diagonal_index; ++j)
+ for (size_type j=(*rowstart_ptr)+1; j<first_right_of_diagonal_index; ++j)
s += val[j] * dst(cols->colnums[j]);
// divide by diagonal element
rowstart_ptr = &cols->rowstart[0];
dst_ptr = &dst(0);
- for (unsigned int row=0; row<n; ++row, ++rowstart_ptr, ++dst_ptr)
+ for (size_type row=0; row<n; ++row, ++rowstart_ptr, ++dst_ptr)
*dst_ptr *= (2.-om)*val[*rowstart_ptr];
// backward sweep
dst_ptr = &dst(n-1);
for (int row=n-1; row>=0; --row, --rowstart_ptr, --dst_ptr)
{
- const unsigned int end_row = *(rowstart_ptr+1);
- const unsigned int first_right_of_diagonal_index
+ const size_type end_row = *(rowstart_ptr+1);
+ const size_type first_right_of_diagonal_index
= (Utilities::lower_bound (&cols->colnums[*rowstart_ptr+1],
&cols->colnums[end_row],
- static_cast<unsigned int>(row)) -
+ static_cast<size_type>(row)) -
&cols->colnums[0]);
number s = 0;
- for (unsigned int j=first_right_of_diagonal_index; j<end_row; ++j)
+ for (size_type j=first_right_of_diagonal_index; j<end_row; ++j)
s += val[j] * dst(cols->colnums[j]);
*dst_ptr -= s * om;
Assert(val[*rowstart_ptr]!= 0., ExcDivideByZero());
AssertDimension (m(), n());
AssertDimension (dst.size(), n());
- for (unsigned int row=0; row<m(); ++row)
+ for (size_type row=0; row<m(); ++row)
{
somenumber s = dst(row);
- for (unsigned int j=cols->rowstart[row]; j<cols->rowstart[row+1]; ++j)
+ for (size_type j=cols->rowstart[row]; j<cols->rowstart[row+1]; ++j)
{
- const unsigned int col = cols->colnums[j];
+ const size_type col = cols->colnums[j];
if (col < row)
s -= val[j] * dst(col);
}
AssertDimension (m(), n());
AssertDimension (dst.size(), n());
- unsigned int row=m()-1;
+ size_type row=m()-1;
while (true)
{
somenumber s = dst(row);
- for (unsigned int j=cols->rowstart[row]; j<cols->rowstart[row+1]; ++j)
+ for (size_type j=cols->rowstart[row]; j<cols->rowstart[row+1]; ++j)
if (cols->colnums[j] > row)
s -= val[j] * dst(cols->colnums[j]);
template <typename somenumber>
void
SparseMatrix<number>::PSOR (Vector<somenumber> &dst,
- const std::vector<unsigned int> &permutation,
- const std::vector<unsigned int> &inverse_permutation,
+ const std::vector<size_type> &permutation,
+ const std::vector<size_type> &inverse_permutation,
const number om) const
{
Assert (cols != 0, ExcNotInitialized());
Assert (m() == inverse_permutation.size(),
ExcDimensionMismatch(m(), inverse_permutation.size()));
- for (unsigned int urow=0; urow<m(); ++urow)
+ for (size_type urow=0; urow<m(); ++urow)
{
- const unsigned int row = permutation[urow];
+ const size_type row = permutation[urow];
somenumber s = dst(row);
- for (unsigned int j=cols->rowstart[row]; j<cols->rowstart[row+1]; ++j)
+ for (size_type j=cols->rowstart[row]; j<cols->rowstart[row+1]; ++j)
{
- const unsigned int col = cols->colnums[j];
+ const size_type col = cols->colnums[j];
if (inverse_permutation[col] < urow)
{
s -= val[j] * dst(col);
template <typename somenumber>
void
SparseMatrix<number>::TPSOR (Vector<somenumber> &dst,
- const std::vector<unsigned int> &permutation,
- const std::vector<unsigned int> &inverse_permutation,
+ const std::vector<size_type> &permutation,
+ const std::vector<size_type> &inverse_permutation,
const number om) const
{
Assert (cols != 0, ExcNotInitialized());
Assert (m() == inverse_permutation.size(),
ExcDimensionMismatch(m(), inverse_permutation.size()));
- for (unsigned int urow=m(); urow != 0;)
+ for (size_type urow=m(); urow != 0;)
{
--urow;
- const unsigned int row = permutation[urow];
+ const size_type row = permutation[urow];
somenumber s = dst(row);
- for (unsigned int j=cols->rowstart[row]; j<cols->rowstart[row+1]; ++j)
+ for (size_type j=cols->rowstart[row]; j<cols->rowstart[row+1]; ++j)
{
- const unsigned int col = cols->colnums[j];
+ const size_type col = cols->colnums[j];
if (inverse_permutation[col] > urow)
s -= val[j] * dst(col);
}
Assert (m() == v.size(), ExcDimensionMismatch(m(),v.size()));
Assert (m() == b.size(), ExcDimensionMismatch(m(),b.size()));
- for (unsigned int row=0; row<m(); ++row)
+ for (size_type row=0; row<m(); ++row)
{
somenumber s = b(row);
- for (unsigned int j=cols->rowstart[row]; j<cols->rowstart[row+1]; ++j)
+ for (size_type j=cols->rowstart[row]; j<cols->rowstart[row+1]; ++j)
{
s -= val[j] * v(cols->colnums[j]);
}
for (int row=m()-1; row>=0; --row)
{
somenumber s = b(row);
- for (unsigned int j=cols->rowstart[row]; j<cols->rowstart[row+1]; ++j)
+ for (size_type j=cols->rowstart[row]; j<cols->rowstart[row+1]; ++j)
{
s -= val[j] * v(cols->colnums[j]);
}
AssertDimension (m(), n());
Assert (m() == dst.size(), ExcDimensionMismatch(m(),dst.size()));
- const unsigned int n = dst.size();
- unsigned int j;
+ const size_type n = dst.size();
+ size_type j;
somenumber s;
- for (unsigned int i=0; i<n; i++)
+ for (size_type i=0; i<n; i++)
{
s = 0.;
for (j=cols->rowstart[i]; j<cols->rowstart[i+1] ; j++)
{
- const unsigned int p = cols->colnums[j];
+ const size_type p = cols->colnums[j];
if (p != SparsityPattern::invalid_entry)
{
if (i>j) s += val[j] * dst(p);
s = 0.;
for (j=cols->rowstart[i]; j<cols->rowstart[i+1] ; j++)
{
- const unsigned int p = cols->colnums[j];
+ const size_type p = cols->colnums[j];
if (p != SparsityPattern::invalid_entry)
{
- if (static_cast<unsigned int>(i)<j) s += val[j] * dst(p);
+ if (static_cast<size_type>(i)<j) s += val[j] * dst(p);
}
}
Assert(val[cols->rowstart[i]]!= 0., ExcDivideByZero());
width = precision+2;
}
- for (unsigned int i=0; i<m(); ++i)
+ for (size_type i=0; i<m(); ++i)
{
- for (unsigned int j=0; j<n(); ++j)
+ for (size_type j=0; j<n(); ++j)
if ((*cols)(i,j) != SparsityPattern::invalid_entry)
out << std::setw(width)
<< val[cols->operator()(i,j)] * denominator << ' ';
Assert (cols != 0, ExcNotInitialized());
Assert (val != 0, ExcNotInitialized());
- for (unsigned int i=0; i<m(); ++i)
+ for (size_type i=0; i<m(); ++i)
{
- for (unsigned int j=0; j<n(); ++j)
+ for (size_type j=0; j<n(); ++j)
if ((*cols)(i,j) == SparsityPattern::invalid_entry)
out << '.';
else if (std::fabs(val[cols->operator()(i,j)]) > threshold)
class SparseMatrixEZ : public Subscriptor
{
public:
+ /**
+ * Declare type for container size.
+ */
+ typedef types::global_dof_index size_type;
+
/**
* The class for storing the
* column number of an entry
* Constructor. Fills column
* and value.
*/
- Entry (const unsigned int column,
+ Entry (const size_type column,
const number &value);
/**
* The column number.
*/
- unsigned int column;
+ size_type column;
/**
* The value there.
/**
* Non-existent column number.
*/
- static const unsigned int invalid = numbers::invalid_unsigned_int;
+ static const size_type invalid = numbers::invalid_size_type;
};
/**
/**
* Constructor.
*/
- RowInfo (unsigned int start = Entry::invalid);
+ RowInfo (size_type start = Entry::invalid);
/**
* Index of first entry of
* the row in the data field.
*/
- unsigned int start;
+ size_type start;
/**
* Number of entries in this
* row.
* pointer is sufficient.
*/
Accessor (const SparseMatrixEZ<number> *matrix,
- const unsigned int row,
+ const size_type row,
const unsigned short index);
/**
* represented by this
* object.
*/
- unsigned int row() const;
+ size_type row() const;
/**
* Index in row of the element
* element represented by
* this object.
*/
- unsigned int column() const;
+ size_type column() const;
/**
* Value of this matrix entry.
/**
* Current row number.
*/
- unsigned int a_row;
+ size_type a_row;
/**
* Current index in row.
* Constructor.
*/
const_iterator(const SparseMatrixEZ<number> *matrix,
- const unsigned int row,
+ const size_type row,
const unsigned short index);
/**
* efficient assembling of the
* matrix.
*/
- explicit SparseMatrixEZ (const unsigned int n_rows,
- const unsigned int n_columns,
- const unsigned int default_row_length = 0,
+ explicit SparseMatrixEZ (const size_type n_rows,
+ const size_type n_columns,
+ const size_type default_row_length = 0,
const unsigned int default_increment = 1);
/**
* efficient assembling of the
* matrix.
*/
- void reinit (const unsigned int n_rows,
- const unsigned int n_columns,
- unsigned int default_row_length = 0,
+ void reinit (const size_type n_rows,
+ const size_type n_columns,
+ size_type default_row_length = 0,
unsigned int default_increment = 1,
- unsigned int reserve = 0);
+ size_type reserve = 0);
/**
* Release all memory and return
* matrix is of dimension
* $m \times n$.
*/
- unsigned int m () const;
+ size_type m () const;
/**
* Return the dimension of the
* matrix is of dimension
* $m \times n$.
*/
- unsigned int n () const;
+ size_type n () const;
/**
* Return the number of entries
* in a specific row.
*/
- unsigned int get_row_length (const unsigned int row) const;
+ size_type get_row_length (const size_type row) const;
/**
* Return the number of nonzero
* elements of this matrix.
*/
- unsigned int n_nonzero_elements () const;
+ size_type n_nonzero_elements () const;
/**
* Determine an estimate for the
* the number of entries in each
* line is printed as well.
*/
- void compute_statistics (unsigned int &used,
- unsigned int &allocated,
- unsigned int &reserved,
- std::vector<unsigned int> &used_by_line,
+ void compute_statistics (size_type &used,
+ size_type &allocated,
+ size_type &reserved,
+ std::vector<size_type> &used_by_line,
const bool compute_by_line) const;
//@}
/**
* finite number an exception
* is thrown.
*/
- void set (const unsigned int i, const unsigned int j,
+ void set (const size_type i, const size_type j,
const number value);
/**
* finite number an exception
* is thrown.
*/
- void add (const unsigned int i,
- const unsigned int j,
+ void add (const size_type i,
+ const size_type j,
const number value);
/**
* into the matrix.
*/
template <typename number2>
- void add (const std::vector<unsigned int> &indices,
- const FullMatrix<number2> &full_matrix,
- const bool elide_zero_values = true);
+ void add (const std::vector<size_type> &indices,
+ const FullMatrix<number2> &full_matrix,
+ const bool elide_zero_values = true);
/**
* Same function as before, but now
* on rows and columns, respectively.
*/
template <typename number2>
- void add (const std::vector<unsigned int> &row_indices,
- const std::vector<unsigned int> &col_indices,
+ void add (const std::vector<size_type> &row_indices,
+ const std::vector<size_type> &col_indices,
const FullMatrix<number2> &full_matrix,
const bool elide_zero_values = true);
* into the matrix.
*/
template <typename number2>
- void add (const unsigned int row,
- const std::vector<unsigned int> &col_indices,
- const std::vector<number2> &values,
- const bool elide_zero_values = true);
+ void add (const size_type row,
+ const std::vector<size_type> &col_indices,
+ const std::vector<number2> &values,
+ const bool elide_zero_values = true);
/**
* Add an array of values given by
* into the matrix.
*/
template <typename number2>
- void add (const unsigned int row,
- const unsigned int n_cols,
- const unsigned int *col_indices,
- const number2 *values,
- const bool elide_zero_values = true,
- const bool col_indices_are_sorted = false);
+ void add (const size_type row,
+ const size_type n_cols,
+ const size_type *col_indices,
+ const number2 *values,
+ const bool elide_zero_values = true,
+ const bool col_indices_are_sorted = false);
/**
* Copy the given matrix to this
* matrix), use the @p el
* function.
*/
- number operator () (const unsigned int i,
- const unsigned int j) const;
+ number operator () (const size_type i,
+ const size_type j) const;
/**
* Return the value of the entry
* (i,j). Returns zero for all
* non-existing entries.
*/
- number el (const unsigned int i,
- const unsigned int j) const;
+ number el (const size_type i,
+ const size_type j) const;
//@}
/**
* @name Multiplications
* is <tt>end(r)</tt>, which does NOT
* point into row @p r..
*/
- const_iterator begin (const unsigned int r) const;
+ const_iterator begin (const size_type r) const;
/**
* Final iterator of row
* @p r. The result may be
* different from <tt>end()</tt>!
*/
- const_iterator end (const unsigned int r) const;
+ const_iterator end (const size_type r) const;
//@}
/**
* @name Input/Output
* zero-pointer if the entry does
* not exist.
*/
- const Entry *locate (const unsigned int row,
- const unsigned int col) const;
+ const Entry *locate (const size_type row,
+ const size_type col) const;
/**
* Find an entry and return a
* zero-pointer if the entry does
* not exist.
*/
- Entry *locate (const unsigned int row,
- const unsigned int col);
+ Entry *locate (const size_type row,
+ const size_type col);
/**
* Find an entry or generate it.
*/
- Entry *allocate (const unsigned int row,
- const unsigned int col);
+ Entry *allocate (const size_type row,
+ const size_type col);
/**
* Version of @p vmult which only
template <typename somenumber>
void threaded_vmult (Vector<somenumber> &dst,
const Vector<somenumber> &src,
- const unsigned int begin_row,
- const unsigned int end_row) const;
+ const size_type begin_row,
+ const size_type end_row) const;
/**
* Version of
*/
template <typename somenumber>
void threaded_matrix_norm_square (const Vector<somenumber> &v,
- const unsigned int begin_row,
- const unsigned int end_row,
+ const size_type begin_row,
+ const size_type end_row,
somenumber *partial_sum) const;
/**
template <typename somenumber>
void threaded_matrix_scalar_product (const Vector<somenumber> &u,
const Vector<somenumber> &v,
- const unsigned int begin_row,
- const unsigned int end_row,
+ const size_type begin_row,
+ const size_type end_row,
somenumber *partial_sum) const;
/**
* used to check vector
* dimensions only.
*/
- unsigned int n_columns;
+ size_type n_columns;
/**
* Info structure for each row.
template <typename number>
inline
-SparseMatrixEZ<number>::Entry::Entry(unsigned int column,
+SparseMatrixEZ<number>::Entry::Entry(size_type column,
const number &value)
:
column(column),
template <typename number>
inline
-SparseMatrixEZ<number>::RowInfo::RowInfo(unsigned int start)
+SparseMatrixEZ<number>::RowInfo::RowInfo(size_type start)
:
start(start),
length(0),
inline
SparseMatrixEZ<number>::const_iterator::Accessor::
Accessor (const SparseMatrixEZ<number> *matrix,
- const unsigned int r,
+ const size_type r,
const unsigned short i)
:
matrix(matrix),
template <typename number>
inline
-unsigned int
+typename SparseMatrixEZ<number>::size_type
SparseMatrixEZ<number>::const_iterator::Accessor::row() const
{
return a_row;
template <typename number>
inline
-unsigned int
+typename SparseMatrixEZ<number>::size_type
SparseMatrixEZ<number>::const_iterator::Accessor::column() const
{
return matrix->data[matrix->row_info[a_row].start+a_index].column;
inline
SparseMatrixEZ<number>::const_iterator::
const_iterator(const SparseMatrixEZ<number> *matrix,
- const unsigned int r,
+ const size_type r,
const unsigned short i)
:
accessor(matrix, r, i)
//---------------------------------------------------------------------------
template <typename number>
inline
-unsigned int SparseMatrixEZ<number>::m () const
+typename SparseMatrixEZ<number>::size_type SparseMatrixEZ<number>::m () const
{
return row_info.size();
}
template <typename number>
inline
-unsigned int SparseMatrixEZ<number>::n () const
+typename SparseMatrixEZ<number>::size_type SparseMatrixEZ<number>::n () const
{
return n_columns;
}
template <typename number>
inline
typename SparseMatrixEZ<number>::Entry *
-SparseMatrixEZ<number>::locate (const unsigned int row,
- const unsigned int col)
+SparseMatrixEZ<number>::locate (const size_type row,
+ const size_type col)
{
Assert (row<m(), ExcIndexRange(row,0,m()));
Assert (col<n(), ExcIndexRange(col,0,n()));
const RowInfo &r = row_info[row];
- const unsigned int end = r.start + r.length;
- for (unsigned int i=r.start; i<end; ++i)
+ const size_type end = r.start + r.length;
+ for (size_type i=r.start; i<end; ++i)
{
Entry *const entry = &data[i];
if (entry->column == col)
template <typename number>
inline
const typename SparseMatrixEZ<number>::Entry *
-SparseMatrixEZ<number>::locate (const unsigned int row,
- const unsigned int col) const
+SparseMatrixEZ<number>::locate (const size_type row,
+ const size_type col) const
{
SparseMatrixEZ<number> *t = const_cast<SparseMatrixEZ<number>*> (this);
return t->locate(row,col);
template <typename number>
inline
typename SparseMatrixEZ<number>::Entry *
-SparseMatrixEZ<number>::allocate (const unsigned int row,
- const unsigned int col)
+SparseMatrixEZ<number>::allocate (const size_type row,
+ const size_type col)
{
Assert (row<m(), ExcIndexRange(row,0,m()));
Assert (col<n(), ExcIndexRange(col,0,n()));
RowInfo &r = row_info[row];
- const unsigned int end = r.start + r.length;
+ const size_type end = r.start + r.length;
- unsigned int i = r.start;
+ size_type i = r.start;
// If diagonal exists and this
// column is higher, start only
// after diagonal.
data.insert(data.begin()+end, increment, Entry());
// Update starts of
// following rows
- for (unsigned int rn=row+1; rn<row_info.size(); ++rn)
+ for (size_type rn=row+1; rn<row_info.size(); ++rn)
row_info[rn].start += increment;
}
}
// Move all entries in this
// row up by one
- for (unsigned int j = i+1; j < end; ++j)
+ for (size_type j = i+1; j < end; ++j)
{
// There should be no invalid
// entry below end
template <typename number>
inline
-void SparseMatrixEZ<number>::set (const unsigned int i,
- const unsigned int j,
+void SparseMatrixEZ<number>::set (const size_type i,
+ const size_type j,
const number value)
{
template <typename number>
inline
-void SparseMatrixEZ<number>::add (const unsigned int i,
- const unsigned int j,
+void SparseMatrixEZ<number>::add (const size_type i,
+ const size_type j,
const number value)
{
template <typename number>
template <typename number2>
-void SparseMatrixEZ<number>::add (const std::vector<unsigned int> &indices,
- const FullMatrix<number2> &full_matrix,
- const bool elide_zero_values)
+void SparseMatrixEZ<number>::add (const std::vector<size_type> &indices,
+ const FullMatrix<number2> &full_matrix,
+ const bool elide_zero_values)
{
//TODO: This function can surely be made more efficient
- for (unsigned int i=0; i<indices.size(); ++i)
- for (unsigned int j=0; j<indices.size(); ++j)
+ for (size_type i=0; i<indices.size(); ++i)
+ for (size_type j=0; j<indices.size(); ++j)
if ((full_matrix(i,j) != 0) || (elide_zero_values == false))
add (indices[i], indices[j], full_matrix(i,j));
}
template <typename number>
template <typename number2>
-void SparseMatrixEZ<number>::add (const std::vector<unsigned int> &row_indices,
- const std::vector<unsigned int> &col_indices,
- const FullMatrix<number2> &full_matrix,
- const bool elide_zero_values)
+void SparseMatrixEZ<number>::add (const std::vector<size_type> &row_indices,
+ const std::vector<size_type> &col_indices,
+ const FullMatrix<number2> &full_matrix,
+ const bool elide_zero_values)
{
//TODO: This function can surely be made more efficient
- for (unsigned int i=0; i<row_indices.size(); ++i)
- for (unsigned int j=0; j<col_indices.size(); ++j)
+ for (size_type i=0; i<row_indices.size(); ++i)
+ for (size_type j=0; j<col_indices.size(); ++j)
if ((full_matrix(i,j) != 0) || (elide_zero_values == false))
add (row_indices[i], col_indices[j], full_matrix(i,j));
}
template <typename number>
template <typename number2>
-void SparseMatrixEZ<number>::add (const unsigned int row,
- const std::vector<unsigned int> &col_indices,
- const std::vector<number2> &values,
- const bool elide_zero_values)
+void SparseMatrixEZ<number>::add (const size_type row,
+ const std::vector<size_type> &col_indices,
+ const std::vector<number2> &values,
+ const bool elide_zero_values)
{
//TODO: This function can surely be made more efficient
- for (unsigned int j=0; j<col_indices.size(); ++j)
+ for (size_type j=0; j<col_indices.size(); ++j)
if ((values[j] != 0) || (elide_zero_values == false))
add (row, col_indices[j], values[j]);
}
template <typename number>
template <typename number2>
-void SparseMatrixEZ<number>::add (const unsigned int row,
- const unsigned int n_cols,
- const unsigned int *col_indices,
- const number2 *values,
- const bool elide_zero_values,
- const bool /*col_indices_are_sorted*/)
+void SparseMatrixEZ<number>::add (const size_type row,
+ const size_type n_cols,
+ const size_type *col_indices,
+ const number2 *values,
+ const bool elide_zero_values,
+ const bool /*col_indices_are_sorted*/)
{
//TODO: This function can surely be made more efficient
- for (unsigned int j=0; j<n_cols; ++j)
+ for (size_type j=0; j<n_cols; ++j)
if ((values[j] != 0) || (elide_zero_values == false))
add (row, col_indices[j], values[j]);
}
template <typename number>
inline
-number SparseMatrixEZ<number>::el (const unsigned int i,
- const unsigned int j) const
+number SparseMatrixEZ<number>::el (const size_type i,
+ const size_type j) const
{
const Entry *entry = locate(i,j);
if (entry)
template <typename number>
inline
-number SparseMatrixEZ<number>::operator() (const unsigned int i,
- const unsigned int j) const
+number SparseMatrixEZ<number>::operator() (const size_type i,
+ const size_type j) const
{
const Entry *entry = locate(i,j);
if (entry)
template <typename number>
inline
typename SparseMatrixEZ<number>::const_iterator
-SparseMatrixEZ<number>::begin (const unsigned int r) const
+SparseMatrixEZ<number>::begin (const size_type r) const
{
Assert (r<m(), ExcIndexRange(r,0,m()));
const_iterator result (this, r, 0);
template <typename number>
inline
typename SparseMatrixEZ<number>::const_iterator
-SparseMatrixEZ<number>::end (const unsigned int r) const
+SparseMatrixEZ<number>::end (const size_type r) const
{
Assert (r<m(), ExcIndexRange(r,0,m()));
const_iterator result(this, r+1, 0);
// loop over the elements of the argument matrix row by row, as suggested
// in the documentation of the sparse matrix iterator class, and
// copy them into the current object
- for (unsigned int row = 0; row < M.m(); ++row)
+ for (size_type row = 0; row < M.m(); ++row)
{
const typename MATRIX::const_iterator end_row = M.end(row);
for (typename MATRIX::const_iterator entry = M.begin(row);
// loop over the elements of the argument matrix row by row, as suggested
// in the documentation of the sparse matrix iterator class, and
// add them into the current object
- for (unsigned int row = 0; row < M.m(); ++row)
+ for (size_type row = 0; row < M.m(); ++row)
{
const typename MATRIX::const_iterator end_row = M.end(row);
for (typename MATRIX::const_iterator entry = M.begin(row);
if (transpose)
while (b1 != b_final)
{
- const unsigned int i = b1->column();
- const unsigned int k = b1->row();
+ const size_type i = b1->column();
+ const size_type k = b1->row();
typename MATRIXB::const_iterator b2 = B.begin();
while (b2 != b_final)
{
- const unsigned int j = b2->column();
- const unsigned int l = b2->row();
+ const size_type j = b2->column();
+ const size_type l = b2->row();
const typename MATRIXA::value_type a = A.el(k,l);
// maximal row for a column in
// advance.
- std::vector<unsigned int> minrow(B.n(), B.m());
- std::vector<unsigned int> maxrow(B.n(), 0);
+ std::vector<size_type> minrow(B.n(), B.m());
+ std::vector<size_type> maxrow(B.n(), 0);
while (b1 != b_final)
{
- const unsigned int r = b1->row();
+ const size_type r = b1->row();
if (r < minrow[b1->column()])
minrow[b1->column()] = r;
if (r > maxrow[b1->column()])
// the work
if (b1->column() == ai->row() && (b1v != 0.))
{
- const unsigned int i = b1->row();
+ const size_type i = b1->row();
typename MATRIXB::const_iterator
b2 = B.begin(minrow[ai->column()]);
{
if (b2->column() == ai->column())
{
- const unsigned int j = b2->row();
+ const size_type j = b2->row();
add (i, j, a * b1v * b2->value());
}
++b2;
void
SparseMatrixEZ<number>::print_statistics(STREAM &out, bool full)
{
- unsigned int used;
- unsigned int allocated;
- unsigned int reserved;
- std::vector<unsigned int> used_by_line;
+ size_type used;
+ size_type allocated;
+ size_type reserved;
+ std::vector<size_type> used_by_line;
compute_statistics (used, allocated, reserved, used_by_line, full);
if (full)
{
- for (unsigned int i=0; i< used_by_line.size(); ++i)
+ for (size_type i=0; i< used_by_line.size(); ++i)
if (used_by_line[i] != 0)
out << "SparseMatrixEZ:entries\t" << i
<< "\trows\t" << used_by_line[i]
template <typename number>
-SparseMatrixEZ<number>::SparseMatrixEZ(const unsigned int n_rows,
- const unsigned int n_cols,
- const unsigned int default_row_length,
+SparseMatrixEZ<number>::SparseMatrixEZ(const size_type n_rows,
+ const size_type n_cols,
+ const size_type default_row_length,
const unsigned int default_increment)
{
reinit(n_rows, n_cols, default_row_length, default_increment);
template <typename number>
void
-SparseMatrixEZ<number>::reinit(const unsigned int n_rows,
- const unsigned int n_cols,
- unsigned int default_row_length,
- unsigned int default_increment,
- unsigned int reserve)
+SparseMatrixEZ<number>::reinit(const size_type n_rows,
+ const size_type n_cols,
+ size_type default_row_length,
+ unsigned int default_increment,
+ size_type reserve)
{
clear();
data.reserve(reserve);
data.resize(default_row_length * n_rows);
- for (unsigned int i=0; i<n_rows; ++i)
+ for (size_type i=0; i<n_rows; ++i)
row_info[i].start = i * default_row_length;
}
Assert(m() == dst.size(), ExcDimensionMismatch(m(),dst.size()));
Assert(n() == src.size(), ExcDimensionMismatch(n(),src.size()));
- const unsigned int end_row = row_info.size();
- for (unsigned int row = 0; row < end_row; ++row)
+ const size_type end_row = row_info.size();
+ for (size_type row = 0; row < end_row; ++row)
{
const RowInfo &ri = row_info[row];
typename std::vector<Entry>::const_iterator
Assert(m() == dst.size(), ExcDimensionMismatch(m(),dst.size()));
Assert(n() == src.size(), ExcDimensionMismatch(n(),src.size()));
- const unsigned int end_row = row_info.size();
- for (unsigned int row = 0; row < end_row; ++row)
+ const size_type end_row = row_info.size();
+ for (size_type row = 0; row < end_row; ++row)
{
const RowInfo &ri = row_info[row];
typename std::vector<Entry>::const_iterator
Assert(n() == dst.size(), ExcDimensionMismatch(n(),dst.size()));
Assert(m() == src.size(), ExcDimensionMismatch(m(),src.size()));
- const unsigned int end_row = row_info.size();
- for (unsigned int row = 0; row < end_row; ++row)
+ const size_type end_row = row_info.size();
+ for (size_type row = 0; row < end_row; ++row)
{
const RowInfo &ri = row_info[row];
typename std::vector<Entry>::const_iterator
{
Assert (ri->diagonal != RowInfo::invalid_diagonal, ExcNoDiagonal());
number s = *src_ptr;
- const unsigned int end_row = ri->start + ri->diagonal;
- for (unsigned int i=ri->start; i<end_row; ++i)
+ const size_type end_row = ri->start + ri->diagonal;
+ for (size_type i=ri->start; i<end_row; ++i)
s -= data[i].value * dst(data[i].column);
*dst_ptr = om * s / data[ri->start + ri->diagonal].value;
{
Assert (ri->diagonal != RowInfo::invalid_diagonal, ExcNoDiagonal());
number s = *src_ptr;
- const unsigned int end_row = ri->start + ri->length;
- for (unsigned int i=ri->start+ri->diagonal+1; i<end_row; ++i)
+ const size_type end_row = ri->start + ri->length;
+ for (size_type i=ri->start+ri->diagonal+1; i<end_row; ++i)
s -= data[i].value * dst(data[i].column);
*dst_ptr = om * s / data[ri->start + ri->diagonal].value;
{
Assert (ri->diagonal != RowInfo::invalid_diagonal, ExcNoDiagonal());
number s = 0;
- const unsigned int end_row = ri->start + ri->diagonal;
- for (unsigned int i=ri->start; i<end_row; ++i)
+ const size_type end_row = ri->start + ri->diagonal;
+ for (size_type i=ri->start; i<end_row; ++i)
s += data[i].value * dst(data[i].column);
*dst_ptr = *src_ptr - s * om;
dst_ptr = dst.begin()+dst.size()-1;
for (rri = row_info.rbegin(); rri != rend; --dst_ptr, ++rri)
{
- const unsigned int end_row = rri->start + rri->length;
+ const size_type end_row = rri->start + rri->length;
number s = 0;
- for (unsigned int i=rri->start+rri->diagonal+1; i<end_row; ++i)
+ for (size_type i=rri->start+rri->diagonal+1; i<end_row; ++i)
s += data[i].value * dst(data[i].column);
*dst_ptr -= s * om;
{
return
sizeof (*this)
- + sizeof(unsigned int) * row_info.capacity()
+ + sizeof(size_type) * row_info.capacity()
+ sizeof(typename SparseMatrixEZ<number>::Entry) * data.capacity();
}
template <typename number>
-unsigned int
-SparseMatrixEZ<number>::get_row_length (const unsigned int row) const
+typename SparseMatrixEZ<number>::size_type
+SparseMatrixEZ<number>::get_row_length (const size_type row) const
{
return row_info[row].length;
}
template <typename number>
-unsigned int
+typename SparseMatrixEZ<number>::size_type
SparseMatrixEZ<number>::n_nonzero_elements() const
{
typename std::vector<RowInfo>::const_iterator row = row_info.begin();
const typename std::vector<RowInfo>::const_iterator endrow = row_info.end();
// Add up entries actually used
- unsigned int used = 0;
+ size_type used = 0;
for (; row != endrow ; ++ row)
used += row->length;
return used;
template <typename number>
void
SparseMatrixEZ<number>::compute_statistics(
- unsigned int &used,
- unsigned int &allocated,
- unsigned int &reserved,
- std::vector<unsigned int> &used_by_line,
+ size_type &used,
+ size_type &allocated,
+ size_type &reserved,
+ std::vector<size_type> &used_by_line,
const bool full) const
{
typename std::vector<RowInfo>::const_iterator row = row_info.begin();
// Add up entries actually used
used = 0;
- unsigned int max_length = 0;
+ size_type max_length = 0;
for (; row != endrow ; ++ row)
{
used += row->length;
}
// TODO: Skip nonexisting entries
- for (unsigned int i=0; i<m(); ++i)
+ for (size_type i=0; i<m(); ++i)
{
- for (unsigned int j=0; j<n(); ++j)
+ for (size_type j=0; j<n(); ++j)
{
const Entry *entry = locate(i,j);
if (entry)
class SparseMIC : public SparseLUDecomposition<number>
{
public:
+ /**
+ * Declare type for container size.
+ */
+ typedef types::global_dof_index size_type;
+
/**
* Constructor. Does nothing, so
* you have to call @p decompose
* Compute the row-th "inner
* sum".
*/
- number get_rowsum (const unsigned int row) const;
+ number get_rowsum (const size_type row) const;
};
/*@}*/
inner_sums.resize (this->m());
// precalc sum(j=k+1, N, a[k][j]))
- for (unsigned int row=0; row<this->m(); row++)
+ for (size_type row=0; row<this->m(); row++)
inner_sums[row] = get_rowsum(row);
- for (unsigned int row=0; row<this->m(); row++)
+ for (size_type row=0; row<this->m(); row++)
{
const number temp = this->begin(row)->value();
number temp1 = 0;
template <typename number>
inline number
-SparseMIC<number>::get_rowsum (const unsigned int row) const
+SparseMIC<number>::get_rowsum (const size_type row) const
{
Assert(this->m()==this->n(), ExcNotQuadratic());
Assert (dst.size() == src.size(), ExcDimensionMismatch(dst.size(), src.size()));
Assert (dst.size() == this->m(), ExcDimensionMismatch(dst.size(), this->m()));
- const unsigned int N=dst.size();
+ const size_type N=dst.size();
// We assume the underlying matrix A is: A = X - L - U, where -L and -U are
// strictly lower- and upper- diagonal parts of the system.
//
// Solve (X-L)X{-1}(X-U) x = b in 3 steps:
dst = src;
- for (unsigned int row=0; row<N; ++row)
+ for (size_type row=0; row<N; ++row)
{
// Now: (X-L)u = b
}
// Now: v = Xu
- for (unsigned int row=0; row<N; row++)
+ for (size_type row=0; row<N; row++)
dst(row) *= diag[row];
// x = (X-U)v
p = this->begin(row)+1;
p != this->end(row);
++p)
- if (p->column() > static_cast<unsigned int>(row))
+ if (p->column() > static_cast<size_type>(row))
dst(row) -= p->value() * dst(p->column());
dst(row) *= inv_diag[row];
class SparseVanka
{
public:
+ /**
+ * Declare type for container size.
+ */
+ typedef types::global_dof_index size_type;
+
/**
* Constructor. Gets the matrix
* for preconditioning and a bit
* mode, several copies of this
* function are spawned.
*/
- void compute_inverses (const unsigned int begin,
- const unsigned int end);
+ void compute_inverses (const size_type begin,
+ const size_type end);
/**
* Compute the inverse of the
* the case where this function
* re-creates it each time.
*/
- void compute_inverse (const unsigned int row,
- std::vector<unsigned int> &local_indices);
+ void compute_inverse (const size_type row,
+ std::vector<size_type> &local_indices);
/**
* Make the derived class a
class SparseBlockVanka : public SparseVanka<number>
{
public:
+ /**
+ * Declate type for container size.
+ */
+ typedef types::global_dof_index size_type;
+
/**
* Enumeration of the different
* methods by which the DoFs are
compute_inverses (0, matrix->m());
else
{
- const unsigned int n_inverses = std::count (selected.begin(),
- selected.end(),
- true);
+ const size_type n_inverses = std::count (selected.begin(),
+ selected.end(),
+ true);
- const unsigned int n_inverses_per_thread = std::max(n_inverses / n_threads,
- 1U);
+ const size_type n_inverses_per_thread = std::max(n_inverses / n_threads, 1U);
// set up start and end index
// for each of the
// consecutive, with other
// consecutive regions where we
// do not have to do something
- std::vector<std::pair<unsigned int, unsigned int> > blocking (n_threads);
+ std::vector<std::pair<size_type, size_type> > blocking (n_threads);
unsigned int c = 0;
unsigned int thread = 0;
blocking[0].first = 0;
- for (unsigned int i=0; (i<matrix->m()) && (thread+1<n_threads); ++i)
+ for (size_type i=0; (i<matrix->m()) && (thread+1<n_threads); ++i)
{
if (selected[i] == true)
++c;
};
blocking[n_threads-1].second = matrix->m();
- typedef void (SparseVanka<number>::*FunPtr)(const unsigned int,
- const unsigned int);
+ typedef void (SparseVanka<number>::*FunPtr)(const size_type,
+ const size_type);
const FunPtr fun_ptr = &SparseVanka<number>::compute_inverses;
// Now spawn the threads
template <typename number>
void
-SparseVanka<number>::compute_inverses (const unsigned int begin,
- const unsigned int end)
+SparseVanka<number>::compute_inverses (const size_type begin,
+ const size_type end)
{
// set-up the vector that will be used
// by the functions which we call
// below.
- std::vector<unsigned int> local_indices;
+ std::vector<size_type> local_indices;
// traverse all rows of the matrix
// which are selected
- for (unsigned int row=begin; row<end; ++row)
+ for (size_type row=begin; row<end; ++row)
if (selected[row] == true)
compute_inverse (row, local_indices);
}
template <typename number>
void
-SparseVanka<number>::compute_inverse (const unsigned int row,
- std::vector<unsigned int> &local_indices)
+SparseVanka<number>::compute_inverse (const size_type row,
+ std::vector<size_type> &local_indices)
{
// first define an alias to the sparsity
// pattern of the matrix, since this
const SparsityPattern &structure
= matrix->get_sparsity_pattern();
- const unsigned int row_length = structure.row_length(row);
+ const size_type row_length = structure.row_length(row);
inverses[row] = new FullMatrix<float> (row_length, row_length);
// collect the dofs that couple
// with @p row
local_indices.resize (row_length);
- for (unsigned int i=0; i<row_length; ++i)
+ for (size_type i=0; i<row_length; ++i)
local_indices[i] = structure.column_number(row, i);
// Build local matrix
Vector<float> b (structure.max_entries_per_row());
Vector<float> x (structure.max_entries_per_row());
- std::map<unsigned int, unsigned int> local_index;
+ std::map<size_type, size_type> local_index;
// traverse all rows of the matrix
// which are selected
- const unsigned int n = matrix->m();
- for (unsigned int row=0; row<n; ++row)
+ const size_type n = matrix->m();
+ for (size_type row=0; row<n; ++row)
if ((selected[row] == true) &&
((range_is_restricted == false) || ((*dof_mask)[row] == true)))
{
- const unsigned int row_length = structure.row_length(row);
+ const size_type row_length = structure.row_length(row);
// if we don't store the
// inverse matrices, then alias
// all degrees of freedom that
// couple with @p row.
local_index.clear ();
- for (unsigned int i=0; i<row_length; ++i)
- local_index.insert(std::pair<unsigned int, unsigned int>
+ for (size_type i=0; i<row_length; ++i)
+ local_index.insert(std::pair<size_type, size_type>
(structure.column_number(row, i), i));
// Build local matrix and rhs
- for (std::map<unsigned int, unsigned int>::const_iterator is=local_index.begin();
+ for (std::map<size_type, size_type>::const_iterator is=local_index.begin();
is!=local_index.end(); ++is)
{
// irow loops over all DoFs that
// couple with the present DoF
- const unsigned int irow = is->first;
+ const size_type irow = is->first;
// index of DoF irow in the matrix
// row corresponding to DoF @p row.
// runs between 0 and row_length
- const unsigned int i = is->second;
+ const size_type i = is->second;
// copy rhs
b(i) = src(irow);
// which itself couples with
// @p row) also couples with
// @p row.
- const std::map<unsigned int, unsigned int>::const_iterator js
+ const std::map<size_type, size_type>::const_iterator js
= local_index.find(p->column());
// if not, then still use
// this dof to modify the rhs
inverses[row]->vmult(x,b);
// Distribute new values
- for (std::map<unsigned int, unsigned int>::const_iterator is=local_index.begin();
+ for (std::map<size_type, size_type>::const_iterator is=local_index.begin();
is!=local_index.end(); ++is)
{
- const unsigned int irow = is->first;
- const unsigned int i = is->second;
+ const size_type irow = is->first;
+ const size_type i = is->second;
if (!range_is_restricted ||
((*dof_mask)[irow] == true))
{
std::size_t mem = (sizeof(*this) +
MemoryConsumption::memory_consumption (selected));
- for (unsigned int i=0; i<inverses.size(); ++i)
+ for (size_type i=0; i<inverses.size(); ++i)
mem += MemoryConsumption::memory_consumption (*inverses[i]);
return mem;
{
Assert (n_blocks > 0, ExcInternalError());
- const unsigned int n_inverses = std::count (selected.begin(),
- selected.end(),
- true);
+ const size_type n_inverses = std::count (selected.begin(),
+ selected.end(),
+ true);
- const unsigned int n_inverses_per_block = std::max(n_inverses / n_blocks, 1U);
+ const size_type n_inverses_per_block = std::max(n_inverses / n_blocks, 1U);
// precompute the splitting points
- std::vector<std::pair<unsigned int, unsigned int> > intervals (n_blocks);
+ std::vector<std::pair<size_type, size_type> > intervals (n_blocks);
// set up start and end index for
// each of the blocks. note that
unsigned int block = 0;
intervals[0].first = 0;
- for (unsigned int i=0; (i<M.m()) && (block+1<n_blocks); ++i)
+ for (size_type i=0; (i<M.m()) && (block+1<n_blocks); ++i)
{
if (selected[i] == true)
++c;
// Lagrange dofs of each
// block access the different
// dofs
- Table<2,unsigned int> access_count (n_blocks, M.m());
+ Table<2,size_type> access_count (n_blocks, M.m());
// set-up the map that will
// be used to store the
// indices each Lagrange dof
// accesses
- std::map<unsigned int, unsigned int> local_index;
+ std::map<size_type, size_type> local_index;
const SparsityPattern &structure = M.get_sparsity_pattern();
- for (unsigned int row=0; row<M.m(); ++row)
+ for (size_type row=0; row<M.m(); ++row)
if (selected[row] == true)
{
// first find out to
// dofs number the
// present index wants
// to write
- const unsigned int row_length = structure.row_length(row);
- for (unsigned int i=0; i<row_length; ++i)
+ const size_type row_length = structure.row_length(row);
+ for (size_type i=0; i<row_length; ++i)
++access_count[block_number][structure.column_number(row, i)];
};
// the of course we leave it
// to the block we put it
// into in the first place
- for (unsigned int row=0; row<M.m(); ++row)
+ for (size_type row=0; row<M.m(); ++row)
if (selected[row] == true)
{
unsigned int block_number = 0;
// find out which block
// accesses this dof
// the most often
- unsigned int max_accesses = 0;
+ size_type max_accesses = 0;
unsigned int max_access_block = 0;
for (unsigned int block=0; block<n_blocks; ++block)
if (access_count[block][row] > max_accesses)
SparseBlockVanka<number>::memory_consumption () const
{
std::size_t mem = SparseVanka<number>::memory_consumption();
- for (unsigned int i=0; i<dof_masks.size(); ++i)
+ for (size_type i=0; i<dof_masks.size(); ++i)
mem += MemoryConsumption::memory_consumption (dof_masks[i]);
return mem;
}
{
namespace SparsityPatternTools
{
+ /**
+ * Declare type for container size.
+ */
+ typedef types::global_dof_index size_type;
+
/**
* Helper function to get the column index from a dereferenced iterator in
* the copy_from() function, if the inner iterator type points to plain
* unsigned integers.
*/
- unsigned int
- get_column_index_from_iterator (const unsigned int i);
+ size_type
+ get_column_index_from_iterator (const size_type i);
/**
* Helper function to get the column index from a dereferenced iterator in
* unsigned integers and some other value.
*/
template <typename value>
- unsigned int
- get_column_index_from_iterator (const std::pair<unsigned int, value> &i);
+ size_type
+ get_column_index_from_iterator (const std::pair<size_type, value> &i);
/**
* Likewise, but sometimes needed for certain types of containers that
* <tt>std::map</tt>).
*/
template <typename value>
- unsigned int
- get_column_index_from_iterator (const std::pair<const unsigned int, value> &i);
+ size_type
+ get_column_index_from_iterator (const std::pair<const size_type, value> &i);
}
}
// forward declaration
class Iterator;
+ /**
+ * Declare type for container size.
+ */
+ typedef types::global_dof_index size_type;
+
/**
* Accessor class for iterators into sparsity patterns. This class is
* also the base class for both const and non-const accessor classes
* with a global index instead.
*/
Accessor (const SparsityPattern *matrix,
- const unsigned int row,
- const unsigned int index) DEAL_II_DEPRECATED;
+ const size_type row,
+ const size_type index) DEAL_II_DEPRECATED;
/**
* Constructor.
* Row number of the element represented by this object. This function can
* only be called for entries for which is_valid_entry() is true.
*/
- unsigned int row () const;
+ size_type row () const;
/**
* Index within the current row of the element represented by this object. This function
* can only be called for entries for which is_valid_entry() is true.
*/
- unsigned int index () const;
+ size_type index () const;
/**
* Column number of the element represented by this object. This function
* can only be called for entries for which is_valid_entry() is true.
*/
- unsigned int column () const;
+ size_type column () const;
/**
* Return whether the sparsity pattern entry pointed to by this iterator
* with a global index instead.
*/
Iterator (const SparsityPattern *sp,
- const unsigned int row,
- const unsigned int index) DEAL_II_DEPRECATED;
+ const size_type row,
+ const size_type index) DEAL_II_DEPRECATED;
/**
* Constructor. Create an iterator into the sparsity pattern @p sp for the
class SparsityPattern : public Subscriptor
{
public:
+ /**
+ * Declare type for container size.
+ */
+ typedef types::global_dof_index size_type;
+
/**
* Typedef an iterator class that allows to walk over all nonzero elements
* of a sparsity pattern.
* @deprecated This typedef is deprecated. Use proper iterators instead.
*/
typedef
- const unsigned int *row_iterator;
+ const size_type *row_iterator;
/**
* Typedef an iterator class that allows to walk over all nonzero elements
* perform some optimizations, but the actual value of the variable may
* change over time.
*/
- static const unsigned int invalid_entry = numbers::invalid_unsigned_int;
+ static const size_type invalid_entry = numbers::invalid_size_type;
/**
* @name Construction and setup
* @deprecated Use the constructor without the last argument since
* it is ignored.
*/
- SparsityPattern (const unsigned int m,
- const unsigned int n,
- const unsigned int max_per_row,
+ SparsityPattern (const size_type m,
+ const size_type n,
+ const size_type max_per_row,
const bool optimize_diagonal) DEAL_II_DEPRECATED;
/**
* @arg n number of columns
* @arg max_per_row maximum number of nonzero entries per row
*/
- SparsityPattern (const unsigned int m,
- const unsigned int n,
- const unsigned int max_per_row);
+ SparsityPattern (const size_type m,
+ const size_type n,
+ const size_type max_per_row);
/**
* Initialize a rectangular matrix.
* @deprecated Use the constructor without the last argument since
* it is ignored.
*/
- SparsityPattern (const unsigned int m,
- const unsigned int n,
- const std::vector<unsigned int> &row_lengths,
+ SparsityPattern (const size_type m,
+ const size_type n,
+ const std::vector<size_type> &row_lengths,
const bool optimize_diagonal) DEAL_II_DEPRECATED;
/**
* @arg row_lengths possible number of nonzero entries for each row. This
* vector must have one entry for each row.
*/
- SparsityPattern (const unsigned int m,
- const unsigned int n,
- const std::vector<unsigned int> &row_lengths);
+ SparsityPattern (const size_type m,
+ const size_type n,
+ const std::vector<size_type> &row_lengths);
/**
* Initialize a quadratic matrix of dimension <tt>n</tt> with at most
* elements. To avoid this, use the constructor taking row and column
* numbers separately.
*/
- SparsityPattern (const unsigned int n,
- const unsigned int max_per_row);
+ SparsityPattern (const size_type n,
+ const size_type max_per_row);
/**
* Initialize a quadratic matrix.
* @deprecated Use the constructor without the last argument since
* it is ignored.
*/
- SparsityPattern (const unsigned int m,
- const std::vector<unsigned int> &row_lengths,
+ SparsityPattern (const size_type m,
+ const std::vector<size_type> &row_lengths,
const bool optimize_diagonal) DEAL_II_DEPRECATED;
/**
* @arg row_lengths possible number of nonzero entries for each row. This
* vector must have one entry for each row.
*/
- SparsityPattern (const unsigned int m,
- const std::vector<unsigned int> &row_lengths);
+ SparsityPattern (const size_type m,
+ const std::vector<size_type> &row_lengths);
/**
* Make a copy with extra off-diagonals.
* compressed after this function finishes.
*/
SparsityPattern (const SparsityPattern &original,
- const unsigned int max_per_row,
- const unsigned int extra_off_diagonals);
+ const size_type max_per_row,
+ const size_type extra_off_diagonals);
/**
* Destructor.
* @deprecated The last argument of this function is ignored. Use the
* version of this function without the last argument.
*/
- void reinit (const unsigned int m,
- const unsigned int n,
- const unsigned int max_per_row,
+ void reinit (const size_type m,
+ const size_type n,
+ const size_type max_per_row,
const bool optimize_diagonal) DEAL_II_DEPRECATED;
/**
* This function simply maps its operations to the other <tt>reinit</tt>
* function.
*/
- void reinit (const unsigned int m,
- const unsigned int n,
- const unsigned int max_per_row);
+ void reinit (const size_type m,
+ const size_type n,
+ const size_type max_per_row);
/**
* Reallocate memory for a matrix of size <tt>m x n</tt>. The number of
* @deprecated The last argument of this function is ignored. Use the
* version of this function without the last argument.
*/
- void reinit (const unsigned int m,
- const unsigned int n,
- const std::vector<unsigned int> &row_lengths,
+ void reinit (const size_type m,
+ const size_type n,
+ const std::vector<size_type> &row_lengths,
const bool optimize_diagonal) DEAL_II_DEPRECATED;
/**
* is true, diagonal elements are stored first in each row to allow
* optimized access in relaxation methods of SparseMatrix.
*/
- void reinit (const unsigned int m,
- const unsigned int n,
- const std::vector<unsigned int> &row_lengths);
+ void reinit (const size_type m,
+ const size_type n,
+ const std::vector<size_type> &row_lengths);
/**
* Same as above, but with a VectorSlice argument instead.
* @deprecated The last argument of this function is ignored. Use the
* version of this function without the last argument.
*/
- void reinit (const unsigned int m,
- const unsigned int n,
- const VectorSlice<const std::vector<unsigned int> > &row_lengths,
+ void reinit (const size_type m,
+ const size_type n,
+ const VectorSlice<const std::vector<size_type> > &row_lengths,
const bool optimize_diagonal) DEAL_II_DEPRECATED;
/**
* Same as above, but with a VectorSlice argument instead.
*/
- void reinit (const unsigned int m,
- const unsigned int n,
- const VectorSlice<const std::vector<unsigned int> > &row_lengths);
+ void reinit (const size_type m,
+ const size_type n,
+ const VectorSlice<const std::vector<size_type> > &row_lengths);
/**
* This function compresses the sparsity structure that this object
* version of this function without the last argument.
*/
template <typename ForwardIterator>
- void copy_from (const unsigned int n_rows,
- const unsigned int n_cols,
+ void copy_from (const size_type n_rows,
+ const size_type n_cols,
const ForwardIterator begin,
const ForwardIterator end,
const bool optimize_diagonal) DEAL_II_DEPRECATED;
* iterators that point to such pairs.
*/
template <typename ForwardIterator>
- void copy_from (const unsigned int n_rows,
- const unsigned int n_cols,
+ void copy_from (const size_type n_rows,
+ const size_type n_cols,
const ForwardIterator begin,
const ForwardIterator end);
*
* If the entry already exists, nothing bad happens.
*/
- void add (const unsigned int i,
- const unsigned int j);
+ void add (const size_type i,
+ const size_type j);
/**
* Add several nonzero entries to the specified matrix row. This function
* If some of the entries already exist, nothing bad happens.
*/
template <typename ForwardIterator>
- void add_entries (const unsigned int row,
- ForwardIterator begin,
- ForwardIterator end,
- const bool indices_are_sorted = false);
+ void add_entries (const size_type row,
+ ForwardIterator begin,
+ ForwardIterator end,
+ const bool indices_are_sorted = false);
// @}
/**
* Note also the discussion in the general documentation of this class about
* the order in which elements are accessed.
*/
- iterator begin (const unsigned int r) const;
+ iterator begin (const size_type r) const;
/**
* Final iterator of row <tt>r</tt>. It points to the first element past the
* particular the case if it is the end iterator for the last row of a
* matrix.
*/
- iterator end (const unsigned int r) const;
+ iterator end (const size_type r) const;
/**
* STL-like iterator with the first entry of row <tt>r</tt>.
* @deprecated Use the iterators provided by the begin() and end()
* functions instead.
*/
- row_iterator row_begin (const unsigned int r) const DEAL_II_DEPRECATED;
+ row_iterator row_begin (const size_type r) const DEAL_II_DEPRECATED;
/**
* Final iterator of row <tt>r</tt>. It points to the first element past the
* @deprecated Use the iterators provided by the begin() and end()
* functions instead.
*/
- row_iterator row_end (const unsigned int r) const DEAL_II_DEPRECATED;
+ row_iterator row_end (const size_type r) const DEAL_II_DEPRECATED;
// @}
/**
* equals the number given to the constructor, while after compression, it
* equals the maximum number of entries actually allocated by the user.
*/
- unsigned int max_entries_per_row () const;
+ size_type max_entries_per_row () const;
/**
* Compute the bandwidth of the matrix represented by this structure. The
* represents a nonzero entry of the matrix. Consequently, the maximum
* bandwidth a $n\times m$ matrix can have is $\max\{n-1,m-1\}$.
*/
- unsigned int bandwidth () const;
+ size_type bandwidth () const;
/**
* Return the number of nonzero elements of this matrix. Actually, it
* This function may only be called if the matrix struct is compressed. It
* does not make too much sense otherwise anyway.
*/
- std::size_t n_nonzero_elements () const;
+ size_type n_nonzero_elements () const;
/**
* Return whether the structure is compressed or not.
* Return number of rows of this matrix, which equals the dimension of the
* image space.
*/
- unsigned int n_rows () const;
+ size_type n_rows () const;
/**
* Return number of columns of this matrix, which equals the dimension of
* the range space.
*/
- unsigned int n_cols () const;
+ size_type n_cols () const;
/**
* Number of entries in a specific row.
*/
- unsigned int row_length (const unsigned int row) const;
+ size_type row_length (const size_type row) const;
/**
* Determine whether the matrix uses the special convention for quadratic
* single row. In such cases, it is more efficient to use iterators over
* the elements of the sparsity pattern or of the sparse matrix.
*/
- unsigned int operator() (const unsigned int i,
- const unsigned int j) const;
+ size_type operator() (const size_type i,
+ const size_type j) const;
/**
* This is the inverse operation to operator()(): given a global index, find
* If <tt>N</tt> is the number of rows of this matrix, then the complexity
* of this function is <i>log(N)</i>.
*/
- std::pair<unsigned int, unsigned int>
- matrix_position (const unsigned int global_index) const;
+ std::pair<size_type, size_type>
+ matrix_position (const size_type global_index) const;
/**
* Check if a value at a certain position may be non-zero.
*/
- bool exists (const unsigned int i,
- const unsigned int j) const;
+ bool exists (const size_type i,
+ const size_type j) const;
/**
* The index of a global matrix entry in its row.
* with respect to the total field, but only with respect to the row
* <tt>j</tt>.
*/
- unsigned int row_position(const unsigned int i,
- const unsigned int j) const;
+ size_type row_position(const size_type i,
+ const size_type j) const;
/**
* Access to column number field. Return the column number of the
* i.e. <tt>column_number(row,i)</tt> <tt><</tt>
* <tt>column_number(row,i+1)</tt>.
*/
- unsigned int column_number (const unsigned int row,
- const unsigned int index) const;
+ size_type column_number (const size_type row,
+ const size_type index) const;
// @}
* yourself, you should also rename this function to avoid programs relying
* on outdated information!
*/
- const unsigned int *get_column_numbers () const DEAL_II_DEPRECATED;
+ const size_type *get_column_numbers () const DEAL_II_DEPRECATED;
BOOST_SERIALIZATION_SPLIT_MEMBER()
/** @addtogroup Exceptions
* be larger than #rows and in this case #rowstart has more elements than
* are used.
*/
- unsigned int max_dim;
+ size_type max_dim;
/**
* Number of rows that this sparsity structure shall represent.
*/
- unsigned int rows;
+ size_type rows;
/**
* Number of columns that this sparsity structure shall represent.
*/
- unsigned int cols;
+ size_type cols;
/**
* Size of the actually allocated array #colnums. Here, the same applies as
* for the #rowstart array, i.e. it may be larger than the actually used
* part of the array.
*/
- std::size_t max_vec_len;
+ size_type max_vec_len;
/**
* Maximum number of elements per row. This is set to the value given to the
* reinit versions are called. Its value is more or less meaningless after
* compress() has been called.
*/
- unsigned int max_row_length;
+ size_type max_row_length;
/**
* Array which hold for each row which is the first element in #colnums
* sorted, such that finding whether an element exists and determining its
* position can be done by a binary search.
*/
- unsigned int *colnums;
+ size_type *colnums;
/**
* Store whether the compress() function was called for this object.
inline
Accessor::
Accessor (const SparsityPattern *sparsity_pattern,
- const unsigned int r,
- const unsigned int i)
+ const size_type r,
+ const size_type i)
:
sparsity_pattern(sparsity_pattern),
index_within_sparsity(sparsity_pattern->rowstart[r]+i)
inline
- unsigned int
+ size_type
Accessor::row() const
{
Assert (is_valid_entry() == true, ExcInvalidIterator());
inline
- unsigned int
+ size_type
Accessor::column() const
{
Assert (is_valid_entry() == true, ExcInvalidIterator());
inline
- unsigned int
+ size_type
Accessor::index() const
{
Assert (is_valid_entry() == true, ExcInvalidIterator());
inline
Iterator::Iterator (const SparsityPattern *sparsity_pattern,
- const unsigned int r,
- const unsigned int i)
+ const size_type r,
+ const size_type i)
:
accessor(sparsity_pattern, sparsity_pattern->rowstart[r]+i)
{}
inline
SparsityPattern::iterator
-SparsityPattern::begin (const unsigned int r) const
+SparsityPattern::begin (const size_type r) const
{
Assert (r<n_rows(), ExcIndexRange(r,0,n_rows()));
inline
SparsityPattern::iterator
-SparsityPattern::end (const unsigned int r) const
+SparsityPattern::end (const size_type r) const
{
Assert (r<n_rows(), ExcIndexRange(r,0,n_rows()));
inline
SparsityPattern::row_iterator
-SparsityPattern::row_begin (const unsigned int r) const
+SparsityPattern::row_begin (const size_type r) const
{
Assert (r<n_rows(), ExcIndexRange(r,0,n_rows()));
return &colnums[rowstart[r]];
inline
SparsityPattern::row_iterator
-SparsityPattern::row_end (const unsigned int r) const
+SparsityPattern::row_end (const size_type r) const
{
Assert (r<n_rows(), ExcIndexRange(r,0,n_rows()));
return &colnums[rowstart[r+1]];
inline
-unsigned int
+SparsityPattern::size_type
SparsityPattern::n_rows () const
{
return rows;
inline
-unsigned int
+SparsityPattern::size_type
SparsityPattern::n_cols () const
{
return cols;
inline
-const unsigned int *
+const SparsityPattern::size_type *
SparsityPattern::get_column_numbers () const
{
return colnums;
inline
-unsigned int
-SparsityPattern::row_length (const unsigned int row) const
+SparsityPattern::size_type
+SparsityPattern::row_length (const size_type row) const
{
Assert(row<rows, ExcIndexRange(row,0,rows));
return rowstart[row+1]-rowstart[row];
inline
-unsigned int
-SparsityPattern::column_number (const unsigned int row,
- const unsigned int index) const
+SparsityPattern::size_type
+SparsityPattern::column_number (const size_type row,
+ const size_type index) const
{
Assert(row<rows, ExcIndexRange(row,0,rows));
Assert(index<row_length(row), ExcIndexRange(index,0,row_length(row)));
inline
-std::size_t
+SparsityPattern::size_type
SparsityPattern::n_nonzero_elements () const
{
Assert ((rowstart!=0) && (colnums!=0), ExcEmptyObject());
template <class Archive>
inline
void
-SparsityPattern::save (Archive &ar, const unsigned int) const
+SparsityPattern::save (Archive &ar, const size_type) const
{
// forward to serialization function in the base class.
ar &static_cast<const Subscriptor &>(*this);
template <class Archive>
inline
void
-SparsityPattern::load (Archive &ar, const unsigned int)
+SparsityPattern::load (Archive &ar, const size_type)
{
// forward to serialization function in the base class.
ar &static_cast<Subscriptor &>(*this);
ar &max_dim &rows &cols &max_vec_len &max_row_length &compressed &store_diagonal_first_in_row;
- rowstart = new std::size_t [max_dim + 1];
- colnums = new unsigned int [max_vec_len];
+ rowstart = new size_type [max_dim + 1];
+ colnums = new size_type [max_vec_len];
ar &boost::serialization::make_array(rowstart, max_dim + 1);
ar &boost::serialization::make_array(colnums, max_vec_len);
store_diagonal_first_in_row != sp2.store_diagonal_first_in_row)
return false;
- for (unsigned int i = 0; i < rows+1; ++i)
+ for (size_type i = 0; i < rows+1; ++i)
if (rowstart[i] != sp2.rowstart[i])
return false;
- for (unsigned int i = 0; i < rowstart[rows]; ++i)
+ for (size_type i = 0; i < rowstart[rows]; ++i)
if (colnums[i] != sp2.colnums[i])
return false;
namespace internal
{
namespace SparsityPatternTools
- {
+ {
+ /**
+ * Declare type for container size.
+ */
+ typedef types::global_dof_index size_type;
+
inline
- unsigned int
- get_column_index_from_iterator (const unsigned int i)
+ size_type
+ get_column_index_from_iterator (const size_type i)
{
return i;
}
template <typename value>
inline
- unsigned int
- get_column_index_from_iterator (const std::pair<unsigned int, value> &i)
+ size_type
+ get_column_index_from_iterator (const std::pair<size_type, value> &i)
{
return i.first;
}
template <typename value>
inline
- unsigned int
- get_column_index_from_iterator (const std::pair<const unsigned int, value> &i)
+ size_type
+ get_column_index_from_iterator (const std::pair<const size_type, value> &i)
{
return i.first;
}
template <typename ForwardIterator>
void
-SparsityPattern::copy_from (const unsigned int n_rows,
- const unsigned int n_cols,
+SparsityPattern::copy_from (const size_type n_rows,
+ const size_type n_cols,
const ForwardIterator begin,
const ForwardIterator end,
const bool)
template <typename ForwardIterator>
void
-SparsityPattern::copy_from (const unsigned int n_rows,
- const unsigned int n_cols,
+SparsityPattern::copy_from (const size_type n_rows,
+ const size_type n_cols,
const ForwardIterator begin,
const ForwardIterator end)
{
- Assert (static_cast<unsigned int>(std::distance (begin, end)) == n_rows,
+ Assert (static_cast<size_type>(std::distance (begin, end)) == n_rows,
ExcIteratorRange (std::distance (begin, end), n_rows));
// first determine row lengths for each row. if the matrix is quadratic,
// is not yet present. as we have to call compress anyway later on, don't
// bother to check whether that diagonal entry is in a certain row or not
const bool is_square = (n_rows == n_cols);
- std::vector<unsigned int> row_lengths;
+ std::vector<size_type> row_lengths;
row_lengths.reserve(n_rows);
for (ForwardIterator i=begin; i!=end; ++i)
row_lengths.push_back (std::distance (i->begin(), i->end())
//
// for use in the inner loop, we define a typedef to the type of the inner
// iterators
- unsigned int row = 0;
+ size_type row = 0;
typedef typename std::iterator_traits<ForwardIterator>::value_type::const_iterator inner_iterator;
for (ForwardIterator i=begin; i!=end; ++i, ++row)
{
- unsigned int *cols = &colnums[rowstart[row]] + (is_square ? 1 : 0);
+ size_type *cols = &colnums[rowstart[row]] + (is_square ? 1 : 0);
const inner_iterator end_of_row = i->end();
for (inner_iterator j=i->begin(); j!=end_of_row; ++j)
{
- const unsigned int col
+ const size_type col
= internal::SparsityPatternTools::get_column_index_from_iterator(*j);
Assert (col < n_cols, ExcIndexRange(col,0,n_cols));
*/
namespace SparsityTools
{
+ /**
+ * Declare type for container size.
+ */
+ typedef types::global_dof_index size_type;
+
/**
* Use the METIS partitioner to generate
* a partitioning of the degrees of
*/
void
reorder_Cuthill_McKee (const SparsityPattern &sparsity,
- std::vector<unsigned int> &new_indices,
- const std::vector<unsigned int> &starting_indices = std::vector<unsigned int>());
+ std::vector<size_type> &new_indices,
+ const std::vector<size_type> &starting_indices = std::vector<size_type>());
#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
*/
template <class CSP_t>
void distribute_sparsity_pattern(CSP_t &csp,
- const std::vector<unsigned int> &rows_per_cpu,
+ const std::vector<size_type> &rows_per_cpu,
const MPI_Comm &mpi_comm,
const IndexSet &myrange);
#endif
void
GridGenerator::moebius (
Triangulation<3> &tria,
- const unsigned int n_cells,
+ const size_type n_cells,
const unsigned int n_rotations,
const double R,
const double r)
double beta_step=n_rotations*numbers::PI/2.0/n_cells;
double alpha_step=2.0*numbers::PI/n_cells;
- for (unsigned int i=0; i<n_cells; ++i)
+ for (size_type i=0; i<n_cells; ++i)
for (unsigned int j=0; j<4; ++j)
{
vertices[4*i+j][0]=R*std::cos(i*alpha_step)+r*std::cos(i*beta_step+j*numbers::PI/2.0)*std::cos(i*alpha_step);
vertices[4*i+j][2]=r*std::sin(i*beta_step+j*numbers::PI/2.0);
}
- unsigned int offset=0;
+ size_type offset=0;
std::vector<CellData<dim> > cells (n_cells);
- for (unsigned int i=0; i<n_cells; ++i)
+ for (size_type i=0; i<n_cells; ++i)
{
for (unsigned int j=0; j<2; ++j)
{
template<int dim>
void
GridGenerator::subdivided_parallelepiped (Triangulation<dim> &tria,
- const unsigned int n_subdivisions,
+ const size_type n_subdivisions,
const Point<dim> (&corners) [dim],
const bool colorize)
{
// Equalise number of subdivisions in each dim-direction, heir
// validity will be checked later
- unsigned int (n_subdivisions_) [dim];
+ size_type (n_subdivisions_) [dim];
for (unsigned int i=0; i<dim; ++i)
n_subdivisions_[i] = n_subdivisions;
template<int dim>
void
GridGenerator::subdivided_parallelepiped (Triangulation<dim> &tria,
- const unsigned int ( n_subdivisions) [dim],
+ const size_type ( n_subdivisions) [dim],
const Point<dim> (&corners) [dim],
const bool colorize)
{
switch (dim)
{
case 1:
- for (unsigned int x=0; x<=n_subdivisions[0]; ++x)
+ for (size_type x=0; x<=n_subdivisions[0]; ++x)
points.push_back (Point<dim> (x*delta[0]));
break;
case 2:
- for (unsigned int y=0; y<=n_subdivisions[1]; ++y)
- for (unsigned int x=0; x<=n_subdivisions[0]; ++x)
+ for (size_type y=0; y<=n_subdivisions[1]; ++y)
+ for (size_type x=0; x<=n_subdivisions[0]; ++x)
points.push_back (Point<dim> (x*delta[0] + y*delta[1]));
break;
case 3:
- for (unsigned int z=0; z<=n_subdivisions[2]; ++z)
- for (unsigned int y=0; y<=n_subdivisions[1]; ++y)
- for (unsigned int x=0; x<=n_subdivisions[0]; ++x)
+ for (size_type z=0; z<=n_subdivisions[2]; ++z)
+ for (size_type y=0; y<=n_subdivisions[1]; ++y)
+ for (size_type x=0; x<=n_subdivisions[0]; ++x)
points.push_back (Point<dim> (x*delta[0] + y*delta[1] + z*delta[2]));
break;
}
// Prepare cell data
- unsigned int n_cells = 1;
+ size_type n_cells = 1;
for (unsigned int i=0; i<dim; ++i)
n_cells *= n_subdivisions[i];
std::vector<CellData<dim> > cells (n_cells);
switch (dim)
{
case 1:
- for (unsigned int x=0; x<n_subdivisions[0]; ++x)
+ for (size_type x=0; x<n_subdivisions[0]; ++x)
{
cells[x].vertices[0] = x;
cells[x].vertices[1] = x+1;
case 2:
{
// Shorthand
- const unsigned int n_dy = n_subdivisions[1];
- const unsigned int n_dx = n_subdivisions[0];
+ const size_type n_dy = n_subdivisions[1];
+ const size_type n_dx = n_subdivisions[0];
- for (unsigned int y=0; y<n_dy; ++y)
- for (unsigned int x=0; x<n_dx; ++x)
+ for (size_type y=0; y<n_dy; ++y)
+ for (size_type x=0; x<n_dx; ++x)
{
- const unsigned int c = y*n_dx + x;
+ const size_type c = y*n_dx + x;
cells[c].vertices[0] = y*(n_dx+1) + x;
cells[c].vertices[1] = y*(n_dx+1) + x+1;
cells[c].vertices[2] = (y+1)*(n_dx+1) + x;
case 3:
{
// Shorthand
- const unsigned int n_dz = n_subdivisions[2];
- const unsigned int n_dy = n_subdivisions[1];
- const unsigned int n_dx = n_subdivisions[0];
+ const size_type n_dz = n_subdivisions[2];
+ const size_type n_dy = n_subdivisions[1];
+ const size_type n_dx = n_subdivisions[0];
- for (unsigned int z=0; z<n_dz; ++z)
- for (unsigned int y=0; y<n_dy; ++y)
- for (unsigned int x=0; x<n_dx; ++x)
+ for (size_type z=0; z<n_dz; ++z)
+ for (size_type y=0; y<n_dy; ++y)
+ for (size_type x=0; x<n_dx; ++x)
{
- const unsigned int c = z*n_dy*n_dx + y*n_dx + x;
+ const size_type c = z*n_dy*n_dx + y*n_dx + x;
cells[c].vertices[0] = z*(n_dy+1)*(n_dx+1) + y*(n_dx+1) + x;
cells[c].vertices[1] = z*(n_dy+1)*(n_dx+1) + y*(n_dx+1) + x+1;
}
double x = 0;
- for (unsigned int j=0; j<step_sizes.at(i).size(); j++)
+ for (size_type j=0; j<step_sizes.at(i).size(); j++)
x += step_sizes[i][j];
Assert(std::fabs(x - (p2(i)-p1(i))) <= 1e-12*std::fabs(x),
ExcInvalidRepetitions (i) );
case 1:
{
double x=0;
- for (unsigned int i=0; ; ++i)
+ for (size_type i=0; ; ++i)
{
points.push_back (Point<dim> (p1[0]+x));
case 2:
{
double y=0;
- for (unsigned int j=0; ; ++j)
+ for (size_type j=0; ; ++j)
{
double x=0;
- for (unsigned int i=0; ; ++i)
+ for (size_type i=0; ; ++i)
{
points.push_back (Point<dim> (p1[0]+x,
p1[1]+y));
case 3:
{
double z=0;
- for (unsigned int k=0; ; ++k)
+ for (size_type k=0; ; ++k)
{
double y=0;
- for (unsigned int j=0; ; ++j)
+ for (size_type j=0; ; ++j)
{
double x=0;
- for (unsigned int i=0; ; ++i)
+ for (size_type i=0; ; ++i)
{
points.push_back (Point<dim> (p1[0]+x,
p1[1]+y,
case 1:
{
cells.resize (step_sizes[0].size());
- for (unsigned int x=0; x<step_sizes[0].size(); ++x)
+ for (size_type x=0; x<step_sizes[0].size(); ++x)
{
cells[x].vertices[0] = x;
cells[x].vertices[1] = x+1;
case 2:
{
cells.resize (step_sizes[1].size()*step_sizes[0].size());
- for (unsigned int y=0; y<step_sizes[1].size(); ++y)
- for (unsigned int x=0; x<step_sizes[0].size(); ++x)
+ for (size_type y=0; y<step_sizes[1].size(); ++y)
+ for (size_type x=0; x<step_sizes[0].size(); ++x)
{
- const unsigned int c = x+y*step_sizes[0].size();
+ const size_type c = x+y*step_sizes[0].size();
cells[c].vertices[0] = y*(step_sizes[0].size()+1)+x;
cells[c].vertices[1] = y*(step_sizes[0].size()+1)+x+1;
cells[c].vertices[2] = (y+1)*(step_sizes[0].size()+1)+x;
case 3:
{
- const unsigned int n_x = (step_sizes[0].size()+1);
- const unsigned int n_xy = (step_sizes[0].size()+1)*(step_sizes[1].size()+1);
+ const size_type n_x = (step_sizes[0].size()+1);
+ const size_type n_xy = (step_sizes[0].size()+1)*(step_sizes[1].size()+1);
cells.resize (step_sizes[2].size()*step_sizes[1].size()*step_sizes[0].size());
- for (unsigned int z=0; z<step_sizes[2].size(); ++z)
- for (unsigned int y=0; y<step_sizes[1].size(); ++y)
- for (unsigned int x=0; x<step_sizes[0].size(); ++x)
+ for (size_type z=0; z<step_sizes[2].size(); ++z)
+ for (size_type y=0; y<step_sizes[1].size(); ++y)
+ for (size_type x=0; x<step_sizes[0].size(); ++x)
{
- const unsigned int c = x+y*step_sizes[0].size() +
+ const size_type c = x+y*step_sizes[0].size() +
z*step_sizes[0].size()*step_sizes[1].size();
cells[c].vertices[0] = z*n_xy + y*n_x + x;
cells[c].vertices[1] = z*n_xy + y*n_x + x+1;
Assert(spacing.size() == 1,
ExcInvalidRepetitionsDimension(1));
- const unsigned int n_cells = material_id.size(0);
+ const size_type n_cells = material_id.size(0);
Assert(spacing[0].size() == n_cells,
ExcInvalidRepetitionsDimension(1));
double delta = std::numeric_limits<double>::max();
- for (unsigned int i=0; i<n_cells; i++)
+ for (size_type i=0; i<n_cells; i++)
{
Assert (spacing[0][i] >= 0, ExcInvalidRepetitions(-1));
delta = std::min (delta, spacing[0][i]);
// generate the necessary points
std::vector<Point<1> > points;
double ax = p[0];
- for (unsigned int x=0; x<=n_cells; ++x)
+ for (size_type x=0; x<=n_cells; ++x)
{
points.push_back (Point<1> (ax));
if (x<n_cells)
ax += spacing[0][x];
}
// create the cells
- unsigned int n_val_cells = 0;
- for (unsigned int i=0; i<n_cells; i++)
+ size_type n_val_cells = 0;
+ for (size_type i=0; i<n_cells; i++)
if (material_id[i]!=numbers::invalid_material_id) n_val_cells++;
std::vector<CellData<1> > cells(n_val_cells);
- unsigned int id = 0;
- for (unsigned int x=0; x<n_cells; ++x)
+ size_type id = 0;
+ for (size_type x=0; x<n_cells; ++x)
if (material_id[x] != numbers::invalid_material_id)
{
cells[id].vertices[0] = x;
Assert(spacing.size() == 2,
ExcInvalidRepetitionsDimension(2));
- std::vector<unsigned int> repetitions(2);
- unsigned int n_cells = 1;
+ std::vector<size_type> repetitions(2);
+ size_type n_cells = 1;
double delta = std::numeric_limits<double>::max();
for (unsigned int i=0; i<2; i++)
{
repetitions[i] = spacing[i].size();
n_cells *= repetitions[i];
- for (unsigned int j=0; j<repetitions[i]; j++)
+ for (size_type j=0; j<repetitions[i]; j++)
{
Assert (spacing[i][j] >= 0, ExcInvalidRepetitions(-1));
delta = std::min (delta, spacing[i][j]);
// generate the necessary points
std::vector<Point<2> > points;
double ay = p[1];
- for (unsigned int y=0; y<=repetitions[1]; ++y)
+ for (size_type y=0; y<=repetitions[1]; ++y)
{
double ax = p[0];
- for (unsigned int x=0; x<=repetitions[0]; ++x)
+ for (size_type x=0; x<=repetitions[0]; ++x)
{
points.push_back (Point<2> (ax,ay));
if (x<repetitions[0])
}
// create the cells
- unsigned int n_val_cells = 0;
- for (unsigned int i=0; i<material_id.size(0); i++)
- for (unsigned int j=0; j<material_id.size(1); j++)
+ size_type n_val_cells = 0;
+ for (size_type i=0; i<material_id.size(0); i++)
+ for (size_type j=0; j<material_id.size(1); j++)
if (material_id[i][j] != numbers::invalid_material_id)
n_val_cells++;
std::vector<CellData<2> > cells(n_val_cells);
- unsigned int id = 0;
- for (unsigned int y=0; y<repetitions[1]; ++y)
- for (unsigned int x=0; x<repetitions[0]; ++x)
+ size_type id = 0;
+ for (size_type y=0; y<repetitions[1]; ++y)
+ for (size_type x=0; x<repetitions[0]; ++x)
if (material_id[x][y]!=numbers::invalid_material_id)
{
cells[id].vertices[0] = y*(repetitions[0]+1)+x;
Assert(spacing.size() == dim,
ExcInvalidRepetitionsDimension(dim));
- std::vector<unsigned int> repetitions(dim);
- unsigned int n_cells = 1;
+ std::vector<size_type > repetitions(dim);
+ size_type n_cells = 1;
double delta = std::numeric_limits<double>::max();
for (unsigned int i=0; i<dim; i++)
{
repetitions[i] = spacing[i].size();
n_cells *= repetitions[i];
- for (unsigned int j=0; j<repetitions[i]; j++)
+ for (size_type j=0; j<repetitions[i]; j++)
{
Assert (spacing[i][j] >= 0, ExcInvalidRepetitions(-1));
delta = std::min (delta, spacing[i][j]);
// generate the necessary points
std::vector<Point<dim> > points;
double az = p[2];
- for (unsigned int z=0; z<=repetitions[2]; ++z)
+ for (size_type z=0; z<=repetitions[2]; ++z)
{
double ay = p[1];
- for (unsigned int y=0; y<=repetitions[1]; ++y)
+ for (size_type y=0; y<=repetitions[1]; ++y)
{
double ax = p[0];
- for (unsigned int x=0; x<=repetitions[0]; ++x)
+ for (size_type x=0; x<=repetitions[0]; ++x)
{
points.push_back (Point<dim> (ax,ay,az));
if (x<repetitions[0])
}
// create the cells
- unsigned int n_val_cells = 0;
- for (unsigned int i=0; i<material_id.size(0); i++)
- for (unsigned int j=0; j<material_id.size(1); j++)
- for (unsigned int k=0; k<material_id.size(2); k++)
+ size_type n_val_cells = 0;
+ for (size_type i=0; i<material_id.size(0); i++)
+ for (size_type j=0; j<material_id.size(1); j++)
+ for (size_type k=0; k<material_id.size(2); k++)
if (material_id[i][j][k]!=numbers::invalid_material_id)
n_val_cells++;
std::vector<CellData<dim> > cells(n_val_cells);
- unsigned int id = 0;
- const unsigned int n_x = (repetitions[0]+1);
- const unsigned int n_xy = (repetitions[0]+1)*(repetitions[1]+1);
- for (unsigned int z=0; z<repetitions[2]; ++z)
- for (unsigned int y=0; y<repetitions[1]; ++y)
- for (unsigned int x=0; x<repetitions[0]; ++x)
+ size_type id = 0;
+ const size_type n_x = (repetitions[0]+1);
+ const size_type n_xy = (repetitions[0]+1)*(repetitions[1]+1);
+ for (size_type z=0; z<repetitions[2]; ++z)
+ for (size_type y=0; y<repetitions[1]; ++y)
+ for (size_type x=0; x<repetitions[0]; ++x)
if (material_id[x][y][z]!=numbers::invalid_material_id)
{
cells[id].vertices[0] = z*n_xy + y*n_x + x;
const Point<1> &,
const double,
const double,
- const unsigned int,
+ const size_type ,
const bool)
{
Assert (false, ExcNotImplemented());
const double,
const double,
const double,
- const unsigned int,
- const unsigned int)
+ const size_type ,
+ const size_type )
{
Assert (false, ExcNotImplemented());
}
const Point<1> &,
const double,
const double,
- const unsigned int,
+ const size_type ,
const bool)
{
Assert (false, ExcNotImplemented());
const Point<1> &,
const double,
const double,
- const unsigned int,
+ const size_type ,
const bool)
{
Assert (false, ExcNotImplemented());
template <>
-void GridGenerator::hyper_shell (Triangulation<2> &tria,
- const Point<2> ¢er,
- const double inner_radius,
- const double outer_radius,
- const unsigned int n_cells,
+void GridGenerator::hyper_shell (Triangulation<2> &tria,
+ const Point<2> ¢er,
+ const double inner_radius,
+ const double outer_radius,
+ const size_type n_cells,
const bool colorize)
{
Assert ((inner_radius > 0) && (inner_radius < outer_radius),
// radial extent (which is the
// difference between the two
// radii)
- const unsigned int N = (n_cells == 0 ?
- static_cast<unsigned int>
- (std::ceil((2*pi* (outer_radius + inner_radius)/2) /
- (outer_radius - inner_radius))) :
- n_cells);
+ const size_type N = (n_cells == 0 ?
+ static_cast<size_type>
+ (std::ceil((2*pi* (outer_radius + inner_radius)/2) /
+ (outer_radius - inner_radius))) :
+ n_cells);
// set up N vertices on the
// outer and N vertices on
// outer one, and all are
// numbered counter-clockwise
std::vector<Point<2> > vertices(2*N);
- for (unsigned int i=0; i<N; ++i)
+ for (size_type i=0; i<N; ++i)
{
vertices[i] = Point<2>( std::cos(2*pi * i/N),
std::sin(2*pi * i/N)) * outer_radius;
std::vector<CellData<2> > cells (N, CellData<2>());
- for (unsigned int i=0; i<N; ++i)
+ for (size_type i=0; i<N; ++i)
{
cells[i].vertices[0] = i;
cells[i].vertices[1] = (i+1)%N;
const double,
const double,
const double,
- const unsigned int,
- const unsigned int)
+ const size_type,
+ const size_type)
{
Assert (false, ExcNotImplemented());
}
// Implementation for 2D only
template <>
void
-GridGenerator::half_hyper_shell (Triangulation<2> &tria,
- const Point<2> ¢er,
- const double inner_radius,
- const double outer_radius,
- const unsigned int n_cells,
+GridGenerator::half_hyper_shell (Triangulation<2> &tria,
+ const Point<2> ¢er,
+ const double inner_radius,
+ const double outer_radius,
+ const size_type n_cells,
const bool colorize)
{
Assert ((inner_radius > 0) && (inner_radius < outer_radius),
// radial extent (which is the
// difference between the two
// radii)
- const unsigned int N = (n_cells == 0 ?
- static_cast<unsigned int>
- (std::ceil((pi* (outer_radius + inner_radius)/2) /
- (outer_radius - inner_radius))) :
- n_cells);
+ const size_type N = (n_cells == 0 ?
+ static_cast<size_type>
+ (std::ceil((pi* (outer_radius + inner_radius)/2) /
+ (outer_radius - inner_radius))) :
+ n_cells);
// set up N+1 vertices on the
// outer and N+1 vertices on
// outer one, and all are
// numbered counter-clockwise
std::vector<Point<2> > vertices(2*(N+1));
- for (unsigned int i=0; i<=N; ++i)
+ for (size_type i=0; i<=N; ++i)
{
// enforce that the x-coordinates
// of the first and last point of
std::vector<CellData<2> > cells (N, CellData<2>());
- for (unsigned int i=0; i<N; ++i)
+ for (size_type i=0; i<N; ++i)
{
cells[i].vertices[0] = i;
cells[i].vertices[1] = (i+1)%(N+1);
template <>
-void GridGenerator::quarter_hyper_shell (Triangulation<2> &tria,
- const Point<2> ¢er,
- const double inner_radius,
- const double outer_radius,
- const unsigned int n_cells,
+void GridGenerator::quarter_hyper_shell (Triangulation<2> &tria,
+ const Point<2> ¢er,
+ const double inner_radius,
+ const double outer_radius,
+ const size_type n_cells,
const bool colorize)
{
Assert ((inner_radius > 0) && (inner_radius < outer_radius),
// radial extent (which is the
// difference between the two
// radii)
- const unsigned int N = (n_cells == 0 ?
- static_cast<unsigned int>
- (std::ceil((pi* (outer_radius + inner_radius)/4) /
- (outer_radius - inner_radius))) :
- n_cells);
+ const size_type N = (n_cells == 0 ?
+ static_cast<size_type>
+ (std::ceil((pi* (outer_radius + inner_radius)/4) /
+ (outer_radius - inner_radius))) :
+ n_cells);
// set up N+1 vertices on the
// outer and N+1 vertices on
// outer one, and all are
// numbered counter-clockwise
std::vector<Point<2> > vertices(2*(N+1));
- for (unsigned int i=0; i<=N; ++i)
+ for (size_type i=0; i<=N; ++i)
{
// enforce that the x-coordinates
// of the last point is exactly
std::vector<CellData<2> > cells (N, CellData<2>());
- for (unsigned int i=0; i<N; ++i)
+ for (size_type i=0; i<N; ++i)
{
cells[i].vertices[0] = i;
cells[i].vertices[1] = (i+1)%(N+1);
const double half_length)
{
// Determine number of cells and vertices
- const unsigned int
- n_cells = static_cast<unsigned int>(std::floor (half_length /
+ const size_type
+ n_cells = static_cast<size_type>(std::floor (half_length /
std::max (radius_0,
radius_1) +
0.5));
- const unsigned int n_vertices = 4 * (n_cells + 1);
+ const size_type n_vertices = 4 * (n_cells + 1);
std::vector<Point<3> > vertices_tmp(n_vertices);
vertices_tmp[0] = Point<3> (-half_length, 0, -radius_0);
const double dx = 2 * half_length / n_cells;
- for (unsigned int i = 0; i < n_cells; ++i)
+ for (size_type i = 0; i < n_cells; ++i)
{
vertices_tmp[4 * (i + 1)]
= vertices_tmp[4 * i] +
vertices_tmp.end());
Table<2,unsigned int> cell_vertices(n_cells,GeometryInfo<3>::vertices_per_cell);
- for (unsigned int i = 0; i < n_cells; ++i)
+ for (size_type i = 0; i < n_cells; ++i)
for (unsigned int j = 0; j < GeometryInfo<3>::vertices_per_cell; ++j)
cell_vertices[i][j] = 4 * i + j;
std::vector<CellData<3> > cells (n_cells, CellData<3> ());
- for (unsigned int i = 0; i < n_cells; ++i)
+ for (size_type i = 0; i < n_cells; ++i)
{
for (unsigned int j = 0; j < GeometryInfo<3>::vertices_per_cell; ++j)
cells[i].vertices[j] = cell_vertices[i][j];
// Implementation for 3D only
template <>
-void GridGenerator::cylinder_shell (Triangulation<3> &tria,
- const double length,
- const double inner_radius,
- const double outer_radius,
- const unsigned int n_radial_cells,
- const unsigned int n_axial_cells)
+void GridGenerator::cylinder_shell (Triangulation<3> &tria,
+ const double length,
+ const double inner_radius,
+ const double outer_radius,
+ const size_type n_radial_cells,
+ const size_type n_axial_cells)
{
Assert ((inner_radius > 0) && (inner_radius < outer_radius),
ExcInvalidRadii ());
// radial extent (which is the
// difference between the two
// radii)
- const unsigned int N_r = (n_radial_cells == 0 ?
- static_cast<unsigned int>
- (std::ceil((2*pi* (outer_radius + inner_radius)/2) /
- (outer_radius - inner_radius))) :
- n_radial_cells);
- const unsigned int N_z = (n_axial_cells == 0 ?
- static_cast<unsigned int>
- (std::ceil (length /
- (2*pi*(outer_radius + inner_radius)/2/N_r))) :
- n_axial_cells);
+ const size_type N_r = (n_radial_cells == 0 ?
+ static_cast<size_type>
+ (std::ceil((2*pi* (outer_radius + inner_radius)/2) /
+ (outer_radius - inner_radius))) :
+ n_radial_cells);
+ const size_type N_z = (n_axial_cells == 0 ?
+ static_cast<size_type>
+ (std::ceil (length /
+ (2*pi*(outer_radius + inner_radius)/2/N_r))) :
+ n_axial_cells);
// set up N vertices on the
// outer and N vertices on
// outer one, and all are
// numbered counter-clockwise
std::vector<Point<2> > vertices_2d(2*N_r);
- for (unsigned int i=0; i<N_r; ++i)
+ for (size_type i=0; i<N_r; ++i)
{
vertices_2d[i] = Point<2>( std::cos(2*pi * i/N_r),
std::sin(2*pi * i/N_r)) * outer_radius;
std::vector<Point<3> > vertices_3d;
vertices_3d.reserve (2*N_r*(N_z+1));
- for (unsigned int j=0; j<=N_z; ++j)
- for (unsigned int i=0; i<2*N_r; ++i)
+ for (size_type j=0; j<=N_z; ++j)
+ for (size_type i=0; i<2*N_r; ++i)
{
const Point<3> v (vertices_2d[i][0],
vertices_2d[i][1],
std::vector<CellData<3> > cells (N_r*N_z, CellData<3>());
- for (unsigned int j=0; j<N_z; ++j)
- for (unsigned int i=0; i<N_r; ++i)
+ for (size_type j=0; j<N_z; ++j)
+ for (size_type i=0; i<N_r; ++i)
{
cells[i+j*N_r].vertices[0] = i + (j+1)*2*N_r;
cells[i+j*N_r].vertices[1] = (i+1)%N_r + (j+1)*2*N_r;
// throw out duplicated vertices from the two meshes
// and create the triangulation
SubCellData subcell_data;
- std::vector<unsigned int> considered_vertices;
+ std::vector<size_type> considered_vertices;
GridTools::delete_duplicated_vertices (vertices, cells, subcell_data, considered_vertices);
result.clear ();
result.create_triangulation (vertices, cells, subcell_data);
void
GridGenerator::
extrude_triangulation(const Triangulation<2, 2> & input,
- const unsigned int n_slices,
+ const size_type n_slices,
const double height,
Triangulation<3,3> &result)
{
std::vector<CellData<3> > cells;
cells.reserve((n_slices-1)*input.n_active_cells());
- for (unsigned int slice=0;slice<n_slices;++slice)
+ for (size_type slice=0;slice<n_slices;++slice)
{
- for (unsigned int i=0;i<input.n_vertices();++i)
+ for (size_type i=0;i<input.n_vertices();++i)
{
const Point<2> & v = input.get_vertices()[i];
for (Triangulation<2,2>::cell_iterator
cell = input.begin(); cell != input.end(); ++cell)
{
- for (unsigned int slice=0;slice<n_slices-1;++slice)
+ for (size_type slice=0;slice<n_slices-1;++slice)
{
CellData<3> this_cell;
for (unsigned int v=0; v<GeometryInfo<2>::vertices_per_cell; ++v)
{
quad.boundary_id = cell->face(f)->boundary_indicator();
bid = std::max(bid, quad.boundary_id);
- for (unsigned int slice=0;slice<n_slices-1;++slice)
+ for (size_type slice=0;slice<n_slices-1;++slice)
{
quad.vertices[0] = cell->face(f)->vertex_index(0)+slice*input.n_vertices();
quad.vertices[1] = cell->face(f)->vertex_index(1)+slice*input.n_vertices();
// this is not necessary here as this is an internal only function.
inline
void GridGenerator::laplace_solve (const SparseMatrix<double> &S,
- const std::map<unsigned int,double> &m,
+ const std::map<size_type,double> &m,
Vector<double> &u)
{
- const unsigned int n_dofs=S.n();
+ const size_type n_dofs=S.n();
FilteredMatrix<Vector<double> > SF (S);
PreconditionJacobi<SparseMatrix<double> > prec;
prec.initialize(S, 1.2);
// Implementation for 1D only
template <>
void GridGenerator::laplace_transformation (Triangulation<1> &,
- const std::map<unsigned int,Point<1> > &)
+ const std::map<size_type,Point<1> > &)
{
Assert(false, ExcNotImplemented());
}
// Implementation for dimensions except 1
template <int dim>
void GridGenerator::laplace_transformation (Triangulation<dim> &tria,
- const std::map<unsigned int,Point<dim> > &new_points)
+ const std::map<size_type,Point<dim> > &new_points)
{
// first provide everything that is
// needed for solving a Laplace
// set up the boundary values for
// the laplace problem
- std::vector<std::map<unsigned int,double> > m(dim);
- typename std::map<unsigned int,Point<dim> >::const_iterator map_iter;
- typename std::map<unsigned int,Point<dim> >::const_iterator map_end=new_points.end();
+ std::vector<std::map<size_type,double> > m(dim);
+ typename std::map<size_type,Point<dim> >::const_iterator map_iter;
+ typename std::map<size_type,Point<dim> >::const_iterator map_end=new_points.end();
// fill these maps using the data
// given by new_points
for (unsigned int vertex_no=0;
vertex_no<GeometryInfo<dim>::vertices_per_face; ++vertex_no)
{
- const unsigned int vertex_index=face->vertex_index(vertex_no);
+ const size_type vertex_index=face->vertex_index(vertex_no);
map_iter=new_points.find(vertex_index);
if (map_iter!=map_end)
for (unsigned int i=0; i<dim; ++i)
- m[i].insert(std::pair<unsigned int,double> (
+ m[i].insert(std::pair<size_type,double> (
face->vertex_dof_index(vertex_no, 0), map_iter->second(i)));
}
}
// points of the triangulation
// according to the computed values
for (cell=dof_handler.begin_active(); cell!=endc; ++cell)
- for (unsigned int vertex_no=0;
+ for (size_type vertex_no=0;
vertex_no<GeometryInfo<dim>::vertices_per_cell; ++vertex_no)
{
Point<dim> &v=cell->vertex(vertex_no);
- const unsigned int dof_index=cell->vertex_dof_index(vertex_no, 0);
+ const size_type dof_index=cell->vertex_dof_index(vertex_no, 0);
for (unsigned int i=0; i<dim; ++i)
v(i)=us[i](dof_index);
}
const double,
const double,
const double,
- const unsigned int,
+ const size_type,
bool)
{
Assert(false, ExcNotImplemented());
const double inner_radius,
const double outer_radius,
const double, // width,
- const unsigned int, // width_repetition,
+ const size_type, // width_repetition,
bool colorize)
{
const int dim = 2;
{
for (unsigned int v=0; v < GeometryInfo<dim>::vertices_per_face; ++v)
{
- unsigned int vv = cell->face(f)->vertex_index(v);
+ size_type vv = cell->face(f)->vertex_index(v);
if (treated_vertices[vv] == false)
{
treated_vertices[vv] = true;
const double inner_radius,
const double outer_radius,
const double L,
- const unsigned int Nz,
+ const size_type Nz,
bool colorize)
{
const int dim = 3;
{
for (unsigned int v=0; v < GeometryInfo<dim>::vertices_per_face; ++v)
{
- unsigned int vv = cell->face(f)->vertex_index(v);
+ size_type vv = cell->face(f)->vertex_index(v);
if (treated_vertices[vv] == false)
{
treated_vertices[vv] = true;
- for (unsigned int i=0; i<=Nz; ++i)
+ for (size_type i=0; i<=Nz; ++i)
{
double d = ((double) i)*L/((double) Nz);
switch (vv-i*16)
}
void
- SolverBase::solve (const unsigned int n_eigenvectors, unsigned int *n_converged)
+ SolverBase::solve (const size_type n_eigenvectors, size_type *n_converged)
{
int ierr;
}
void
- SolverBase::get_eigenpair (const unsigned int index,
+ SolverBase::get_eigenpair (const size_type index,
#ifndef PETSC_USE_COMPLEX
double &kr,
#else
{
namespace MA27
{
+ typedef types::global_dof_index size_type;
+
extern "C"
- void ma27ad_ (const unsigned int *,
- const unsigned int *,
- const unsigned int *,
- const unsigned int *,
- unsigned int *,
- const unsigned int *,
- unsigned int *,
- unsigned int *,
- unsigned int *,
+ void ma27ad_ (const size_type *,
+ const size_type *,
+ const size_type *,
+ const size_type *,
+ size_type *,
+ const size_type *,
+ size_type *,
+ size_type *,
+ size_type *,
int *)
{
AssertThrow (false,
extern "C"
- void ma27bd_ (const unsigned int *,
- const unsigned int *,
- const unsigned int *,
- const unsigned int *,
+ void ma27bd_ (const size_type *,
+ const size_type *,
+ const size_type *,
+ const size_type *,
double *,
- const unsigned int *,
- unsigned int *,
- const unsigned int *,
- const unsigned int *,
- const unsigned int *,
- unsigned int *,
- unsigned int *,
+ const size_type *,
+ size_type *,
+ const size_type *,
+ const size_type *,
+ const size_type *,
+ size_type *,
+ size_type *,
int *)
{
AssertThrow (false,
extern "C"
- void ma27cd_ (const unsigned int *,
+ void ma27cd_ (const size_type *,
const double *,
- const unsigned int *,
- const unsigned int *,
- const unsigned int *,
+ const size_type *,
+ const size_type *,
+ const size_type *,
double *,
- const unsigned int *,
+ const size_type *,
double *,
- const unsigned int *,
- const unsigned int *)
+ const size_type *,
+ const size_type *)
{
AssertThrow (false,
ExcMessage("You can only use the HSL functions after putting "
}
- extern "C" void ma27x1_ (unsigned int *)
+ extern "C" void ma27x1_ (size_type *)
{
AssertThrow (false,
ExcMessage("You can only use the HSL functions after putting "
}
- extern "C" void ma27x2_ (unsigned int *)
+ extern "C" void ma27x2_ (size_type *)
{
AssertThrow (false,
ExcMessage("You can only use the HSL functions after putting "
}
- extern "C" void ma27x3_ (const unsigned int *)
+ extern "C" void ma27x3_ (const size_type *)
{
AssertThrow (false,
ExcMessage("You can only use the HSL functions after putting "
{
namespace MA47
{
+ typedef types::global_dof_index size_type;
+
extern "C"
void ma47id_ (double *,
- unsigned int *)
+ size_type *)
{
AssertThrow (false,
ExcMessage("You can only use the HSL functions after putting "
extern "C"
- void ma47ad_ (const unsigned int *,
- const unsigned int *,
- unsigned int *,
- unsigned int *,
- unsigned int *,
- const unsigned int *,
- unsigned int *,
- const unsigned int *,
+ void ma47ad_ (const size_type *,
+ const size_type *,
+ size_type *,
+ size_type *,
+ size_type *,
+ const size_type *,
+ size_type *,
+ const size_type *,
double *,
int *)
{
extern "C"
- void ma47bd_ (const unsigned int *,
- const unsigned int *,
- const unsigned int *,
+ void ma47bd_ (const size_type *,
+ const size_type *,
+ const size_type *,
double *,
- const unsigned int *,
- unsigned int *,
- const unsigned int *,
- const unsigned int *,
+ const size_type *,
+ size_type *,
+ const size_type *,
+ const size_type *,
const double *,
- const unsigned int *,
- unsigned int *,
+ const size_type *,
+ size_type *,
double *,
int *)
{
extern "C"
- void ma47cd_ (const unsigned int *,
+ void ma47cd_ (const size_type *,
const double *,
- const unsigned int *,
- const unsigned int *,
- const unsigned int *,
+ const size_type *,
+ const size_type *,
+ const size_type *,
double *,
double *,
- unsigned int *,
- const unsigned int *)
+ size_type *,
+ const size_type *)
{
AssertThrow (false,
ExcMessage("You can only use the HSL functions after putting "
const std::size_t N,
const char * /*debug_info*/) const
{
- unsigned int count = 0;
+ size_type count = 0;
while (count < sizeof(T)*N)
{
// repeat writing until
const std::size_t N,
const char * /*debug_info*/) const
{
- unsigned int count = 0;
+ size_type count = 0;
while (count < sizeof(T)*N)
{
int ret = -1;
// requested
if (suppress_output)
{
- const unsigned int LP = 0;
+ const size_type LP = 0;
call_ma27x3 (&LP);
};
sparsity_pattern = &sp;
- const unsigned int
+ const size_type
n_rows = sparsity_pattern->n_rows();
// first count number of nonzero elements in the upper right part. the
// matrix is symmetric, so this suffices
n_nonzero_elements = 0;
- for (unsigned int row=0; row<n_rows; ++row)
+ for (size_type row=0; row<n_rows; ++row)
for (SparsityPattern::iterator col = sparsity_pattern->begin(row);
col < sparsity_pattern->end(row); ++col)
if (row <= col->column())
row_numbers.resize (n_nonzero_elements);
column_numbers.resize (n_nonzero_elements);
- unsigned int global_index = 0;
- for (unsigned int row=0; row<n_rows; ++row)
+ size_type global_index = 0;
+ for (size_type row=0; row<n_rows; ++row)
for (SparsityPattern::iterator col = sparsity_pattern->begin(row);
col < sparsity_pattern->end(row); ++col)
// note that the matrix must be
// initialize scratch arrays and
// variables
- LIW = static_cast<unsigned int>((2*n_nonzero_elements + 3*n_rows + 1) *
+ LIW = static_cast<size_type>((2*n_nonzero_elements + 3*n_rows + 1) *
LIW_factor_1);
IW.resize (detached_mode_set() ? 0 : LIW);
IKEEP.resize (detached_mode_set() ? 0 : 3*n_rows);
break;
// otherwise: increase LIW and retry
- LIW = static_cast<unsigned int>(LIW * LIW_increase_factor_1);
+ LIW = static_cast<size_type>(LIW * LIW_increase_factor_1);
IW.resize (LIW);
}
while (true);
// if necessary extend IW
if (LIW < NIRNEC * LIW_factor_2)
{
- LIW = static_cast<unsigned int>(NIRNEC * LIW_factor_2);
+ LIW = static_cast<size_type>(NIRNEC * LIW_factor_2);
IW.resize (LIW);
};
- const unsigned int n_rows = matrix.get_sparsity_pattern().n_rows();
+ const size_type n_rows = matrix.get_sparsity_pattern().n_rows();
// loop until memory requirements
// are satisfied or we are not
// more used
if (call_succeeded)
{
- std::vector<unsigned int> tmp1, tmp2, tmp3;
+ std::vector<size_type> tmp1, tmp2, tmp3;
row_numbers.swap (tmp1);
column_numbers.swap (tmp2);
IKEEP.swap (tmp3);
if (LIW_increase_factor_2 <= 1)
goto exit_loop;
- LIW = static_cast<unsigned int>(LIW * LIW_increase_factor_2);
+ LIW = static_cast<size_type>(LIW * LIW_increase_factor_2);
IW.resize (LIW);
break;
};
// allocation.
std::cout << "<*>" << std::flush;
- LA = static_cast<unsigned int>(LA * LA_increase_factor);
+ LA = static_cast<size_type>(LA * LA_increase_factor);
if (true)
{
std::vector<double> tmp;
{
Assert (factorize_called == true, ExcFactorizeNotCalled());
- const unsigned int n_rows = rhs_and_solution.size();
+ const size_type n_rows = rhs_and_solution.size();
call_ma27cd (&n_rows, &A[0], &LA,
&IW[0], &LIW, &MAXFRT,
&rhs_and_solution(0), &IW1[0], &NSTEPS);
Vector<double> tmp (rhs_and_solution.size());
tmp = rhs_and_solution;
- const unsigned int n_rows = rhs_and_solution.size();
+ const size_type n_rows = rhs_and_solution.size();
call_ma27cd (&n_rows, &A[0], &LA,
&IW[0], &LIW, &MAXFRT,
&tmp(0), &IW1[0], &NSTEPS);
const SparsityPattern &sparsity_pattern = matrix.get_sparsity_pattern ();
- const unsigned int n_rows = sparsity_pattern.n_rows();
+ const size_type n_rows = sparsity_pattern.n_rows();
- unsigned int global_index = 0;
- for (unsigned int row=0; row<n_rows; ++row)
+ size_type global_index = 0;
+ for (size_type row=0; row<n_rows; ++row)
for (typename SparseMatrix<number>::const_iterator col=matrix.begin(row);
col < matrix.end(row); ++col)
// note that the matrix must be
-void SparseDirectMA27::call_ma27ad (const unsigned int *N,
- const unsigned int *NZ,
- const unsigned int *IRN,
- const unsigned int *ICN,
- unsigned int *IW,
- const unsigned int *LIW,
- unsigned int *IKEEP,
- unsigned int *IW1,
- unsigned int *NSTEPS,
- int *IFLAG)
+void SparseDirectMA27::call_ma27ad (const size_type *N,
+ const size_type *NZ,
+ const size_type *IRN,
+ const size_type *ICN,
+ size_type *IW,
+ const size_type *LIW,
+ size_type *IKEEP,
+ size_type *IW1,
+ size_type *NSTEPS,
+ int *IFLAG)
{
if (detached_mode_set() == false)
HSL::MA27::ma27ad_ (N, NZ, IRN, ICN, IW, LIW,
-void SparseDirectMA27::call_ma27bd (const unsigned int *N,
- const unsigned int *NZ,
- const unsigned int *IRN,
- const unsigned int *ICN,
- double *A,
- const unsigned int *LA,
- unsigned int *IW,
- const unsigned int *LIW,
- const unsigned int *IKEEP,
- const unsigned int *NSTEPS,
- unsigned int *MAXFRT,
- unsigned int *IW1,
- int *IFLAG)
+void SparseDirectMA27::call_ma27bd (const size_type *N,
+ const size_type *NZ,
+ const size_type *IRN,
+ const size_type *ICN,
+ double *A,
+ const size_type *LA,
+ size_type *IW,
+ const size_type *LIW,
+ const size_type *IKEEP,
+ const size_type *NSTEPS,
+ size_type *MAXFRT,
+ size_type *IW1,
+ int *IFLAG)
{
if (detached_mode_set() == false)
HSL::MA27::ma27bd_ (N, NZ, IRN, ICN, A, LA, IW, LIW,
-void SparseDirectMA27::call_ma27cd (const unsigned int *N,
- const double *A,
- const unsigned int *LA,
- const unsigned int *IW,
- const unsigned int *LIW,
- const unsigned int *MAXFRT,
- double *RHS,
- const unsigned int *IW1,
- const unsigned int *NSTEPS) const
+void SparseDirectMA27::call_ma27cd (const size_type *N,
+ const double *A,
+ const size_type *LA,
+ const size_type *IW,
+ const size_type *LIW,
+ const size_type *MAXFRT,
+ double *RHS,
+ const size_type *IW1,
+ const size_type *NSTEPS) const
{
if (detached_mode_set() == false)
{
-void SparseDirectMA27::call_ma27x1 (unsigned int *NRLNEC)
+void SparseDirectMA27::call_ma27x1 (size_type *NRLNEC)
{
if (detached_mode_set() == false)
HSL::MA27::ma27x1_ (NRLNEC);
-void SparseDirectMA27::call_ma27x2 (unsigned int *NIRNEC)
+void SparseDirectMA27::call_ma27x2 (size_type *NIRNEC)
{
if (detached_mode_set() == false)
HSL::MA27::ma27x2_ (NIRNEC);
-void SparseDirectMA27::call_ma27x3 (const unsigned int *LP)
+void SparseDirectMA27::call_ma27x3 (const size_type *LP)
{
if (detached_mode_set() == false)
HSL::MA27::ma27x3_ (LP);
matrix = &m;
const SparsityPattern &sparsity_pattern = matrix->get_sparsity_pattern();
- const unsigned int
+ const size_type
n_rows = sparsity_pattern.n_rows();
// first count number of nonzero
// part. the matrix is symmetric,
// so this suffices
n_nonzero_elements = 0;
- for (unsigned int row=0; row<n_rows; ++row)
+ for (size_type row=0; row<n_rows; ++row)
for (SparseMatrix<double>::const_iterator col = m.begin(row);
col < m.end(row); ++col)
// skip zero elements, as required by the docs of MA47
row_numbers.resize (n_nonzero_elements);
column_numbers.resize (n_nonzero_elements);
- unsigned int global_index = 0;
- for (unsigned int row=0; row<n_rows; ++row)
+ size_type global_index = 0;
+ for (size_type row=0; row<n_rows; ++row)
for (SparseMatrix<double>::const_iterator col = m.begin(row);
col < m.end(row); ++col)
// note that the matrix must be
// initialize scratch arrays and
// variables
- LIW = static_cast<unsigned int>((2*n_nonzero_elements + 5*n_rows + 4) *
+ LIW = static_cast<size_type>((2*n_nonzero_elements + 5*n_rows + 4) *
LIW_factor_1);
IW.resize (LIW);
KEEP.resize (n_nonzero_elements + 5*n_rows + 2);
break;
// otherwise: increase LIW and retry
- LIW = static_cast<unsigned int>(LIW * LIW_increase_factor_1);
+ LIW = static_cast<size_type>(LIW * LIW_increase_factor_1);
IW.resize (LIW);
}
while (true);
// if necessary extend IW
if (LIW < INFO[6] * LIW_factor_2)
{
- LIW = static_cast<unsigned int>(INFO[6] * LIW_factor_2);
+ LIW = static_cast<size_type>(INFO[6] * LIW_factor_2);
IW.resize (LIW);
};
- const unsigned int n_rows = m.get_sparsity_pattern().n_rows();
+ const size_type n_rows = m.get_sparsity_pattern().n_rows();
IW1.resize (2*n_rows+2);
// output info flags
if (LIW_increase_factor_2 <= 1)
goto exit_loop;
- LIW = static_cast<unsigned int>(LIW * LIW_increase_factor_2);
+ LIW = static_cast<size_type>(LIW * LIW_increase_factor_2);
IW.resize (LIW);
break;
};
// allocation.
std::cout << "<*>" << std::flush;
- LA = static_cast<unsigned int>(LA * LA_increase_factor);
+ LA = static_cast<size_type>(LA * LA_increase_factor);
if (true)
{
std::vector<double> tmp;
{
Assert (factorize_called == true, ExcFactorizeNotCalled());
- const unsigned int n_rows = rhs_and_solution.size();
+ const size_type n_rows = rhs_and_solution.size();
call_ma47cd (&n_rows, &A[0], &LA,
&IW[0], &LIW,
&rhs_and_solution(0), &IW1[0], &ICNTL[0]);
const SparsityPattern &sparsity_pattern = matrix.get_sparsity_pattern ();
- const unsigned int n_rows = sparsity_pattern.n_rows();
+ const size_type n_rows = sparsity_pattern.n_rows();
- unsigned int global_index = 0;
- for (unsigned int row=0; row<n_rows; ++row)
+ size_type global_index = 0;
+ for (size_type row=0; row<n_rows; ++row)
for (SparseMatrix<double>::const_iterator col=matrix.begin(row);
col < matrix.end(row); ++col)
// note that the matrix must be
void
SparseDirectMA47::
-call_ma47ad (const unsigned int *n_rows, //scalar
- const unsigned int *n_nonzero_elements, //scalar
- unsigned int *row_numbers, //length n_nonzero
- unsigned int *column_numbers, //length n_nonzero
- unsigned int *IW, //length LIW
- const unsigned int *LIW, //scalar
- unsigned int *KEEP, //n_nonzero+5*n_rows+2
+call_ma47ad (const size_type *n_rows, //scalar
+ const size_type *n_nonzero_elements, //scalar
+ size_type *row_numbers, //length n_nonzero
+ size_type *column_numbers, //length n_nonzero
+ size_type *IW, //length LIW
+ const size_type *LIW, //scalar
+ size_type *KEEP, //n_nonzero+5*n_rows+2
const unsigned int *ICNTL, //length 7
int *INFO) //length 24
{
void
SparseDirectMA47::
-call_ma47bd (const unsigned int *n_rows, //scalar
- const unsigned int *n_nonzero_elements, //scalar
- const unsigned int *column_numbers, //length n_nonzero
+call_ma47bd (const size_type *n_rows, //scalar
+ const size_type *n_nonzero_elements, //scalar
+ const size_type *column_numbers, //length n_nonzero
double *A, //length LA
- const unsigned int *LA, //scalar
- unsigned int *IW, //length LIW
- const unsigned int *LIW, //scalar
- const unsigned int *KEEP, //n_nonzero+5*n_rows+2
+ const size_type *LA, //scalar
+ size_type *IW, //length LIW
+ const size_type *LIW, //scalar
+ const size_type *KEEP, //n_nonzero+5*n_rows+2
const double *CNTL, //length 2
const unsigned int *ICNTL, //length 7
- unsigned int *IW1, //2*n_rows+2
+ size_type *IW1, //2*n_rows+2
int *INFO) //length 24
{
double RINFO[4];
void
SparseDirectMA47::
-call_ma47cd (const unsigned int *n_rows, //scalar
+call_ma47cd (const size_type *n_rows, //scalar
const double *A, //length LA
- const unsigned int *LA, //scalar
- const unsigned int *IW, //length LIW
- const unsigned int *LIW, //scalar
+ const size_type *LA, //scalar
+ const size_type *IW, //length LIW
+ const size_type *LIW, //scalar
double *rhs_and_solution, //length n_rows
- unsigned int *IW1, //length 2*n_rows+2
+ size_type *IW1, //length 2*n_rows+2
const unsigned int *ICNTL) //length 7
{
std::vector<double> W(*n_rows);
// second entry in a row
//
// ignore rows with only one or no entry
- for (unsigned int row=0; row<matrix.m(); ++row)
+ for (size_type row=0; row<matrix.m(); ++row)
{
// we may have to move some elements
// that are left of the diagonal but
sort_arrays (const SparseMatrixEZ<number> &matrix)
{
//same thing for SparseMatrixEZ
- for (unsigned int row=0; row<matrix.m(); ++row)
+ for (size_type row=0; row<matrix.m(); ++row)
{
long int cursor = Ap[row];
while ((cursor < Ap[row+1]-1) &&
// columns. we can do the same
// thing as above, but we have to
// do it multiple times
- for (unsigned int row=0; row<matrix.m(); ++row)
+ for (size_type row=0; row<matrix.m(); ++row)
{
long int cursor = Ap[row];
- for (unsigned int block=0; block<matrix.n_block_cols(); ++block)
+ for (size_type block=0; block<matrix.n_block_cols(); ++block)
{
// find the next
clear ();
- const unsigned int N = matrix.m();
+ const size_type N = matrix.m();
// copy over the data from the matrix to
// the data structures UMFPACK wants. note
// first fill row lengths array
Ap[0] = 0;
- for (unsigned int row=1; row<=N; ++row)
+ for (size_type row=1; row<=N; ++row)
Ap[row] = Ap[row-1] + matrix.get_row_length(row-1);
- Assert (static_cast<unsigned int>(Ap.back()) == Ai.size(),
+ Assert (static_cast<size_type>(Ap.back()) == Ai.size(),
ExcInternalError());
// then copy over matrix
// loop over the elements of the matrix row by row, as suggested
// in the documentation of the sparse matrix iterator class
- for (unsigned int row = 0; row < matrix.m(); ++row)
+ for (size_type row = 0; row < matrix.m(); ++row)
{
for (typename Matrix::const_iterator p=matrix.begin(row);
p!=matrix.end(row); ++p)
// at the end, we should have
// written all rows completely
- for (unsigned int i=0; i<Ap.size()-1; ++i)
+ for (size_type i=0; i<Ap.size()-1; ++i)
Assert (row_pointers[i] == Ap[i+1], ExcInternalError());
}
irn = new int[nz];
jcn = new int[nz];
- unsigned int index = 0;
+ size_type index = 0;
// loop over the elements of the matrix row by row, as suggested
// in the documentation of the sparse matrix iterator class
- for (unsigned int row = 0; row < matrix.m(); ++row)
+ for (size_type row = 0; row < matrix.m(); ++row)
{
for (typename Matrix::const_iterator ptr = matrix.begin (row);
ptr != matrix.end (row); ++ptr)
// Object denoting a MUMPS data structure
rhs = new double[n];
- for (unsigned int i = 0; i < n; ++i)
+ for (size_type i = 0; i < n; ++i)
rhs[i] = vector (i);
id.rhs = rhs;
// Copy solution into the given vector
if (Utilities::MPI::this_mpi_process (MPI_COMM_WORLD) == 0)
{
- for (unsigned int i=0; i<n; ++i)
+ for (size_type i=0; i<n; ++i)
vector(i) = rhs[i];
delete[] rhs;
// Object denoting a MUMPS data structure:
rhs = new double[n];
- for (unsigned int i = 0; i < n; ++i)
+ for (size_type i = 0; i < n; ++i)
rhs[i] = src (i);
id.rhs = rhs;
#ifdef DEAL_II_MSVC
__declspec(selectany) // Weak extern binding due to multiple link error
#endif
-const unsigned int SparsityPattern::invalid_entry;
+const SparsityPattern::size_type SparsityPattern::invalid_entry;
-SparsityPattern::SparsityPattern (const unsigned int m,
- const unsigned int n,
- const unsigned int max_per_row,
+SparsityPattern::SparsityPattern (const size_type m,
+ const size_type n,
+ const size_type max_per_row,
const bool)
:
max_dim(0),
-SparsityPattern::SparsityPattern (const unsigned int m,
- const unsigned int n,
- const unsigned int max_per_row)
+SparsityPattern::SparsityPattern (const size_type m,
+ const size_type n,
+ const size_type max_per_row)
:
max_dim(0),
max_vec_len(0),
-SparsityPattern::SparsityPattern (const unsigned int m,
- const unsigned int n,
- const std::vector<unsigned int> &row_lengths,
+SparsityPattern::SparsityPattern (const size_type m,
+ const size_type n,
+ const std::vector<size_type> &row_lengths,
const bool)
:
max_dim(0),
}
-SparsityPattern::SparsityPattern (const unsigned int m,
- const unsigned int n,
- const std::vector<unsigned int> &row_lengths)
+SparsityPattern::SparsityPattern (const size_type m,
+ const size_type n,
+ const std::vector<size_type> &row_lengths)
:
max_dim(0),
max_vec_len(0),
-SparsityPattern::SparsityPattern (const unsigned int n,
- const unsigned int max_per_row)
+SparsityPattern::SparsityPattern (const size_type n,
+ const size_type max_per_row)
:
max_dim(0),
max_vec_len(0),
-SparsityPattern::SparsityPattern (const unsigned int m,
- const std::vector<unsigned int> &row_lengths,
+SparsityPattern::SparsityPattern (const size_type m,
+ const std::vector<size_type> &row_lengths,
const bool)
:
max_dim(0),
}
-SparsityPattern::SparsityPattern (const unsigned int m,
- const std::vector<unsigned int> &row_lengths)
+SparsityPattern::SparsityPattern (const size_type m,
+ const std::vector<size_type> &row_lengths)
:
max_dim(0),
max_vec_len(0),
SparsityPattern::SparsityPattern (const SparsityPattern &original,
- const unsigned int max_per_row,
- const unsigned int extra_off_diagonals)
+ const size_type max_per_row,
+ const size_type extra_off_diagonals)
:
max_dim(0),
max_vec_len(0),
// now copy the entries from
// the other object
- for (unsigned int row=0; row<original.rows; ++row)
+ for (size_type row=0; row<original.rows; ++row)
{
// copy the elements of this row
// of the other object
// the rest from that element onwards
// which is not a side-diagonal any
// more.
- const unsigned int *const
+ const size_type *const
original_row_start = &original.colnums[original.rowstart[row]] + 1;
// the following requires that
// @p{original} be compressed since
// otherwise there might be invalid_entry's
- const unsigned int *const
+ const size_type *const
original_row_end = &original.colnums[original.rowstart[row+1]];
// find pointers before and
// these pointers such that no
// copying is necessary (see
// the @p{copy} commands)
- const unsigned int *const
+ const size_type *const
original_last_before_side_diagonals
= (row > extra_off_diagonals ?
Utilities::lower_bound (original_row_start,
row-extra_off_diagonals) :
original_row_start);
- const unsigned int *const
+ const size_type *const
original_first_after_side_diagonals
= (row < rows-extra_off_diagonals-1 ?
std::upper_bound (original_row_start,
// find first free slot. the
// first slot in each row is
// the diagonal element
- unsigned int *next_free_slot = &colnums[rowstart[row]] + 1;
+ size_type *next_free_slot = &colnums[rowstart[row]] + 1;
// copy elements before side-diagonals
next_free_slot = std::copy (original_row_start,
next_free_slot);
// insert left and right side-diagonals
- for (unsigned int i=1; i<=std::min(row,extra_off_diagonals);
+ for (size_type i=1; i<=std::min(row,extra_off_diagonals);
++i, ++next_free_slot)
*next_free_slot = row-i;
- for (unsigned int i=1; i<=std::min(extra_off_diagonals, rows-row-1);
+ for (size_type i=1; i<=std::min(extra_off_diagonals, rows-row-1);
++i, ++next_free_slot)
*next_free_slot = row+i;
void
-SparsityPattern::reinit (const unsigned int m,
- const unsigned int n,
- const unsigned int max_per_row,
+SparsityPattern::reinit (const size_type m,
+ const size_type n,
+ const size_type max_per_row,
const bool)
{
// simply map this function to the
// other @p{reinit} function
- const std::vector<unsigned int> row_lengths (m, max_per_row);
+ const std::vector<size_type> row_lengths (m, max_per_row);
reinit (m, n, row_lengths);
}
void
-SparsityPattern::reinit (const unsigned int m,
- const unsigned int n,
- const unsigned int max_per_row)
+SparsityPattern::reinit (const size_type m,
+ const size_type n,
+ const size_type max_per_row)
{
// simply map this function to the
// other @p{reinit} function
- const std::vector<unsigned int> row_lengths (m, max_per_row);
+ const std::vector<size_type> row_lengths (m, max_per_row);
reinit (m, n, row_lengths);
}
void
-SparsityPattern::reinit (const unsigned int m,
- const unsigned int n,
- const VectorSlice<const std::vector<unsigned int> > &row_lengths,
+SparsityPattern::reinit (const size_type m,
+ const size_type n,
+ const VectorSlice<const std::vector<size_type> > &row_lengths,
const bool)
{
reinit (m, n, row_lengths);
void
-SparsityPattern::reinit (const unsigned int m,
- const unsigned int n,
- const VectorSlice<const std::vector<unsigned int> > &row_lengths)
+SparsityPattern::reinit (const size_type m,
+ const size_type n,
+ const VectorSlice<const std::vector<size_type> > &row_lengths)
{
AssertDimension (row_lengths.size(), m);
// per row is bounded by the number
// of columns
std::size_t vec_len = 0;
- for (unsigned int i=0; i<m; ++i)
+ for (size_type i=0; i<m; ++i)
vec_len += std::min((store_diagonal_first_in_row ?
std::max(row_lengths[i], 1U) :
row_lengths[i]),
}
max_vec_len = vec_len;
- colnums = new unsigned int[max_vec_len];
+ colnums = new size_type[max_vec_len];
}
max_row_length = (row_lengths.size() == 0 ?
}
max_vec_len = vec_len;
- colnums = new unsigned int[max_vec_len];
+ colnums = new size_type[max_vec_len];
}
// set the rowstart array
rowstart[0] = 0;
- for (unsigned int i=1; i<=rows; ++i)
+ for (size_type i=1; i<=rows; ++i)
rowstart[i] = rowstart[i-1] +
(store_diagonal_first_in_row ?
std::max(std::min(row_lengths[i-1],n),1U) :
// special: let the first entry in
// each row be the diagonal value
if (store_diagonal_first_in_row)
- for (unsigned int i=0; i<rows; i++)
+ for (size_type i=0; i<rows; i++)
colnums[rowstart[i]] = i;
compressed = false;
if (compressed)
return;
- unsigned int next_free_entry = 0,
- next_row_start = 0,
- row_length = 0;
+ size_type next_free_entry = 0,
+ next_row_start = 0,
+ row_length = 0;
// first find out how many non-zero
// elements there are, in order to
const std::size_t nonzero_elements
= std::count_if (&colnums[rowstart[0]],
&colnums[rowstart[rows]],
- std::bind2nd(std::not_equal_to<unsigned int>(), invalid_entry));
+ std::bind2nd(std::not_equal_to<size_type>(), invalid_entry));
// now allocate the respective memory
- unsigned int *new_colnums = new unsigned int[nonzero_elements];
+ size_type *new_colnums = new size_type[nonzero_elements];
// reserve temporary storage to
// store the entries of one row
- std::vector<unsigned int> tmp_entries (max_row_length);
+ std::vector<size_type> tmp_entries (max_row_length);
// Traverse all rows
- for (unsigned int line=0; line<rows; ++line)
+ for (size_type line=0; line<rows; ++line)
{
// copy used entries, break if
// first unused entry is reached
row_length = 0;
- for (unsigned int j=rowstart[line]; j<rowstart[line+1]; ++j,++row_length)
+ for (size_type j=rowstart[line]; j<rowstart[line+1]; ++j,++row_length)
if (colnums[j] != invalid_entry)
tmp_entries[row_length] = colnums[j];
else
// insert column numbers
// into the new field
- for (unsigned int j=0; j<row_length; ++j)
+ for (size_type j=0; j<row_length; ++j)
new_colnums[next_free_entry++] = tmp_entries[j];
// note new start of this and
// diagonal entry is in a certain
// row or not
const bool do_diag_optimize = (csp.n_rows() == csp.n_cols());
- std::vector<unsigned int> row_lengths (csp.n_rows());
- for (unsigned int i=0; i<csp.n_rows(); ++i)
+ std::vector<size_type> row_lengths (csp.n_rows());
+ for (size_type i=0; i<csp.n_rows(); ++i)
{
row_lengths[i] = csp.row_length(i);
if (do_diag_optimize && !csp.exists(i,i))
// the diagonal element
// preallocated
if (n_rows() != 0 && n_cols() != 0)
- for (unsigned int row = 0; row<csp.n_rows(); ++row)
+ for (size_type row = 0; row<csp.n_rows(); ++row)
{
- unsigned int *cols = &colnums[rowstart[row]] + (do_diag_optimize ? 1 : 0);
+ size_type *cols = &colnums[rowstart[row]] + (do_diag_optimize ? 1 : 0);
typename CSP::row_iterator col_num = csp.row_begin (row),
end_row = csp.row_end (row);
for (; col_num != end_row; ++col_num)
{
- const unsigned int col = *col_num;
+ const size_type col = *col_num;
if ((col!=row) || !do_diag_optimize)
*cols++ = col;
}
// also have to allocate memory for the
// diagonal entry, unless we have already
// counted it
- std::vector<unsigned int> entries_per_row (matrix.m(), 0);
- for (unsigned int row=0; row<matrix.m(); ++row)
+ std::vector<size_type> entries_per_row (matrix.m(), 0);
+ for (size_type row=0; row<matrix.m(); ++row)
{
- for (unsigned int col=0; col<matrix.n(); ++col)
+ for (size_type col=0; col<matrix.n(); ++col)
if (matrix(row,col) != 0)
++entries_per_row[row];
if ((matrix.m() == matrix.n())
reinit (matrix.m(), matrix.n(), entries_per_row);
// now set entries
- for (unsigned int row=0; row<matrix.m(); ++row)
- for (unsigned int col=0; col<matrix.n(); ++col)
+ for (size_type row=0; row<matrix.m(); ++row)
+ for (size_type col=0; col<matrix.n(); ++col)
if (matrix(row,col) != 0)
add (row,col);
void
-SparsityPattern::reinit (const unsigned int m,
- const unsigned int n,
- const std::vector<unsigned int> &row_lengths,
+SparsityPattern::reinit (const size_type m,
+ const size_type n,
+ const std::vector<size_type> &row_lengths,
const bool)
{
reinit(m, n, make_slice(row_lengths));
void
-SparsityPattern::reinit (const unsigned int m,
- const unsigned int n,
- const std::vector<unsigned int> &row_lengths)
+SparsityPattern::reinit (const size_type m,
+ const size_type n,
+ const std::vector<size_type> &row_lengths)
{
reinit(m, n, make_slice(row_lengths));
}
-unsigned int
+SparsityPattern::size_type
SparsityPattern::max_entries_per_row () const
{
// if compress() has not yet been
// if compress() was called, we
// use a better algorithm which
// gives us a sharp bound
- unsigned int m = 0;
- for (unsigned int i=1; i<rows; ++i)
- m = std::max (m, static_cast<unsigned int>(rowstart[i]-rowstart[i-1]));
+ size_type m = 0;
+ for (size_type i=1; i<rows; ++i)
+ m = std::max (m, static_cast<size_type>(rowstart[i]-rowstart[i-1]));
return m;
}
-unsigned int
-SparsityPattern::operator () (const unsigned int i,
- const unsigned int j) const
+SparsityPattern::size_type
+SparsityPattern::operator () (const size_type i,
+ const size_type j) const
{
Assert ((rowstart!=0) && (colnums!=0), ExcEmptyObject());
Assert (i<rows, ExcIndexRange(i,0,rows));
// top of this function, so it may
// not be called for noncompressed
// structures.
- const unsigned int *sorted_region_start = (store_diagonal_first_in_row ?
- &colnums[rowstart[i]+1] :
- &colnums[rowstart[i]]);
- const unsigned int *const p
- = Utilities::lower_bound<const unsigned int *> (sorted_region_start,
+ const size_type *sorted_region_start = (store_diagonal_first_in_row ?
+ &colnums[rowstart[i]+1] :
+ &colnums[rowstart[i]]);
+ const size_type *const p
+ = Utilities::lower_bound<const size_type *> (sorted_region_start,
&colnums[rowstart[i+1]],
j);
if ((p != &colnums[rowstart[i+1]]) && (*p == j))
void
-SparsityPattern::add (const unsigned int i,
- const unsigned int j)
+SparsityPattern::add (const size_type i,
+ const size_type j)
{
Assert ((rowstart!=0) && (colnums!=0), ExcEmptyObject());
Assert (i<rows, ExcIndexRange(i,0,rows));
template <typename ForwardIterator>
void
-SparsityPattern::add_entries (const unsigned int row,
- ForwardIterator begin,
- ForwardIterator end,
- const bool indices_are_sorted)
+SparsityPattern::add_entries (const size_type row,
+ ForwardIterator begin,
+ ForwardIterator end,
+ const bool indices_are_sorted)
{
if (indices_are_sorted == true)
{
bool
-SparsityPattern::exists (const unsigned int i, const unsigned int j) const
+SparsityPattern::exists (const size_type i, const size_type j) const
{
Assert ((rowstart!=0) && (colnums!=0), ExcEmptyObject());
Assert (i<rows, ExcIndexRange(i,0,rows));
Assert (j<cols, ExcIndexRange(j,0,cols));
- for (unsigned int k=rowstart[i]; k<rowstart[i+1]; k++)
+ for (size_type k=rowstart[i]; k<rowstart[i+1]; k++)
{
// entry already exists
if (colnums[k] == j) return true;
-unsigned int
-SparsityPattern::row_position (const unsigned int i, const unsigned int j) const
+SparsityPattern::size_type
+SparsityPattern::row_position (const size_type i, const size_type j) const
{
Assert ((rowstart!=0) && (colnums!=0), ExcEmptyObject());
Assert (i<rows, ExcIndexRange(i,0,rows));
Assert (j<cols, ExcIndexRange(j,0,cols));
- for (unsigned int k=rowstart[i]; k<rowstart[i+1]; k++)
+ for (size_type k=rowstart[i]; k<rowstart[i+1]; k++)
{
// entry exists
if (colnums[k] == j) return k-rowstart[i];
-std::pair<unsigned int, unsigned int>
-SparsityPattern::matrix_position (const unsigned int global_index) const
+std::pair<SparsityPattern::size_type, SparsityPattern::size_type>
+SparsityPattern::matrix_position (const size_type global_index) const
{
Assert (compressed == true, ExcNotCompressed());
Assert (global_index < n_nonzero_elements(),
// for the one-past-last row, we
// can simply use a bisection
// search on it
- const unsigned int row
+ const size_type row
= (std::upper_bound (&rowstart[0], &rowstart[rows], global_index)
- &rowstart[0] - 1);
// now, the column index is simple
// since that is what the colnums
// array stores:
- const unsigned int col = colnums[global_index];
+ const size_type col = colnums[global_index];
// so return the respective pair
return std::make_pair (row,col);
// 2. that the @p{add} function can
// be called on elements that
// already exist without any harm
- for (unsigned int row=0; row<rows; ++row)
- for (unsigned int k=rowstart[row]; k<rowstart[row+1]; k++)
+ for (size_type row=0; row<rows; ++row)
+ for (size_type k=rowstart[row]; k<rowstart[row+1]; k++)
{
// check whether we are at
// the end of the entries of
AssertThrow (out, ExcIO());
- for (unsigned int i=0; i<rows; ++i)
+ for (size_type i=0; i<rows; ++i)
{
out << '[' << i;
- for (unsigned int j=rowstart[i]; j<rowstart[i+1]; ++j)
+ for (size_type j=rowstart[i]; j<rowstart[i+1]; ++j)
if (colnums[j] != invalid_entry)
out << ',' << colnums[j];
out << ']' << std::endl;
AssertThrow (out, ExcIO());
- for (unsigned int i=0; i<rows; ++i)
- for (unsigned int j=rowstart[i]; j<rowstart[i+1]; ++j)
+ for (size_type i=0; i<rows; ++i)
+ for (size_type j=rowstart[i]; j<rowstart[i+1]; ++j)
if (colnums[j] != invalid_entry)
// while matrix entries are
// usually written (i,j),
-unsigned int
+SparsityPattern::size_type
SparsityPattern::bandwidth () const
{
Assert ((rowstart!=0) && (colnums!=0), ExcEmptyObject());
- unsigned int b=0;
- for (unsigned int i=0; i<rows; ++i)
- for (unsigned int j=rowstart[i]; j<rowstart[i+1]; ++j)
+ size_type b=0;
+ for (size_type i=0; i<rows; ++i)
+ for (size_type j=rowstart[i]; j<rowstart[i+1]; ++j)
if (colnums[j] != invalid_entry)
{
- if (static_cast<unsigned int>(std::abs(static_cast<int>(i-colnums[j]))) > b)
+ if (static_cast<size_type>(std::abs(static_cast<int>(i-colnums[j]))) > b)
b = std::abs(static_cast<signed int>(i-colnums[j]));
}
else
delete[] colnums;
rowstart = new std::size_t[max_dim+1];
- colnums = new unsigned int[max_vec_len];
+ colnums = new size_type[max_vec_len];
// then read data
in.read (reinterpret_cast<char *>(&rowstart[0]),
std::size_t
SparsityPattern::memory_consumption () const
{
- return (max_dim * sizeof(unsigned int) +
+ return (max_dim * sizeof(size_type) +
sizeof(*this) +
- max_vec_len * sizeof(unsigned int));
+ max_vec_len * sizeof(size_type));
}
template void SparsityPattern::copy_from<float> (const FullMatrix<float> &);
template void SparsityPattern::copy_from<double> (const FullMatrix<double> &);
-template void SparsityPattern::add_entries<const unsigned int *> (const unsigned int,
- const unsigned int *,
- const unsigned int *,
+template void SparsityPattern::add_entries<const SparsityPattern::size_type *> (const size_type ,
+ const size_type *,
+ const size_type *,
const bool);
#ifndef DEAL_II_VECTOR_ITERATOR_IS_POINTER
-template void SparsityPattern::add_entries<std::vector<unsigned int>::const_iterator>
-(const unsigned int,
- std::vector<unsigned int>::const_iterator,
- std::vector<unsigned int>::const_iterator,
+template void SparsityPattern::add_entries<std::vector<SparsityPattern::size_type>::const_iterator>
+(const size_type,
+ std::vector<size_type>::const_iterator,
+ std::vector<size_type>::const_iterator,
const bool);
#endif
-template void SparsityPattern::add_entries<std::vector<unsigned int>::iterator>
-(const unsigned int,
- std::vector<unsigned int>::iterator,
- std::vector<unsigned int>::iterator,
+template void SparsityPattern::add_entries<std::vector<SparsityPattern::size_type>::iterator>
+(const size_type,
+ std::vector<size_type>::iterator,
+ std::vector<size_type>::iterator,
const bool);
DEAL_II_NAMESPACE_CLOSE
int_rowstart.reserve(sparsity_pattern.n_rows()+1);
std::vector<idx_t> int_colnums;
int_colnums.reserve(sparsity_pattern.n_nonzero_elements());
- for (unsigned int row=0; row<sparsity_pattern.n_rows(); ++row)
+ for (size_type row=0; row<sparsity_pattern.n_rows(); ++row)
{
for (SparsityPattern::iterator col=sparsity_pattern.begin(row);
col < sparsity_pattern.end(row); ++col)
* invalid_unsigned_int indicates that a node has not been numbered yet),
* pick a valid starting index among the as-yet unnumbered one.
*/
- unsigned int
+ size_type
find_unnumbered_starting_index (const SparsityPattern &sparsity,
- const std::vector<unsigned int> &new_indices)
+ const std::vector<size_type> &new_indices)
{
{
- unsigned int starting_point = numbers::invalid_unsigned_int;
- unsigned int min_coordination = sparsity.n_rows();
- for (unsigned int row=0; row<sparsity.n_rows(); ++row)
+ size_type starting_point = numbers::invalid_unsigned_int;
+ size_type min_coordination = sparsity.n_rows();
+ for (size_type row=0; row<sparsity.n_rows(); ++row)
// look over all as-yet unnumbered indices
if (new_indices[row] == numbers::invalid_unsigned_int)
{
break;
// post-condition after loop: coordination, i.e. the number of
// entries in this row is now j-rowstart[row]
- if (static_cast<unsigned int>(j-sparsity.begin(row)) <
+ if (static_cast<size_type>(j-sparsity.begin(row)) <
min_coordination)
{
min_coordination = j-sparsity.begin(row);
// starting point, e.g. the first unnumbered one
if (starting_point == numbers::invalid_unsigned_int)
{
- for (unsigned int i=0; i<new_indices.size(); ++i)
+ for (size_type i=0; i<new_indices.size(); ++i)
if (new_indices[i] == numbers::invalid_unsigned_int)
{
starting_point = i;
void
reorder_Cuthill_McKee (const SparsityPattern &sparsity,
- std::vector<unsigned int> &new_indices,
- const std::vector<unsigned int> &starting_indices)
+ std::vector<size_type> &new_indices,
+ const std::vector<size_type> &starting_indices)
{
Assert (sparsity.n_rows() == sparsity.n_cols(),
ExcDimensionMismatch (sparsity.n_rows(), sparsity.n_cols()));
ExcDimensionMismatch (sparsity.n_rows(), new_indices.size()));
Assert (starting_indices.size() <= sparsity.n_rows(),
ExcMessage ("You can't specify more starting indices than there are rows"));
- for (unsigned int i=0; i<starting_indices.size(); ++i)
+ for (size_type i=0; i<starting_indices.size(); ++i)
Assert (starting_indices[i] < sparsity.n_rows(),
ExcMessage ("Invalid starting index"));
// store the indices of the dofs renumbered in the last round. Default to
// starting points
- std::vector<unsigned int> last_round_dofs (starting_indices);
+ std::vector<size_type> last_round_dofs (starting_indices);
// initialize the new_indices array with invalid values
std::fill (new_indices.begin(), new_indices.end(),
numbers::invalid_unsigned_int);
// delete disallowed elements
- for (unsigned int i=0; i<last_round_dofs.size(); ++i)
+ for (size_type i=0; i<last_round_dofs.size(); ++i)
if ((last_round_dofs[i]==numbers::invalid_unsigned_int) ||
(last_round_dofs[i]>=sparsity.n_rows()))
last_round_dofs[i] = numbers::invalid_unsigned_int;
std::remove_if (last_round_dofs.begin(), last_round_dofs.end(),
- std::bind2nd(std::equal_to<unsigned int>(),
+ std::bind2nd(std::equal_to<size_type>(),
numbers::invalid_unsigned_int));
// now if no valid points remain: find dof with lowest coordination number
new_indices));
// store next free dof index
- unsigned int next_free_number = 0;
+ size_type next_free_number = 0;
// enumerate the first round dofs
- for (unsigned int i=0; i!=last_round_dofs.size(); ++i)
+ for (size_type i=0; i!=last_round_dofs.size(); ++i)
new_indices[last_round_dofs[i]] = next_free_number++;
// now do as many steps as needed to
{
// store the indices of the dofs to be
// renumbered in the next round
- std::vector<unsigned int> next_round_dofs;
+ std::vector<size_type> next_round_dofs;
// find all neighbors of the
// dofs numbered in the last
// round
- for (unsigned int i=0; i<last_round_dofs.size(); ++i)
+ for (size_type i=0; i<last_round_dofs.size(); ++i)
for (SparsityPattern::iterator j=sparsity.begin(last_round_dofs[i]);
j<sparsity.end(last_round_dofs[i]); ++j)
if (j->is_valid_entry() == false)
std::sort (next_round_dofs.begin(), next_round_dofs.end());
// delete multiple entries
- std::vector<unsigned int>::iterator end_sorted;
+ std::vector<size_type>::iterator end_sorted;
end_sorted = std::unique (next_round_dofs.begin(), next_round_dofs.end());
next_round_dofs.erase (end_sorted, next_round_dofs.end());
// store for each coordination
// number the dofs with these
// coordination number
- std::multimap<unsigned int, int> dofs_by_coordination;
+ std::multimap<size_type, int> dofs_by_coordination;
// find coordination number for
// each of these dofs
- for (std::vector<unsigned int>::iterator s=next_round_dofs.begin();
+ for (std::vector<size_type>::iterator s=next_round_dofs.begin();
s!=next_round_dofs.end(); ++s)
{
- unsigned int coordination = 0;
+ size_type coordination = 0;
for (SparsityPattern::iterator j=sparsity.begin(*s);
j<sparsity.end(*s); ++j)
if (j->is_valid_entry() == false)
// insert this dof at its
// coordination number
- const std::pair<const unsigned int, int> new_entry (coordination, *s);
+ const std::pair<const size_type, int> new_entry (coordination, *s);
dofs_by_coordination.insert (new_entry);
}
// assign new DoF numbers to
// the elements of the present
// front:
- std::multimap<unsigned int, int>::iterator i;
+ std::multimap<size_type, int>::iterator i;
for (i = dofs_by_coordination.begin(); i!=dofs_by_coordination.end(); ++i)
new_indices[i->second] = next_free_number++;
#ifdef DEAL_II_COMPILER_SUPPORTS_MPI
template <class CSP_t>
void distribute_sparsity_pattern(CSP_t &csp,
- const std::vector<unsigned int> &rows_per_cpu,
+ const std::vector<size_type> &rows_per_cpu,
const MPI_Comm &mpi_comm,
const IndexSet &myrange)
{
- unsigned int myid = Utilities::MPI::this_mpi_process(mpi_comm);
- std::vector<unsigned int> start_index(rows_per_cpu.size()+1);
+ size_type myid = Utilities::MPI::this_mpi_process(mpi_comm);
+ std::vector<size_type> start_index(rows_per_cpu.size()+1);
start_index[0]=0;
- for (unsigned int i=0; i<rows_per_cpu.size(); ++i)
+ for (size_type i=0; i<rows_per_cpu.size(); ++i)
start_index[i+1]=start_index[i]+rows_per_cpu[i];
- typedef std::map<unsigned int, std::vector<unsigned int> > map_vec_t;
+ typedef std::map<size_type, std::vector<size_type> > map_vec_t;
map_vec_t send_data;
{
unsigned int dest_cpu=0;
- unsigned int n_local_rel_rows = myrange.n_elements();
- for (unsigned int row_idx=0; row_idx<n_local_rel_rows; ++row_idx)
+ size_type n_local_rel_rows = myrange.n_elements();
+ for (size_type row_idx=0; row_idx<n_local_rel_rows; ++row_idx)
{
- unsigned int row=myrange.nth_index_in_set(row_idx);
+ size_type row=myrange.nth_index_in_set(row_idx);
//calculate destination CPU
while (row>=start_index[dest_cpu+1])
continue;
}
- unsigned int rlen = csp.row_length(row);
+ size_type rlen = csp.row_length(row);
//skip empty lines
if (!rlen)
continue;
//save entries
- std::vector<unsigned int> &dst = send_data[dest_cpu];
+ std::vector<size_type> &dst = send_data[dest_cpu];
dst.push_back(rlen); // number of entries
dst.push_back(row); // row index
- for (unsigned int c=0; c<rlen; ++c)
+ for (size_type c=0; c<rlen; ++c)
{
//columns
- unsigned int column = csp.column_number(row, c);
+ size_type column = csp.column_number(row, c);
dst.push_back(column);
}
}