Geogram Version 1.9.6-rc
A programming library of geometric algorithms
Loading...
Searching...
No Matches
linear_least_squares.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2000-2022 Inria
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 * * Neither the name of the ALICE Project-Team nor the names of its
14 * contributors may be used to endorse or promote products derived from this
15 * software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 * POSSIBILITY OF SUCH DAMAGE.
28 *
29 * Contact: Bruno Levy
30 *
31 * https://www.inria.fr/fr/bruno-levy
32 *
33 * Inria,
34 * Domaine de Voluceau,
35 * 78150 Le Chesnay - Rocquencourt
36 * FRANCE
37 *
38 */
39
40#ifndef H_EXPLORAGRAM_OPTIMAL_TRANSPORT_LINEAR_LEAST_SQUARES_H
41#define H_EXPLORAGRAM_OPTIMAL_TRANSPORT_LINEAR_LEAST_SQUARES_H
42
45
53namespace GEO {
54
64 public:
70
74 void begin();
75
82 void end();
83
91 void add_point(const double* p, double v);
92
100 double eval(const double* p) const;
101
102 protected:
103
109 void add_point_degree_1(const double* p, double v);
110
116 void add_point_degree_2(const double* p, double v);
117
121 index_t dim() const {
122 return dim_;
123 }
124
132 void eval_basis(const double* p, double* b) const;
133
137 static const int MAX_DIM = 10;
138
139 private:
140 index_t degree_;
141 index_t dim_;
142 Matrix<4,double> AtA_4_;
143 Matrix<10,double> AtA_10_;
144 double Atb_[MAX_DIM];
145 double eqn_[MAX_DIM];
146 };
147}
148
149#endif
Computes the linear least squares regression of a function evaluated in 3d.
void add_point_degree_1(const double *p, double v)
Implementation of add_point() for degree 1.
LinearLeastSquares(index_t degree)
Constructs a new LinearLeastSquares.
void eval_basis(const double *p, double *b) const
Evaluates the function basis at a given point.
void add_point_degree_2(const double *p, double v)
Implementation of add_point() for degree 2.
double eval(const double *p) const
Evaluates the least-squares linear estimate at a given point.
void end()
Ends the current computation.
void begin()
Starts a new computation.
void add_point(const double *p, double v)
Adds a sample to the current computation.
index_t dim() const
Gets the dimension of the function basis.
A matrix type.
Definition matrix.h:66
#define EXPLORAGRAM_API
Linkage declaration for exploragram symbols.
Definition defs.h:18
Included by all headers in exploragram.
Generic matrix type.
Global Vorpaline namespace.
Definition basic.h:55
geo_index_t index_t
The type for storing and manipulating indices.
Definition numeric.h:329