numo.hpp

C++ header for Numo and Rice

BSD-2-CLAUSE License

Stars
2

Numo.hpp

C++ header for Numo and Rice

Installation

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

Getting Started

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;

Methods

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

Projects that use Numo.hpp

History

View the changelog

Contributing

Everyone is encouraged to help improve this project. Here are a few ways you can help:

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