llohse/libnpy

C++ library for reading and writing of numpy's .npy files

What it solves

libnpy provides a straightforward way for C++ programs to interact with NumPy's .npy file format. It is primarily designed to help developers write numerical data from C++ applications into .npy files, while also supporting basic reading capabilities.

How it works

It is a header-only C++14 library. You simply include npy.hpp in your project to start reading or writing data. It maps standard C++ vectors to .npy arrays, supporting scalar numeric types like integers, floating-point numbers, and complex numbers. For writing, it offers options to either copy data or use pointers to avoid unnecessary memory duplication.

Who it’s for

This library is for C++ developers who need to exchange numerical data with Python environments or other tools that rely on the NumPy file format.

Highlights

  • Header-only design for easy integration into C++ projects.
  • Supports writing C++ vectors directly to .npy files.
  • Allows reading .npy files into new or existing C++ vectors.
  • Supports scalar numeric types, including signed/unsigned integers, floats, and complex numbers.
  • Provides memory-efficient writing options using pointers to avoid data copying.

相关

  • 项目
  • 项目
  • 项目
  • 项目