[Gambas-devel] Function Signature

Benoît Minisini gambas at ...1...
Thu Feb 16 00:38:39 CET 2012


Le 16/02/2012 00:08, Randall Morgan a écrit :
> Thanks! I'll look at that now.
>

Yes, you have to add a ';' at the end of the class name in signatures.

Anyway, I looked at the polynomial part of the GSL documentation, and I 
think you shouldn't use the library interface directly, but create one 
class for each polynomial type:

Polynomial: 'gsl_poly_*' functions.
ComplexPolynomial: 'gsl_complex_poly_*' functions.
NewtonPolynomial: 'gsl_poly_dd_*' functions.

The C structures associated with these classes would be:

typedef
   struct {
     GB_BASE ob;
     double *c; // coefficients
     int len;
     }
   CPOLYNOMIAL;

typedef
   struct {
     GB_BASE ob;
     gsl_complex *c; // coefficients
     int len;
     }
   CCOMPLEXPOLYNOMIAL;

These two classes should act like an array (_get, _put methods, Count, 
Max property).

Contrary to arrays, writing the i-th element should automatically 
expands the internal '*c' array. Then we should add an arbitrary maximum 
length to a polynomial.

A ToString() methods is a good idea too.

typedef
   struct {
     GB_BASE ob;
     double *dd;
     double *xa;
     int len;
     }
   CNEWTONPOLYNOMIAL;

This class is not exactly like an array, as a Newton polynomial is 
defined by two arrays of double. But AFAIK, you have only three methods 
to implement:

gsl_poly_dd_init: create a NewtonPolynomial from an array of points.

gsl_poly_dd_eval: evaluate the value of a NewtonPolynomial for a 
specific value of 'x'.

gsl_poly_dd_taylor: converts a NewtonPolynomial to a Taylor expansion. 
Apparently this taylor expansion is just an array of double, and is not 
used anywhere else in the library. So no need to create a specific 
object for it.

Tell me what you think about that, and if you see where to go exactly. 
If you have difficulties to write the array methods of these classes, I 
will help you.

Regards,

-- 
Benoît Minisini




More information about the Devel mailing list