Commit 997cdaef by Martin Reinecke

### make metric calculation optional

parent f30e88f9
 ... @@ -41,7 +41,7 @@ def _get_acceptable_location(op, loc, lin): ... @@ -41,7 +41,7 @@ def _get_acceptable_location(op, loc, lin): for i in range(50): for i in range(50): try: try: loc2 = loc+dir loc2 = loc+dir lin2 = op(Linearization.make_var(loc2)) lin2 = op(Linearization.make_var(loc2, lin.want_metric)) if np.isfinite(lin2.val.sum()) and abs(lin2.val.sum()) < 1e20: if np.isfinite(lin2.val.sum()) and abs(lin2.val.sum()) < 1e20: break break except FloatingPointError: except FloatingPointError: ... @@ -54,14 +54,14 @@ def _get_acceptable_location(op, loc, lin): ... @@ -54,14 +54,14 @@ def _get_acceptable_location(op, loc, lin): def _check_consistency(op, loc, tol, ntries, do_metric): def _check_consistency(op, loc, tol, ntries, do_metric): for _ in range(ntries): for _ in range(ntries): lin = op(Linearization.make_var(loc)) lin = op(Linearization.make_var(loc, do_metric)) loc2, lin2 = _get_acceptable_location(op, loc, lin) loc2, lin2 = _get_acceptable_location(op, loc, lin) dir = loc2-loc dir = loc2-loc locnext = loc2 locnext = loc2 dirnorm = dir.norm() dirnorm = dir.norm() for i in range(50): for i in range(50): locmid = loc + 0.5*dir locmid = loc + 0.5*dir linmid = op(Linearization.make_var(locmid)) linmid = op(Linearization.make_var(locmid, do_metric)) dirder = linmid.jac(dir) dirder = linmid.jac(dir) numgrad = (lin2.val-lin.val) numgrad = (lin2.val-lin.val) xtol = tol * dirder.norm() / np.sqrt(dirder.size) xtol = tol * dirder.norm() / np.sqrt(dirder.size) ... ...
 ... @@ -53,7 +53,7 @@ class InverseGammaModel(Operator): ... @@ -53,7 +53,7 @@ class InverseGammaModel(Operator): outer = 1/outer_inv outer = 1/outer_inv jac = makeOp(Field.from_local_data(self._domain, inner*outer)) jac = makeOp(Field.from_local_data(self._domain, inner*outer)) jac = jac(x.jac) jac = jac(x.jac) return Linearization(points, jac) return x.new(points, jac) @staticmethod @staticmethod def IG(field, alpha, q): def IG(field, alpha, q): ... ...