Marmote Core
The project aims at realizing the prototype of a software environment dedicated to modeling with Markov chains.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations
alias.h
Go to the documentation of this file.
1 
2 /* Copyright(C) (2002) (ID - IMAG) <Florent.Morata@imag.fr> */
3 
4 /*
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  */
19 
20 
29 #ifndef _ALIAS_H_
30 #define _ALIAS_H_
31 
32 #include <vector>
33 #include <string>
34 #include <fstream>
35 #include <cmath>
36 
38 using namespace std;
39 
40 #include "hbf.h"
41 
43 const double EPS = 1e-12;
44 
46 typedef vector<int>::iterator iteri;
48 typedef vector<double>::iterator iterd;
49 
51 typedef double Threshold;
53 typedef int Index;
54 
55 
61 class Alias{
62  private:
66  struct AliasStruct{
68  Threshold t;
70  Index col;
72  Index alias;
73  };
74 
76  typedef struct AliasStruct stock;
78  vector<stock> S;
79 
80 
81  public:
82 
83  int size() const;
84  double threshold(const int i) const;
85  int col(const int i) const;
86  int alias(const int i) const;
87  void init(const int d);
88  void mk_walker(const int d);
89  void transpose(const int d);
90  int read(const string path);
91  void write_construct(const string file_name,const int d);
92  int walk(const double rand,const int j,const int n,const int d,const int i);
93 };
94 
95 
96 
97 #include "alias.inl"
98 
99 
100 #endif