Interfacing D to C R standalone math library
TJB
broughtj at gmail.com
Thu May 31 05:40:56 PDT 2012
One more question, if I may. I noticed that I forgot to include
the set_seed function. The call to rnorm works the way I have
called it, but it must be using some default seed (its a random
number generator).
I have tried including the set_seed function as follows:
import std.stdio;
extern (C) void set_seed(unsigned int, unsigned int);
extern (C) double rnorm(double, double);
void main() {
set_seed(0,77991);
foreach(i; 0 .. 100) {
writeln(myfunc(0.0, 1.0));
}
}
double myfunc(double a, double b) {
return rnorm(a, b);
}
I compile this the same way as you suggest, but now the compiler
is squealing at me with the following message:
$ dmd rnorm.d -L-L/usr/lob -L-lRmath -L-lm
rnorm.d(6): found 'int' when expecting ')'
rnorm.d(6): semicolon expected following function declaration
rnorm.d(6): Declaration expected, not ','
When I grep set_seed in Rmath.h I get:
$ grep set_seed Rmath.h
void set_seed(unsigned int, unsigned int);
So I think I have called it correctly. Any thoughts or
suggestions?
Thanks, you have been so helpful!
TJB
More information about the Digitalmars-d-learn
mailing list