Files

92 lines
3.4 KiB
C++

/*
Copyright (C) 2008 Jiri Pittner <jiri.pittner@jh-inst.cas.cz> or <jiri@pittnerovi.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _basic_h
#define _basic_h
#include "version.h"
#include <complex>
#include <iostream>
#ifdef COMPLEX_VERSION
typedef std::complex<double> FIELD;
#else
typedef double FIELD;
#endif
typedef double REAL;
typedef std::complex<double> COMPLEX;
typedef unsigned int lexindex;
typedef unsigned char index4type; //max 256 orbitals
typedef short Q2index; //must be at least index4type + sign
typedef unsigned char electronindex; //max 256 electrons
typedef index4type orbindex;
typedef short spinorbindex;
typedef /*signed*/ char occnum; //signed type is crucial to ensure correct processing of tests >=0 in loops
typedef unsigned char index4type; //must be able to hold up to number of orbitals ... possibly enlarge to unsigned short
#include "la.h"
using namespace LA;
//pure virtual base class for second quantized operators (just for general pointers)
template<typename F>
class general_implicit_operator {
public:
general_implicit_operator() {};
virtual void gemv(const F beta, NRVec<F> &r, const char trans, const F alpha, const NRVec<F> &x) const =0;
virtual REAL norm() const =0;
virtual lexindex nrows() const =0;
virtual lexindex ncols() const =0;
virtual void printme(std::ostream &o) const {};
virtual ~general_implicit_operator() {};
};
typedef general_implicit_operator<FIELD> implicit_operator;
//abstract base class with purely virtual functions
template<typename F>
class general_secondquantized_hamiltonian : public general_implicit_operator<F> {
public:
general_secondquantized_hamiltonian() {};
virtual const F *diagonalof(NRVec<F> &d,const bool divide, bool cache) const =0;
virtual void gemv(const F beta, NRVec<F> &r, const char trans, const F alpha, const NRVec<F> &x) const =0;
virtual lexindex nrows() const =0;
virtual lexindex ncols() const =0;
virtual bool issymmetric() const =0;
virtual ~general_secondquantized_hamiltonian() {};
virtual void printme(std::ostream &o) const {}; //print terms if applicable
virtual int sort(int direction=0, int from=0, int to= -1, int *perm=NULL) {return 0;}; //sort the terms if well defined
};
typedef general_secondquantized_hamiltonian<FIELD> secondquantized_hamiltonian;
enum hamiltonian_type {quantchem=0, quantchem_uhf=1, hubbard=2, general_2body=3, relativistic=4}; //relativistic: spinors in the standard numbering A = 1..n, B = n+1..2n (doc/cauga3.tex)
typedef NRSMat_from1<FIELD> OneElInt;
typedef NRSMat_from1<SparseMat<REAL> > Ugenerators;
typedef NRVec<NRSMat_from1<SparseMat<REAL> > > Ugenerators_resorted;
typedef matel4<index4type,FIELD> MATEL4;
typedef matel4stored<index4type,FIELD> MATEL4STORED;
#endif