Copy numo.hpp into your project and add the following lines to extconf.rb
:
require "numo/narray"
numo = File.join(Gem.loaded_specs["numo-narray"].require_path, "numo")
abort "Numo header not found" unless find_header("numo/narray.h", numo)
abort "Numo library not found" if Gem.win_platform? && !find_library("narray", nil, numo)
$LDFLAGS += " -Wl,-undefined,dynamic_lookup" if RbConfig::CONFIG["host_os"] =~ /darwin/i
Include the header
#include "numo.hpp"
Use Numo types for arguments (including numo::NArray
for any type)
define_function("sum", [](numo::SFloat a) { /* your code */ });
Or create a new array
auto a = numo::Int64({3, 5});
And use a pointer to write to it
auto ptr = a.write_ptr();
ptr[0] = 4;
ptr[1] = 3;
Get the number of dimensions
a.ndim();
Get the number of elements
a.size();
Get the shape
a.shape();
Get a read pointer
a.read_ptr();
Get a write pointer
a.write_ptr();
Check if contiguous
a.is_contiguous();
Projects that use Numo.hpp
View the changelog
Everyone is encouraged to help improve this project. Here are a few ways you can help:
- Report bugs
- Fix bugs and submit pull requests
- Write, clarify, or fix documentation
- Suggest or add new features
To get started with development:
git clone https://github.com/ankane/numo.hpp.git
cd numo.hpp
bundle install
bundle exec rake compile
bundle exec rake test