MGIS 3.1.0
Loading...
Searching...
No Matches
NumPySupport.hxx File Reference
#include <span>
#include <vector>
#include <variant>
#include <pybind11/pybind11.h>
#include <pybind11/numpy.h>
#include "MGIS/Config.hxx"

Namespaces

namespace  mgis
 the namespace mgis encloses all the MGIS project.

Functions

pybind11::array_t< double > mgis::python::wrapInNumPyArray (std::span< double > &, pybind11::handle)
 create a 1D-ndarray object from a vector. The ndarray does not own the data, the lifetime of which is handled by the vector.
pybind11::array_t< double > mgis::python::wrapInNumPyArray (std::variant< std::span< double >, std::vector< double > > &, pybind11::handle)
 create a 1D-ndarray object from a vector. The ndarray does not own the data, the lifetime of which is handled by the vector.
pybind11::array_t< double > mgis::python::wrapInNumPyArray (std::vector< double > &, pybind11::handle)
 create a 1D-ndarray object from a vector. The ndarray does not own the data, the lifetime of which is handled by the vector.
pybind11::array_t< double > mgis::python::wrapInNumPyArray (std::span< double > &, const mgis::size_type, pybind11::handle)
 create a 2D-ndarray object from a vector. The ndarray does not own the data, the lifetime of which is handled by the vector.
pybind11::array_t< double > mgis::python::wrapInNumPyArray (std::variant< std::span< double >, std::vector< double > > &, const mgis::size_type, pybind11::handle)
 create a 2D-ndarray object from a vector. The ndarray does not own the data, the lifetime of which is handled by the vector.
pybind11::array_t< double > mgis::python::wrapInNumPyArray (std::vector< double > &, const mgis::size_type, pybind11::handle)
 create a 2D-ndarray object from a vector. The ndarray does not own the data, the lifetime of which is handled by the vector.
pybind11::array_t< double > mgis::python::wrapInNumPyArray (std::span< double > &, const mgis::size_type, const mgis::size_type, pybind11::handle)
 create a 3D-ndarray object from a vector. The ndarray does not own the data, the lifetime of which is handled by the vector.
pybind11::array_t< double > mgis::python::wrapInNumPyArray (std::variant< std::span< double >, std::vector< double > > &, const mgis::size_type, const mgis::size_type, pybind11::handle)
 create a 3D-ndarray object from a vector. The ndarray does not own the data, the lifetime of which is handled by the vector.
pybind11::array_t< double > mgis::python::wrapInNumPyArray (std::vector< double > &, const mgis::size_type, const mgis::size_type, pybind11::handle)
 create a 3D-ndarray object from a vector. The ndarray does not own the data, the lifetime of which is handled by the vector.
std::span< mgis::real > mgis::python::mgis_convert_to_span (const pybind11::array_t< double > &)
std::span< mgis::real > mgis::python::mgis_convert_to_mutable_span (const pybind11::object &)
 convert an object in which values are written into a span. Contrary to mgis_convert_to_span, an exception is thrown if the object is converted into a copy, in which the written values would be lost, or if the object is read-only.

Detailed Description

Author
Thomas Helfer
Date
07/11/2018

Function Documentation

◆ mgis_convert_to_mutable_span()

std::span< mgis::real > mgis::python::mgis_convert_to_mutable_span ( const pybind11::object & )

convert an object in which values are written into a span. Contrary to mgis_convert_to_span, an exception is thrown if the object is converted into a copy, in which the written values would be lost, or if the object is read-only.

Parameters
[in]oobject

◆ wrapInNumPyArray() [1/9]

pybind11::array_t< double > mgis::python::wrapInNumPyArray ( std::span< double > & ,
const mgis::size_type ,
const mgis::size_type ,
pybind11::handle  )

create a 3D-ndarray object from a vector. The ndarray does not own the data, the lifetime of which is handled by the vector.

Parameters
[in]vvalues
[in]nlnumber of line
[in]ncnumber of columns
[in]baseobject owning the values, kept alive by the ndarray

◆ wrapInNumPyArray() [2/9]

pybind11::array_t< double > mgis::python::wrapInNumPyArray ( std::span< double > & ,
const mgis::size_type ,
pybind11::handle  )

create a 2D-ndarray object from a vector. The ndarray does not own the data, the lifetime of which is handled by the vector.

Parameters
[in]vvalues
[in]ncnumber of columns
[in]baseobject owning the values, kept alive by the ndarray

◆ wrapInNumPyArray() [3/9]

pybind11::array_t< double > mgis::python::wrapInNumPyArray ( std::span< double > & ,
pybind11::handle  )

create a 1D-ndarray object from a vector. The ndarray does not own the data, the lifetime of which is handled by the vector.

Parameters
[in]vvalues
[in]baseobject owning the values, kept alive by the ndarray

◆ wrapInNumPyArray() [4/9]

pybind11::array_t< double > mgis::python::wrapInNumPyArray ( std::variant< std::span< double >, std::vector< double > > & ,
const mgis::size_type ,
const mgis::size_type ,
pybind11::handle  )

create a 3D-ndarray object from a vector. The ndarray does not own the data, the lifetime of which is handled by the vector.

Parameters
[in]vvalues
[in]nlnumber of line
[in]ncnumber of columns
[in]baseobject owning the values, kept alive by the ndarray

◆ wrapInNumPyArray() [5/9]

pybind11::array_t< double > mgis::python::wrapInNumPyArray ( std::variant< std::span< double >, std::vector< double > > & ,
const mgis::size_type ,
pybind11::handle  )

create a 2D-ndarray object from a vector. The ndarray does not own the data, the lifetime of which is handled by the vector.

Parameters
[in]vvalues
[in]ncnumber of columns
[in]baseobject owning the values, kept alive by the ndarray

◆ wrapInNumPyArray() [6/9]

pybind11::array_t< double > mgis::python::wrapInNumPyArray ( std::variant< std::span< double >, std::vector< double > > & ,
pybind11::handle  )

create a 1D-ndarray object from a vector. The ndarray does not own the data, the lifetime of which is handled by the vector.

Parameters
[in]vvalues
[in]baseobject owning the values, kept alive by the ndarray

◆ wrapInNumPyArray() [7/9]

pybind11::array_t< double > mgis::python::wrapInNumPyArray ( std::vector< double > & ,
const mgis::size_type ,
const mgis::size_type ,
pybind11::handle  )

create a 3D-ndarray object from a vector. The ndarray does not own the data, the lifetime of which is handled by the vector.

Parameters
[in]vvector holding the values
[in]nlnumber of line
[in]ncnumber of columns
[in]baseobject owning the values, kept alive by the ndarray

◆ wrapInNumPyArray() [8/9]

pybind11::array_t< double > mgis::python::wrapInNumPyArray ( std::vector< double > & ,
const mgis::size_type ,
pybind11::handle  )

create a 2D-ndarray object from a vector. The ndarray does not own the data, the lifetime of which is handled by the vector.

Parameters
[in]vvector holding the values
[in]ncnumber of columns
[in]baseobject owning the values, kept alive by the ndarray

◆ wrapInNumPyArray() [9/9]

pybind11::array_t< double > mgis::python::wrapInNumPyArray ( std::vector< double > & ,
pybind11::handle  )

create a 1D-ndarray object from a vector. The ndarray does not own the data, the lifetime of which is handled by the vector.

Parameters
[in]vvector holding the values
[in]baseobject owning the values, kept alive by the ndarray