Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 1a1e1ef0 authored by hhakim's avatar hhakim
Browse files

Bind C++ Faust::seed (faust_prng) into the python wrapper (pyfaust.seed).

parent b7488c35
No related branches found
No related tags found
No related merge requests found
......@@ -150,6 +150,8 @@ class FaustCoreCpp
bool save_mat_file(const char* filepath) const;
static FaustCoreCpp<FPP, DEV>* read_from_mat_file(const char* filepath);
static int get_mat_file_type(const char* filepath);
static void set_seed(unsigned int seed) {Faust::seed(seed);};
static unsigned int get_seed() {return Faust::seed();};
FaustCoreCpp<FPP,DEV>* swap_cols(const unsigned int id1, const unsigned int id2,
const bool permutation, const bool inplace);
FaustCoreCpp<FPP,DEV>* swap_rows(const unsigned int id1, const unsigned int id2,
......
......@@ -72,6 +72,10 @@ cdef extern from "FaustCoreCpp.h":
@CPP_CORE_CLASS@[FPP]* read_from_mat_file(const char* filepath);
@staticmethod
int get_mat_file_type(const char* filepath);
@staticmethod
void set_seed(unsigned int seed);
@staticmethod
unsigned int get_seed();
@CPP_CORE_CLASS@[FPP]* swap_cols(const unsigned int id1, const unsigned int id2,
const bool permutation, const bool inplace);
@CPP_CORE_CLASS@[FPP]* swap_rows(const unsigned int id1, const unsigned int id2,
......
......@@ -431,7 +431,7 @@ cdef class FaustCoreGen@TYPE_NAME@@PROC@:
def power_iteration(self, threshold, max_num_its):
cdef @TYPE@[:] _lambda_view
_lambda = np.empty((1,), dtype=np.complex)
_lambda = np.empty((1,), dtype=type2dtype('@TYPE@'))
_lambda_view = _lambda
self.@CORE_OBJ@.power_iteration(&_lambda_view[0], threshold, max_num_its)
return _lambda[0]
......@@ -702,6 +702,12 @@ cdef class FaustCoreGen@TYPE_NAME@@PROC@:
PyMem_Free(cfilepath)
return _type
@staticmethod
def set_seed(seed):
if not np.isreal(seed) or np.floor(seed) != seed:
raise ValueError("seed must be an integer")
seed = int(seed)
FaustCoreCy.@CPP_CORE_CLASS@[@TYPE@].set_seed(seed)
def transpose(self):
core = @CORE_CLASS@(core=True)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment