pybind / pybind11

Seamless operability between C++11 and Python
https://pybind11.readthedocs.io/
Other
15.39k stars 2.07k forks source link

[NOT A BUG] Links/similarities with R's cpp11 #4754

Open pachadotdev opened 1 year ago

pachadotdev commented 1 year ago

Required prerequisites

What version (or hash if on master) of pybind11 are you using?

ec1b57c50c72a7c2ef4aa3b14d7723918da4235e

Problem description

Not a problem. This is similar to R's cpp11 (https://cpp11.r-lib.org/). I wonder how easy would it be to have some convergence with cpp11 This might interest @DavisVaughan @s3alfisc @lrberge

Reproducible example code

// say we can easily port this R-cpp11 code
// then translating linear algebra between R and Python is "free"

#include <cpp11.hpp>

using namespace cpp11;

doubles_matrix<> XtX(doubles_matrix<> X)
{
    int NX = X.nrow();
    int MX = X.ncol();

    writable::doubles_matrix<> R(MX, MX);

    for (int i = 0; i < MX; i++)
    {
        for (int j = 0; j < MX; j++)
        {
            for (int k = 0; k < NX; k++)
            {
                R(i, j) += X(k, i) * X(k, j);
            }
        }
    }

    return R;
}

Is this a regression? Put the last known working version here if it is.

Not a regression