Skip to content

Commit

Permalink
Revert "poisson test"
Browse files Browse the repository at this point in the history
This reverts commit c109aff.
  • Loading branch information
cryptokatz committed Nov 14, 2018
1 parent c109aff commit 895b30b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 58 deletions.
4 changes: 1 addition & 3 deletions src/Common/Math.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@
#include "Math.h"

namespace {
#ifdef MSVC
char suppressMSVCWarningLNK4221;
#endif
char suppressMSVCWarningLNK4221;
}
65 changes: 10 additions & 55 deletions src/Common/int-util.h
Original file line number Diff line number Diff line change
@@ -1,20 +1,7 @@
// Copyright (c) 2012-2016, The CryptoNote developers, The Bytecoin developers
// Copyright (c) 2018 ryo-project
//
// This file is part of Bytecoin.
//
// Bytecoin is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Bytecoin is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with Bytecoin. If not, see <http://www.gnu.org/licenses/>.
// Copyright (c) 2011-2017 The Cryptonote developers
// Copyright (c) 2018 The Circle Foundation
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#pragma once

Expand All @@ -23,11 +10,6 @@
#include <stdint.h>
#include <string.h>
#include <sys/param.h>
#include <math.h>

#if defined(__ANDROID__)
#include <byteswap.h>
#endif

#if defined(_MSC_VER)
#include <stdlib.h>
Expand Down Expand Up @@ -132,25 +114,15 @@ static inline uint32_t div128_32(uint64_t dividend_hi, uint64_t dividend_lo, uin
static inline uint32_t ident32(uint32_t x) { return x; }
static inline uint64_t ident64(uint64_t x) { return x; }

#ifndef __OpenBSD__
# if defined(__ANDROID__) && defined(__swap32) && !defined(swap32)
# define swap32 __swap32
# elif !defined(swap32)
static inline uint32_t swap32(uint32_t x) {
x = ((x & 0x00ff00ff) << 8) | ((x & 0xff00ff00) >> 8);
return (x << 16) | (x >> 16);
x = ((x & 0x00ff00ff) << 8) | ((x & 0xff00ff00) >> 8);
return (x << 16) | (x >> 16);
}
# endif
# if defined(__ANDROID__) && defined(__swap64) && !defined(swap64)
# define swap64 __swap64
# elif !defined(swap64)
static inline uint64_t swap64(uint64_t x) {
x = ((x & 0x00ff00ff00ff00ff) << 8) | ((x & 0xff00ff00ff00ff00) >> 8);
x = ((x & 0x0000ffff0000ffff) << 16) | ((x & 0xffff0000ffff0000) >> 16);
return (x << 32) | (x >> 32);
x = ((x & 0x00ff00ff00ff00ff) << 8) | ((x & 0xff00ff00ff00ff00) >> 8);
x = ((x & 0x0000ffff0000ffff) << 16) | ((x & 0xffff0000ffff0000) >> 16);
return (x << 32) | (x >> 32);
}
# endif
#endif /* __OpenBSD__ */

#if defined(__GNUC__)
#define UNUSED __attribute__((unused))
Expand Down Expand Up @@ -193,24 +165,7 @@ static inline void memcpy_swap64(void *dst, const void *src, size_t n) {
}
}

// Calculate ln(p) of Poisson distribution
// https://github.com/ryo-currency/ryo-writeups/blob/master/poisson-writeup.md
// Original idea : https://stackoverflow.com/questions/30156803/implementing-poisson-distribution-in-c
// Using logarithms avoids dealing with very large (k!) and very small (p < 10^-44) numbers
// lam - lambda parameter - in our case, how many blocks, on average, you would expect to see in the interval
// k - k parameter - in our case, how many blocks we have actually seen
// !!! k must not be zero
// return - ln(p)

static inline double calc_poisson_ln(double lam, uint64_t k)
{
double logx = -lam + k * log(lam);
do
{
logx -= log(k); // This can be tabulated
} while (--k > 0);
return logx;
}


#if !defined(BYTE_ORDER) || !defined(LITTLE_ENDIAN) || !defined(BIG_ENDIAN)
static_assert(false, "BYTE_ORDER is undefined. Perhaps, GNU extensions are not enabled");
Expand Down

0 comments on commit 895b30b

Please sign in to comment.