bpp-seq3  3.0.0
UserAlphabetIndex2.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #ifndef BPP_SEQ_ALPHABETINDEX_USERALPHABETINDEX2_H
6 #define BPP_SEQ_ALPHABETINDEX_USERALPHABETINDEX2_H
7 
9 
10 #include "AlphabetIndex2.h"
11 
12 // From the STL:
13 #include <vector>
14 
15 namespace bpp
16 {
22  public virtual AlphabetIndex2
23 {
24 private:
25  std::shared_ptr<const Alphabet> alph_;
27  bool sym_;
28 
29 public:
30  UserAlphabetIndex2(std::shared_ptr<const Alphabet> alph, const Matrix<double>& mat) :
31  alph_(alph),
32  index_(mat),
33  sym_(false)
34  {
36  }
37 
39  alph_(uAlph.alph_),
40  index_(uAlph.index_),
41  sym_(uAlph.sym_)
42  {}
43 
45  {
46  alph_ = uAlph.alph_;
47  index_ = uAlph.index_;
48  sym_ = uAlph.sym_;
49 
50  return *this;
51  }
52 
53  virtual ~UserAlphabetIndex2() {}
54 
55  UserAlphabetIndex2* clone() const { return new UserAlphabetIndex2(*this); }
56 
57 public:
58  double getIndex(int state1, int state2) const
59  {
60  return index_(alph_->getStateIndex(state1) - 1, alph_->getStateIndex(state2) - 1);
61  }
62 
63  double getIndex(const std::string& state1, const std::string& state2) const
64  {
65  return index_(alph_->getStateIndex(state1) - 1, alph_->getStateIndex(state2) - 1);
66  }
67 
68  void setIndexMatrix(const Matrix<double>& mat)
69  {
70  index_ = mat;
72  }
73 
75 
76  std::shared_ptr<const Alphabet> getAlphabet() const { return alph_; }
77 
78  const Alphabet& alphabet() const { return *alph_; }
79 
83  virtual bool isSymmetric() const
84  {
85  return sym_;
86  }
87 };
88 } // end of namespace bpp.
89 #endif // BPP_SEQ_ALPHABETINDEX_USERALPHABETINDEX2_H
Two dimensionnal alphabet index interface.
The Alphabet interface.
Definition: Alphabet.h:99
static bool isSymmetric(const MatrixA &A)
Alphabet index given by user.
void setIndexMatrix(const Matrix< double > &mat)
std::shared_ptr< const Alphabet > getAlphabet() const
Get the alphabet associated to this index.
UserAlphabetIndex2 & operator=(const UserAlphabetIndex2 &uAlph)
LinearMatrix< double > * getIndexMatrix() const
double getIndex(const std::string &state1, const std::string &state2) const
Get the index associated to a pair of states.
UserAlphabetIndex2(const UserAlphabetIndex2 &uAlph)
virtual bool isSymmetric() const
std::shared_ptr< const Alphabet > alph_
LinearMatrix< double > index_
UserAlphabetIndex2(std::shared_ptr< const Alphabet > alph, const Matrix< double > &mat)
UserAlphabetIndex2 * clone() const
double getIndex(int state1, int state2) const
Get the index associated to a pair of states.
const Alphabet & alphabet() const
Get the alphabet associated to this index.
This alphabet is used to deal NumericAlphabet.