Skip to content
Snippets Groups Projects
Commit d2ce5f3b authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

Add IndexType to global matrix and vector types.

Check for equality of the types
parent 98f46db5
No related branches found
No related tags found
No related merge requests found
......@@ -31,6 +31,7 @@ class DenseVector : public std::valarray<T>
{
public:
typedef T FP_T;
using IndexType = std::size_t; // The type of valarray indices.
public:
using std::valarray<T>::operator=;
......
......@@ -30,6 +30,7 @@ class GlobalDenseMatrix: public DenseMatrix<FP_TYPE, IDX_TYPE>
{
public:
typedef FP_TYPE FP_T;
using IndexType = IDX_TYPE;
public:
/// Dense square matrix constructor.
......
......@@ -33,6 +33,7 @@ class EigenMatrix final
{
public:
using RawMatrixType = Eigen::SparseMatrix<double, Eigen::RowMajor>;
using IndexType = RawMatrixType::Index;
/**
* constructor
......
......@@ -17,6 +17,7 @@
#endif
#include <Eigen/Eigen>
#include <Eigen/Sparse>
namespace MathLib
{
......@@ -27,6 +28,11 @@ class EigenVector final
public:
using RawVectorType = Eigen::VectorXd;
// The Index type of the Eigen::VectorXd class differs from the
// Eigen::SparseMatrix<double> index type. Maybe an Eigen::SparseVector is a
// more appropriate RawVectorType for the global vectors.
using IndexType = Eigen::SparseMatrix<double>::Index;
/// Constructor for initialization of the number of rows
/// @param length number of rows
explicit EigenVector(std::size_t length) : _vec(length) {}
......
......@@ -44,6 +44,8 @@ struct SetMatrixSparsity<LisMatrix, SPARSITY_PATTERN>;
*/
class LisMatrix
{
public:
using IndexType = LIS_INT;
public:
/**
* constructor
......
......@@ -27,6 +27,8 @@ namespace MathLib
*/
class LisVector
{
public:
using IndexType = LIS_INT;
public:
/**
* Constructor for initialization of the number of rows
......
......@@ -33,6 +33,9 @@ namespace MathLib
*/
class PETScMatrix
{
public:
using IndexType = PetscInt;
public:
/*!
\brief Constructor for a square matrix partitioning with more options
......
......@@ -34,6 +34,9 @@ namespace MathLib
*/
class PETScVector
{
public:
using IndexType = PetscInt;
public:
/*!
......
......@@ -103,5 +103,18 @@ using GlobalSetupType =
// Check the configuration
//
static_assert(std::is_class<GlobalSetupType>::value,
"GlobalSetupType was not defined.");
"GlobalSetupType was not defined.");
static_assert(std::is_integral<detail::GlobalMatrixType::IndexType>::value,
"The index type for global matrices is not an integral type.");
static_assert(std::is_integral<detail::GlobalVectorType::IndexType>::value,
"The index type for global vectors is not an integral type.");
static_assert(std::is_same<detail::GlobalMatrixType::IndexType,
detail::GlobalVectorType::IndexType>::value,
"The global matrix and vector index types do not match.");
// Both types are integral types and equal, define a single GlobalIndexType.
/// A type used for indexing of global vectors and matrices. It is equal to the
/// GlobalMatrixType::IndexType and the GlobalVectorType::IndexType.
using GlobalIndexType = detail::GlobalMatrixType::IndexType;
#endif // APPLICATIONS_NUMERICSCONFIG_H_
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment