Alexandria  2.18
Please provide a description of the 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-2021 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 
29 #include "SOM/Distance.h"
30 #include "SOM/InitFunc.h"
31 #include <array>
32 #include <limits>
33 #include <tuple>
34 #include <type_traits>
35 #include <vector>
36 
37 namespace Euclid {
38 namespace SOM {
39 
45 template <std::size_t ND, typename DistFunc = Distance::L2<ND>>
46 class SOM {
47 
48  static_assert(std::is_base_of<Distance::Interface<ND>, DistFunc>::value,
49  "DistFunc must be a subclass of the Distance::Interface<ND>");
50 
51 public:
53  using iterator = typename CellGridType::iterator;
55 
57 
58  SOM(SOM<ND, DistFunc>&&) = default;
59  SOM& operator=(SOM<ND, DistFunc>&&) = default;
60 
64  virtual ~SOM() = default;
65 
67 
69 
71 
72  iterator begin();
73 
74  iterator end();
75 
76  const_iterator begin() const;
77 
78  const_iterator end() const;
79 
81 
83 
85 
87  const std::array<double, ND>& uncertainties) const;
88 
89  template <typename InputType, typename WeightFunc>
90  std::tuple<std::size_t, std::size_t, double> findBMU(const InputType& input, WeightFunc weight_func) const;
91 
92  template <typename InputType, typename WeightFunc, typename UncertaintyFunc>
93  std::tuple<std::size_t, std::size_t, double> findBMU(const InputType& input, WeightFunc weight_func,
94  UncertaintyFunc uncertainty_func) const;
95 
96 private:
99 
100 }; /* End of SOM class */
101 
102 } /* namespace SOM */
103 } /* namespace Euclid */
104 
105 #include "SOM/_impl/SOM.icpp"
106 
107 #endif
SOM(std::size_t x, std::size_t y, InitFunc::Signature init_func=InitFunc::zero)
Definition: SOM.icpp:30
iter< cell_type const > const_iterator
std::tuple< std::size_t, std::size_t, double > findBMU(const std::array< double, ND > &input) const
Definition: SOM.icpp:107
const std::pair< std::size_t, std::size_t > & getSize() const
Definition: SOM.icpp:43
CellGridType m_cells
Definition: SOM.h:97
virtual ~SOM()=default
Destructor.
Representation of a multi-dimensional grid which contains axis information.
Definition: GridContainer.h:97
iterator begin()
Definition: SOM.icpp:58
std::array< double, ND > & operator()(std::size_t x, std::size_t y)
Definition: SOM.icpp:48
SOM & operator=(SOM< ND, DistFunc > &&)=default
iterator end()
Definition: SOM.icpp:63
typename CellGridType::iterator iterator
Definition: SOM.h:53
const_iterator cend()
Definition: SOM.icpp:83
typename CellGridType::const_iterator const_iterator
Definition: SOM.h:54
STL class.
std::pair< std::size_t, std::size_t > m_size
Definition: SOM.h:98
const_iterator cbegin()
Definition: SOM.icpp:78