How to use the pysces.lib.FirstDerivatives.DerivVar function in pysces

To help you get started, we’ve selected a few pysces 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 PySCeS / pysces / pysces / lib / FirstDerivatives.py View on Github external
def arctan2(self, other):
        den = self.value*self.value+other.value*other.value
        s = self.value/den
        o = other.value/den
        return DerivVar(numpy.arctan2(self.value, other.value),
                _mapderiv(lambda a,b: a-b,
                      list(map(lambda x,f=o: f*x, self.deriv)),
                      list(map(lambda x,f=s: f*x, other.deriv))))
github PySCeS / pysces / pysces / lib / FirstDerivatives.py View on Github external
def __mul__(self, other):
        return DerivVar(self.value*other.value,
            _mapderiv(lambda a,b: a+b,
                  list(map(lambda x,f=other.value:f*x, self.deriv)),
                  list(map(lambda x,f=self.value:f*x, other.deriv))))
github PySCeS / pysces / pysces / lib / FirstDerivatives.py View on Github external
def __add__(self, other):
        return DerivVar(self.value + other.value,
                _mapderiv(lambda a,b: a+b, self.deriv, other.deriv))
github PySCeS / pysces / pysces / lib / FirstDerivatives.py View on Github external
def sign(self):
        if self.value == 0:
            raise ValueError("can't differentiate sign() at zero")
        return DerivVar(numpy.sign(self.value), 0)
github PySCeS / pysces / pysces / lib / FirstDerivatives.py View on Github external
def arctan(self):
        v = numpy.arctan(self.value)
        d = 1./(1.+pow(self.value,2))
        return DerivVar(v, list(map(lambda x,f=d: f*x, self.deriv)))
github PySCeS / pysces / pysces / lib / FirstDerivatives.py View on Github external
def log10(self):
        v = numpy.log10(self.value)
        d = 1./(self.value * numpy.log(10))
        return DerivVar(v, list(map(lambda x,f=d: f*x, self.deriv)))
github PySCeS / pysces / pysces / lib / FirstDerivatives.py View on Github external
def arccos(self):
        v = numpy.arccos(self.value)
        d = -1./numpy.sqrt(1.-pow(self.value,2))
        return DerivVar(v, list(map(lambda x,f=d: f*x, self.deriv)))
github PySCeS / pysces / pysces / lib / FirstDerivatives.py View on Github external
def __rsub__(self, other):
        return DerivVar(other.value - self.value,
            _mapderiv(lambda a,b: a-b, other.deriv, self.deriv))
github PySCeS / pysces / pysces / lib / FirstDerivatives.py View on Github external
def cosh(self):
        v = numpy.cosh(self.value)
        d = numpy.sinh(self.value)
        return DerivVar(v, list(map(lambda x,f=d: f*x, self.deriv)))
github PySCeS / pysces / pysces / lib / FirstDerivatives.py View on Github external
def __div__(self, other):
        if not other.value:
            raise ZeroDivisionError('DerivVar division')
        inv = 1./other.value
        return DerivVar(self.value*inv,
                _mapderiv(lambda a,b: a-b,
                      list(map(lambda x,f=inv: f*x, self.deriv)),
                      list(map(lambda x,f=self.value*inv*inv: f*x,
                          other.deriv))))