summaryrefslogtreecommitdiff
path: root/src/util/sampler.h
blob: d52da6211e86e6e562c3019fd2a3c47539e5d2a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/******************************************************************************
 * Top contributors (to current version):
 *   Andres Noetzli, Mathias Preiner
 *
 * This file is part of the cvc5 project.
 *
 * Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
 * in the top-level source directory and their institutional affiliations.
 * All rights reserved.  See the file COPYING in the top-level source
 * directory for licensing information.
 * ****************************************************************************
 *
 * Sampler class that generates random values of different sorts
 *
 * The Sampler class can be used to generate random values of different sorts
 * with biased and unbiased distributions.
 */

#include "cvc5_private.h"

#ifndef CVC5__UTIL_FLOATINGPOINT_SAMPLER_H
#define CVC5__UTIL_FLOATINGPOINT_SAMPLER_H

#include "util/floatingpoint.h"

namespace cvc5 {

class Sampler
{
 public:
  /**
   * Generates a random, uniform bit-vector value.
   */
  static BitVector pickBvUniform(unsigned sz);

  /**
   * Generates a random, uniform floating-point value.
   */
  static FloatingPoint pickFpUniform(unsigned e, unsigned s);

  /**
   * Generates a random floating-point value biased towards special values
   * (e.g.  +/- inf) and interesting bit-patterns (e.g. values with a zero
   * significand).
   */
  static FloatingPoint pickFpBiased(unsigned e, unsigned s);

 private:
  /**
   * Probablility with which special floating-point values are picked when
   * picking a biased floating-point value
   */
  static constexpr double probSpecial = 0.2;
};

}  // namespace cvc5

#endif /* CVC5__UTIL_FLOATINGPOINT_SAMPLER_H */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback