root/bdm/itpp_ext.h @ 276

Revision 276, 1.8 kB (checked in by smidl, 15 years ago)

support itpp 4.0.6 (again)

  • 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// template<class Num_T>
30// void set_subvector(vec &ov, ivec &iv, const Vec<Num_T> &v);
31
32        void set_subvector ( vec &ov, const ivec &iv, const vec &v );
33
34        template<class Num_T> inline
35        void set_col_part(mat &M, int c, const Vec<Num_T> &v)
36        {
37                copy_vector(v.size(), v._data(), M._data() + c*M.rows());
38        }
39
40        /*!
41          \brief Gamma distribution
42          \ingroup randgen
43        */
44        class Gamma_RNG {
45                public:
46//! constructor. Set lambda.
47                        Gamma_RNG ( double a=1.0, double b=1.0 );
48                        //! Set lambda
49                        void setup ( double a0, double b0 ) { alpha=a0; beta=b0;}
50                        //! get lambda
51                        double get_setup() const;
52                        //! Get one sample.
53                        double operator() () { return sample(); }
54                        //! Get a sample vector.
55                        vec operator() ( int n );
56                        //! Get a sample matrix.
57                        mat operator() ( int h, int w );
58                protected:
59                private:
60                        //!
61                        double sample();
62                        //!
63                        double alpha;
64                        //!
65                        double beta;
66                        //!
67                        Random_Generator RNG;
68                        Normal_RNG NRNG;
69                        //! compatibility with R
70                        inline double exp_rand() {return -std::log ( RNG.random_01() );}
71                        inline double unif_rand() {return RNG.random_01();}
72                        inline double norm_rand() {return NRNG.sample();}
73
74        };
75        bool qr ( const mat &A, mat &R );
76
77        //! reimplementation of matlab num2str
78        std::string num2str(double d);
79
80        //! reimplementation of matlabs num2str
81        std::string num2str(int i);
82}
83
84
85#endif //ITEX_H
Note: See TracBrowser for help on using the browser.