On 7/24/06, Ivan Liu <[EMAIL PROTECTED]> wrote:
Thanks Martin. But could you make it more explicit? How do you use
"this" pointer to pass the constant parameters?

Suppose you want to find a root of a quadratic function f with
parameters b and c, defined as follows:

 f(x) = x^2 + b*x + c

(Just for the sake of illustration; of couse you could find the roots
analytically in this particular case.)  Then you could implement this
as follows (Java syntax):

class QuadraticFunction
 implements Function // (as in a previous message)
{
 double b;
 double c;

 QuadraticFunction(double b, double c) {
   this.b = b;
   this.c = c;
 }

 public double f(double x) {
   return (x + this.b) * x + this.c;
 }
}

GSL gives you essentially the same design, except that it happens to
be written in C, so there is no implicit "this" pointer, and instead
an explicit void pointer for handling arbitrary fixed parameters has
to be passed around.  C++ simply hides that part from you.

-- mj


_______________________________________________
Help-gsl mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gsl

Reply via email to