StochHMM  v0.34
Flexible Hidden Markov Model C++ Library and Application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
index.h
Go to the documentation of this file.
1 //
2 // index.h
3 
4 //Copyright (c) 2007-2012 Paul C Lott
5 //University of California, Davis
6 //Genome and Biomedical Sciences Facility
7 //UC Davis Genome Center
8 //Ian Korf Lab
9 //Website: www.korflab.ucdavis.edu
10 //Email: lottpaul@gmail.com
11 //
12 //Permission is hereby granted, free of charge, to any person obtaining a copy of
13 //this software and associated documentation files (the "Software"), to deal in
14 //the Software without restriction, including without limitation the rights to
15 //use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
16 //the Software, and to permit persons to whom the Software is furnished to do so,
17 //subject to the following conditions:
18 //
19 //The above copyright notice and this permission notice shall be included in all
20 //copies or substantial portions of the Software.
21 //
22 //THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 //IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
24 //FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
25 //COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
26 //IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 //CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 
29 #ifndef StochHMM_index_cpp
30 #define StochHMM_index_cpp
31 
32 #include <vector>
33 #include <algorithm>
34 #include <stdlib.h>
35 #include "stochMath.h"
36 namespace StochHMM{
37 
38  /* \class Index
39  \brief Class used for calculating index of word in the emission and transitions
40  This class is used to seemlessly work with ambiguious character and their index in the emission or lexical transition tables. If there is no ambiguous characters the index can be calculated as a int. However, if there is ambiguous character then it has multiple indices.
41  */
42  class Index{
43  public:
44  Index();
45  Index(const Index&);
46 
47  ~Index();
48 
49  /*! \fn bool isAmbiguous()
50  \brief Returns whether there is an ambiguous character
51  */
52  inline bool isAmbiguous(){return ambiguous;};
53 
54 
55  void setAmbiguous(const std::vector<size_t>&); //! Set the Index as ambiguous
56 
57 
58  Index& operator= (const Index&); //! Assign Index
59  Index operator+ (const Index&); //! Add Index
60  void operator += (const Index&); //! Add and assign Index
61  void operator += (const size_t); //!Add int to Index
62  void operator *= (const size_t); //!Multiply int to Index
63  Index operator* (const size_t); //!Multiply int to Index
64  size_t size(); //!Get Number of indices
65 
66  size_t operator[](const size_t);
67 
68  private:
69  size_t index;
70  std::vector<size_t>* amb;
71  bool ambiguous;
72  };
73 
74 
75 }
76 #endif