// // C++ Interface: itpp_ext // // Description: // // // Author: smidl , (C) 2008 // // Copyright: See COPYING file that comes with this distribution // // #include #ifndef ITEX_H #define ITEX_H using std::cout; using std::endl; namespace itpp { Array to_Arr ( const ivec &indices ); ivec linspace ( int from, int to ); vec get_vec(const vec &v, const ivec &indexlist); bvec operator& ( const bvec &a, const bvec &b ); bvec operator| ( const bvec &a, const bvec &b ); // template // void set_subvector(vec &ov, ivec &iv, const Vec &v); void set_subvector ( vec &ov, const ivec &iv, const vec &v ); template inline void set_col_part(mat &M, int c, const Vec &v) { copy_vector(v.size(), v._data(), M._data() + c*M.rows()); } /*! \brief Gamma distribution \ingroup randgen */ class Gamma_RNG { public: //! constructor. Set lambda. Gamma_RNG ( double a=1.0, double b=1.0 ); //! Set lambda void setup ( double a0, double b0 ) { alpha=a0; beta=b0;} //! get lambda double get_setup() const; //! Get one sample. double operator() () { return sample(); } //! Get a sample vector. vec operator() ( int n ); //! Get a sample matrix. mat operator() ( int h, int w ); protected: private: //! double sample(); //! double alpha; //! double beta; //! Random_Generator RNG; Normal_RNG NRNG; //! compatibility with R inline double exp_rand() {return -std::log ( RNG.random_01() );} inline double unif_rand() {return RNG.random_01();} inline double norm_rand() {return NRNG.sample();} }; bool qr ( const mat &A, mat &R ); //! reimplementation of matlab num2str std::string num2str(double d); //! reimplementation of matlabs num2str std::string num2str(int i); //! implementation of digamma (psi) function double psi(double); } #endif //ITEX_H