// 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 "Basis/BiorthogonalBasis/ULowdinPairingBasis.hpp"
#include "gqcpy/include/interfaces.hpp"

#include <pybind11/pybind11.h>
#include <pybind11/stl.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 `ULowdinPairingBasis`.
 *
 *  @tparam Class               The type of the Pybind11 `class_` (generated by the compiler).
 *
 *  @param py_class             The Pybind11 `class_` that should obtain APIs related to `ULowdinPairingBasis`.
 */
template <typename Class>
void bindULowdinPairingBasisInterface(Class& py_class) {

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


    /**
     *  MARK: Constructors
     */

    py_class
        .def(py::init<const UTransformation<Scalar>&, const UTransformation<Scalar>&, const ScalarUSQOneElectronOperator<Scalar>&, const size_t, const size_t, const double>(),
             py::arg("C_bra"),
             py::arg("C_ket"),
             py::arg("overlap_operator"),
             py::arg("number_of_occupied_alpha_orbitals"),
             py::arg("number_of_occupied_beta_orbitals"),
             py::arg("zero_threshold") = 1e-8);


    // Expose some Mulliken API to the Python class;
    bindLowdinPairingBasisInterface(py_class);
}


/**
 *  Register `ULowdinPairingBasis_d` and `ULowdinPairingBasis_cd` 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 bindULowdinPairingBases(py::module& module) {

    // Define the Python class for `ULowdinPairingBasis_d`.
    py::class_<ULowdinPairingBasis<double>> py_ULowdinPairingBasis_d {module, "ULowdinPairingBasis_d", "A class that represents a real, biorthogonalized Lowdin pairing basis, created from `unrestricted` states."};

    bindULowdinPairingBasisInterface(py_ULowdinPairingBasis_d);


    // Define the Python class for `ULowdinPairingBasis_cd`.
    py::class_<ULowdinPairingBasis<complex>> py_ULowdinPairingBasis_cd {module, "ULowdinPairingBasis_cd", "A class that represents a complex, biorthogonalized Lowdin pairing basis, created from `unrestricted` states."};

    bindULowdinPairingBasisInterface(py_ULowdinPairingBasis_cd);
}


}  // namespace gqcpy
