Ejemplo n.º 1
0
 def firstDerivatives(self, mpar):
     nmpar = len(mpar)
     h = matrix(zeros(shape=(nmpar, 1)))
     dldp = matrix(zeros(shape=(nmpar, 1)))
     for ipar in range(nmpar):
         h[ipar] = setH(self.__eps, mpar[ipar])
         dldp[ipar] = fivePointStencilWrapper(self.__calculate, mpar, h)
         h[ipar] = 0.0
     return dldp
Ejemplo n.º 2
0
 def firstDerivatives( self, mpar ):
     nmpar= len(mpar)
     h= matrix( zeros( shape=(nmpar,1) ) )
     dldp= matrix( zeros( shape=(nmpar,1) ) )
     for ipar in range( nmpar ):
         h[ipar]= setH( self.__eps, mpar[ipar] )
         dldp[ipar]= fivePointStencilWrapper( self.__calculate, mpar, h )
         h[ipar]= 0.0
     return dldp
Ejemplo n.º 3
0
 def secondDerivatives( self, mpar ):
     def calcd2ldp2( mpar, hi, hj ):
         def dldp( mpar ):
             return fivePointStencilWrapper( self.__calculate, mpar, hi )
         return fivePointStencilWrapper( dldp, mpar, hj )
     nmpar= len(mpar)
     hi= matrix( zeros( shape=(nmpar,1) ) )
     hj= matrix( zeros( shape=(nmpar,1) ) )
     d2ldp2= matrix( zeros( shape=(nmpar,nmpar) ) )
     for ipar in range( nmpar ):
         hi[ipar]= setH( self.__eps, mpar[ipar] )
         for jpar in range( ipar, nmpar ):
             hj[jpar]= setH( self.__eps, mpar[jpar] )
             d2ldp2[ipar,jpar]= calcd2ldp2( mpar, hi, hj )
             if jpar > ipar:
                 d2ldp2[jpar,ipar]= d2ldp2[ipar,jpar]
             hj[jpar]= 0.0
         hi[ipar]= 0.0
     return d2ldp2
Ejemplo n.º 4
0
    def secondDerivatives(self, mpar):
        def calcd2ldp2(mpar, hi, hj):
            def dldp(mpar):
                return fivePointStencilWrapper(self.__calculate, mpar, hi)

            return fivePointStencilWrapper(dldp, mpar, hj)

        nmpar = len(mpar)
        hi = matrix(zeros(shape=(nmpar, 1)))
        hj = matrix(zeros(shape=(nmpar, 1)))
        d2ldp2 = matrix(zeros(shape=(nmpar, nmpar)))
        for ipar in range(nmpar):
            hi[ipar] = setH(self.__eps, mpar[ipar])
            for jpar in range(ipar, nmpar):
                hj[jpar] = setH(self.__eps, mpar[jpar])
                d2ldp2[ipar, jpar] = calcd2ldp2(mpar, hi, hj)
                if jpar > ipar:
                    d2ldp2[jpar, ipar] = d2ldp2[ipar, jpar]
                hj[jpar] = 0.0
            hi[ipar] = 0.0
        return d2ldp2