25 for ($i = 0; $i < $npts; ++$i) {
28 $sum = $sum + (
$d*
$d);
57 function solve(
$x, $a,
$y, $s, $vary,
$f, $lambda, $termepsilon, $maxiter, $verbose) {
62 print(
"solve x[".count(
$x).
"][".count(
$x[0]).
"]");
63 print(
" a[".count($a).
"]");
64 println(
" y[".count(length).
"]");
81 for($i = 0; $i < $npts; ++$i) {
82 $oos2[$i] = 1./($s[$i]*$s[$i]);
91 for( $r = 0; $r < $nparm; ++$r) {
92 for( $c = 0; $c < $nparm; ++$c) {
93 for( $i = 0; $i < $npts; ++$i) {
94 if ($i == 0) $H[$r][$c] = 0.;
96 $H[$r][$c] += ($oos2[$i] *
$f->grad($xi, $a, $r) *
$f->grad($xi, $a, $c));
102 for( $r = 0; $r < $nparm; ++$r)
103 $H[$r][$r] *= (1. + $lambda);
106 for( $r = 0; $r < $nparm; ++$r) {
107 for( $i = 0; $i < $npts; ++$i) {
108 if ($i == 0) $g[$r] = 0.;
110 $g[$r] += ($oos2[$i] * (
$y[$i]-
$f->val($xi,$a)) *
$f->grad($xi, $a, $r));
116 for( $r = 0; $r < $nparm; ++$r) {
117 $g[$r] = -0.5 * $g[$r];
118 for( $c = 0; $c < $nparm; ++$c) {