Skip to content

ankane/numo.hpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Numo.hpp

C++ header for Numo and Rice

Build Status

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

About

C++ header for Numo and Rice

Resources

License

Stars

Watchers

Forks

Packages

No packages published