Skip to content

Find a way to expose ufuncs/rvectorize #11

Open
@wolfv

Description

@wolfv

We have the (working) rvectorize, but afaik there is no way to expose just a function pointer with RCpp (without the decorations).
Maybe @eddelbuettel has a hint?

I.e. this is corresponding code for xtensor-python, where the result of xt::pyvectorize get's bound to a function name in python.

#include "pybind11/pybind11.h"
#include "xtensor-python/pyvectorize.hpp"
#include <numeric>
#include <cmath>

namespace py = pybind11;

double scalar_func(double i, double j)
{
    return std::sin(i) - std::cos(j);
}

PYBIND11_PLUGIN(xtensor_python_test)
{
    py::module m("xtensor_python_test", "Test module for xtensor python bindings");

    m.def("vectorized_func", xt::pyvectorize(scalar_func), "");

    return m.ptr();
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions