Alexandria  2.16
Please provide a description of the project.
SOM.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2020 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 
28 #include <vector>
29 #include <array>
30 #include <limits>
31 #include <type_traits>
32 #include <tuple>
34 #include "SOM/InitFunc.h"
35 #include "SOM/Distance.h"
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:
52 
54  using iterator = typename CellGridType::iterator;
56 
58 
59  SOM(SOM<ND, DistFunc>&&) = default;
60  SOM& operator=(SOM<ND, DistFunc>&&) = default;
61 
65  virtual ~SOM() = default;
66 
68 
70 
72 
73  iterator begin();
74 
75  iterator end();
76 
77  const_iterator begin() const;
78 
79  const_iterator end() const;
80 
82 
84 
86 
88  const std::array<double, ND>& uncertainties) const;
89 
90  template <typename InputType, typename WeightFunc>
92  WeightFunc weight_func) const;
93 
94  template <typename InputType, typename WeightFunc, typename UncertaintyFunc>
96  WeightFunc weight_func,
97  UncertaintyFunc uncertainty_func) const;
98 
99 private:
100 
103 
104 }; /* End of SOM class */
105 
106 } /* namespace SOM */
107 } /* namespace Euclid */
108 
109 #include "SOM/_impl/SOM.icpp"
110 
111 #endif
SOM(std::size_t x, std::size_t y, InitFunc::Signature init_func=InitFunc::zero)
std::tuple< std::size_t, std::size_t, double > findBMU(const std::array< double, ND > &input) const
CellGridType m_cells
Definition: SOM.h:101
virtual ~SOM()=default
Destructor.
SOM & operator=(SOM< ND, DistFunc > &&)=default
iterator end()
const_iterator cbegin()
const_iterator cend()
typename CellGridType::iterator iterator
Definition: SOM.h:54
std::array< double, ND > & operator()(std::size_t x, std::size_t y)
typename CellGridType::const_iterator const_iterator
Definition: SOM.h:55
const std::pair< std::size_t, std::size_t > & getSize() const
STL class.
std::pair< std::size_t, std::size_t > m_size
Definition: SOM.h:102
iterator begin()