Thread overview
Binding to GSL library
Nov 25, 2015
Radek
Nov 25, 2015
drug
Nov 25, 2015
Radek
Nov 26, 2015
Andrew
Nov 26, 2015
lobo
Nov 26, 2015
Artur Skawina
November 25, 2015
Hi, I'm making a trying to bind a gsl library http://www.gnu.org/software/gsl/ so far it was working but when i started binding complex numbers some functions won't work, like trigonometric functions - called they return null.

in gsl code complex struct looks like:

typedef struct
  {
    double dat[2];
  }
gsl_complex;


my complex struct looks like that:

struct _gsl_complex {
  double dat[2];
}
alias gsl_complex = _gsl_complex*;

So, what im doing wrong?
November 25, 2015
On 25.11.2015 19:11, Radek wrote:
> Hi, I'm making a trying to bind a gsl library
> http://www.gnu.org/software/gsl/ so far it was working but when i
> started binding complex numbers some functions won't work, like
> trigonometric functions - called they return null.
>
> in gsl code complex struct looks like:
>
> typedef struct
>    {
>      double dat[2];
>    }
> gsl_complex;
>
>
> my complex struct looks like that:
>
> struct _gsl_complex {
>    double dat[2];
> }
> alias gsl_complex = _gsl_complex*;
>
> So, what im doing wrong?
A little bit offtopic but do you know about https://github.com/abrown25/gsld? It would be nice to join efforts.
November 25, 2015
i have found bug. It shoul be
alias gsl_complex = _gsl_complex;
not
alias gsl_complex = _gsl_complex*;

On Wednesday, 25 November 2015 at 16:35:06 UTC, drug wrote:
> A little bit offtopic but do you know about https://github.com/abrown25/gsld? It would be nice to join efforts.

Sure, I'll share my code :)

Ask me next month. That what I'm doing is my student project and first i need to complete it :)
November 26, 2015
On Wednesday, 25 November 2015 at 16:11:56 UTC, Radek wrote:
> Hi, I'm making a trying to bind a gsl library http://www.gnu.org/software/gsl/ so far it was working but when i started binding complex numbers some functions won't work, like trigonometric functions - called they return null.
>
> in gsl code complex struct looks like:
>
> typedef struct
>   {
>     double dat[2];
>   }
> gsl_complex;
>
>
> my complex struct looks like that:
>
> struct _gsl_complex {
>   double dat[2];
> }
> alias gsl_complex = _gsl_complex*;
>
> So, what im doing wrong?

I believe if you're interfacing with C you should use __gshared:

alias gsl_complex = __gshared _gsl_complex*;

bye,
lobo
November 26, 2015
On 11/25/15 17:11, Radek via Digitalmars-d-learn wrote:
> Hi, I'm making a trying to bind a gsl library http://www.gnu.org/software/gsl/ so far it was working but when i started binding complex numbers some functions won't work, like trigonometric functions - called they return null.
> 
> in gsl code complex struct looks like:
> 
> typedef struct
>   {
>     double dat[2];
>   }
> gsl_complex;
> 
> 
> my complex struct looks like that:
> 
> struct _gsl_complex {
>   double dat[2];
> }
> alias gsl_complex = _gsl_complex*;
> 
> So, what im doing wrong?

That's not a struct but a pointer to a struct.

Also, you can just drop the `typedef` hack (which is used in C to avoid having to type the 'struct' keyword), so:

   struct gsl_complex {
      double[2] dat;
   }

artur
November 26, 2015
On Wednesday, 25 November 2015 at 16:45:51 UTC, Radek wrote:
> i have found bug. It shoul be
> alias gsl_complex = _gsl_complex;
> not
> alias gsl_complex = _gsl_complex*;
>
> On Wednesday, 25 November 2015 at 16:35:06 UTC, drug wrote:
>> A little bit offtopic but do you know about https://github.com/abrown25/gsld? It would be nice to join efforts.
>
> Sure, I'll share my code :)
>
> Ask me next month. That what I'm doing is my student project and first i need to complete it :)

Hi, I've been a little slow updating that repository because of work, and I got a little stuck with function pointers, I hope to get back to it soon. It would be lovely if it's all finished by that time :)