-
Notifications
You must be signed in to change notification settings - Fork 3
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
Showing
22 changed files
with
312 additions
and
99 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 |
---|---|---|
@@ -1,10 +1,12 @@ | ||
set(SOURCES ${SOURCES} | ||
${CMAKE_CURRENT_LIST_DIR}/random.cc | ||
${CMAKE_CURRENT_LIST_DIR}/halton.cc | ||
${CMAKE_CURRENT_LIST_DIR}/random_sampler.cc | ||
PARENT_SCOPE) | ||
|
||
set(HEADERS ${HEADERS} | ||
${CMAKE_CURRENT_LIST_DIR}/random_base.h | ||
${CMAKE_CURRENT_LIST_DIR}/random.h | ||
${CMAKE_CURRENT_LIST_DIR}/halton.h | ||
${CMAKE_CURRENT_LIST_DIR}/random_base.h | ||
${CMAKE_CURRENT_LIST_DIR}/random_sampler.h | ||
PARENT_SCOPE) |
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
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
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#define SPICA_RANDOM_SAMPLER_EXPORT | ||
#include "random_sampler.h" | ||
|
||
namespace spica { | ||
|
||
RandomSampler::RandomSampler() | ||
: _rng() | ||
{ | ||
} | ||
|
||
RandomSampler::~RandomSampler() | ||
{ | ||
} | ||
|
||
void RandomSampler::request(Stack<double>* rands, int n) { | ||
if (_rng) { | ||
_rng->request(rands, n); | ||
} | ||
} | ||
|
||
RandomSampler::RandomSampler(RandomSampler&& rs) | ||
: _rng(std::move(rs._rng)) | ||
{ | ||
} | ||
|
||
RandomSampler& RandomSampler::operator=(RandomSampler&& rs) { | ||
this->_rng = std::move(rs._rng); | ||
return *this; | ||
} | ||
|
||
} // namespace spica |
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,48 @@ | ||
#ifdef _MSC_VER | ||
#pragma once | ||
#endif | ||
|
||
#ifndef _SPICA_RANDOM_SAMPLER_H_ | ||
#define _SPICA_RANDOM_SAMPLER_H_ | ||
|
||
#if defined(_WIN32) || defined(__WIN32__) | ||
#ifdef SPICA_RANDOM_SAMPLER_EXPORT | ||
#define SPICA_RANDOM_SAMPLER_DLL __declspec(dllexport) | ||
#else | ||
#define SPICA_RANDOM_SAMPLER_DLL __declspec(dllimport) | ||
#endif | ||
#else | ||
#define SPICA_RANDOM_SAMPLER_DLL | ||
#endif | ||
|
||
#include <memory> | ||
|
||
#include "random_base.h" | ||
#include "../utils/stack.h" | ||
|
||
namespace spica { | ||
|
||
class RandomSampler { | ||
private: | ||
std::unique_ptr<RandomBase> _rng; | ||
|
||
public: | ||
RandomSampler(); | ||
~RandomSampler(); | ||
|
||
void request(Stack<double>* rands, int n); | ||
|
||
RandomSampler(RandomSampler&& rs); | ||
RandomSampler& operator=(RandomSampler&& rs); | ||
|
||
private: | ||
RandomSampler(const RandomSampler&) = delete; | ||
RandomSampler& operator=(const RandomSampler&) = delete; | ||
|
||
friend class Random; | ||
friend class Halton; | ||
}; | ||
|
||
} // namespace spica | ||
|
||
#endif // _SPICA_RANDOM_SAMPLER_H_ |
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
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
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
Oops, something went wrong.