- Main Page
- Related Pages
- Classes
- Files

- File List
- File Members

# itpp_ext.h

    00001 //
    00002 // C++ Interface: itpp_ext
    00003 //
    00004 // Description:
    00005 //
    00006 //
    00007 // Author: smidl <smidl@utia.cas.cz>, (C) 2008
    00008 //
    00009 // Copyright: See COPYING file that comes with this distribution
    00010 //
    00011 //
    00012 #include <itpp/itbase.h>
    00013
    00014 #ifndef ITEX_H
    00015 #define ITEX_H
    00016
    00017 using std::cout;
    00018 using std::endl;
    00019
    00020 namespace itpp {
    00021 Array<int> to_Arr ( const ivec &indices );
    00022 ivec linspace ( int from, int to );
    00023
    00024 vec get_vec ( const vec &v, const ivec &indexlist );
    00025
    00026 bvec operator& ( const bvec &a, const bvec &b );
    00027 bvec operator| ( const bvec &a, const bvec &b );
    00028
    00029 bvec operator> ( const vec &t1, const vec &t2 );
    00030
    00031 bvec operator< ( const vec &t1, const vec &t2 );
    00032
    00033 // template<class Num_T>
    00034 // void set_subvector(vec &ov, ivec &iv, const Vec<Num_T> &v);
    00035
    00036 void set_subvector ( vec &ov, const ivec &iv, const vec &v );
    00037
    00038 template<class Num_T> inline
    00039 void set_col_part ( mat &M, int c, const Vec<Num_T> &v ) {
    00040         copy_vector ( v.size(), v._data(), M._data() + c*M.rows() );
    00041 }
    00042
    00043 const double inf = std::numeric_limits<double>::infinity();
    00044
    00045 #if 0
    00046
    00050 class Gamma_RNG {
    00051 public:
    00053         Gamma_RNG ( double a = 1.0, double b = 1.0 );
    00055         void setup ( double a0, double b0 ) {
    00056                 alpha = a0;
    00057                 beta = b0;
    00058         }
    00060         double get_setup() const;
    00062         double operator() () {
    00063                 return sample();
    00064         }
    00066         vec operator() ( int n );
    00068         mat operator() ( int h, int w );
    00069 protected:
    00070 private:
    00072         double sample();
    00074         double alpha;
    00076         double beta;
    00078         Random_Generator RNG;
    00079         Normal_RNG NRNG;
    00081         inline double exp_rand() {
    00082                 return -std::log ( RNG.random_01() );
    00083         }
    00084         inline double unif_rand() {
    00085                 return RNG.random_01();
    00086         }
    00087         inline double norm_rand() {
    00088                 return NRNG.sample();
    00089         }
    00090
    00091 };
    00092 bool qr ( const mat &A, mat &R );
    00093 #endif
    00095 std::string num2str ( double d );
    00096
    00098 std::string num2str ( int i );
    00099
    00101 double psi ( double );
    00102
    00104 void triu(mat &A);
    00105
    00109 double randun();
    00111 vec randun(int n);
    00113 mat randun(int n, int m);
    00114
    00116 ivec unique(const ivec &in);
    00117
    00119 ivec unique_complement(const ivec &in, const ivec &base);
    00120 }
    00121
    00122
    00123 #endif //ITEX_H