Scientific computing and parallel computing C++23/C++26
sfp
sfp at cims.nyu.edu
Tue Jan 18 22:08:18 UTC 2022
On Tuesday, 18 January 2022 at 22:00:42 UTC, bachmeier wrote:
> On Tuesday, 18 January 2022 at 21:22:11 UTC, H. S. Teoh wrote:
>> [...]
>
> The next release of my embedr library (which I've been able to
> do now that my work life is finally returning to normal) will
> make it trivial to call D functions from R. What I mean by that
> is that you write a file of D functions and by the magic of
> metaprogramming, you don't need to write any boilerplate at all.
>
> Example:
>
> ```
> import mir.random;
> import mir.random.variable;
>
> RVector rngexample(int n) {
> auto gen = Random(unpredictableSeed);
> auto rv = uniformVar(-10, 10); // [-10, 10]
> auto result = RVector(n);
> foreach(ii; 0..n) {
> result[ii] = rv(gen);
> }
> return result;
> }
> mixin(createRFunction!rngexample);
> ```
>
> The only way you can do better is if someone else writes the
> program for you. But then it doesn't make much difference which
> language is used.
This is all news to me. It's a shame these libraries and their
capabilities aren't advertised my prominently.
How hard would it be to automatically wrap a D library and expose
it to Python, MATLAB, and Julia simultaneously? Say the library
even has a simple C-style API, or a very simple
single-inheritance OO hierarchy with no templates.
More information about the Digitalmars-d
mailing list