root/library/bdm/itpp_ext.h @ 679

Revision 679, 2.7 kB (checked in by smidl, 15 years ago)

Major changes in BM -- OK is only test suite and tests/tutorial -- the rest is broken!!!

  • 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        extern vec empty_vec;
22       
23Array<int> to_Arr ( const ivec &indices );
24ivec linspace ( int from, int to );
25
26vec get_vec ( const vec &v, const ivec &indexlist );
27
28bvec operator& ( const bvec &a, const bvec &b );
29bvec operator| ( const bvec &a, const bvec &b );
30
31bvec operator> ( const vec &t1, const vec &t2 );
32
33bvec operator< ( const vec &t1, const vec &t2 );
34
35// template<class Num_T>
36// void set_subvector(vec &ov, ivec &iv, const Vec<Num_T> &v);
37
38void set_subvector ( vec &ov, const ivec &iv, const vec &v );
39
40template<class Num_T> inline
41void set_col_part ( mat &M, int c, const Vec<Num_T> &v ) {
42        copy_vector ( v.size(), v._data(), M._data() + c*M.rows() );
43}
44
45const double inf = std::numeric_limits<double>::infinity();
46
47//#if 0
48/*!
49  \brief Gamma distribution
50  \ingroup randgen
51*/
52class Gamma_RNG {
53public:
54//! constructor. Set lambda.
55        Gamma_RNG ( double a = 1.0, double b = 1.0 );
56        //! Set lambda
57        void setup ( double a0, double b0 ) {
58                alpha = a0;
59                beta = b0;
60        }
61        //! get lambda
62        double get_setup() const;
63        //! Get one sample.
64        double operator() () {
65                return sample();
66        }
67        //! Get a sample vector.
68        vec operator() ( int n );
69        //! Get a sample matrix.
70        mat operator() ( int h, int w );
71protected:
72private:
73        //!
74        double sample();
75        //!
76        double alpha;
77        //!
78        double beta;
79        //!
80        Random_Generator RNG;
81        Normal_RNG NRNG;
82        //! compatibility with R
83        inline double exp_rand() {
84                return -std::log ( RNG.random_01() );
85        }
86        inline double unif_rand() {
87                return RNG.random_01();
88        }
89        inline double norm_rand() {
90                return NRNG.sample();
91        }
92
93};
94bool qr ( const mat &A, mat &R );
95//#endif
96//! reimplementation of matlab num2str
97std::string num2str ( double d );
98
99//! reimplementation of matlabs num2str
100std::string num2str ( int i );
101
102//! implementation of digamma (psi) function
103double psi ( double );
104
105//! implementation of matlab triu function
106void triu(mat &A);
107
108//! implementation of Mixtools function randun
109//! This function uses Park-Miller linear congruential pseudo-random generator with A=16807 B=0 M=2^31-1
110//!     (it spans all 2^31-1 numbers and has good statistical properties)
111double randun();
112//! implementation of Mixtools function randun
113vec randun(int n);
114//! implementation of Mixtools function randun
115mat randun(int n, int m);
116
117//! function returns unique entries in input vector \c in
118ivec unique(const ivec &in);
119
120//! function returns unique entries of vector \c in that are not present in vector \c base
121ivec unique_complement(const ivec &in, const ivec &base);
122}
123
124
125#endif //ITEX_H
Note: See TracBrowser for help on using the browser.