root/library/bdm/itpp_ext.h @ 661

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

doc

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