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


or_libs
Author(s): Viktor Seib
autogenerated on Tue Jan 7 2014 11:24:03