Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e0eea27
Showing
7 changed files
with
170 additions
and
0 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,27 @@ | ||
Copyright (c) 2011 XXX. | ||
|
||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions | ||
are met: | ||
1. Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
2. Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
3. Neither the name of the author nor the names of his contributors | ||
may be used to endorse or promote products derived from this software | ||
without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR | ||
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | ||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | ||
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | ||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | ||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
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,35 @@ | ||
Haskell-sprng, Haskell bindings to the SPRNG library | ||
---------------------------------------------------- | ||
|
||
How to build | ||
------------ | ||
|
||
Testing | ||
------- | ||
|
||
How to enable testing | ||
--------------------- | ||
|
||
How to run the unit tests | ||
------------------------- | ||
|
||
How to run standalone tests | ||
--------------------------- | ||
|
||
License and Copyright | ||
--------------------- | ||
|
||
Haskell-sprng is distributed as open source software under the terms of the BSD | ||
License (see the file LICENSE in the top directory). | ||
|
||
Author(s): Bernie Pope, Copyright ... 2011 | ||
|
||
Contact information | ||
------------------- | ||
|
||
Email Bernie Pope: | ||
|
||
florbitous <at> gmail <dot> com | ||
|
||
History | ||
------- |
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,3 @@ | ||
#!/usr/bin/env runhaskell | ||
> import Distribution.Simple | ||
> main = defaultMain |
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,37 @@ | ||
name: haskell-sprng | ||
version: 0.0.1 | ||
cabal-version: >= 1.6 | ||
synopsis: Binding to the SPRNG Pseuod Random Number Generator Library. | ||
description: Write long description here. | ||
category: FFI, Random Numbers | ||
license: BSD3 | ||
license-file: LICENSE | ||
copyright: (c) | ||
author: Bernard James Pope (Bernie Pope) | ||
maintainer: florbitous@gmail.com | ||
homepage: http://github.com/bjpop/haskell-sprng | ||
build-type: Simple | ||
stability: experimental | ||
tested-with: GHC==7.0.2 | ||
extra-source-files: src/cbits/*.cpp src/include/*.h README.txt | ||
|
||
source-repository head | ||
type: git | ||
location: git://github.com/bjpop/haskell-sprng.git | ||
|
||
Library | ||
extra-libraries: sprng | ||
build-tools: | ||
ghc-options: -Wall -fno-warn-name-shadowing -fno-warn-orphans -pgml g++ | ||
c-sources: | ||
src/cbits/lfg_wrapper.cpp | ||
include-dirs: | ||
src/include | ||
hs-source-dirs: | ||
src | ||
build-depends: | ||
base > 3 && <= 5, | ||
haskell98 | ||
exposed-modules: | ||
Sprng.Internal | ||
other-modules: |
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,23 @@ | ||
{-# 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 | ||
) where | ||
|
||
import Foreign.Ptr (Ptr) | ||
import Foreign.C.Types (CInt, CFloat, CDouble) | ||
|
||
type LFGPtr = 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 () |
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,31 @@ | ||
#include "lfg_wrapper.h" | ||
|
||
LFG * new_lfg(void) | ||
{ | ||
return new LFG; | ||
} | ||
|
||
void init_lfg(LFG *lfg, int streamnum, int nstreams, int seed, int pa) | ||
{ | ||
lfg->init_rng(streamnum, nstreams, seed, pa); | ||
} | ||
|
||
int get_rn_int_lfg(LFG *lfg) | ||
{ | ||
return lfg->get_rn_int(); | ||
} | ||
|
||
float get_rn_flt_lfg(LFG *lfg) | ||
{ | ||
return lfg->get_rn_flt(); | ||
} | ||
|
||
double get_rn_dbl_lfg(LFG *lfg) | ||
{ | ||
return lfg->get_rn_dbl(); | ||
} | ||
|
||
void free_lfg(LFG *lfg) | ||
{ | ||
lfg->free_rng(); | ||
} |
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,14 @@ | ||
#ifndef LFG_WRAPPER_H | ||
#define LFG_WRAPPER_H | ||
|
||
#include "sprng.h" | ||
#include "lfg.h" | ||
|
||
extern "C" LFG * new_lfg(void); | ||
extern "C" void init_lfg(LFG *, int, int, int, int); | ||
extern "C" int get_rn_int_lfg(LFG *); | ||
extern "C" float get_rn_flt_lfg(LFG *); | ||
extern "C" double get_rn_dbl_lfg(LFG *); | ||
extern "C" void free_lfg(LFG *); | ||
|
||
#endif |