root/library/bdm/itpp_ext.h @ 404

Revision 404, 2.1 kB (checked in by smidl, 15 years ago)

Change in epdf: evallog returns -inf for points out of support. Merger is aware of it now.

  • Property svn:eol-style set to native
Line 
1//
2// C++ Interface: itpp_ext
3//
4// Description:
5//
6//
7// Author: smidl <smidl@utia.cas.cz>, (C) 2008
8//
9// Copyright: See COPYING file that comes with this distribution
10//
11//
12#include <itpp/itbase.h>
13
14#ifndef ITEX_H
15#define ITEX_H
16
17using std::cout;
18using std::endl;
19
20namespace itpp {
21        Array<int> to_Arr ( const ivec &indices );
22        ivec linspace ( int from, int to );
23
24        vec get_vec(const vec &v, const ivec &indexlist);
25       
26        bvec operator& ( const bvec &a, const bvec &b );
27        bvec operator| ( const bvec &a, const bvec &b );
28       
29        bvec operator>(const vec &t1, const vec &t2); 
30
31        bvec operator<(const vec &t1, const vec &t2); 
32
33        // template<class Num_T>
34// void set_subvector(vec &ov, ivec &iv, const Vec<Num_T> &v);
35
36        void set_subvector ( vec &ov, const ivec &iv, const vec &v );
37
38        template<class Num_T> inline
39        void set_col_part(mat &M, int c, const Vec<Num_T> &v)
40        {
41                copy_vector(v.size(), v._data(), M._data() + c*M.rows());
42        }
43
44        const double inf =std::numeric_limits<double>::infinity();
45       
46//#if 0
47        /*!
48          \brief Gamma distribution
49          \ingroup randgen
50        */
51        class Gamma_RNG {
52                public:
53//! constructor. Set lambda.
54                        Gamma_RNG ( double a=1.0, double b=1.0 );
55                        //! Set lambda
56                        void setup ( double a0, double b0 ) { alpha=a0; beta=b0;}
57                        //! get lambda
58                        double get_setup() const;
59                        //! Get one sample.
60                        double operator() () { return sample(); }
61                        //! Get a sample vector.
62                        vec operator() ( int n );
63                        //! Get a sample matrix.
64                        mat operator() ( int h, int w );
65                protected:
66                private:
67                        //!
68                        double sample();
69                        //!
70                        double alpha;
71                        //!
72                        double beta;
73                        //!
74                        Random_Generator RNG;
75                        Normal_RNG NRNG;
76                        //! compatibility with R
77                        inline double exp_rand() {return -std::log ( RNG.random_01() );}
78                        inline double unif_rand() {return RNG.random_01();}
79                        inline double norm_rand() {return NRNG.sample();}
80
81        };
82        bool qr ( const mat &A, mat &R );
83//#endif
84        //! reimplementation of matlab num2str
85        std::string num2str(double d);
86
87        //! reimplementation of matlabs num2str
88        std::string num2str(int i);
89
90        //! implementation of digamma (psi) function
91        double psi(double);
92}
93
94
95#endif //ITEX_H
Note: See TracBrowser for help on using the browser.