Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
1f56bf3b
Commit
1f56bf3b
authored
22 years ago
by
Christophe Geuzaine
Browse files
Options
Downloads
Patches
Plain Diff
rename some variables to avoid confusion
parent
fec8d9bc
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Numeric/gsl_newt.cpp
+21
-23
21 additions, 23 deletions
Numeric/gsl_newt.cpp
with
21 additions
and
23 deletions
Numeric/gsl_newt.cpp
+
21
−
23
View file @
1f56bf3b
// $Id: gsl_newt.cpp,v 1.
5
2003-02-20 1
6:49:21
geuzaine Exp $
// $Id: gsl_newt.cpp,v 1.
6
2003-02-20 1
7:02:00
geuzaine Exp $
//
// Copyright (C) 1997 - 2003 C. Geuzaine, J.-F. Remacle
//
...
...
@@ -37,10 +37,10 @@
#define MAXITER 10000
#define PREC 1.e-8
int
gsl_
dim
;
double
gsl_
u
[
MAX_DIM_NEWT
],
gsl_
v
[
MAX_DIM_NEWT
];
static
void
(
*
nrfunc
)(
int
n
,
double
x
[],
double
y
[]);
struct
gsl_dummy
{;};
int
nr
dim
;
double
nr
u
[
MAX_DIM_NEWT
],
nr
v
[
MAX_DIM_NEWT
];
static
void
(
*
nrfunc
)(
int
n
,
double
x
[],
double
y
[]);
struct
gsl_dummy
{;};
void
convert_vector_from_gsl
(
const
gsl_vector
*
gv
,
double
*
v
){
int
i
,
m
;
...
...
@@ -58,15 +58,15 @@ void convert_vector_to_gsl(double *v, int n, gsl_vector *gv){
}
int
gslfunc
(
const
gsl_vector
*
xx
,
void
*
params
,
gsl_vector
*
f
){
convert_vector_from_gsl
(
xx
,
gsl_
u
);
(
*
nrfunc
)(
gsl_dim
,
gsl_u
,
gsl_
v
);
//
Msg(INFO, "f(%lf,%lf) = %lf %lf\n",
gsl_
u[1],
gsl_
u[2],
gsl_
v[1],
gsl_
v[2]);
convert_vector_to_gsl
(
gsl_v
,
gsl_
dim
,
f
);
convert_vector_from_gsl
(
xx
,
nr
u
);
(
*
nrfunc
)(
nrdim
,
nru
,
nr
v
);
// Msg(INFO, "f(%lf,%lf) = %lf %lf\n",
nr
u[1],
nr
u[2],
nr
v[1],
nr
v[2]);
convert_vector_to_gsl
(
nrv
,
nr
dim
,
f
);
return
GSL_SUCCESS
;
}
// Warning: for compatibility with the old newt from NR, x[]
is
// indexed from 1 to
N!
// Warning: for compatibility with the old newt from NR, x[]
and the
//
arguments of func() are
indexed from 1 to
n...
void
newt
(
double
x
[],
int
n
,
int
*
check
,
void
(
*
func
)(
int
,
double
[],
double
[])){
const
gsl_multiroot_fsolver_type
*
T
;
...
...
@@ -78,7 +78,7 @@ void newt(double x[], int n, int *check, void (*func)(int, double [],double []))
gsl_vector
*
xx
=
gsl_vector_alloc
(
n
);
if
(
n
>
MAX_DIM_NEWT
-
1
)
Msg
(
FATAL
,
"Maximum Newton dimension exceeded
\n
"
);
gsl_
dim
=
n
;
nr
dim
=
n
;
nrfunc
=
func
;
convert_vector_to_gsl
(
x
,
n
,
xx
);
...
...
@@ -90,22 +90,20 @@ void newt(double x[], int n, int *check, void (*func)(int, double [],double []))
do
{
iter
++
;
status
=
gsl_multiroot_fsolver_iterate
(
s
);
//
Msg(INFO, "status %d %d %d %lf %lf\n",status,n,iter,gsl_vector_get(s->x,0),gsl_vector_get(s->x,1));
// Msg(INFO, "status %d %d %d %lf %lf\n",status,n,iter,gsl_vector_get(s->x,0),gsl_vector_get(s->x,1));
if
(
status
)
break
;
// solver problem
status
=
gsl_multiroot_test_residual
(
s
->
f
,
n
*
PREC
);
}
while
(
status
==
GSL_CONTINUE
&&
iter
<
MAXITER
);
if
(
status
==
GSL_CONTINUE
)
// problem !!!
{
*
check
=
1
;
}
else
// converged
{
// Msg(INFO, "status %d %d %d %lf %lf\n",status,n,iter,gsl_vector_get(s->x,0),gsl_vector_get(s->x,1));
convert_vector_from_gsl
(
s
->
x
,
x
);
*
check
=
0
;
}
if
(
status
==
GSL_CONTINUE
){
*
check
=
1
;
// problem !!!
}
else
{
// Msg(INFO, "status %d %d %d %lf %lf\n",status,n,iter,gsl_vector_get(s->x,0),gsl_vector_get(s->x,1));
convert_vector_from_gsl
(
s
->
x
,
x
);
*
check
=
0
;
// converged
}
gsl_multiroot_fsolver_free
(
s
);
gsl_vector_free
(
xx
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment