comparison liboctave/NLEqn.cc @ 253:e208bd9ade36

[project @ 1993-12-06 22:01:37 by jwe]
author jwe
date Mon, 06 Dec 1993 22:01:37 +0000
parents 780cbbc57b7c
children c23f50e61c58
comparison
equal deleted inserted replaced
252:bc5e6cb785d1 253:e208bd9ade36
31 #include "f77-uscore.h" 31 #include "f77-uscore.h"
32 #include "lo-error.h" 32 #include "lo-error.h"
33 33
34 extern "C" 34 extern "C"
35 { 35 {
36 int F77_FCN (hybrd1) (int (*)(), const int*, double*, double*, 36 int F77_FCN (hybrd1) (int (*)(int*, double*, double*, int*),
37 const int*, double*, double*, const double*,
38 int*, double*, const int*);
39
40 int F77_FCN (hybrj1) (int (*)(int*, double*, double*, double*, int*, int*),
41 const int*, double*, double*, double*, const int*,
37 const double*, int*, double*, const int*); 42 const double*, int*, double*, const int*);
38
39 int F77_FCN (hybrj1) (int (*)(), const int*, double*, double*,
40 double*, const int*, const double*, int*,
41 double*, const int*);
42 } 43 }
43 44
44 static nonlinear_fcn user_fun; 45 static nonlinear_fcn user_fun;
45 static jacobian_fcn user_jac; 46 static jacobian_fcn user_jac;
46 47
141 for (int i = 0; i < nn; i++) 142 for (int i = 0; i < nn; i++)
142 tmp_x.elem (i) = x[i]; 143 tmp_x.elem (i) = x[i];
143 144
144 tmp_f = (*user_fun) (tmp_x); 145 tmp_f = (*user_fun) (tmp_x);
145 146
146 for (i = 0; i < nn; i++) 147 if (tmp_f.length () == 0)
147 fvec[i] = tmp_f.elem (i); 148 *iflag = -1;
149 else
150 {
151 for (i = 0; i < nn; i++)
152 fvec[i] = tmp_f.elem (i);
153 }
148 154
149 return 0; 155 return 0;
150 } 156 }
151 157
152 int 158 int
164 { 170 {
165 Vector tmp_f (nn); 171 Vector tmp_f (nn);
166 172
167 tmp_f = (*user_fun) (tmp_x); 173 tmp_f = (*user_fun) (tmp_x);
168 174
169 for (i = 0; i < nn; i++) 175 if (tmp_f.length () == 0)
170 fvec[i] = tmp_f.elem (i); 176 *iflag = -1;
177 else
178 {
179 for (i = 0; i < nn; i++)
180 fvec[i] = tmp_f.elem (i);
181 }
171 } 182 }
172 else 183 else
173 { 184 {
174 Matrix tmp_fj (nn, nn); 185 Matrix tmp_fj (nn, nn);
175 186
176 tmp_fj = (*user_jac) (tmp_x); 187 tmp_fj = (*user_jac) (tmp_x);
177 188
178 int ld = *ldfjac; 189 if (tmp_fj.rows () == 0 || tmp_fj.columns () == 0)
179 for (int j = 0; j < nn; j++) 190 *iflag = -1;
180 for (i = 0; i < nn; i++) 191 else
181 fjac[j*ld+i] = tmp_fj.elem (i, j); 192 {
193 int ld = *ldfjac;
194 for (int j = 0; j < nn; j++)
195 for (i = 0; i < nn; i++)
196 fjac[j*ld+i] = tmp_fj.elem (i, j);
197 }
182 } 198 }
183 199
184 return 0; 200 return 0;
185 } 201 }
186 202
225 241
226 delete [] wa; 242 delete [] wa;
227 delete [] fjac; 243 delete [] fjac;
228 } 244 }
229 245
246 Vector retval;
247
230 info = tmp_info; 248 info = tmp_info;
231 249
232 Vector retval (n); 250 if (info >= 0)
233 251 {
234 for (i = 0; i < n; i++) 252 retval.resize (n);
235 retval.elem (i) = px[i]; 253
254 for (i = 0; i < n; i++)
255 retval.elem (i) = px[i];
256 }
236 257
237 return retval; 258 return retval;
238 } 259 }
239 260
240 /* 261 /*