MathStuff.h

Go to the documentation of this file.
00001 /*
00002 * Copyright (C) 2007-2008 Anael Orlinski
00003 *
00004 * This file is part of Panomatic.
00005 *
00006 * Panomatic is free software; you can redistribute it and/or modify
00007 * it under the terms of the GNU General Public License as published by
00008 * the Free Software Foundation; either version 2 of the License, or
00009 * (at your option) any later version.
00010 *
00011 * Panomatic is distributed in the hope that it will be useful,
00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 * GNU General Public License for more details.
00015 *
00016 * You should have received a copy of the GNU General Public License
00017 * along with Panomatic; if not, write to the Free Software
00018 * <http://www.gnu.org/licenses/>.
00019 */
00020 
00021 #ifndef __lfeat_math_h
00022 #define __lfeat_math_h
00023 
00024 #include <vector>
00025 
00026 #define PI      3.14159
00027 
00028 namespace lfeat
00029 {
00030 struct Math
00031 {
00032 
00033     static bool                         SolveLinearSystem33(double* solution, double sq[3][3]);
00034     static bool                         Normalize(double* iVec, int iLen);
00035 
00036 
00037 };
00038 
00039 template <int LBound = -128, int UBound = 127, class TResult = double, class TArg = double>
00040 class LUT
00041 {
00042 public:
00043     explicit LUT (TResult (*f) (TArg), double coeffadd = 0, double coeffmul = 1)
00044     {
00045         lut = lut_array - LBound;
00046         for (int i = LBound; i <= UBound; i++)
00047         {
00048             lut[i] = f(coeffmul * (i+coeffadd));
00049         }
00050     }
00051 
00052     const TResult& operator()(int i) const
00053     {
00054         return lut[i];
00055     }
00056 private:
00057     TResult lut_array[UBound - LBound + 1];
00058     TResult* lut;
00059 };
00060 
00061 }
00062 
00063 #endif //__lfeat_math_h

Generated on 1 Jul 2016 for Hugintrunk by  doxygen 1.4.7