• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python mpmath.arange函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mpmath.arange函数的典型用法代码示例。如果您正苦于以下问题:Python arange函数的具体用法?Python arange怎么用?Python arange使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了arange函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: getNthPolyPrime

def getNthPolyPrime( n, poly ):
    result = getNthPrime( n )

    for i in arange( 1, poly ):
        result = getNthPrime( result )

    return result
开发者ID:ConceptJunkie,项目名称:rpn,代码行数:7,代码来源:rpnPrimeUtils.py


示例2: OLDgetPartitionNumber

def OLDgetPartitionNumber( n ):
    if n < 0:
        return 0

    if n < 2:
        return 1

    result = mpmathify( 0 )

    for k in arange( 1, n + 1 ):
        #n1 = n - k * ( 3 * k - 1 ) / 2
        n1 = fsub( n, fdiv( fmul( k, fsub( fmul( 3, k ), 1 ) ), 2 ) )
        #n2 = n - k * ( 3 * k + 1 ) / 2
        n2 = fsub( n, fdiv( fmul( k, fadd( fmul( 3, k ), 1 ) ), 2 ) )

        result = fadd( result, fmul( power( -1, fadd( k, 1 ) ), fadd( getPartitionNumber( n1 ), getPartitionNumber( n2 ) ) ) )

        if n1 <= 0:
            break

    #old = NOT_QUITE_AS_OLDgetPartitionNumber( n )
    #
    #if ( old != result ):
    #    raise ValueError( "It's broke." )

    return result
开发者ID:ConceptJunkie,项目名称:rpn,代码行数:26,代码来源:rpnCombinatorics.py


示例3: CalibrationHa

def CalibrationHa(z,oldLum,it):
	newLum = [0. for x in range((it.shape[0]))]
	oldpara = np.array([[0. for i in range(3)] for i in range(it.shape[0])])
	oldLF = np.array([0. for i in range(it.shape[0])])
	interpolatingSize =100
	for i in range(oldpara.shape[0]):
	        oldpara[i][0] = 1.37e-3
	        oldpara[i][2] = -1.35
	        if z[it[i]] <1.3 :oldpara[i][1] = 5.1e41*np.power((1+z[it[i]]),3.1)
	        if z[it[i]] >=1.3:oldpara[i][1] =6.8e42
	        oldLF[i] = LuminosityFunction(oldpara[i],oldLum[i])
	rangea = oldLF.copy()
	rangea.sort()
	rangea = rangea[rangea>0]
	grid = np.array([[0. for i in range(interpolatingSize)] for i in range(2)])
	mpgrid = mpmath.arange(mpmath.log10(rangea.min()),mpmath.log10(rangea.max()),(np.log10(rangea.max())-np.log10(rangea.min()))/interpolatingSize)
	grid[0] = np.ogrid[np.log10(rangea.min()):np.log10(oldLF.max()):interpolatingSize*1j]
	grid[1] = np.ogrid[0:6:interpolatingSize*1j]
	newLF = np.array([[0.for i in range(interpolatingSize)] for i in range(interpolatingSize)])
	for i in range(interpolatingSize):
		for j in range(interpolatingSize):
			newLF[i][j]= optimize.brentq(rootfinding,1e30,1e50,args=(luminosityParameterHa(grid[1][i]),mpgrid[j]))
	newLum = interpolate.interpn([grid[0],grid[1]],newLF,np.array([np.log10(oldLF),z[it]]).T,bounds_error=False,fill_value=0.0)
	newLum = np.power(10,newLum)
	return newLum
开发者ID:kazewong,项目名称:intercut,代码行数:25,代码来源:LuminosityFunction.py


示例4: getNthDelannoyNumber

def getNthDelannoyNumber( n ):
    result = 0

    for k in arange( 0, fadd( real( n ), 1 ) ):
        result = fadd( result, fmul( binomial( n, k ), binomial( fadd( n, k ), k ) ) )

    return result
开发者ID:flawr,项目名称:rpn,代码行数:7,代码来源:rpnCombinatorics.py


示例5: tetrate

def tetrate( i, j ):
    result = i

    for x in arange( 1, j ):
        result = power( result, i )

    return result
开发者ID:ConceptJunkie,项目名称:rpn,代码行数:7,代码来源:rpnMath.py


示例6: tetrateRight

def tetrateRight( i, j ):
    result = i

    for x in arange( 1, j ):
        result = power( i, result )

    return result
开发者ID:ConceptJunkie,项目名称:rpn,代码行数:7,代码来源:rpnMath.py


示例7: getNthFibonorial

def getNthFibonorial( n ):
    result = 1

    for i in arange( 2, real( n ) ):
        result = fmul( result, fib( i ) )

    return result
开发者ID:flawr,项目名称:rpn,代码行数:7,代码来源:rpnNumberTheory.py


示例8: getNthAperyNumber

def getNthAperyNumber( n ):
    result = 0

    for k in arange( 0, real( n ) + 1 ):
        result = fadd( result, fmul( power( binomial( n, k ), 2 ),
                                     power( binomial( fadd( n, k ), k ), 2 ) ) )

    return result
开发者ID:flawr,项目名称:rpn,代码行数:8,代码来源:rpnCombinatorics.py


示例9: getNextPrimes

def getNextPrimes( p, k, func=getNextPrimeCandidateForAny ):
    result = [ ]

    for i in arange( 0, k ):
        p = getNextPrime( p, func )
        result.append( p )

    return result
开发者ID:ConceptJunkie,项目名称:rpn,代码行数:8,代码来源:rpnPrimeUtils.py


示例10: getNthMotzkinNumber

def getNthMotzkinNumber( n ):
    result = 0

    for j in arange( 0, floor( fdiv( real( n ), 3 ) ) + 1 ):
        result = fadd( result, fprod( [ power( -1, j ), binomial( fadd( n, 1 ), j ),
                                      binomial( fsub( fmul( 2, n ), fmul( 3, j ) ), n ) ] ) )

    return fdiv( result, fadd( n, 1 ) )
开发者ID:flawr,项目名称:rpn,代码行数:8,代码来源:rpnCombinatorics.py


示例11: getNthPolytopeNumber

def getNthPolytopeNumber( n, d ):
    result = real_int( n )
    m = n + 1

    for i in arange( 1, d - 1 ):
        result = fmul( result, m )
        m += 1

    return fdiv( result, fac( d - 1 ) )
开发者ID:flawr,项目名称:rpn,代码行数:9,代码来源:rpnPolytope.py


示例12: rollMultipleDice

def rollMultipleDice( expression, times ):
    result = [ ]

    dice = parseDiceExpression( expression )

    for i in arange( 0, times ):
        result.append( evaluateDiceExpression( dice ) )

    return result
开发者ID:flawr,项目名称:rpn,代码行数:9,代码来源:rpnDice.py


示例13: getNthMerten

def getNthMerten( n ):
    if real( n ) == 1:
        return 1

    result = 0

    for i in arange( 1, n + 1 ):
        result = fadd( result, getMobius( i ) )

    return result
开发者ID:flawr,项目名称:rpn,代码行数:10,代码来源:rpnNumberTheory.py


示例14: PlotPos

 def PlotPos(self, fignum=None, color='g', dt=0.01, lw=2):
     tVect = arange(0, self.duration, dt)
     if tVect[-1] < self.duration:
         tVect = np.append(tVect, self.duration)
         
     xVect = [self.EvalPos(t) for t in tVect]
     if fignum is not None:
         plt.figure(fignum)
     plt.plot(tVect, xVect, color=color, linewidth=lw)
     plt.show(False)
开发者ID:AbuShaqra,项目名称:openrave,代码行数:10,代码来源:ramp.py


示例15: getNthPrimorial

def getNthPrimorial( n ):
    if real_int( n ) == 0:
        return 1

    result = 2

    for i in arange( 1, n ):
        result = fmul( result, getNthPrime( i + 1 ) )

    return result
开发者ID:ConceptJunkie,项目名称:rpn,代码行数:10,代码来源:rpnPrimeUtils.py


示例16: getPreviousPrimes

def getPreviousPrimes( p, k, func = getPreviousPrimeCandidateForAny ):
    if p < 1000000000 and getNthPrime( p ) < k:
        raiseError( 'There is no previous prime to 2.' )

    result = [ ]

    for i in arange( 0, k ):
        p = getPreviousPrime( p, func )
        result.append( p )

    return result
开发者ID:ConceptJunkie,项目名称:rpn,代码行数:11,代码来源:rpnPrimeUtils.py


示例17: getNthReversalAddition

def getNthReversalAddition( n, k ):
    next = int( real_int( n ) )
    yield next

    previous = next

    for i in arange( k ):
        if isPalindrome( next ):
            break

        next = fadd( reverseDigits( next ), next )
        yield next
开发者ID:flawr,项目名称:rpn,代码行数:12,代码来源:rpnLexicographic.py


示例18: getNthSylvester

def getNthSylvester( n ):
    if real( n ) == 1:
        return 2
    elif n == 2:
        return 3
    else:
        list = [ 2, 3 ]

        for i in arange( 2, n ):
            list.append( fprod( list ) + 1 )

    return list[ -1 ]
开发者ID:flawr,项目名称:rpn,代码行数:12,代码来源:rpnCombinatorics.py


示例19: exponentiatePolynomial

def exponentiatePolynomial( n, k ):
    if not isinstance( n, list ):
        n = [ n ]

    if isinstance( k, list ):
        return [ multiplyPolynomials( n, i ) for i in k ]
    else:
        result = n

        for i in arange( 0, k - 1 ):
            result = multiplyPolynomials( result, n )

        return result
开发者ID:flawr,项目名称:rpn,代码行数:13,代码来源:rpnPolynomials.py


示例20: getNthAlternatingFactorial

def getNthAlternatingFactorial( n ):
    result = 0

    negative = False

    for i in arange( real( n ), 0, -1 ):
        if negative:
            result = fadd( result, fneg( fac( i ) ) )
            negative = False
        else:
            result = fadd( result, fac( i ) )
            negative = True

    return result
开发者ID:flawr,项目名称:rpn,代码行数:14,代码来源:rpnNumberTheory.py



注:本文中的mpmath.arange函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python mpmath.exp函数代码示例发布时间:2022-05-27
下一篇:
Python mplwidget.MplWidget类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap