[Gambas-user] Gambas3 and Gnu scientific library

Jussi Lahtinen jussi.lahtinen at ...626...
Sat May 21 01:30:24 CEST 2011


Hmmm.... but then there should be also some kind of Struct@ function.
Doesn't sound easy to implement!

Jussi


On Sat, May 21, 2011 at 02:08, Jussi Lahtinen <jussi.lahtinen at ...626...>wrote:

> Corrected (and working) version attached.
> Though I'm not fully satisfied to it. Benoit, is it possible to have
> pointer to struct with varptr?
> Right now it cannot be done..? If you look at that attachment you will see
> why it would be useful...
>
> Jussi
>
>
>
> On Fri, May 20, 2011 at 13:57, wally <wally at ...2037...> wrote:
>
>>
>> Of course i want to try some other functionality of GSL too.
>> and of course I'm too stupid :)
>>
>> now 1st derivative
>> the code contains also the working C original and the necessary header
>> files
>> containing the necessary definitions.
>>
>> error message is : FMain class  line 50
>> "VarPtr() argument must be a dynamic, a static or a local variable"
>>
>> wally
>>
>>
>> On Wednesday, May 18, 2011 18:07:56 Jussi Lahtinen wrote:
>> > Seems to work (Gambas 3 rev 3850 @ Ubuntu 10.10 64bit), though, I
>> haven't
>> > check if the results are correct.
>> > I'm out of time.
>> >
>> > Source attached.
>> >
>> > BTW. Why 'Library "libgsl"' doesn't find *any* library? However 'Library
>> > "libgsl:0"' does!
>> >
>> > Jussi
>> >
>> > On Wed, May 18, 2011 at 18:53, wally <wally at ...2037...> wrote:
>> > > Yes, few surprises in direction science are highly appreciated :)
>> > >
>> > > I have compile problems with the new "extern"
>> > > At revision 3850.    OpenSuse 11.3
>> > >
>> > >
>> > > gambas3_svn/trunk/main/gbx/gbx_c_application.c:401: undefined
>> reference
>> > > to `EXTERN_get_symbol'
>> > > collect2: ld returned 1 exit status
>> > >
>> > > wally
>> > >
>> > > On Wednesday, May 18, 2011 17:33:31 Jussi Lahtinen wrote:
>> > > > Benoit keeps on amazing us!
>> > > >
>> > > > Jussi
>> > > > P.S. I haven't test it yet...
>> > > >
>> > > > On Wed, May 18, 2011 at 18:21, wally <wally at ...2037...> wrote:
>> > > > > Thanks a lot ! :)
>> > > > > wally
>> > > > >
>> > > > > On Wednesday, May 18, 2011 17:07:09 Benoît Minisini wrote:
>> > > > > > > Hello  Jussi,
>> > > > > > >
>> > > > > > > in C the stuff works pretty nice, so i agree to your
>> suggestion
>> > > > > > > 2.
>> > > > > > >
>> > > > > > > Do all math stuff directly in Gambas is an option i should
>> check.
>> > > > > > >
>> > > > > > > I think i mentioned that i use Gambas3 and want to make
>> > > > > > > interpolations, derivatives and integrals from an integrarray.
>> > > > > > > The array contains ADC outputs from a CCD linear array sensor
>> > > > >
>> > > > > measurment
>> > > > >
>> > > > > > > wally
>> > > > > > >
>> > > > > > > On Monday, May 16, 2011 17:46:51 Jussi Lahtinen wrote:
>> > > > > > > > Not very easy task...
>> > > > > > > > Here is interpolation example in C.
>> > >
>> > >
>> http://www.gnu.org/software/gsl/manual/html_node/Interpolation-Example-
>> > >
>> > > > > > > > pr og rams.html
>> > > > > > > >
>> > > > > > > > As you can see, you need to call several functions to get
>> what
>> > >
>> > > you
>> > >
>> > > > > > > > want. Declaring those in Gambas is OK, except determining
>> > > > > > > > interpolation type!
>> > > > > > > >
>> > > > > > > > You can find definition of interpolation type from
>> > >
>> > > "gsl_interp.h",
>> > >
>> > > > > > > > and unfortunately it is not anything simple;
>> > > > > > > >
>> > > > > > > > typedef struct {
>> > > > > > > >
>> > > > > > > >   const char * name;
>> > > > > > > >   unsigned int min_size;
>> > > > > > > >   void *  (*alloc) (size_t size);
>> > > > > > > >   int     (*init)    (void *, const double xa[], const
>> double
>> > >
>> > > ya[],
>> > >
>> > > > > > > >   size_t
>> > > > > > > >
>> > > > > > > > size);
>> > > > > > > >
>> > > > > > > >   int     (*eval)    (const void *, const double xa[], const
>> > >
>> > > double
>> > >
>> > > > > > > >   ya[],
>> > > > > > > >
>> > > > > > > > size_t size, double x, gsl_interp_accel *, double * y);
>> > > > > > > >
>> > > > > > > >   int     (*eval_deriv)  (const void *, const double xa[],
>> > > > > > > >   const
>> > > > >
>> > > > > double
>> > > > >
>> > > > > > > > ya[], size_t size, double x, gsl_interp_accel *, double *
>> y_p);
>> > > > > > > >
>> > > > > > > >   int     (*eval_deriv2) (const void *, const double xa[],
>> > > > > > > >   const
>> > > > >
>> > > > > double
>> > > > >
>> > > > > > > > ya[], size_t size, double x, gsl_interp_accel *, double *
>> > > > > > > > y_pp);
>> > > > > > > >
>> > > > > > > >   int     (*eval_integ)  (const void *, const double xa[],
>> > > > > > > >   const
>> > > > >
>> > > > > double
>> > > > >
>> > > > > > > > ya[], size_t size, gsl_interp_accel *, double a, double b,
>> > > > > > > > double
>> > >
>> > > *
>> > >
>> > > > > > > > result); void    (*free)         (void *);
>> > > > > > > >
>> > > > > > > > } gsl_interp_type;
>> > > > > > > >
>> > > > > > > > GSL_VAR const gsl_interp_type * gsl_interp_cspline; * <--
>> this
>> > > > > > > > is
>> > > > >
>> > > > > used
>> > > > >
>> > > > > > > > in example*
>> > > > > > > >
>> > > > > > > >
>> > > > > > > > Right now I don't know how to implement that reasonably in
>> > >
>> > > Gambas.
>> > >
>> > > > > > > > There are at least three possibilities to overcome this
>> > > > > > > > problem:
>> > > > > > > >
>> > > > > > > > 1. Hope that Benoit will implement new feature to use
>> external
>> > > > > > > > structures. 2. Use C to write your own interface between GSL
>> > > > > > > > and Gambas. Perhaps easiest option.
>> > > > > > > > 3. Do not use GSL at all, and write what you need purely
>> with
>> > > > > > > > Gambas.
>> > > > > > > >
>> > > > > > > > That's all I can say...
>> > > > > > > > Also because you didn't specify what you need exactly, nor
>> are
>> > >
>> > > you
>> > >
>> > > > > > > > using Gambas 2 or 3.
>> > > > > > > >
>> > > > > > > > Jussi
>> > > > > >
>> > > > > > Hi,
>> > > > > >
>> > > > > > I added a System.GetExternSymbol() method in the last revision
>> so
>> > >
>> > > that
>> > >
>> > > > > you
>> > > > >
>> > > > > > can get the address of the interpolation type structure.
>> > > > > >
>> > > > > > You have to do something like that:
>> > > > > >       Dim gsl_interp_cspline As Pointer
>> > > > > >
>> > > > > >       gsl_interp_cspline =
>> > > > > >       Pointer@(System.GetExternSymbol("libgsl",
>> > > > > >
>> > > > > >               "gsl_interp_cspline"))
>> > > > > >
>> > > > > > Maybe the Pointer@() is not needed, I don't know. The symbol
>> can be
>> > > > > > directly the address of the structure (no Pointer@ needed), or
>> a
>> > > > > > pointer to the address of the structure.
>> > > > > >
>> > > > > > Try and tell me.
>> > > > > >
>> > > > > > Regards,
>> > >
>> > >
>> -------------------------------------------------------------------------
>> > >
>> > > > > ----- What Every C/C++ and Fortran developer Should Know!
>> > > > > Read this article and learn how Intel has extended the reach of
>> its
>> > > > > next-generation tools to help Windows* and Linux* C/C++ and
>> Fortran
>> > > > > developers boost performance applications - including clusters.
>> > > > > http://p.sf.net/sfu/intel-dev2devmay
>> > > > > _______________________________________________
>> > > > > Gambas-user mailing list
>> > > > > Gambas-user at lists.sourceforge.net
>> > > > > https://lists.sourceforge.net/lists/listinfo/gambas-user
>> > >
>> > >
>> -------------------------------------------------------------------------
>> > > --
>> > >
>> > > > --- What Every C/C++ and Fortran developer Should Know!
>> > > > Read this article and learn how Intel has extended the reach of its
>> > > > next-generation tools to help Windows* and Linux* C/C++ and Fortran
>> > > > developers boost performance applications - including clusters.
>> > > > http://p.sf.net/sfu/intel-dev2devmay
>> > > > _______________________________________________
>> > > > Gambas-user mailing list
>> > > > Gambas-user at lists.sourceforge.net
>> > > > https://lists.sourceforge.net/lists/listinfo/gambas-user
>> > >
>> > >
>> -------------------------------------------------------------------------
>> > > ----- What Every C/C++ and Fortran developer Should Know!
>> > > Read this article and learn how Intel has extended the reach of its
>> > > next-generation tools to help Windows* and Linux* C/C++ and Fortran
>> > > developers boost performance applications - including clusters.
>> > > http://p.sf.net/sfu/intel-dev2devmay
>> > > _______________________________________________
>> > > Gambas-user mailing list
>> > > Gambas-user at lists.sourceforge.net
>> > > https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
>>
>> ------------------------------------------------------------------------------
>>
>> What Every C/C++ and Fortran developer Should Know!
>> Read this article and learn how Intel has extended the reach of its
>> next-generation tools to help Windows* and Linux* C/C++ and Fortran
>> developers boost performance applications - including clusters.
>> http://p.sf.net/sfu/intel-dev2devmay
>> _______________________________________________
>> Gambas-user mailing list
>> Gambas-user at lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>
>>
>



More information about the User mailing list