File: Pybind11StOptCDF.cpp

package info (click to toggle)
stopt 6.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,264 kB
  • sloc: cpp: 75,778; python: 6,012; makefile: 72; sh: 57
file content (38 lines) | stat: -rw-r--r-- 1,061 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright (C) 2020 EDF
// All Rights Reserved
// This code is published under the GNU Lesser General Public License (GNU LGPL)

/** \file PyBind11StOptCDF.cpp
 * \brief Map CDF calculation   classes to python
 * \author Xavier Warin
 */

#include <Eigen/Dense>
#include <iostream>
#include <memory>
#include <pybind11/pybind11.h>
#include <pybind11/eigen.h>
#include "StOpt/python/Pybind11VectorAndList.h"
#include "StOpt/cdf/fastCDF.h"
#include "StOpt/cdf/fastCDFOnSample.h"
#include "StOpt/core/utils/version.h"

namespace py = pybind11;

using namespace Eigen;

ArrayXd fastCDFWrap(const Eigen::ArrayXXd &p_x, const  pybind11::list     &p_z, const Eigen::ArrayXd &p_y)
{
    std::vector< std::shared_ptr<Eigen::ArrayXd> >    vecGrid(convertFromListShPtr<Eigen::ArrayXd>(p_z));

    return StOpt::fastCDF(p_x, vecGrid, p_y);
}

/// \brief Encapsulation for CDF module
PYBIND11_MODULE(StOptCDF, m)
{
    // version
    m.def("getVersion", StOpt::getStOptVersion);
    m.def("fastCDF", &fastCDFWrap);
    m.def("fastCDFOnSample", &StOpt::fastCDFOnSample);
}