~ubuntu-branches/ubuntu/trusty/hugin/trusty-proposed

« back to all changes in this revision

Viewing changes to src/hugin_cpfind/localfeatures/MathStuff.h

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Metzler
  • Date: 2011-01-06 14:28:24 UTC
  • mfrom: (1.1.9 upstream) (0.1.21 experimental)
  • Revision ID: james.westby@ubuntu.com-20110106142824-zn9lxylg5z44dynn
* Drop Cyril Brulebois from Uploaders. Thank you very much for your work.
* Bump package version. (rc3 was re-released as 2010.4.0).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
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
struct Math {
 
30
 
 
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);
 
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