BenchUtil.h
Go to the documentation of this file.
00001 
00002 #ifndef EIGEN_BENCH_UTIL_H
00003 #define EIGEN_BENCH_UTIL_H
00004 
00005 #include <Eigen/Core>
00006 #include "BenchTimer.h"
00007 
00008 using namespace std;
00009 using namespace Eigen;
00010 
00011 #include <boost/preprocessor/repetition/enum_params.hpp>
00012 #include <boost/preprocessor/repetition.hpp>
00013 #include <boost/preprocessor/seq.hpp>
00014 #include <boost/preprocessor/array.hpp>
00015 #include <boost/preprocessor/arithmetic.hpp>
00016 #include <boost/preprocessor/comparison.hpp>
00017 #include <boost/preprocessor/punctuation.hpp>
00018 #include <boost/preprocessor/punctuation/comma.hpp>
00019 #include <boost/preprocessor/stringize.hpp>
00020 
00021 template<typename MatrixType> void initMatrix_random(MatrixType& mat) __attribute__((noinline));
00022 template<typename MatrixType> void initMatrix_random(MatrixType& mat)
00023 {
00024   mat.setRandom();// = MatrixType::random(mat.rows(), mat.cols());
00025 }
00026 
00027 template<typename MatrixType> void initMatrix_identity(MatrixType& mat) __attribute__((noinline));
00028 template<typename MatrixType> void initMatrix_identity(MatrixType& mat)
00029 {
00030   mat.setIdentity();
00031 }
00032 
00033 #ifndef __INTEL_COMPILER
00034 #define DISABLE_SSE_EXCEPTIONS()  { \
00035   int aux; \
00036   asm( \
00037   "stmxcsr   %[aux]           \n\t" \
00038   "orl       $32832, %[aux]   \n\t" \
00039   "ldmxcsr   %[aux]           \n\t" \
00040   : : [aux] "m" (aux)); \
00041 }
00042 #else
00043 #define DISABLE_SSE_EXCEPTIONS()  
00044 #endif
00045 
00046 #ifdef BENCH_GMM
00047 #include <gmm/gmm.h>
00048 template <typename EigenMatrixType, typename GmmMatrixType>
00049 void eiToGmm(const EigenMatrixType& src, GmmMatrixType& dst)
00050 {
00051   dst.resize(src.rows(),src.cols());
00052   for (int j=0; j<src.cols(); ++j)
00053     for (int i=0; i<src.rows(); ++i)
00054       dst(i,j) = src.coeff(i,j);
00055 }
00056 #endif
00057 
00058 
00059 #ifdef BENCH_GSL
00060 #include <gsl/gsl_matrix.h>
00061 #include <gsl/gsl_linalg.h>
00062 #include <gsl/gsl_eigen.h>
00063 template <typename EigenMatrixType>
00064 void eiToGsl(const EigenMatrixType& src, gsl_matrix** dst)
00065 {
00066   for (int j=0; j<src.cols(); ++j)
00067     for (int i=0; i<src.rows(); ++i)
00068       gsl_matrix_set(*dst, i, j, src.coeff(i,j));
00069 }
00070 #endif
00071 
00072 #endif // EIGEN_BENCH_UTIL_H


re_vision
Author(s): Dorian Galvez-Lopez
autogenerated on Sun Jan 5 2014 11:30:47