Normal order requires all annihilators to stand right from all creators. However, the operators
do not commute. It is
The representation of a Kronecker symbol is rather simple. Here it goes:
Interface: Kronecker.H
1 #ifndef KRONECKER_H
2 #define KRONECKER_H
3
4 #include <iostream>
5
6 using namespace std;
7
8
9 /*!
10 Implements a Kronecker symbol \[ \delta_{ij} \]
11 */
12
13 class Kronecker {
14 public:
15 //! construct from given orbitals
16 Kronecker(char orb1, char orb2);
17
18
19 //! get first index
20 char orb1() const;
21
22 //! get second index
23 char orb2() const;
24
25
26 //! "artificial" ordering relation (for sorting purposes)
27 bool operator < (Kronecker const & k) const;
28
29 private:
30 char _orb1;
31 char _orb2;
32 };
33
34
35 //! output operator for Kronecker
36 ostream & operator << (ostream & o, Kronecker const & k);
37
38 #endif
Implementation: Kronecker.C
1 #include "Kronecker.H"
2
3
4
5 Kronecker::Kronecker(char orb1, char orb2) :
6 _orb1(orb1), _orb2(orb2) {}
7
8
9 char Kronecker::orb1() const
10 { return _orb1; }
11
12 char Kronecker::orb2() const
13 { return _orb2; }
14
15
16 bool Kronecker::operator < (Kronecker const & k) const
17 {
18 if ( _orb1<k._orb1 )
19 return true;
20 if ( k._orb1<_orb1 )
21 return false;
22 return _orb2<k._orb2;
23 }
24
25
26 ostream & operator << (ostream & o, Kronecker const & k)
27 {
28 o << "d(" << k.orb1() << k.orb2() << ")";
29 return o;
30 }
Let's test it: Kronecker_Test.C
1 #include "Kronecker.H"
2
3 int main()
4 {
5 Kronecker k('i', 'j');
6
7 cout << k << endl;
8 }
The output is (download files into a fresh directory, compile and link with g++ *.C, run a.out)
d(ij)Okay. Rather trivial but it works...