From 78c05afbc2085ae6eb8b12fab19c639045591fe6 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Sat, 15 Jan 2022 09:23:57 +0000 Subject: [PATCH] - removed noise c-sources git-svn-id: http://moon:8086/svn/software/trunk/projects/Rbm@812 b431acfa-c32f-4a4a-93f1-934dc6c82436 --- source/DrawComponent.cpp | 1 - source/Rbm.cpp | 2 - source/Rbm.hpp | 2 - source/noise.c | 80 ---------------------------------------- source/noise.h | 42 --------------------- 5 files changed, 127 deletions(-) delete mode 100644 source/noise.c delete mode 100644 source/noise.h diff --git a/source/DrawComponent.cpp b/source/DrawComponent.cpp index e828773..676795c 100644 --- a/source/DrawComponent.cpp +++ b/source/DrawComponent.cpp @@ -18,7 +18,6 @@ */ //[Headers] You can add your own extra header files here... -#include "noise.h" void mylog(const char* format, ...); //[/Headers] diff --git a/source/Rbm.cpp b/source/Rbm.cpp index b39e9cc..6f0abba 100644 --- a/source/Rbm.cpp +++ b/source/Rbm.cpp @@ -24,7 +24,6 @@ Rbm::Rbm(size_t numVisible, size_t numHidden) { assert(numVisible > 0); assert(numHidden > 0); - Noise_Init(&m_noise, 0x32727155); } Rbm::Rbm(const Rbm& orig) @@ -37,7 +36,6 @@ Rbm::Rbm(const Rbm& orig) Rbm::~Rbm() { - Noise_Free(&m_noise); } size_t Rbm::numHidden() const diff --git a/source/Rbm.hpp b/source/Rbm.hpp index 8b0ceff..6b5821e 100644 --- a/source/Rbm.hpp +++ b/source/Rbm.hpp @@ -18,7 +18,6 @@ #include #include -#include "noise.h" class Rbm { @@ -161,7 +160,6 @@ protected: arma::mat m_bv; private: - noise_gen_t m_noise; arma::mat m_whv; }; diff --git a/source/noise.c b/source/noise.c deleted file mode 100644 index 542d48f..0000000 --- a/source/noise.c +++ /dev/null @@ -1,80 +0,0 @@ -// -------------------------------------------------------------- -// -------------------------------------------------------------- - -#include -#include -#include -#include - -#include "noise.h" - -// -------------------------------------------------------------- -// internal funcs -// -------------------------------------------------------------- -#define PM_IA 16807 -#define PM_IM 2147483647 -#define PM_AM (1.0/PM_IM) -#define PM_IQ 127773 -#define PM_IR 2836 -#define PM_MASK 123459876 - -// 'Minimal' random number generator of Park and Miller. Returns a uniform random deviate -// between 0.0 and 1.0. Set or reset idum to any integer value (except the unlikely value MASK) -// to initialize the sequence; idum must not be altered between calls for successive deviates in -// a sequence. -double ran0(long *idum) -{ - long k; - double ans; - - *idum ^= PM_MASK; // XORing with MASK allows use of zero and other - k=(*idum)/PM_IQ; // simple bit patterns for idum. - *idum=PM_IA*(*idum-k*PM_IQ)-PM_IR *k; // Compute idum=(IA*idum) % IM without over- - // flows by Schrage’s method. - if (*idum < 0) - *idum += PM_IM; - - ans=PM_AM*(*idum); // Convert idumto a floating result. - *idum ^= PM_MASK; // Unmask before return. - - return ans; -} - -// -------------------------------------------------------------- -// Exported functions -// -------------------------------------------------------------- -void Noise_Init(noise_gen_t *pObj, long seed) -{ - - pObj->state = seed; -} - -void Noise_Free(noise_gen_t *pObj) -{ -} - -// 0 .. 1 -double Noise_Uniform(noise_gen_t *pObj) -{ - return ran0(&pObj->state); -} - -double Noise_Gaussian(noise_gen_t *pObj) -{ - double U1, U2, V1, V2, S, Y; - - do - { - U1 = Noise_Uniform(pObj); // U1=[0,1] - U2 = Noise_Uniform(pObj); // U2=[0,1] - V1 = 2 * U1 - 1; // V1=[-1,1] - V2 = 2 * U2 - 1; // V2=[-1,1] - S = V1 * V1 + V2 * V2; - - } while (S >= 1); - - // X = sqrt(-2 * log(S) / S) * V1; - Y = sqrt(-2 * log(S) / S) * V2; - - return Y; -} diff --git a/source/noise.h b/source/noise.h deleted file mode 100644 index cc56e29..0000000 --- a/source/noise.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - ============================================================================== - - noise.h - Created: 21 Sep 2014 1:55:07pm - Author: jens - - ============================================================================== -*/ -// -------------------------------------------------------------- -#ifndef _NOISE_H_ -#define _NOISE_H_ - -#define __func__ "" -// -------------------------------------------------------------- -// Types -// -------------------------------------------------------------- -typedef struct _snoise_gen_t -{ - long state; -} noise_gen_t; - -// -------------------------------------------------------------- -#if defined(__cplusplus) -extern "C" { -#endif - -// -------------------------------------------------------------- -// Exported functions -// -------------------------------------------------------------- -void Noise_Init(noise_gen_t *pObj, long seed); -void Noise_Free(noise_gen_t *pObj); -double Noise_Uniform(noise_gen_t *pObj); -double Noise_Gaussian(noise_gen_t *pObj); - -#if defined(__cplusplus) -} - -#endif -// -------------------------------------------------------------- - -#endif // _NOISE_H_