template class QPanda::FermionOp

Overview

Fermion operator class. More…

#include <FermionOperator.h>

template <class T>
class FermionOp
{
public:
    // typedefs

    typedef std::pair<FermionPair, T> FermionItem;
    typedef std::vector<FermionItem> FermionData;
    typedef std::map<std::string, T> FermionMap;

    // construction

    FermionOp();
    FermionOp(double value);
    FermionOp(const T& value);

    FermionOp(
        const std::string& key,
        const T& value
        );

    FermionOp(const FermionMap& map);
    FermionOp(FermionData&& fermion_data);
    FermionOp(const FermionData& fermion_data);
    FermionOp(FermionOp&& op);
    FermionOp(const FermionOp& op);

    // methods

    FermionOp& operator = (const FermionOp& op);
    FermionOp& operator = (FermionOp&& op);
    FermionOp normal_ordered();
    size_t getMaxIndex() const;
    bool isEmpty();
    std::string toString() const;
    void setErrorThreshold(double threshold);
    double error_threshold() const;
    FermionData data() const;
    FermionOp operator + (const FermionOp& rhs) const;
    FermionOp operator - (const FermionOp& rhs) const;
    FermionOp operator * (const FermionOp& rhs) const;
    FermionOp& operator += (const FermionOp& rhs);
    FermionOp& operator -= (const FermionOp& rhs);
    FermionOp& operator *= (const FermionOp& rhs);
};

Detailed Documentation

Fermion operator class.

Construction

FermionOp()

Constructor of FermionOp class.

Methods

FermionOp normal_ordered()

Compute and return the normal ordered form of a FermionOperator.

In our convention, normal ordering implies terms are ordered from highest tensor factor (on left) to lowest (on right). In addition: a^dagger comes before a

Returns:

FermionOp the normal ordered form of a FermionOperator

size_t getMaxIndex() const

get the max index

Returns:

size_t the max index

bool isEmpty()

Judge whether it is empty.

Returns:

bool if data is empty, return true, or else return false

std::string toString() const

data to string

Returns:

std::string convert data val to string

void setErrorThreshold(double threshold)

set error threshold

Parameters:

double

threshold val

double error_threshold() const

get error threshold

Returns:

double return the error threshold val

FermionData data() const

get data

Returns:

FermionData return fermion data

FermionOp operator + (const FermionOp& rhs) const

overload +

Returns:

FermionOp return (FermionOp_1 + FermionOp_2)

FermionOp operator - (const FermionOp& rhs) const

overload -

Returns:

FermionOp return (FermionOp_1 - FermionOp_2)

FermionOp operator * (const FermionOp& rhs) const

overload *

Returns:

FermionOp return (FermionOp_1 * FermionOp_2)

FermionOp& operator += (const FermionOp& rhs)

overload +=

Returns:

FermionOp & return (FermionOp_1 += FermionOp_2)

FermionOp& operator -= (const FermionOp& rhs)

overload -=

Returns:

FermionOp & return (FermionOp_1 -= FermionOp_2)

FermionOp& operator *= (const FermionOp& rhs)

overload *=

Returns:

FermionOp & return (FermionOp_1 *= FermionOp_2)