C++ header for numo-narray-alt and Rice
Copy numo.hpp into your project and add the following lines to extconf.rb:
require "numo/narray/alt"
numo = File.join(Gem.loaded_specs["numo-narray-alt"].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}/narray")
$LDFLAGS += " -Wl,-undefined,dynamic_lookup" if RbConfig::CONFIG["host_os"] =~ /darwin/iInclude 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
numo::Int64 a({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
size_t ndim = a.ndim();Get the number of elements
size_t size = a.size();Get the shape
const size_t* shape = a.shape();Get a read pointer
const auto* ptr = a.read_ptr();Get a write pointer
auto* ptr = a.write_ptr();Check if contiguous
bool 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