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

Added ZigguratGaussianRng #651

Merged

Conversation

ralfkonrad
Copy link
Contributor

Not sure if we can add it elsewhere?!

@lballabio lballabio added this to the Release 1.35 milestone Jun 18, 2024
@lballabio
Copy link
Owner

I guess we could also export RandomSequenceGenerator<ZigguratGaussianRng<Xoshiro256StarStarUniformRng>>?

@ralfkonrad
Copy link
Contributor Author

Okay, I'll give it a try.

@ralfkonrad
Copy link
Contributor Author

Hm, it doesn't work out-of-the-box: template<class RNG> class RandomSequenceGenerator expects

RandomSequenceGenerator(Size dimensionality,
                        BigNatural seed = 0);

which translate into a missing constructor

explicit ZigguratGaussianRng<RNG>(BigNatural seed = 0);

We could add in SWIG something like

{%
template <class RNG>
class ZigguratGaussianRngExtension
    : public QuantLib::ZigguratGaussianRng<RNG> {
  public:
    ZigguratGaussianRngExtension(BigNatural seed = 0)
        : QuantLib::ZigguratGaussianRng<RNG>(RNG(seed)) {}
  };
%}

%template(ZigguratXoshiro256StarStarGaussianRsg)
    RandomSequenceGenerator<
        ZigguratGaussianRngExtension<Xoshiro256StarStarUniformRng>>;

which works but creates e.g. these artificial java classes like SWIGTYPE_p_ZigguratGaussianRngExtensionT_Xoshiro256StarStarUniformRng_t.

We could add the constructor explicit ZigguratGaussianRng<RNG>(BigNatural seed = 0); in QuantLib directly but that's also a bit dirty.

Any better idea?

@lballabio
Copy link
Owner

Added — I hid it behind a typedef and exported the available interface only.

@lballabio lballabio merged commit 8849cae into lballabio:master Jun 19, 2024
8 checks passed
@ralfkonrad
Copy link
Contributor Author

Fine, thanks!

@ralfkonrad ralfkonrad deleted the feature/add_ZigguratGaussianRng branch June 19, 2024 14:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants