Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MathStuff.h
Go to the documentation of this file.
1 /*
2 * Copyright (C) 2007-2008 Anael Orlinski
3 *
4 * This file is part of Panomatic.
5 *
6 * Panomatic is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * Panomatic is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with Panomatic; if not, write to the Free Software
18 * <http://www.gnu.org/licenses/>.
19 */
20 
21 #ifndef __lfeat_math_h
22 #define __lfeat_math_h
23 
24 #include <vector>
25 
26 #define PI 3.14159
27 
28 namespace lfeat
29 {
30 struct Math
31 {
32 
33  static bool SolveLinearSystem33(double* solution, double sq[3][3]);
34  static bool Normalize(double* iVec, int iLen);
35 
36 
37 };
38 
39 template <int LBound = -128, int UBound = 127, class TResult = double, class TArg = double>
40 class LUT
41 {
42 public:
43  explicit LUT (TResult (*f) (TArg), double coeffadd = 0, double coeffmul = 1)
44  {
45  lut = lut_array - LBound;
46  for (int i = LBound; i <= UBound; i++)
47  {
48  lut[i] = f(coeffmul * (i+coeffadd));
49  }
50  }
51 
52  const TResult& operator()(int i) const
53  {
54  return lut[i];
55  }
56 private:
57  TResult lut_array[UBound - LBound + 1];
58  TResult* lut;
59 };
60 
61 }
62 
63 #endif //__lfeat_math_h
static bool SolveLinearSystem33(double *solution, double sq[3][3])
Definition: MathStuff.cpp:24
TResult lut_array[UBound-LBound+1]
Definition: MathStuff.h:57
static bool Normalize(double *iVec, int iLen)
Definition: MathStuff.cpp:84
LUT(TResult(*f)(TArg), double coeffadd=0, double coeffmul=1)
Definition: MathStuff.h:43
TResult * lut
Definition: MathStuff.h:58
const TResult & operator()(int i) const
Definition: MathStuff.h:52