class QPanda::Variational::var

Overview

The class denotes the variable. More…

#include <var.h>

class var
{
public:
    // fields

    std::shared_ptr<impl> pimpl;

    // construction

    var(std::shared_ptr<impl>);
    var(double);
    var(const MatrixXd&);

    var(
        double,
        bool
        );

    var(
        const MatrixXd&,
        bool
        );

    var(op_type op, const std::vector<var>& children);
    var(var&&);
    var(const var&);

    // methods

    var& operator = (var&&);
    var& operator = (const var&);
    var clone();
    virtual size_t getNumOpArgs();
    MatrixXd getValue() const;
    void setValue(const MatrixXd&);
    op_type getOp() const;
    void setOp(op_type);
    std::vector<var>& getChildren() const;
    std::vector<var> getParents() const;
    long getUseCount() const;
    bool getValueType() const;
    MatrixXd _eval();

    MatrixXd _back_single(
        const MatrixXd& dx,
        size_t op_idx
        );

    std::vector<MatrixXd> _back(
        const MatrixXd& dx,
        const std::unordered_set<var>& nonconsts
        );

    std::vector<MatrixXd> _back(const MatrixXd& dx);
    bool operator == (const var& rhs) const;
    const var operator [] (int subscript);
};

Detailed Documentation

The class denotes the variable.

Construction

var(std::shared_ptr<impl>)

Construct a new var object by the impl object.

var(double)

Construct a new var object by a double.

var(const MatrixXd&)

Construct a new var object by a Eigen matrix.

var(op_type op, const std::vector<var>& children)

Construct a new var object by the operator type and children.

Parameters:

op

operator type

children

children of the operator. For example, c = a + b. c is a and b’s parent, a and b are c’s children

var(var&&)

move constructor of var

Methods

var& operator = (var&&)

Returns:

var&