Skip to content
Snippets Groups Projects
Commit 3b889849 authored by Dr. Felix Tobias Schindler's avatar Dr. Felix Tobias Schindler Committed by Tobias Leibner
Browse files

[la.eigen-solver] treat 1d vector as 1x1d matrix

parent 8e6a14e0
No related branches found
No related tags found
1 merge request!44ccache and clang sanitizer flags for CI
Pipeline #65330 canceled
......@@ -21,6 +21,8 @@
#include <dune/common/typetraits.hh>
#include <dune/xt/common/configuration.hh>
#include <dune/xt/common/vector.hh>
#include <dune/xt/common/type_traits.hh>
#include <dune/xt/la/exceptions.hh>
#include <dune/xt/la/container.hh>
......@@ -34,7 +36,11 @@ namespace LA {
* \note This class needs to be specialized for each MatrixType, the purpose of this variant is merely to document the
* expected functionality.
*/
template <class MatrixType, bool is_matrix = XT::Common::is_matrix<MatrixType>::value>
template <class MatrixType,
bool is_matrix =
XT::Common::is_matrix<MatrixType>::value
|| (XT::Common::is_vector<MatrixType>::value && XT::Common::VectorAbstraction<MatrixType>::has_static_size
&& XT::Common::VectorAbstraction<MatrixType>::static_size == 1)>
class EigenSolverOptions
{
static_assert(AlwaysFalse<MatrixType>::value,
......@@ -60,7 +66,11 @@ Common::Configuration eigen_solver_options(const MatrixType& /*matrix*/, const s
}
template <class MatrixImp, bool is_matrix = XT::Common::is_matrix<MatrixImp>::value>
template <class MatrixImp,
bool is_matrix =
XT::Common::is_matrix<MatrixImp>::value
|| (XT::Common::is_vector<MatrixImp>::value && XT::Common::VectorAbstraction<MatrixImp>::has_static_size
&& XT::Common::VectorAbstraction<MatrixImp>::static_size == 1)>
class EigenSolver
{
static_assert(AlwaysFalse<MatrixImp>::value,
......
......@@ -18,7 +18,9 @@
#include <dune/common/typetraits.hh>
#include <dune/xt/common/fmatrix.hh>
#include <dune/xt/common/fvector.hh>
#include <dune/xt/common/matrix.hh>
#include <dune/xt/common/memory.hh>
#include <dune/xt/common/numeric_cast.hh>
#include <dune/xt/common/vector.hh>
#include <dune/xt/la/container/conversion.hh>
......@@ -72,6 +74,17 @@ class EigenSolverOptions<Dune::XT::Common::FieldMatrix<K, SIZE, SIZE>, true>
{};
template <class K>
class EigenSolverOptions<Dune::FieldVector<K, 1>, true> : public EigenSolverOptions<Dune::FieldMatrix<K, 1, 1>, true>
{};
template <class K>
class EigenSolverOptions<Dune::XT::Common::FieldVector<K, 1>, true>
: public EigenSolverOptions<Dune::FieldMatrix<K, 1, 1>, true>
{};
template <class K, int SIZE>
class EigenSolver<Dune::FieldMatrix<K, SIZE, SIZE>, true>
: public internal::EigenSolverBase<Dune::FieldMatrix<K, SIZE, SIZE>,
......@@ -184,6 +197,40 @@ public:
};
template <class K>
class EigenSolver<Dune::XT::Common::FieldVector<K, 1>, true>
: Common::ConstStorageProvider<Dune::FieldMatrix<K, 1, 1>>
, public EigenSolver<Dune::FieldMatrix<K, 1, 1>>
{
using Storage = Common::ConstStorageProvider<Dune::FieldMatrix<K, 1, 1>>;
using BaseType = EigenSolver<Dune::FieldMatrix<K, 1, 1>>;
public:
template <class... Args>
EigenSolver(const Dune::XT::Common::FieldVector<K, 1>& vector, Args&&... args)
: Storage(vector[0])
, BaseType(Storage::access(), std::forward<Args>(args)...)
{}
};
template <class K>
class EigenSolver<Dune::FieldVector<K, 1>, true>
: Common::ConstStorageProvider<Dune::FieldMatrix<K, 1, 1>>
, public EigenSolver<Dune::FieldMatrix<K, 1, 1>>
{
using Storage = Common::ConstStorageProvider<Dune::FieldMatrix<K, 1, 1>>;
using BaseType = EigenSolver<Dune::FieldMatrix<K, 1, 1>>;
public:
template <class... Args>
EigenSolver(const Dune::FieldVector<K, 1>& vector, Args&&... args)
: Storage(vector[0])
, BaseType(Storage::access(), std::forward<Args>(args)...)
{}
};
} // namespace LA
} // namespace XT
} // namespace Dune
......
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