Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] generates a vector of random numbers #24

Closed
Nelson-numerical-software opened this issue Apr 21, 2021 · 1 comment
Closed
Assignees

Comments

@Nelson-numerical-software

Currently, it is possible to generate a vector with a loop but it could be great to have a method to "quickly" generates an vector.

It could be:

Random::getVector<double>(-1, 1, N)

Thanks for your library

@ilqvya ilqvya self-assigned this Apr 22, 2021
ilqvya added a commit that referenced this issue Apr 24, 2021
ilqvya added a commit that referenced this issue Apr 25, 2021
ilqvya added a commit that referenced this issue Apr 25, 2021
ilqvya added a commit that referenced this issue Apr 26, 2021
@ilqvya
Copy link
Owner

ilqvya commented Apr 26, 2021

Hello

Support for random containers has been added in a recent 1.4.0 release

Resulting container elements type is automatically deducted from type of a two first arguments
Any container including standard STL containers with at least "begin", "end" and "insert" (nor for arrays) methods are valid

Usage examples:

auto vec = Random::get<std::vector>(1, 9, 5); // decltype(vec) is std::vector<int> with size = 5
// Note: "reserve" method invokes automatically for performance

auto mset = Random::get<std::multiset>(1.0, 9.9, 10); // decltype(mset) is std::multiset<double> with size = 10

auto arr = Random::get<std::array, 5>('0', '9'); // decltype(arr) is std::array<char, 5>
// Warning: Returning arrays with large size could be ineficcient

@ilqvya ilqvya closed this as completed Apr 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants