Alexandria  2.27.0
SDC-CH common library for the Euclid project
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SOM.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2022 Euclid Science Ground Segment
3  *
4  * This library is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU Lesser General Public License as published by the Free
6  * Software Foundation; either version 3.0 of the License, or (at your option)
7  * any later version.
8  *
9  * This library is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
25 #ifndef _SOM_SOM_H
26 #define _SOM_SOM_H
27 
30 #include "SOM/Distance.h"
31 #include "SOM/InitFunc.h"
32 #include <array>
33 #include <limits>
34 #include <tuple>
35 #include <type_traits>
36 #include <vector>
37 
38 namespace Euclid {
39 namespace SOM {
40 
46 template <typename DistFunc = Distance::L2>
47 class SOM {
48 
50  "DistFunc must be a subclass of the Distance::Interface");
51 
52 public:
55  using iterator = typename CellGridType::iterator;
58 
60 
61  SOM(SOM<DistFunc>&&) = default;
62  SOM& operator=(SOM<DistFunc>&&) = default;
63 
67  virtual ~SOM() = default;
68 
70 
72 
74 
75  std::size_t getDimensions() const;
76 
77  iterator begin();
78 
79  iterator end();
80 
81  const_iterator begin() const;
82 
83  const_iterator end() const;
84 
86 
88 
90 
92  const std::vector<double>& uncertainties) const;
93 
94  template <typename InputType, typename WeightFunc>
95  std::tuple<std::size_t, std::size_t, double> findBMU(const InputType& input, WeightFunc weight_func) const;
96 
97  template <typename InputType, typename WeightFunc, typename UncertaintyFunc>
98  std::tuple<std::size_t, std::size_t, double> findBMU(const InputType& input, WeightFunc weight_func,
99  UncertaintyFunc uncertainty_func) const;
100 
101 private:
105 
106 }; /* End of SOM class */
107 
108 } /* namespace SOM */
109 } /* namespace Euclid */
110 
111 #include "SOM/_impl/SOM.icpp"
112 
113 #endif
std::tuple< std::size_t, std::size_t, double > findBMU(const std::vector< double > &input) const
Definition: SOM.icpp:95
virtual ~SOM()=default
Destructor.
typename CellGridType::const_iterator const_iterator
Definition: SOM.h:56
const_iterator cend()
Definition: SOM.icpp:90
const_iterator cbegin()
Definition: SOM.icpp:85
CellGridType m_cells
Definition: SOM.h:103
typename CellGridType::iterator iterator
Definition: SOM.h:55
iter< cell_type const, pointer_type const, reference_type const > const_iterator
std::pair< std::size_t, std::size_t > m_size
Definition: SOM.h:104
const std::pair< std::size_t, std::size_t > & getSize() const
Definition: SOM.icpp:45
decltype(ref_test< GridCellManagerTraits< GridCellManager >>(nullptr)) typedef reference_type
Reference type.
iterator end()
Definition: SOM.icpp:70
typename CellGridType::reference_type reference_type
Definition: SOM.h:57
iterator begin()
Definition: SOM.icpp:65
reference_type operator()(std::size_t x, std::size_t y)
Definition: SOM.icpp:55
std::size_t m_dimensions
Definition: SOM.h:102
SOM(std::size_t nd, std::size_t x, std::size_t y, InitFunc::Signature init_func=InitFunc::zero)
Definition: SOM.icpp:30
std::size_t getDimensions() const
Definition: SOM.icpp:50
SOM & operator=(SOM< DistFunc > &&)=default