
#ifndef ___LOCALIZATIONFUNCTION_HPP___
#define ___LOCALIZATIONFUNCTION_HPP___

#include <vector>
#include <algorithm>
#include <complex>

#include "hark-lib/matrix.h"

//#ifdef ENABLE_LAPACK
//typedef std::vector<float> fvector;
//typedef std::vector<fcomplex> fcvector;
//typedef Matrix fmatrix;
//typedef Matrix fcmatrix;
//#else
//#include <boost/numeric/ublas/matrix.hpp>
//#include <boost/numeric/ublas/matrix_proxy.hpp>
//#include <boost/multi_array.hpp>
//typedef boost::numeric::ublas::vector<float> fvector;
//typedef boost::numeric::ublas::vector<fcomplex> fcvector;
//typedef boost::numeric::ublas::matrix<float> fmatrix;
//typedef boost::numeric::ublas::matrix<fcomplex> fcmatrix;
//typedef boost::multi_array<fcmatrix, 2> AMatrixArray;
//typedef boost::multi_array<fcmatrix, 3> AMatrixArray3D;
//#endif

//typedef boost::numeric::ublas::matrix<std::complex<double>,
//                                      boost::numeric::ublas::column_major> dcmatrix;

using namespace hark;

float MaxOfAbsValueFvector(std::vector<float>& A);
void mulfcomplex(std::complex<float>& a, std::complex<float>& b, std::complex<float>& c);
void addfcomplex(std::complex<float>& a, std::complex<float>& b, std::complex<float>& c);
void subfcomplex(std::complex<float>& a, std::complex<float>& b, std::complex<float>& c);
void devfcomplex(std::complex<float>& a, std::complex<float>& b, std::complex<float>& c);
void mulfcomplex_const(std::complex<float>& a, std::complex<float>& b, std::complex<float>& c);
void addfcomplex_const(std::complex<float>& a, std::complex<float>& b, std::complex<float>& c);
void subfcomplex_const(std::complex<float>& a, std::complex<float>& b, std::complex<float>& c);
void devfcomplex_const(std::complex<float>& a, std::complex<float>& b, std::complex<float>& c);
void mulMAT(Matrix<std::complex<float> >& a, Matrix<std::complex<float> >& b, Matrix<std::complex<float> >& c);
void invMAT(Matrix<std::complex<float> >& a, Matrix<std::complex<float> >& c);
void mulMATdot(Matrix<std::complex<float> >& a, Matrix<std::complex<float> >& b, Matrix<std::complex<float> >& c);
void devMATdot(Matrix<std::complex<float> >& a, Matrix<std::complex<float> >& b, Matrix<std::complex<float> >& c);

void zeroMAT(Matrix<std::complex<float> >& a, Matrix<std::complex<float> >& c);
void identityMAT(Matrix<std::complex<float> >& a, Matrix<std::complex<float> >& c);

void display_fcmat(Matrix<std::complex<float> >& a);
void read_fcmat(char *name1,char *name2, Matrix<std::complex<float> >& a);
int save_mat_fcmat(char *name1, char *name2, Matrix<std::complex<float> >& a);
int save_mat_fcmat_real(char *name1, Matrix<std::complex<float> >& a);
void save_mat_fmat_real(char *name1, Matrix<float>& a);

void AddToCorrelationAllFreq(std::vector<Matrix<std::complex<float> > >& Rxx, int FreqLength, Matrix<std::complex<float> >& X);
void NormalizeCorrelationAllFreq(std::vector<Matrix<std::complex<float> > >& Rxx, int FreqLength, int sum_count);
void ClearCorrelationAllFreq(std::vector<Matrix<std::complex<float> > >& Rxx, int FreqLength);
void LoadCorrelation(char *tmp_name1, char *tmp_name2, std::vector<Matrix<std::complex<float> > >& Rxx);
void SaveCorrelation(char *tmp_name1, char *tmp_name2, std::vector<Matrix<std::complex<float> > >& Rxx);

float powfloat(float a, float b);
void makeLambda(std::vector<float>& a, Matrix<std::complex<float> >& b, float decay);

void norm_display_fcmat(Matrix<std::complex<float> >& a);

void sort_eig_fvec_ascending(std::vector<float>& ai, Matrix<std::complex<float> >& bi, std::vector<float>& af, Matrix<std::complex<float> >& bf);
void sort_eig_fcvec_ascending(std::vector<std::complex<float> >& ai, Matrix<std::complex<float> >& bi, std::vector<float>& af, Matrix<std::complex<float> >& bf);
void sort_eig_fvec_descending(std::vector<float>& ai, Matrix<std::complex<float> >& bi, std::vector<float>& af, Matrix<std::complex<float> >& bf);
void sort_eig_fcvec_descending(std::vector<std::complex<float> >& ai, Matrix<std::complex<float> >& bi, std::vector<float>& af, Matrix<std::complex<float> >& bf);
/*
#ifdef ENABLE_LAPACK
#else
void ReadTransferFunction(const char* filename,
                          AMatrixArray& A,
                          std::vector<int>& search_dir,
                          std::vector<int>& search_range);

void ReadTransferFunction(const char* filename,
                          AMatrixArray& A,
                          std::vector<int>& search_dir,
                          std::vector<int>& search_range,
                          std::vector<int>& ch);

void ReadTransferFunction(const char* filename,
                          AMatrixArray3D& A,
                          std::vector<float>& search_height,
                          std::vector<float>& search_dir,
                          std::vector<float>& search_range);

void ReadTransferFunction(const char* filename,
                          AMatrixArray3D& A,
                          std::vector<float>& search_height,
                          std::vector<float>& search_dir,
                          std::vector<float>& search_range,
                          std::vector<int>& ch);
#endif
*/

#endif //___LOCALIZATIONFUNCTION_HPP___
