00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 char et_bin_bhns_extr_max_C[] = "$Header: /cvsroot/Lorene/C++/Source/Etoile/et_bin_bhns_extr_max.C,v 1.1 2004/11/30 20:50:24 k_taniguchi Exp $" ;
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #include <math.h>
00044
00045
00046 #include "et_bin_bhns_extr.h"
00047
00048
00049 void Et_bin_bhns_extr::ent_max_search(double& xx, double& yy) const {
00050
00051
00052
00053
00054
00055 const Tenseur& dent = ent.gradient() ;
00056
00057 double xxp = 0. ;
00058 double yyp = 0. ;
00059 double xtmp, ytmp ;
00060 int mm, nn ;
00061 double rr = 0. ;
00062 double pp = M_PI/2. ;
00063 double dval_x ;
00064 double dval_y ;
00065 double ss ;
00066
00067 while ( fabs(dent(0).val_point(rr, M_PI/2., pp)) > 1.e-15 ||
00068 fabs(dent(1).val_point(rr, M_PI/2., pp)) > 5.e-15) {
00069
00070 double dx = 1. ;
00071 double dy = 1. ;
00072 double diff_dent_x ;
00073 double diff_dent_y ;
00074
00075 while ( dy > 1.e-15 ) {
00076
00077 diff_dent_y = 1. ;
00078 nn = 0 ;
00079 dy = 0.1 * dy ;
00080
00081 rr = sqrt( xxp*xxp + yyp*yyp ) ;
00082
00083 if ( xxp == 0. ) {
00084 pp = M_PI/2. ;
00085 }
00086 else {
00087 pp = acos( xxp / rr ) ;
00088 }
00089
00090 dval_y = dent(1).val_point(rr, M_PI/2., pp) ;
00091
00092 if ( dval_y > 0. ) {
00093 ss = 1. ;
00094 }
00095 else {
00096 ss = -1. ;
00097 }
00098
00099 while( diff_dent_y > 1.e-15 ) {
00100
00101 nn++ ;
00102 ytmp = yyp + ss * nn * dy ;
00103
00104 rr = sqrt( xxp*xxp + ytmp*ytmp ) ;
00105
00106 if ( xxp == 0. ) {
00107 if ( ss > 0. ) {
00108 pp = M_PI/2. ;
00109 }
00110 else {
00111 pp = 1.5*M_PI ;
00112 }
00113 }
00114 else {
00115 pp = acos( xxp / rr ) ;
00116 }
00117
00118 diff_dent_y = ss * dent(1).val_point(rr, M_PI/2., pp) ;
00119
00120 }
00121 yyp += ss * (nn - 1) * dy ;
00122
00123 }
00124
00125 while ( dx > 1.e-15 ) {
00126
00127 diff_dent_x = 1. ;
00128 mm = 0 ;
00129 dx = 0.1 * dx ;
00130
00131 rr = sqrt( xxp*xxp + yyp*yyp ) ;
00132
00133 if ( xxp == 0. ) {
00134 pp = M_PI/2. ;
00135 }
00136 else {
00137 pp = acos( xxp / rr ) ;
00138 }
00139
00140 dval_x = dent(0).val_point(rr, M_PI/2., pp) ;
00141
00142 if ( dval_x > 0. ) {
00143 ss = 1. ;
00144 }
00145 else {
00146 ss = -1. ;
00147 }
00148
00149 while( diff_dent_x > 1.e-15 ) {
00150
00151 mm++ ;
00152 xtmp = xxp + ss * mm * dx ;
00153
00154 rr = sqrt( xtmp*xtmp + yyp*yyp ) ;
00155
00156 if ( xtmp == 0. ) {
00157 if ( ss > 0. ) {
00158 pp = M_PI/2. ;
00159 }
00160 else {
00161 pp = 1.5*M_PI ;
00162 }
00163 }
00164 else {
00165 pp = acos( xtmp / rr ) ;
00166 }
00167
00168 diff_dent_x = ss * dent(0).val_point(rr, M_PI/2., pp) ;
00169
00170 }
00171 xxp += ss * (mm - 1) * dx ;
00172
00173 }
00174 }
00175
00176 xx = xxp ;
00177 yy = yyp ;
00178
00179 }