Skip to content

Commit

Permalink
implement custom zero tensor
Browse files Browse the repository at this point in the history
as long as it is not supported by Eigen

Conflicts:
	src/wrappers.hpp
  • Loading branch information
Alexander Voigt authored and Alexander Voigt committed Jul 22, 2016
1 parent a757413 commit 57d5248
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
68 changes: 68 additions & 0 deletions src/eigen_tensor.hpp
@@ -0,0 +1,68 @@
// ====================================================================
// This file is part of FlexibleSUSY.
//
// FlexibleSUSY is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published
// by the Free Software Foundation, either version 3 of the License,
// or (at your option) any later version.
//
// FlexibleSUSY is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with FlexibleSUSY. If not, see
// <http://www.gnu.org/licenses/>.
// ====================================================================

#ifndef EIGEN_TENSOR_H
#define EIGEN_TENSOR_H

#include <Eigen/Core>

#if EIGEN_VERSION_AT_LEAST(3,3,0)

#include <unsupported/Eigen/CXX11/Tensor>

namespace flexiblesusy {

template <class Scalar, int N, int M, int K>
class ZeroTensor3 : public Eigen::TensorFixedSize<Scalar, Eigen::Sizes<N,M,K> > {
typedef Eigen::TensorFixedSize<Scalar, Eigen::Sizes<N,M,K> > Base;

using Base::setZero;

ZeroTensor3() : Base() {
setZero();
}
};

template <class Scalar, int N, int M, int K, int L>
class ZeroTensor4 : public Eigen::TensorFixedSize<Scalar, Eigen::Sizes<N,M,K,L> > {
typedef Eigen::TensorFixedSize<Scalar, Eigen::Sizes<N,M,K,L> > Base;

using Base::setZero;

ZeroTensor4() : Base() {
setZero();
}
};

} // namespace flexiblesusy

#else

namespace flexiblesusy {

template <class Scalar, int N, int M, int K>
class ZeroTensor3;

template <class Scalar, int N, int M, int K, int L>
class ZeroTensor4;

} // namespace flexiblesusy

#endif

#endif
1 change: 1 addition & 0 deletions src/module.mk
Expand Up @@ -63,6 +63,7 @@ LIBFLEXI_HDR := \
$(DIR)/derivative.hpp \
$(DIR)/dilog.hpp \
$(DIR)/eigen_utils.hpp \
$(DIR)/eigen_tensor.hpp \
$(DIR)/error.hpp \
$(DIR)/ew_input.hpp \
$(DIR)/ewsb_solver.hpp \
Expand Down
5 changes: 5 additions & 0 deletions src/wrappers.hpp
Expand Up @@ -30,6 +30,7 @@
#include <boost/lexical_cast.hpp>

#include "dilog.hpp"
#include "eigen_tensor.hpp"

namespace flexiblesusy {

Expand Down Expand Up @@ -466,11 +467,15 @@ void Symmetrize(Eigen::MatrixBase<Derived>& m)

#define UNITMATRIX(rows) Eigen::Matrix<double,rows,rows>::Identity()
#define ZEROMATRIX(rows,cols) Eigen::Matrix<double,rows,cols>::Zero()
#define ZEROTENSOR3(d1,d2,d3) ZeroTensor3<double,d1,d2,d3>
#define ZEROTENSOR4(d1,d2,d3,d4) ZeroTensor4<double,d1,d2,d3,d4>
#define ZEROVECTOR(rows) Eigen::Matrix<double,rows,1>::Zero()
#define ZEROARRAY(rows) Eigen::Array<double,rows,1>::Zero()
#define UNITMATRIXCOMPLEX(rows) Eigen::Matrix<std::complex<double>,rows,rows>::Identity()
#define ZEROMATRIXCOMPLEX(rows,cols) Eigen::Matrix<std::complex<double>,rows,cols>::Zero()
#define ZEROVECTORCOMPLEX(rows) Eigen::Matrix<std::complex<double>,rows,1>::Zero()
#define ZEROTENSOR3COMPLEX(d1,d2,d3) ZeroTensor3<std::complex<double>,d1,d2,d3>
#define ZEROTENSOR4COMPLEX(d1,d2,d3,d4) ZeroTensor4<std::complex<double>,d1,d2,d3,d4>
#define ZEROARRAYCOMPLEX(rows) Eigen::Array<std::complex<double>,rows,1>::Zero()

// MxN matrix projection operator, which projects on the (X,Y)
Expand Down

0 comments on commit 57d5248

Please sign in to comment.