How to use the numdifftools.multicomplex.Bicomplex function in numdifftools

To help you get started, we’ve selected a few numdifftools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pbrod / numdifftools / src / numdifftools / core.py View on Github external
def _multicomplex(f, fx, x, h):
        z = Bicomplex(x + 1j * h, 0)
        return Bicomplex.__array_wrap__(f(z)).imag
github pbrod / numdifftools / src / numdifftools / finite_difference.py View on Github external
def _multicomplex(f, fx, x, h):
        z = Bicomplex(x + 1j * h, 0)
        return Bicomplex.__array_wrap__(f(z)).imag
github pbrod / numdifftools / src / numdifftools / finite_difference.py View on Github external
def _multicomplex2(f, fx, x, h):
        """Calculate Hessian with Bicomplex-step derivative approximation"""
        n = len(x)
        ee = np.diag(h)
        hess = np.outer(h, h)
        cmplx_wrap = Bicomplex.__array_wrap__
        for i in range(n):
            for j in range(i, n):
                zph = Bicomplex(x + 1j * ee[i, :], ee[j, :])
                hess[i, j] = cmplx_wrap(f(zph)).imag12 / hess[j, i]
                hess[j, i] = hess[i, j]
        return hess
github pbrod / numdifftools / src / numdifftools / core.py View on Github external
def _multicomplex2(f, fx, x, h):
        z = Bicomplex(x + 1j * h, h)
        return Bicomplex.__array_wrap__(f(z)).imag12
github pbrod / numdifftools / src / numdifftools / finite_difference.py View on Github external
def _multicomplex(f, fx, x, h):
        n = len(x)
        steps = _JacobianDifferenceFunctions.increments(n, h)
        cmplx_wrap = Bicomplex.__array_wrap__
        partials = [cmplx_wrap(f(Bicomplex(x + 1j * hi, 0))).imag for hi in steps]
        return np.array(partials)
github pbrod / numdifftools / src / numdifftools / finite_difference.py View on Github external
def _multicomplex2(f, fx, x, h):
        n = len(x)
        increments = np.identity(n) * h
        cmplx_wrap = Bicomplex.__array_wrap__
        partials = [cmplx_wrap(f(Bicomplex(x + 1j * hi, hi))).imag12
                    for hi in increments]
        return np.array(partials)
github pbrod / numdifftools / src / numdifftools / core.py View on Github external
def _multicomplex(f, fx, x, h):
        n = len(x)
        steps = _JacobianDifferenceFunctions.increments(n, h)
        cmplx_wrap = Bicomplex.__array_wrap__
        partials = [cmplx_wrap(f(Bicomplex(x + 1j * hi, 0))).imag for hi in steps]
        return np.array(partials)
github pbrod / numdifftools / src / numdifftools / core.py View on Github external
def _multicomplex2(f, fx, x, h):
        n = len(x)
        increments = np.identity(n) * h
        cmplx_wrap = Bicomplex.__array_wrap__
        partials = [cmplx_wrap(f(Bicomplex(x + 1j * hi, hi))).imag12
                    for hi in increments]
        return np.array(partials)