Skip to content

bio-nim/rmath

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rmath

This repository comprises of Nim bindings to libRmath, a local fork of libRmath patched by the Julia developers to use a faster random number generator.

This is currently a work in progress, and while the low-level wrapper is mostly complete, the high level wrappers have yet to be written.

Compiling libRmath-nim

git clone http://github.com/sdwfrost/libRmath-nim.git
cd libRmath-nim
make

You will need to ensure that the shared library (libRmath-nim.dylib, libRmath-nim.so, or Rmath-nim.dll) can be found (e.g. by setting LD_LIBRARY_PATH).

Installation

The package can be installed using nimble.

git clone http://github.com/sdwfrost/rmath.git
cd rmath
nimble install

Usage

import random
import rmath

randomize()
set_seed(random(2500),random(2500))

var x=unif_rand()
echo x

var z=norm_rand()
echo z

var y=pchisq(3.84,1,true,false)
echo y

Testing

cd test
nim c --app:console -d:release --run test.nim

The above should give something like the following.

0.4356026948512537
-0.1727166441552057
0.9499564787512947

Future work

  • Generate wrappers that convert types.
  • Implement higher level wrappers modelled from Julia's Distributions.jl package.

Releases

No releases published

Packages

No packages published

Languages