Medusa  1.1
Coordinate Free Mehless Method implementation
ScalarField_fwd.hpp
Go to the documentation of this file.
1 #ifndef MEDUSA_BITS_TYPES_SCALARFIELD_FWD_HPP_
2 #define MEDUSA_BITS_TYPES_SCALARFIELD_FWD_HPP_
3 
11 #include <medusa/Config.hpp>
12 #include <Eigen/Core>
13 #include "traits.hpp"
14 
15 namespace mm {
16 
26 template <typename Scalar>
27 class ScalarField : public Eigen::Matrix<Scalar, Eigen::Dynamic, 1> {
28  public:
29  typedef Scalar scalar_t;
30  typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1> Base;
31  using Base::Base; // inherit constructors
32  using Base::operator=; // inherit assignment operators
34  template <typename OtherDerived>
35  ScalarField(const Eigen::MatrixBase<OtherDerived>& other);
37  template <typename OtherDerived>
38  ScalarField& operator=(const Eigen::MatrixBase<OtherDerived>& other);
39 
40  private:
44  const indexes_t& indexes;
45  friend class ScalarField;
48  public:
50  void operator=(const scalar_t& s) {
51  sf(indexes) = ScalarField::Constant(indexes.size(), s);
52  }
54  template <typename OtherDerived>
55  void operator=(const Eigen::MatrixBase<OtherDerived>& other) {
56  sf(indexes) = other;
57  }
59  void operator=(const ScalarFieldView& other) {
60  sf(indexes) = other.sf(other.indexes);
61  }
62  };
63 
64  public:
65  using Base::operator[];
68  return ScalarFieldView(*this, indexes);
69  }
70 };
71 
74 
76 template <typename T> struct scalar_type<ScalarField<T>> {
77  typedef T type;
78 };
79 
80 } // namespace mm
81 
82 #endif // MEDUSA_BITS_TYPES_SCALARFIELD_FWD_HPP_
mm
Root namespace for the whole library.
Definition: Gaussian.hpp:14
mm::ScalarField::ScalarFieldView::ScalarFieldView
ScalarFieldView(ScalarField &sf, const indexes_t &indexes)
Construct a non contiguous view to a scalar field.
Definition: ScalarField_fwd.hpp:47
mm::ScalarField::operator=
ScalarField & operator=(const Eigen::MatrixBase< OtherDerived > &other)
This method allows assignments of Eigen expressions to ScalarField.
mm::ScalarField
Represents a discretization of a scalar field, a finite collection of scalars.
Definition: ScalarField_fwd.hpp:27
mm::ScalarField::ScalarField
ScalarField(const Eigen::MatrixBase< OtherDerived > &other)
This constructor allows construction of ScalarField from Eigen expressions.
mm::ScalarField::ScalarFieldView::indexes
const indexes_t & indexes
Indexes of this view.
Definition: ScalarField_fwd.hpp:44
mm::ScalarField::Base
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > Base
Base class typedef.
Definition: ScalarField_fwd.hpp:30
mm::ScalarField::ScalarFieldView
Represents a non contiguous view to a scalar field.
Definition: ScalarField_fwd.hpp:42
Config.hpp
mm::scalar_type< ScalarField< T > >::type
T type
Underlying scalar type.
Definition: ScalarField_fwd.hpp:77
mm::ScalarFieldd
ScalarField< double > ScalarFieldd
Convenience typedef for ScalarField of doubles.
Definition: ScalarField_fwd.hpp:72
mm::indexes_t
std::vector< int > indexes_t
Class representing a collection of indices.
Definition: Config.hpp:36
mm::ScalarField::ScalarFieldView::operator=
void operator=(const scalar_t &s)
Assign a scalar to this view.
Definition: ScalarField_fwd.hpp:50
mm::ScalarField::ScalarFieldView::operator=
void operator=(const Eigen::MatrixBase< OtherDerived > &other)
Assign another Eigen expression to this view.
Definition: ScalarField_fwd.hpp:55
mm::ScalarField::ScalarFieldView::sf
ScalarField & sf
Reference to the viewed field.
Definition: ScalarField_fwd.hpp:43
mm::ScalarField::operator[]
ScalarFieldView operator[](const indexes_t &indexes)
Multiindex view to given ScalarField.
Definition: ScalarField_fwd.hpp:67
Matrix
Matrix(const Scalar &s)
Construct matrix from scalar. Enabled only for fixed size matrices.
Definition: MatrixAddons.hpp:21
traits.hpp
mm::scalar_type
Type trait for scalar fields to obtain their underlying scalar type.
Definition: traits.hpp:17
mm::ScalarField::scalar_t
Scalar scalar_t
Scalar data type.
Definition: ScalarField_fwd.hpp:29
mm::ScalarFieldf
ScalarField< float > ScalarFieldf
Convenience typedef for ScalarField of floats.
Definition: ScalarField_fwd.hpp:73
mm::ScalarField::ScalarFieldView::operator=
void operator=(const ScalarFieldView &other)
Assign another ScalarFieldView.
Definition: ScalarField_fwd.hpp:59