{"id":13689120,"url":"https://github.com/fwilliams/numpyeigen","last_synced_at":"2025-03-17T15:13:13.219Z","repository":{"id":50621798,"uuid":"137667660","full_name":"fwilliams/numpyeigen","owner":"fwilliams","description":" Fast zero-overhead bindings between NumPy and Eigen","archived":false,"fork":false,"pushed_at":"2024-08-29T20:52:07.000Z","size":640,"stargazers_count":139,"open_issues_count":15,"forks_count":16,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-09T01:41:59.178Z","etag":null,"topics":["binding","eigen","numpy","python","scipy","zer"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fwilliams.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"fwilliams","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2018-06-17T16:01:19.000Z","updated_at":"2025-02-01T15:46:11.000Z","dependencies_parsed_at":"2024-01-17T06:11:58.365Z","dependency_job_id":"bd7ed296-0ecc-419b-8f41-90b6efff055f","html_url":"https://github.com/fwilliams/numpyeigen","commit_stats":{"total_commits":295,"total_committers":9,"mean_commits":32.77777777777778,"dds":"0.47796610169491527","last_synced_commit":"6ad0c04f0e18726cdb6582b74ff048286be14198"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fwilliams%2Fnumpyeigen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fwilliams%2Fnumpyeigen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fwilliams%2Fnumpyeigen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fwilliams%2Fnumpyeigen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fwilliams","download_url":"https://codeload.github.com/fwilliams/numpyeigen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244056425,"owners_count":20390719,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["binding","eigen","numpy","python","scipy","zer"],"created_at":"2024-08-02T15:01:34.304Z","updated_at":"2025-03-17T15:13:13.198Z","avatar_url":"https://github.com/fwilliams.png","language":"Python","funding_links":["https://github.com/sponsors/fwilliams"],"categories":["Python"],"sub_categories":[],"readme":"﻿# NumpyEigen - Fast zero-overhead bindings between NumPy and Eigen\n![Tests Status](https://github.com/fwilliams/numpyeigen/actions/workflows/cmake.yml/badge.svg)\n\n**NumpyEigen** makes it easy to transparently convert [NumPy](http://www.numpy.org/) \ndense arrays and [SciPy](https://docs.scipy.org/doc/scipy/reference/sparse.html) sparse \nmatrices to [Eigen](https://www.google.com/search?client=ubuntu\u0026channel=fs\u0026q=eigen\u0026ie=utf-8\u0026oe=utf-8) \nwith zero copy overhead while taking advantage of Eigen's expression template system for maximum performance.\n\n[Eigen](https://www.google.com/search?client=ubuntu\u0026channel=fs\u0026q=eigen\u0026ie=utf-8\u0026oe=utf-8) is a C++ numerical \nlinear algebra library. It uses expression templates to pick the fastest numerical algorithms for a given set of input \ntypes. NumPy and SciPy are libraries exposing fast numerical routines in Python. \n\nSince type information in Python is only available at runtime, it is not easy to write bindings which accept \nmultiple NumPy or SciPy types, have zero copy overhead, and can make use of the fastest numerical kernels in Eigen. \nNumpyEigen transparently generates bindings which do all of the above, exposing numpy type information at compile \ntime to C++ code. \n\n### Zero Copy-Overhead \nBindings written with NumpyEigen have zero copy overhead from Python to C++ and vice versa for any NumPy dense array or \nSciPy CSR or CSC sparse matrix.\n\n### Binding Function Overloading\nNumpyEigen allows type overloading of binding input arguments. The type of the argument is made available at compile \ntime to the C++ code. This type information is in turn used to drive Eigen's expression template system to choose \nthe fastest numerical algorithm for a given input type.\n\n### Build System Support\nNumpyEigen comes built-in with [CMake](https://cmake.org/) tools to integrate with existing build systems in a\n single line of code. A set of scripts to integrate with other build systems will be included in the future.\n\n### Minimal Dependencies\nNumpyEigen only requires the system to have a valid C++ 14 (or later) compiler and a running Python interpreter with version \u003e= 2.7. \n\nNumpyEigen uses [pybind11](https://github.com/pybind/pybind11) under the hood which is included automatically by the cmake project. \n\n\n## Example\nSee the [Example Project Repository](https://github.com/fwilliams/NumpyEigen-Example-Project) for a fully \nrunning example project.\n\nWhen compiled, the following code will generate a function `foo(a, b, c, d, e, f)` callable from Python. \n`foo` returns a tuple of values computed from its inputs.\n\n```c++\n#include \u003cnpe.h\u003e\n#include \u003ctuple\u003e\n#include \u003cstring\u003e\n\n// Create a function named foo exposed to python\nnpe_function(foo)                     \n\n// The arguments to foo are as follows:\n// Each of these are transparently converted from numpy types to appropriate Eigen::Map types\n// wiith zero copy overhead.\nnpe_arg(a, dense_double, dense_float)   // a is a numpy array with dtype either float or double\nnpe_arg(b, matches(a))                  // b is a numpy array whose type has to match a\nnpe_arg(c, dense_int32, dense_int64)       // c is a numpy array whose type is either int or long\nnpe_arg(d, std::string)                 // d is a string\nnpe_arg(f, sparse_float, sparse_double) // f is a sparse matrix whose data is either float or double\nnpe_arg(e, int)                         // e is an int\n\n// NumpyEigen supports doc strings which are expression evaluating to C strings or std::string types\nnpe_doc(\"A function which computes various values from input matrices\")\n\n// The C++ code for the function starts after this line\nnpe_begin_code()\n\n// npe_Matrix_* are Eigen::Matrix\u003cT\u003e or Eigen::SparseMatrix\u003cT\u003e types corresponding to the inputs\nnpe_Matrix_a ret1 = a + b;\nnpe_Matrix_a ret2 = a - c;\nint ret3 = d + std::string(\"concatenated\");\nint ret4 = e + 2;\nnpe_Matrix_f ret5 = f * 1.5;\n\n// npe::move() wraps an Eigen type in a NumPy or SciPy type with zero copy overhead\nreturn std::make_tuple(npe::move(ret1), npe::move(ret2), ret3, ret4, npe::move(ret5));\n\nnpe_end_code()\n```\n\n#### Building with CMake\nTo create a Python Module named `mymodule` which exposes the function foo, \nstored in foo.cpp add the following to your `CMakeLists.txt`:\n\n```cmake\n# Make numpyeigen available in the current project\nset(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} /path/to/numpyeigen/cmake)\ninclude(numpyeigen)\n\nnpe_add_module(mymodule, BINDING_SOURCES foo.cpp)\n```\n\n\n## Configuring NumpyEigen\nNumpyEigen exposes several configuration options via CMake:\n* `NPE_PYTHON_EXECUTABLE`: The path to the python interpreter to build against. This interpreter is used to determine the correct headers and libraries when building.\n* `NPE_PYTHON_VERSION`: Request a specific version of Python on the system . NOTE: if `NPE_PYTHON_EXECUTABLE` is set, then this option is ignored.\n* `NPE_WITH_EIGEN`: NumpyEigen includes a bundled version of Eigen for convenience. If this option is set, then an interface library named `Eigen3::Eigen` is exposed and used to compile NumpyEigen modules. \n* `NPE_ROOT`: The path to the root of the NumpyEigen codebase. If you include `numpyeigen.cmake` directly from this repository, you do not need to set this.\n\n\n## Building and Running Tests\n\nBuilding the tests should be as easy as:\n```\nmkdir build\ncd build\ncmake ..\nmake\nmake test\n```\n\n### Windows ❄️\n\nOpen a Visual Studio Command Prompt and run the following commands:\n\n```\nmkdir build\ncd build\ncmake ..\ncmake --build . --config Release\nctest -C Release\n```\n\nThere's an `tests/environment.yml` file which can be used to generate conda environment with \nall the right dependencies by running:\n```\nconda env create -f environment.yml\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffwilliams%2Fnumpyeigen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffwilliams%2Fnumpyeigen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffwilliams%2Fnumpyeigen/lists"}