2
* Copyright (C) 2007-2008 Anael Orlinski
4
* This file is part of Panomatic.
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.
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.
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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
#ifndef __lfeat_math_h
22
#define __lfeat_math_h
31
static bool SolveLinearSystem33(double *solution, double sq[3][3]);
32
static inline double Abs(const double iD) { return (iD > 0.0 ? iD : -iD); }
33
static inline int Round(const double iD) { return (int)(iD + 0.5); }
34
static bool Normalize(double* iVec, int iLen);
39
template <int LBound = -128, int UBound = 127, class TResult = double, class TArg = double>
43
explicit LUT (TResult (*f) (TArg), double coeffadd = 0, double coeffmul = 1)
45
lut = lut_array - LBound;
46
for (int i = LBound; i <= UBound; i++)
48
lut[i] = f(coeffmul * (i+coeffadd));
52
const TResult & operator()(int i) const
57
TResult lut_array[UBound - LBound + 1];
63
#endif //__lfeat_math_h