Coder Social home page Coder Social logo

use Armadillo RNG support about ensmallen HOT 8 CLOSED

mlpack avatar mlpack commented on August 22, 2024
use Armadillo RNG support

from ensmallen.

Comments (8)

conradsnicta avatar conradsnicta commented on August 22, 2024

Armadillo has an internal class called arma_rng_cxx11, but it's not part of the public API.

The ARMA_USE_EXTERN_CXX11_RNG define is set by the armadillo cmake installer to indicate that the arma::arma_rng_cxx11_instance is available in the armadillo wrapper library. The define not meant to be used outside of that specific use case. Furthermore, it's only valid on Linux systems with gcc 4.8.3+. It currently doesn't work with macOS or windoze. (it should be trivial to make it work with macOS, now that Apple has proper support for thethread_local storage class in C++11).

Perhaps it would be sufficient to simply use the public randi(), randu(), randn() and randg() functions ?

In armadillo version 8.400+ all of the above functions were extended to output single scalars.
randg() was added in version 4.650. randi() was added in version 3.930.
randu() and randn() have been available "since forever".

If armadillo 8.400 is "too recent", it's still possible to use the above functions to generate scalars. Simply use as_scalar() on a random vector that has only one dimension.

As a sidenote, armadillo 8.400 is available in Ubuntu 18.04.

from ensmallen.

zoq avatar zoq commented on August 22, 2024

In case of:

std::shuffle(visitationOrder.begin(), visitationOrder.end(), mlpack::math::randGen);

it should be reasonable to use:

visitationOrder = arma::shuffel(visitationOrder);

any thoughts?

from ensmallen.

zoq avatar zoq commented on August 22, 2024

For the other cases I agree, it would be simple to use: arma::as_scalar(randi(...)).

from ensmallen.

rcurtin avatar rcurtin commented on August 22, 2024

Agreed on both counts---I wonder why we didn't just use arma::shuffle(visitationOrder) originally?

from ensmallen.

zoq avatar zoq commented on August 22, 2024

I guess the benefit is that std::shuffel works inplace; should be neglectable here.

from ensmallen.

conradsnicta avatar conradsnicta commented on August 22, 2024

arma:shuffle() should detect aliasing and do an inplace shuffle:
https://gitlab.com/conradsnicta/armadillo-code/blob/9.200.x/include/armadillo_bits/op_shuffle_meat.hpp#L62
https://gitlab.com/conradsnicta/armadillo-code/blob/9.200.x/include/armadillo_bits/op_shuffle_meat.hpp#L129

from ensmallen.

zoq avatar zoq commented on August 22, 2024

Thanks for the clarification, should have checked first. 05a8743 implements the modifications.

from ensmallen.

rcurtin avatar rcurtin commented on August 22, 2024

I think this one is fully handled now---I see no use of any random object or anything other than Armadillo's existing public random functions.

from ensmallen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.