Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
Function.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 MATHUTILS_FUNCTION_H
26#define MATHUTILS_FUNCTION_H
27
30#include <memory>
31#include <vector>
32
33namespace Euclid {
34namespace MathUtils {
35
41template <typename Seq>
43public:
44};
45
52template <std::size_t... Is>
54public:
55 template <std::size_t>
56 using Doubles = double;
57
58 template <std::size_t>
60
62 virtual ~NAryFunctionImpl() = default;
63
69 virtual double operator()(Doubles<Is>... xn) const = 0;
70
80 virtual void operator()(const Vectors<Is>&... xs, std::vector<double>& output) const {
81 output.resize(std::get<0>(std::tuple<const Vectors<Is>&...>(xs...)).size());
82 for (size_t i = 0; i < output.size(); ++i) {
83 output[i] = (*this)(xs[i]...);
84 }
85 }
86};
87
103template <std::size_t N>
104class NAryFunction : public NAryFunctionImpl<_make_index_sequence<N>> {
105public:
113};
114
117
120
123
124} // namespace MathUtils
125} // end of namespace Euclid
126
127#endif /* MATHUTILS_FUNCTION_H */
virtual double operator()(Doubles< Is >... xn) const =0
virtual void operator()(const Vectors< Is > &... xs, std::vector< double > &output) const
Definition Function.h:80
Interface class representing a function with an arbitrary number of parameters.
Definition Function.h:104
virtual std::unique_ptr< NAryFunction > clone() const =0
std::array< std::vector< double >, N > Coordinates
Used to pass the grid coordinates to interpn. Internally will make a copy of the required values.
T size(T... args)