-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generalised wrapper from LFG class to Sprng class.
- Loading branch information
Showing
7 changed files
with
74 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,25 @@ | ||
{-# LANGUAGE ForeignFunctionInterface #-} | ||
{-# OPTIONS_GHC -fno-warn-missing-signatures #-} | ||
module Sprng.Internal | ||
( LFGPtr | ||
, new_lfg | ||
, init_lfg | ||
, get_rn_int_lfg | ||
, get_rn_flt_lfg | ||
, get_rn_dbl_lfg | ||
, free_lfg | ||
( SprngPtr | ||
, new_rng | ||
, init_rng | ||
, get_rn_int | ||
, get_rn_flt | ||
, get_rn_dbl | ||
, free_rng | ||
, print_rng | ||
) where | ||
|
||
import Foreign.Ptr (Ptr) | ||
import Foreign.C.Types (CInt, CFloat, CDouble) | ||
|
||
type LFGPtr = Ptr () | ||
type SprngPtr = Ptr () | ||
|
||
foreign import ccall "new_lfg" new_lfg :: IO LFGPtr | ||
foreign import ccall "init_lfg" init_lfg :: LFGPtr -> CInt -> CInt -> CInt -> CInt -> IO () | ||
foreign import ccall "get_rn_int_lfg" get_rn_int_lfg :: LFGPtr -> IO CInt | ||
foreign import ccall "get_rn_flt_lfg" get_rn_flt_lfg :: LFGPtr -> IO CFloat | ||
foreign import ccall "get_rn_dbl_lfg" get_rn_dbl_lfg :: LFGPtr -> IO CDouble | ||
foreign import ccall "free_lfg" free_lfg :: LFGPtr -> IO () | ||
foreign import ccall "new_rng" new_rng :: CInt -> IO SprngPtr | ||
foreign import ccall "init_rng" init_rng :: SprngPtr -> CInt -> CInt -> CInt -> CInt -> IO () | ||
foreign import ccall "get_rn_int" get_rn_int :: SprngPtr -> IO CInt | ||
foreign import ccall "get_rn_flt" get_rn_flt :: SprngPtr -> IO CFloat | ||
foreign import ccall "get_rn_dbl" get_rn_dbl :: SprngPtr -> IO CDouble | ||
foreign import ccall "free_rng" free_rng :: SprngPtr -> IO () | ||
foreign import ccall "print_rng" print_rng :: SprngPtr -> IO () |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include "sprng_wrapper.h" | ||
|
||
// Sprng * new_rng(Rng_type type) | ||
// XXX should use the enum type instead. | ||
Sprng * new_rng(int type) | ||
{ | ||
return SelectType(type); | ||
} | ||
|
||
void init_rng(Sprng *rng, int streamnum, int nstreams, int seed, int pa) | ||
{ | ||
rng->init_rng(streamnum, nstreams, seed, pa); | ||
} | ||
|
||
int get_rn_int(Sprng *rng) | ||
{ | ||
return rng->get_rn_int(); | ||
} | ||
|
||
float get_rn_flt(Sprng *rng) | ||
{ | ||
return rng->get_rn_flt(); | ||
} | ||
|
||
double get_rn_dbl(Sprng *rng) | ||
{ | ||
return rng->get_rn_dbl(); | ||
} | ||
|
||
void free_rng(Sprng *rng) | ||
{ | ||
rng->free_rng(); | ||
} | ||
|
||
void print_rng(Sprng *rng) | ||
{ | ||
rng->print_rng(); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef SPRNG_WRAPPER_H | ||
#define SPRNG_WRAPPER_H | ||
|
||
#include "sprng.h" | ||
#include "sprng_cpp.h" | ||
|
||
typedef enum { LFG, LCG, LCG64, CMRG, MLFG, PMLCG } Rng_type; | ||
|
||
//extern "C" Sprng * new_rng(Rng_type); | ||
extern "C" Sprng * new_rng(int); | ||
extern "C" void init_rng(Sprng *, int, int, int, int); | ||
extern "C" int get_rn_int(Sprng *); | ||
extern "C" float get_rn_flt(Sprng *); | ||
extern "C" double get_rn_dbl(Sprng *); | ||
extern "C" void free_rng(Sprng *); | ||
extern "C" void print_rng(Sprng *); | ||
|
||
#endif |