[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-gsl] Problem with gsl_root_fdfsolver_newton (corrected)
From: |
Clemens Prestele |
Subject: |
[Help-gsl] Problem with gsl_root_fdfsolver_newton (corrected) |
Date: |
Wed, 19 Oct 2005 23:57:52 +0200 (CEST) |
.
.
Dear Ladies and Gentlemen.
I would be very grateful if you could help me overcome the followingproblem
that I have encountered on the
usage of gsl_root_fdfsolver_newton.
First of all: I am using GSL-1.6. under Windows XP plus Microsoft VisualStudio.
Net 2003 (Version 7.1.3088).
I have essentially copied the example from the gsl-ref.pdf documentregarding
the gsl_root_fdfsolver_newton
routine, namely I have the following code:
in "main.c" lies:
#include <stdio.h>
#include <gsl/gsl_errno.h>
#include <gsl/gsl_math.h>
#include <gsl/gsl_roots.h>
#include "demo_fn.h"
int main(void)
{
int status;
int iter = 0, max_iter = 100;
const gsl_root_fdfsolver_type *T;
gsl_root_fdfsolver *s;
double x0, x = 5.0, r_expected = sqrt(5.0);
gsl_function_fdf FDF;
struct quadratic_params params = {1.0, 0.0,-5.0};
FDF.f =&quadratic;
FDF.df =&quadratic_deriv;
FDF.fdf =&quadratic_fdf;
FDF.params= ¶ms;
T =gsl_root_fdfsolver_newton;
s =gsl_root_fdfsolver_alloc (T);
gsl_root_fdfsolver_set (s, &FDF, x);
printf("using %s method\n",
gsl_root_fdfsolver_name (s));
printf("%-5s %10s %10s %10s\n",
"iter", "root", "err","err(est)");
do
{
iter++;
status =gsl_root_fdfsolver_iterate (s);
x0 = x;
x =gsl_root_fdfsolver_root (s);
status =gsl_root_test_delta (x, x0, 0, 1e-3);
if (status == GSL_SUCCESS) printf("Converged:\n");
printf ("%5d%10.7f %+10.7f %10.7f\n",
iter, x, x -r_expected, x - x0);
}
while (status == GSL_CONTINUE &&iter < max_iter);
return status;
}
and in "demo_fn.h" lies:
struct quadratic_params
{
double a, b, c;
};
double quadratic(double x, void*params)
{
struct quadratic_params *p
=(struct quadratic_params *) params;
double a = p->a;
double b = p->b;
double c = p->c;
return (a * x + b) * x + c;
}
double quadratic_deriv(double x, void*params)
{
struct quadratic_params *p
=(struct quadratic_params *) params;
double a = p->a;
double b = p->b;
double c = p->c;
return 2.0 * a * x + b;
}
void quadratic_fdf(double x, void*params,double *y,double *dy)
{
struct quadratic_params *p
=(struct quadratic_params *) params;
double a = p->a;
double b = p->b;
double c = p->c;
*y = (a *x + b) * x + c;
*dy = 2.0* a * x + b;
}
When I compile the above I obtain the following error messages:
------ Build started: Project: Test 0, Configuration: DebugWin32 ------
Linking...
libgsl.a(roots_secant.o) : error LNK2019: unresolved external symbol_finite
referenced in function _newton_iterate
H:\C\Dokumente und
Einstellungen\Clemens\EigeneDateien\Diverse\Clemens\Universitaet\C++\Visual C++
Testprogramme\TestProject 0\Test 0\Debug\Test 0.exe : fatal error LNK1120: 1
unresolvedexternals
Build log was saved at"file://h:\C\Dokumente und
Einstellungen\Clemens\EigeneDateien\Diverse\Clemens\Universitaet\C++\Visual C++
Testprogramme\TestProject 0\Test 0\Debug\BuildLog.htm"
Test 0 - 2 error(s), 0 warning(s)
---------------------- Done ----------------------
Build: 0 succeeded, 1 failed, 0 skipped
Following the suggestions made on
http://sources.redhat.com/ml/gsl-discuss/2004-q2/msg00000.html
I have added
"libgslcblas.a libgsl.a"
under
Configuration Properties->Linker->Input->AdditionalDependencies
Could it have anything to do with these additionally setproperties? Or do you
have any other idea what the problem might be andwhat I could change in order
to make the program work?
Thank you very much already in advance!
Clemens
.
.
---------------------------------
1000 kostenlose SMS gewinnen? Verschicken Sie diese Woche SMS über Yahoo! Mail:
http://advision.webevents.yahoo.com/de/mobile/1000text
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Help-gsl] Problem with gsl_root_fdfsolver_newton (corrected),
Clemens Prestele <=