def arccosh(inp): if isinstance(inp, ooarray) and any([isinstance(elem, oofun) for elem in atleast_1d(inp)]): return ooarray([arccosh(elem) for elem in inp]) if hasStochastic and isinstance(inp, distribution.stochasticDistribution): return distribution.stochasticDistribution(arccosh(inp.values), inp.probabilities.copy())._update(inp) if not isinstance(inp, oofun): return np.arccosh(inp) r = oofun(st_arccosh, inp, d = lambda x: Diag(1.0/np.sqrt(x**2-1.0)), vectorized = True) F0, shift = 0.0, 1.0 r._interval_ = lambda domain, dtype: nonnegative_interval(inp, np.arccosh, domain, dtype, F0, shift) return r
def sqrt(inp, attachConstraints = True): if isinstance(inp, ooarray) and any([isinstance(elem, oofun) for elem in atleast_1d(inp)]): return ooarray([sqrt(elem) for elem in inp]) if hasStochastic and isinstance(inp, distribution.stochasticDistribution): return distribution.stochasticDistribution(sqrt(inp.values), inp.probabilities.copy())._update(inp) if not isinstance(inp, oofun): return np.sqrt(inp) # def fff(x): # print x # return np.sqrt(x) r = oofun(st_sqrt, inp, d = lambda x: Diag(0.5 / np.sqrt(x)), vectorized = True) F0 = 0.0 r._interval_ = lambda domain, dtype: nonnegative_interval(inp, np.sqrt, domain, dtype, F0) if attachConstraints: r.attach((inp>0)('sqrt_domain_zero_bound_%d' % r._id, tol=-1e-7)) return r