WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
UniformRandom.hpp
Go to the documentation of this file.
1/******************************************************************************
2* Copyright (c) ATTX INC 2025. All Rights Reserved.
3*
4* This software and associated documentation (the "Software") are the
5* proprietary and confidential information of ATTX INC. The Software is
6* furnished under a license agreement between ATTX and the user organization
7* and may be used or copied only in accordance with the terms of the agreement.
8* Refer to 'license/attx_license.adoc' for standard license terms.
9*
10* EXPORT CONTROL NOTICE: THIS SOFTWARE MAY INCLUDE CONTENT CONTROLLED UNDER THE
11* INTERNATIONAL TRAFFIC IN ARMS REGULATIONS (ITAR) OR THE EXPORT ADMINISTRATION
12* REGULATIONS (EAR99). No part of the Software may be used, reproduced, or
13* transmitted in any form or by any means, for any purpose, without the express
14* written permission of ATTX INC.
15******************************************************************************/
16/*
17Uniform Random Distribution Header File
18
19Author: Alex Reynolds
20*/
21#ifndef UNIFORM_RANDOM_HPP
22#define UNIFORM_RANDOM_HPP
23
24#include <random>
25
28
29namespace warptwin {
30
41 template<typename T>
43 public:
48 UniformRandom(T set_min, T set_max, unsigned int seed = 0);
50
52
55
58
61 protected:
62 std::mt19937 _engine;
63 std::uniform_real_distribution<double> _distribution;
64 };
65
66 template <typename T>
67 UniformRandom<T>::UniformRandom(T set_min, T set_max, unsigned int seed)
68 : _engine{seed}, _distribution(0, 1.0) {
69 // Handle the case where someone put numbers in backwards. Someone will.
70 if(set_min > set_max) {
71 min(set_max);
72 max(set_min);
73 } else {
74 min(set_min);
75 max(set_max);
76 }
77 }
78
79 template <typename T>
81 // Calculate our distribution as
82 // val = min + (max - min)*rng
83
84 return min() + _distribution(_engine)*(max() - min());
85 }
86
87}
88
89#endif
Class for inter-object communication.
Definition DataIO.hpp:60
Base class for object organization.
Definition GraphTreeObject.h:98
~UniformRandom()
Definition UniformRandom.hpp:49
T operator()()
Definition UniformRandom.hpp:80
std::uniform_real_distribution< double > _distribution
Definition UniformRandom.hpp:63
clockwerk::DataIO< T > min
The min of the uniform distribution output. Can be get/set.
Definition UniformRandom.hpp:54
clockwerk::DataIO< T > max
The max of the uniform distribution output. Can be get/set.
Definition UniformRandom.hpp:57
clockwerk::DataIO< int > seed
Definition UniformRandom.hpp:60
UniformRandom(T set_min, T set_max, unsigned int seed=0)
Constructor for the normal random distribution.
Definition UniformRandom.hpp:67
std::mt19937 _engine
Definition UniformRandom.hpp:62
Class to propagate CR3BP dynamics in characteristic units.
Definition statistics.hpp:22
int min(T *array, unsigned int size, T &result)
Definition statistics.hpp:85
int max(T *array, unsigned int size, T &result)
Definition statistics.hpp:67