root/bdm/itpp_ext.h @ 86

Revision 86, 1.2 kB (checked in by smidl, 16 years ago)

linspace ITpp extenion

  • 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
24/*!
25  \brief Gamma distribution
26  \ingroup randgen
27*/
28class Gamma_RNG {
29public:
30//! constructor. Set lambda.
31Gamma_RNG ( double a=1.0, double b=1.0 );
32        //! Set lambda
33        void setup ( double a0, double b0 ) { alpha=a0; beta=b0;}
34        //! get lambda
35        double get_setup() const;
36        //! Get one sample.
37        double operator() () { return sample(); }
38        //! Get a sample vector.
39        vec operator() ( int n );
40        //! Get a sample matrix.
41        mat operator() ( int h, int w );
42protected:
43private:
44        //!
45        double sample();
46        //!
47        double alpha;
48        //!
49        double beta;
50        //!
51        Random_Generator RNG;
52        Normal_RNG NRNG;
53        //! compatibility with R
54        inline double exp_rand() {return -std::log ( RNG.random_01() );}
55        inline double unif_rand() {return RNG.random_01();}
56        inline double norm_rand() {return NRNG.sample();}
57
58};
59
60bool qr ( const mat &A, mat &R );
61
62}
63#endif //ITEX_H
Note: See TracBrowser for help on using the browser.