Documentation of MARTY
A Modern ARtificial Theoretical phYsicist
semiSimpleAlgebra.h
Go to the documentation of this file.
1 // This file is part of MARTY.
2 //
3 // MARTY is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // MARTY is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with MARTY. If not, see <https://www.gnu.org/licenses/>.
15 
26 #ifndef SEMISIMPLEALGEBRA_H_INCLUDED
27 #define SEMISIMPLEALGEBRA_H_INCLUDED
28 
29 #include <vector>
30 #include <algorithm>
31 #include <iostream>
32 #include <initializer_list>
33 #include <string>
34 #include <csl.h>
35 #include "algebraState.h"
36 
37 //Forward declaration of Irrep and SumIrrep
38 namespace mty {
39 class Irrep;
40 class SumIrrep;
41 }
42 
47 namespace mty::algebra {
48 
52  enum class Type {
53  R,
54  A,
55  B,
56  C,
57  D,
58  E6,
59  E7,
60  E8,
61  F4,
62  G2,
63  };
64 
72  std::ostream& operator<<(std::ostream& fout, mty::algebra::Type obj);
73 }
74 
75 namespace mty {
76 
77 int getCoxeterNumber(
78  algebra::Type type,
79  int l = 0
80  );
81 
82 struct IndexData {
83  AlgebraState state;
84  size_t p;
85  csl::Expr index;
86 };
87 
97 
98  public:
99 
104  explicit
105  SemiSimpleAlgebra(int t_l);
106 
110  virtual
112 
136  csl::Expr getQuadraticCasimir(const AlgebraState& irrep) const;
137 
138  virtual csl::Expr getIndex(
139  const Irrep& irrep,
140  size_t n) const;
141 
149  virtual
150  Irrep highestWeightRep(const AlgebraState& highestWeight, bool mult = true) const;
151 
160  virtual
161  Irrep highestWeightRep(const std::vector<int>& highestWeight, bool mult = true) const;
162 
168  virtual
169  Irrep getTrivialRep() const;
170 
171  virtual
172  Irrep getDefiningRep() const;
173 
183  virtual
184  SumIrrep tensorProduct(const Irrep& A,
185  const Irrep& B,
186  bool mult = true) const;
187  virtual
188  SumIrrep tensorProduct(const SumIrrep& A,
189  const Irrep& B,
190  bool mult = true) const;
191  virtual
192  SumIrrep tensorProduct(const Irrep& A,
193  const SumIrrep& B,
194  bool mult = true) const;
195  SumIrrep tensorProduct(const SumIrrep& A,
196  const SumIrrep& B,
197  bool mult = true) const;
198 
207  virtual
208  void sortRep(std::vector<AlgebraState>& rep,
209  std::vector<int>& mult) const;
210 
216  int getOrderL() const;
217 
222  virtual
223  algebra::Type getType() const = 0;
224 
225  protected:
226 
231  void init();
232 
237  virtual
238  void setCartanMatrix() = 0;
239 
244  virtual
245  void setSquaredNorm() = 0;
246 
247  virtual csl::Expr getEta() const {
248  return CSL_2;
249  }
250 
251  private:
252 
260  static bool isPositiveRoot(const std::vector<int>& root);
261 
269  static bool isPositiveWeight(const AlgebraState& state);
270 
278  static AlgebraState addWeights(const AlgebraState& A,
279  const AlgebraState& B);
280 
289  bool isOnWall(const AlgebraState& state) const;
290 
308  AlgebraState toDominantWeylChamber(const AlgebraState& state,
309  int& sign) const;
310 
318  std::vector<int> weylReflection(int simpleRoot,
319  const std::vector<int>& root) const;
320 
327  AlgebraState weylReflection(int simpleRoot,
328  const AlgebraState& state) const;
329 
336  std::vector<int> weylReflection(int simpleRoot1,
337  int simpleRoot2) const;
338 
345  void invertCartanMatrix();
346 
355  void generateWeylGroup();
356 
367  csl::Expr convertState(const AlgebraState& state) const;
368 
378  bool comparatorHighest(const AlgebraState& A,
379  const AlgebraState& B) const;
380 
391  csl::Expr computeScalarDot(const csl::Expr& rootA,
392  const csl::Expr& rootB) const;
393 
400  csl::Expr computeSquaredNorm(const csl::Expr& root) const;
401 
409  AlgebraState applyAnnihilationOperator(int annihilator,
410  const AlgebraState& state) const;
411 
419  AlgebraState applyAnnihilationOperator(const std::vector<int>& root,
420  const AlgebraState& state) const;
421 
429  AlgebraState applyCreationOperator(int creator,
430  const AlgebraState& state) const;
431 
439  AlgebraState applyCreationOperator(const std::vector<int>& root,
440  const AlgebraState& state) const;
441 
453  std::vector<AlgebraState> getSingleChain(
454  const AlgebraState& state,
455  int direction) const;
456 
457  void getSingleChainExperimental(
458  const AlgebraState& state,
459  std::vector<AlgebraState> &states,
460  std::vector<std::vector<bool>> &directionExplored,
461  int direction) const;
462 
480  std::vector<AlgebraState> getRootChain(
481  const AlgebraState& highestWeightState,
482  std::vector<AlgebraState> states
483  = std::vector<AlgebraState>(0),
484  std::vector<std::vector<bool> > directions
485  = std::vector<std::vector<bool> >(0)) const;
486 
487  void getRootChainExperimental(
488  const AlgebraState& highestWeightState,
489  std::vector<AlgebraState> &states,
490  std::vector<std::vector<bool> > &directions) const;
491 
503  void computeMultiplicity(std::vector<int>& multiplicities,
504  const std::vector<AlgebraState>& rep,
505  const AlgebraState& state) const;
506 
513  std::vector<int> multiplicities(std::vector<AlgebraState>& rep) const;
514 
522  friend
523  std::ostream& operator<<(std::ostream& fout,
524  const SemiSimpleAlgebra& algebra);
525 
526  protected:
527 
531  const int l;
532 
540  std::vector<int> rho;
541 
546  csl::vector_expr absoluteNorms;
547 
552  std::vector<int> squaredNorm;
553 
559  std::vector<std::vector<int>> positiveRoots;
560 
564  std::vector<std::vector<int>> cartanMatrix;
565 
570  std::vector<std::vector<int>> rootMetric;
571 
577 
582 
587 
593 
598  csl::vector_expr symbolicRoots;
599 
603  csl::vector_expr symbolicSquaredNorms;
604 
605  mutable
606  std::vector<std::pair<AlgebraState, Irrep>> irreps;
607 
608  mutable std::vector<IndexData> indices;
609 };
610 
611 } // End of namespace mty
612 
617 namespace mty::algebra{
618 
629 class R: public mty::SemiSimpleAlgebra{
630 
631  public:
632 
636  R();
637 
641  ~R(){};
642 
643  algebra::Type getType() const override;
644 
649  void setCartanMatrix() override;
650 
655  void setSquaredNorm() override;
656 
662  mty::Irrep highestWeightRep(
663  const mty::AlgebraState& highestWeight,
664  bool mult = true) const override;
665 
671  mty::Irrep highestWeightRep(
672  const std::vector<int>& highestWeight,
673  bool mult = true) const override;
674 
678  mty::Irrep getTrivialRep() const override;
679 
687  mty::SumIrrep tensorProduct(const mty::Irrep& A,
688  const mty::Irrep& B,
689  bool mult = true) const override;
690 
697  void sortRep(std::vector<mty::AlgebraState>& rep,
698  std::vector<int>& mult) const override;
699 
700  csl::Expr getEta() const override {
701  return CSL_0;
702  }
703 };
704 
709 class A: public mty::SemiSimpleAlgebra{
710 
711  public:
712 
717  explicit
718  A(int t_l);
719 
723  ~A(){};
724 
725  algebra::Type getType() const override;
726 
727  void setCartanMatrix() override;
728 
729  void setSquaredNorm() override;
730 
731  csl::Expr getEta() const override {
732  return CSL_1;
733  }
734 
735  mty::Irrep getDefiningRep() const override;
736 };
737 
742 class B: public mty::SemiSimpleAlgebra{
743 
744  public:
745 
750  explicit
751  B(int t_l);
752 
756  ~B(){};
757 
758  algebra::Type getType() const override;
759 
760  void setCartanMatrix() override;
761 
762  void setSquaredNorm() override;
763 
764  mty::Irrep getDefiningRep() const override;
765 };
766 
771 class C: public mty::SemiSimpleAlgebra{
772 
773  public:
774 
779  explicit
780  C(int t_l);
781 
785  ~C(){};
786 
787  algebra::Type getType() const override;
788 
789  void setCartanMatrix() override;
790 
791  void setSquaredNorm() override;
792 
793  mty::Irrep getDefiningRep() const override;
794 };
795 
800 class D: public mty::SemiSimpleAlgebra{
801 
802  public:
803 
808  explicit
809  D(int t_l);
810 
814  ~D(){};
815 
816  algebra::Type getType() const override;
817 
818  void setCartanMatrix() override;
819 
820  void setSquaredNorm() override;
821 
822  mty::Irrep getDefiningRep() const override;
823 };
824 
830 
831  public:
832 
836  E6();
837 
841  ~E6(){};
842 
843  algebra::Type getType() const override;
844 
845  void setCartanMatrix() override;
846 
847  void setSquaredNorm() override;
848 
849  mty::Irrep getDefiningRep() const override;
850 };
851 
857 
858  public:
859 
863  E7();
864 
868  ~E7(){};
869 
870  algebra::Type getType() const override;
871 
872  void setCartanMatrix() override;
873 
874  void setSquaredNorm() override;
875 
876  mty::Irrep getDefiningRep() const override;
877 };
878 
884 
885  public:
886 
890  E8();
891 
895  ~E8(){};
896 
897  algebra::Type getType() const override;
898 
899  void setCartanMatrix() override;
900 
901  void setSquaredNorm() override;
902 
903  mty::Irrep getDefiningRep() const override;
904 };
905 
911 
912  public:
913 
917  F4();
918 
922  ~F4(){};
923 
924  algebra::Type getType() const override;
925 
926  void setCartanMatrix() override;
927 
928  void setSquaredNorm() override;
929 
930  mty::Irrep getDefiningRep() const override;
931 };
932 
938 
939  public:
940 
944  G2();
945 
949  ~G2(){};
950 
951  algebra::Type getType() const override;
952 
953  void setCartanMatrix() override;
954 
955  void setSquaredNorm() override;
956 
957  mty::Irrep getDefiningRep() const override;
958 };
959 } // End of namespace mty::algebra
960 
962 /*************************************************/
963 // Helper functions in calculations in .cpp //
964 /*************************************************/
966 
967 template<typename T>
968 std::ostream& operator<<(std::ostream& fout, const std::vector<T>& vec)
969 {
970  for (const auto& el : vec)
971  fout << el << " ";
972  fout << std::endl;
973 
974  return fout;
975 }
976 
977 template<typename T>
978 int findInVector(const std::vector<T>& v,
979  const T & element)
980 {
981  const typename std::vector<T>::const_iterator iter
982  = find(v.begin(), v.end(), element);
983  if (iter != v.end())
984  return distance(v.begin(), iter);
985  return -1;
986 }
987 
988 template<typename T>
989 int binaryFindInVector(const std::vector<T>& v,
990  const T & element)
991 {
992  size_t a = 0;
993  size_t b = v.size();
994  while (b != a) {
995  const auto middleIndex = (a+b) / 2;
996  const auto middle = v[middleIndex];
997  if (element < middle) {
998  b = middleIndex;
999  }
1000  else if (middle < element) {
1001  a = middleIndex;
1002  }
1003  else
1004  return middleIndex;
1005  }
1006  return -1;
1007 }
1008 
1009 template<typename T>
1010 bool addCarefully(std::vector<T>& vec,
1011  T element)
1012 {
1013  if (findInVector<T>(vec,element) == -1) {
1014  vec.push_back(element);
1015  return true;
1016  }
1017  return false;
1018 }
1019 
1020 template<typename T>
1021 std::vector<T> operator+(const std::vector<T>& x,
1022  const std::vector<T>& y)
1023 {
1024  if (x.size() != y.size()) {
1025  std::cout << "Type: two std::vectors must have "
1026  << "the same dimension in product.\n";
1027  std::exit(1);
1028  }
1029  std::vector<T> rep(x.size());
1030  for (size_t i=0; i!=x.size(); ++i)
1031  rep[i] = x[i]+y[i];
1032 
1033  return rep;
1034 }
1035 
1036 template<typename T>
1037 std::vector<T> operator-(const std::vector<T>& x,
1038  const std::vector<T>& y)
1039 {
1040  if (x.size() != y.size()) {
1041  std::cout << "Type: two std::vectors must have "
1042  << "the same dimension in product.\n";
1043  std::exit(1);
1044  }
1045  std::vector<T> rep(x.size());
1046  for (size_t i=0; i!=x.size(); ++i)
1047  rep[i] = x[i]-y[i];
1048 
1049  return rep;
1050 }
1051 
1052 template<typename T>
1053 std::vector<T> operator-(const std::vector<T>& x)
1054 {
1055  std::vector<T> rep(x);
1056  for (auto& el : rep)
1057  el *= -1;
1058  return rep;
1059 }
1060 
1061 template<typename T>
1062 std::vector<T> operator*(T a,
1063  const std::vector<T>& x)
1064 {
1065  std::vector<T> rep(x);
1066  for (auto& el : rep)
1067  el *= a;
1068  return rep;
1069 }
1070 
1071 template<typename T>
1072 std::vector<T> operator*(const std::vector<T>& x,
1073  T a)
1074 {
1075  std::vector<T> rep(x);
1076  for (auto& el : rep)
1077  el *= a;
1078  return rep;
1079 }
1080 
1081 template<typename T>
1082 T operator*(const std::vector<T>& x,
1083  const std::vector<T>& y)
1084 {
1085  if (x.size() != y.size()) {
1086  std::cout << "Type: two std::vectors must have "
1087  << "the same dimension in product.\n";
1088  std::exit(1);
1089  }
1090  T rep = 0;
1091  for (size_t i=0; i!=x.size(); ++i)
1092  rep += x[i]*y[i];
1093 
1094  return rep;
1095 }
1096 
1097 
1098 template<typename T>
1099 std::vector<T> operator*(const std::vector<std::vector<T>>& A,
1100  const std::vector<T>& x)
1101 {
1102  if (A.size() == 0)
1103  return std::vector<T>(0);
1104  if (A[0].size() != x.size()) {
1105  std::cout << "Type: two std::vectors must have "
1106  << "the same dimension in product.\n";
1107  std::exit(1);
1108  }
1109  std::vector<T> rep(A.size(),0);
1110  for (size_t i=0; i!=A.size(); ++i)
1111  for (size_t j=0; j!=x.size(); ++j)
1112  rep[i] += A[i][j]*x[j];
1113 
1114  return rep;
1115 }
1116 
1117 template<typename T>
1118 std::vector<T> operator*(const std::vector<T> &x,
1119  const std::vector<std::vector<T>>& A)
1120 {
1121  if (A.size() == 0)
1122  return std::vector<T>(0);
1123  if (A[0].size() != x.size()) {
1124  std::cout << "Type: two std::vectors must have "
1125  << "the same dimension in product.\n";
1126  std::exit(1);
1127  }
1128  std::vector<T> rep(A.size(),0);
1129  for (size_t i=0; i!=A.size(); ++i)
1130  for (size_t j=0; j!=x.size(); ++j)
1131  rep[i] += A[i][j]*x[j];
1132 
1133  return rep;
1134 }
1135 
1136 template<typename T>
1137 std::vector<std::vector<T> > operator*(const std::vector<std::vector<T>>& A,
1138  const std::vector<std::vector<T>>& B)
1139 {
1140  if (A.size() == 0 or B.size() == 0) {
1141  return std::vector<std::vector<T> >(0);
1142  }
1143  if (A[0].size() != B.size()) {
1144  std::cout << "Type: two std::vectors must have "
1145  << "the same dimension in product.\n";
1146  std::exit(1);
1147  }
1148  std::vector<std::vector<T> > rep(A.size(), std::vector<T>(B[0].size(),0));
1149  for (size_t i=0; i!=A.size(); ++i)
1150  for (size_t j=0; j!=B[0].size(); ++j)
1151  for (size_t k=0; k!=A[0].size(); ++k)
1152  rep[i][j] += A[i][k]*B[k][j];
1153 
1154  return rep;
1155 }
1156 
1157 #endif
1158 
Semi-simple Lie algebra D(l) == so(2l).
Definition: semiSimpleAlgebra.h:800
~B()
Destructor.
Definition: semiSimpleAlgebra.h:756
csl::Expr inverseCartan
Inverse cartan matrix.
Definition: semiSimpleAlgebra.h:586
~G2()
Destructor.
Definition: semiSimpleAlgebra.h:949
csl::vector_expr symbolicSquaredNorms
Symbolic version of squaredNorm.
Definition: semiSimpleAlgebra.h:603
~A()
Destructor.
Definition: semiSimpleAlgebra.h:723
virtual ~SemiSimpleAlgebra()
Destructor.
Definition: semiSimpleAlgebra.h:111
std::vector< std::vector< int > > positiveRoots
Contains all positive roots in a std::vector. Each positive root is a std::vector of integers of size...
Definition: semiSimpleAlgebra.h:559
~D()
Destructor.
Definition: semiSimpleAlgebra.h:814
Namespace of MARTY.
Definition: 2HDM.h:31
~E8()
Destructor.
Definition: semiSimpleAlgebra.h:895
Expr operator+(const Expr &a, const Expr &b)
Class inherited from std::vector<int>, dynkin labels for a state of a semi-simple algebra (see docume...
Definition: algebraState.h:35
Expr operator-(const Expr &a, const Expr &b)
std::vector< int > rho
std::vector of size l. Particular root (half-sum of simple roots) useful in calculations.
Definition: semiSimpleAlgebra.h:540
Contains a sum of Irrep (irreducible representation) of a given SemiSimpleAlgebra.
Definition: representation.h:363
Algebra (R, +) of the U(1) group.
Definition: semiSimpleAlgebra.h:629
Exceptional semi-simple Lie algebra E8.
Definition: semiSimpleAlgebra.h:883
csl::Expr symbolicRho
Symbolic version of the half-sum of simple roots (see positiveRoots). Contains the factor 1/2 that po...
Definition: semiSimpleAlgebra.h:576
Type
Different types of semi-simple Lie algebras.
Definition: semiSimpleAlgebra.h:52
~C()
Destructor.
Definition: semiSimpleAlgebra.h:785
Semi-simple Lie algebra A(l) == su(l+1).
Definition: semiSimpleAlgebra.h:709
~E7()
Destructor.
Definition: semiSimpleAlgebra.h:868
Abstract base class for all semi-simple Lie algebras.
Definition: semiSimpleAlgebra.h:96
Class AlgebraState that represents the set of dinkin labels for a state in a semi simple Lie Algebra...
std::vector< std::vector< int > > cartanMatrix
Cartan matrix of the algebra.
Definition: semiSimpleAlgebra.h:564
Exceptional semi-simple Lie algebra E7.
Definition: semiSimpleAlgebra.h:856
csl::vector_expr symbolicRoots
Symbolic version of positiveRoots, each root is a csl::Vector of csl::Integer in co-root space (dinki...
Definition: semiSimpleAlgebra.h:598
~R()
Destructor.
Definition: semiSimpleAlgebra.h:641
Expr operator*(const Expr &a, const Expr &b)
Exceptional semi-simple Lie algebra G2.
Definition: semiSimpleAlgebra.h:937
csl::Expr symbolicCartan
Symbolic version of the cartan matrix.
Definition: semiSimpleAlgebra.h:581
std::vector< int > squaredNorm
std::vector of integers of size l. Contains squared norms of all simple roots.
Definition: semiSimpleAlgebra.h:552
Definition: semiSimpleAlgebra.h:82
Exceptional semi-simple Lie algebra E6.
Definition: semiSimpleAlgebra.h:829
Exceptional semi-simple Lie algebra F4.
Definition: semiSimpleAlgebra.h:910
std::vector< std::vector< int > > rootMetric
Metric for roots in co-root space, i.e. metrix to apply in order to compute scalar dot between roots ...
Definition: semiSimpleAlgebra.h:570
Semi-simple Lie algebra B(l) == so(2l+1).
Definition: semiSimpleAlgebra.h:742
~E6()
Destructor.
Definition: semiSimpleAlgebra.h:841
Handles the irreducible representation of a given semi-simple algebra.
Definition: representation.h:42
Semi-simple Lie algebra C(l) == sp(2l).
Definition: semiSimpleAlgebra.h:771
csl::vector_expr absoluteNorms
Absolute norms of simple roots used in the computation of the quadratic Casimir operator. See SemiSimpleAlgebra::getQuadraticCasimir().
Definition: semiSimpleAlgebra.h:546
~F4()
Destructor.
Definition: semiSimpleAlgebra.h:922
std::ostream & operator<<(std::ostream &fout, mty::algebra::Type obj)
Overload of operator<< for algebra::Type. Allows to display a string corresponding to the type of alg...
csl::Expr symbolicMetric
Symbolic metric in root space. i.e. different from rootMetric that is the metric in co-root space...
Definition: semiSimpleAlgebra.h:592
Enumeration of types of semi simple Lie algebras. The names being very small, we use a namespace to a...
Definition: semiSimpleAlgebra.h:47
const int l
Order of the semi-simple algebra, i.e. number of simple roots.
Definition: semiSimpleAlgebra.h:531