Alexandria  2.18
Please provide a description of the project.
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;
60 
64  virtual ~SOM() = default;
65 
67 
69 
71 
73 
75 
77 
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
std::tuple< std::size_t, std::size_t, double > findBMU(const std::array< double, ND > &input, const std::array< double, ND > &uncertainties) const
std::pair< std::size_t, std::size_t > m_size
Definition: SOM.h:98
iterator begin()
iterator end()
SOM & operator=(SOM< ND, DistFunc > &&)=default
const std::pair< std::size_t, std::size_t > & getSize() const
const_iterator cend()
const_iterator begin() const
SOM(std::size_t x, std::size_t y, InitFunc::Signature init_func=InitFunc::zero)
std::array< double, ND > & operator()(std::size_t x, std::size_t y)
typename CellGridType::const_iterator const_iterator
Definition: SOM.h:54
typename CellGridType::iterator iterator
Definition: SOM.h:53
std::tuple< std::size_t, std::size_t, double > findBMU(const InputType &input, WeightFunc weight_func, UncertaintyFunc uncertainty_func) const
virtual ~SOM()=default
Destructor.
CellGridType m_cells
Definition: SOM.h:97
std::tuple< std::size_t, std::size_t, double > findBMU(const InputType &input, WeightFunc weight_func) const
SOM(SOM< ND, DistFunc > &&)=default
const_iterator cbegin()
const_iterator end() const
const std::array< double, ND > & operator()(std::size_t x, std::size_t y) const
std::tuple< std::size_t, std::size_t, double > findBMU(const std::array< double, ND > &input) const