root/bdm/itpp_ext.h @ 266

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

switch to svn version of itpp

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