// This file is part of GQCG-GQCP.
//
// Copyright (C) 2017-2020  the GQCG developers
//
// GQCG-GQCP is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// GQCG-GQCP 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with GQCG-GQCP.  If not, see <http://www.gnu.org/licenses/>.

#include "Operator/SecondQuantized/GSQTwoElectronOperator.hpp"
#include "Utilities/complex.hpp"
#include "gqcpy/include/interfaces.hpp"

#include <pybind11/pybind11.h>


namespace py = pybind11;


namespace gqcpy {


// Provide some shortcuts for frequent namespaces.
namespace py = pybind11;
using namespace GQCP;


/**
 *  Add Python bindings for some APIs related to `GSQOneElectronOperatorProduct`.
 * 
 *  @tparam Class               The type of the Pybind11 `class_` (generated by the compiler).
 *  
 *  @param py_class             The Pybind11 `class_` that should obtain APIs related to `GSQOneElectronOperatorProduct`.
 */
template <typename Class>
void bindScalarGSQOneElectronOperatorProductInterface(Class& py_class) {

    // The C++ type corresponding to the Python class.
    using Type = typename Class::type;


    py_class

        /*
         *  MARK: Access
         */

        .def(
            "oneElectron",
            [](const Type& op) {
                return op.oneElectron();
            },
            "Return a read-only reference to the one-electron part of the product.")

        .def(
            "twoElectron",
            [](const Type& op) {
                return op.twoElectron();
            },
            "Return a read-only reference to the two-electron part of the product.")


        /*
         *  MARK: Expectation value
         */

        .def("calculateExpectationValue",
             &Type::calculateExpectationValue,
             py::arg("D"),
             py::arg("d"),
             "Calculate the expectation value of this one-electron operator product.");


    bindVectorSpaceArithmeticInterface(py_class);
    bindBasisTransformableInterface(py_class);
}


/**
 *  Register multiple templated variations of `GSQOneElectronOperatorProduct`, to the gqcpy module and expose parts of their C++ interfaces to Python.
 * 
 *  @param module           The Pybind11 module in which the classes should be registered.
 */
void bindScalarGSQOneElectronOperatorProduct(py::module& module) {

    // Real-valued Python bindings.
    py::class_<ScalarGSQOneElectronOperatorProduct<double>> py_ScalarGSQOneElectronOperatorProduct_d {module, "ScalarGSQOneElectronOperatorProduct_d", "A type that encapsulates the matrix elements of the product of two real-valued scalar, generalized one-electron operators."};

    bindScalarGSQOneElectronOperatorProductInterface(py_ScalarGSQOneElectronOperatorProduct_d);


    // Complex-valued Python bindings.
    py::class_<ScalarGSQOneElectronOperatorProduct<complex>> py_ScalarGSQOneElectronOperatorProduct_cd {module, "ScalarGSQOneElectronOperatorProduct_cd", "A type that encapsulates the matrix elements of the product of two complex-valued scalar, generalized one-electron operators."};

    bindScalarGSQOneElectronOperatorProductInterface(py_ScalarGSQOneElectronOperatorProduct_cd);
}


}  // namespace gqcpy
