root/library/bdm/itpp_ext.h @ 737

Revision 737, 2.8 kB (checked in by mido, 15 years ago)

ASTYLER RUN OVER THE WHOLE LIBRARY, JUPEE

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