Learn R Programming

natcpp

The goal of natcpp is to provide accelerated routines through compiled C++ code for basic functions to support the natverse computational neuroanatomy ecosystem. natcpp is not designed to be used by end users but instead the nat package will use it when available to enable large speed-ups for some primitive operations. End users should therefore not count on the natcpp functions/interface being stable, especially during its initial development.

Our plan is to get this onto CRAN quite quickly so that binary packages will be available to Mac/Windows users who do not have a full C compiler toolchain installed. Once on CRAN, we will try to keep the package simple and stable, with infrequent updates. A development version will be available via the relevant github repository (see below). We do not intend to specify a GitHub remote so these updates will not be installed by default i.e. we will prefer CRAN binaries unless the user intervenes.

Installation

Install the released version of natcpp from CRAN with:

install.packages("natcpp")

For the development version, please do:

install.packages("natmanager")
natmanager::install(pkgs = 'natverse/natcpp')

Example

As already noted, the intention is that end users will only use the nat package (and that will automagically use natcpp when available). However to prove that everything is set up properly, you could do:

library(nat)
library(natcpp)
topntail(as.seglist(Cell07PNs[[1]]))

Copy Link

Version

Install

install.packages('natcpp')

Monthly Downloads

208

Version

0.2

License

GPL (>= 3)

Issues

Pull Requests

Stars

Forks

Maintainer

Gregory Jefferis

Last Published

October 14th, 2025

Functions in natcpp (0.2)

c_ijkpos

Convert physical coordinates to pixel coordinates
c_seglengths

Compute summed segment lengths or total cable
c_coords21dindex

Convert physical coordinates to 1d indices into image array
c_sub2ind

Find 1D index given n-dimensional indices
c_EdgeListFromSegList

Turn a segment list into an edgelist suitable for constructing an ngraph
c_listlengths

A simple function to compute the lengths of the elements of an R list
c_ListofMatrixRows

Convert a matrix into list of row vectors
c_topntail

Find the first and last elements of all vectors in a list
natcpp-package

natcpp: Fast C++ Primitives for the 'NeuroAnatomy Toolbox'