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

Python all.imag_part函数代码示例

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

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



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

示例1: checkselfdual

    def checkselfdual(self):
        """ Checks whether coefficients are real to determine
            whether L-function is selfdual
        """

        self.selfdual = True
        for n in range(1, min(8, len(self.dirichlet_coefficients))):
            if abs(imag_part(self.dirichlet_coefficients[n] / self.dirichlet_coefficients[0])) > 0.00001:
                self.selfdual = False
开发者ID:nmascot,项目名称:lmfdb,代码行数:9,代码来源:Lfunction_base.py


示例2: createLcalcfile_ver1

def createLcalcfile_ver1(L):
    """ Creates the lcalcfile of L, version 1
    """

    thefile = ""
    if L.selfdual:
        thefile += "2\n"  # 2 means real coefficients
    else:
        thefile += "3\n"  # 3 means complex coefficients

    thefile += "0\n"  # 0 means unknown type

    thefile += str(len(L.dirichlet_coefficients)) + "\n"

    thefile += "0\n"  # assume the coefficients are not periodic

    thefile += str(L.quasidegree) + "\n"  # number of actual Gamma functions

    for n in range(0, L.quasidegree):
        thefile = thefile + str(L.kappa_fe[n]) + "\n"
        thefile = thefile + str(real_part(L.lambda_fe[n])) + " " + str(imag_part(L.lambda_fe[n])) + "\n"

    thefile += str(real_part(L.Q_fe)) + "\n"

    thefile += str(real_part(L.sign)) + " " + str(imag_part(L.sign)) + "\n"

    thefile += str(len(L.poles)) + "\n"  # counts number of poles

    for n in range(0, len(L.poles)):
        thefile += str(real_part(L.poles[n])) + " " + str(imag_part(L.poles[n])) + "\n"  # pole location
        thefile += str(
            real_part(L.residues[n])) + " " + str(imag_part(L.residues[n])) + "\n"  # residue at pole

    for n in range(0, len(L.dirichlet_coefficients)):
        thefile += str(real_part(L.dirichlet_coefficients[n]))   # add real part of Dirichlet coefficient
        if not L.selfdual:  # if not selfdual
            thefile += " " + str(imag_part(L.dirichlet_coefficients[n]))
                                 # add imaginary part of Dirichlet coefficient
        thefile += "\n"

    return(thefile)
开发者ID:am-github,项目名称:lmfdb,代码行数:41,代码来源:LfunctionLcalc.py


示例3: checkselfdual

    def checkselfdual(self):
        """ Checks whether coefficients are real to determine
            whether L-function is selfdual
        """

        if not hasattr(self, 'selfdual'):
    #    if 'selfdual' not in self:
     #   if self.selfdual not in [True, False]:
            self.selfdual = True
            for n in range(1, min(8, len(self.dirichlet_coefficients))):
                if abs(imag_part(self.dirichlet_coefficients[n] / self.dirichlet_coefficients[0])) > 0.00001:
                    self.selfdual = False
开发者ID:StockpotCreative,项目名称:lmfdb,代码行数:12,代码来源:Lfunction_base.py


示例4: pretty_coeff

def pretty_coeff(c, prec=9):
    '''
    Format the complex coefficient `c` for display on the website.
    '''
    if isinstance(c, complex):
        x = c.real
        y = c.imag
    else:
        x = real_part(c)
        y = imag_part(c)
    # the number of digits to display 'prec' digits after the .
    digits = lambda z: len(str(abs(z)).split('.')[0].lstrip('0')) + prec

    res =  display_complex(x, y, digits = max(map(digits, [x, y])))

    if res == '0':
        return ' 0'
    else:
        return res
开发者ID:koffie,项目名称:lmfdb,代码行数:19,代码来源:mwf_classes.py


示例5: seriescoeff

def seriescoeff(coeff, index, seriescoefftype, seriestype, truncationexp, precision):
  # seriescoefftype can be: series, serieshtml, signed, literal, factor
#  truncationexp is used to determine if a number is 'really' 0 or 1 or -1 or I or -I or 0.5 or -0.5
#  precision is used to truncate decimal numbers
    truncation = float(10 ** truncationexp)
    try:
        if isinstance(coeff,str) or isinstance(coeff,unicode):
            coeff = string2number(coeff)
        if type(coeff) == complex:
            rp = coeff.real
            ip = coeff.imag
        else:
            rp = real_part(coeff)
            ip = imag_part(coeff)
    except TypeError:     # mostly a hack for Dirichlet L-functions
        if seriescoefftype == "serieshtml":
            if coeff == "I":
                return " + " + "$i$" + "·" + seriesvar(index, seriestype)
            elif coeff == "-I":
                return "−" + " $i$" + "·" + seriesvar(index, seriestype)
            else:
                return " +" + coeff + "·" + seriesvar(index, seriestype)
        else:
            return coeff
# below we use float(abs()) instead of abs() to avoid a sage bug
    if (float(abs(rp)) > truncation) & (float(abs(ip)) > truncation):  # has a real and an imaginary part
        ans = ""
        if seriescoefftype == "series" or seriescoefftype == "signed":
            ans += "+"
            ans += "("
            ans += truncate_number(rp, precision)
        elif seriescoefftype == "serieshtml":
            ans += " + "
            ans += "("
            if rp > 0:
                ans += truncate_number(rp, precision)
            else:
                ans += "−"+truncate_number(float(abs(rp)), precision)
        elif seriescoefftype == "factor":
            ans += "("
            ans += truncate_number(rp, precision)
        else:
            ans += truncate_number(rp, precision)
        if ip > 0:
            ans += " + "
        if seriescoefftype == "series" or seriescoefftype == "signed":
            ans += truncate_number(ip, precision) + " i"
        elif seriescoefftype == "serieshtml":
            if ip > 0:
                ans += truncate_number(ip, precision)
            else:
                ans += " − "+truncate_number(float(abs(ip)), precision)
            ans += "<em>i</em>"
        elif seriescoefftype == "factor":
            ans += truncate_number(ip, precision) + "i" + ")"
        else:
            ans += truncate_number(ip, precision) + "i"
        if seriescoefftype == "series" or seriescoefftype == "serieshtml" or seriescoefftype == "signed":
            return(ans + ")" + " " + seriesvar(index, seriestype))
        else:
            return(ans)

    elif (float(abs(rp)) < truncation) & (float(abs(ip)) < truncation):
        if seriescoefftype != "literal":
            return("")
        else:
            return("0")
# if we get this far, either pure real or pure imaginary
    ans = ""
    if rp > truncation:
        if float(abs(rp - 1)) < truncation:
            if seriescoefftype == "literal":
                return("1")
            elif seriescoefftype == "signed":
                return("+1")
            elif seriescoefftype == "factor":
                return("")
            elif seriescoefftype == "series" or seriescoefftype == "serieshtml":
                return(ans + " + " + seriesvar(index, seriestype))
        else:
            if seriescoefftype == "series" or seriescoefftype == "serieshtml":
                return(" + " + ans + truncate_number(rp, precision) + "&middot;" + seriesvar(index, seriestype))
            elif seriescoefftype == "signed":
                return(ans + "+" + truncate_number(rp, precision))
            elif seriescoefftype == "literal" or seriescoefftype == "factor":
                return(ans + truncate_number(rp, precision))
    elif rp < -1 * truncation:
        if float(abs(rp + 1)) < truncation:
            if seriescoefftype == "literal":
                return("-1" + seriesvar(index, seriestype))
            elif seriescoefftype == "signed":
                return("-1" + seriesvar(index, seriestype))
            elif seriescoefftype == "factor":
                return("-" + seriesvar(index, seriestype))
            elif seriescoefftype == "series":  # adding space between minus sign and value
                return(" - " + seriesvar(index, seriestype))
            elif seriescoefftype == "serieshtml":  # adding space between minus sign and value
                return(" &minus; " + seriesvar(index, seriestype))
            else:
                return("-" + seriesvar(index, seriestype))
#.........这里部分代码省略.........
开发者ID:sanni85,项目名称:lmfdb,代码行数:101,代码来源:Lfunctionutilities.py


示例6: mu_fe_prec

 def mu_fe_prec(x):
     if L._Ltype == 'maass':
         return real_digits(imag_part(x))
     else:
         return 3
开发者ID:koffie,项目名称:lmfdb,代码行数:5,代码来源:Lfunctionutilities.py


示例7: seriescoeff

def seriescoeff(coeff, index, seriescoefftype, seriestype, digits):
    # seriescoefftype can be: series, serieshtml, signed, literal, factor
    try:
        if isinstance(coeff,str) or isinstance(coeff,unicode):
            if coeff == "I":
                rp = 0
                ip = 1
            elif coeff == "-I":
                rp = 0
                ip = -1
            else:
                coeff = string2number(coeff)
        if type(coeff) == complex:
            rp = coeff.real
            ip = coeff.imag
        else:
            rp = real_part(coeff)
            ip = imag_part(coeff)
    except TypeError:     # mostly a hack for Dirichlet L-functions
        if seriescoefftype == "serieshtml":
            return " +" + coeff + "&middot;" + seriesvar(index, seriestype)
        else:
            return coeff
    ans = ""
    if seriescoefftype in ["series", "serieshtml", "signed", "factor"]:
        parenthesis = True
    else:
        parenthesis = False
    coeff_display =  display_complex(rp, ip, digits, method="truncate", parenthesis=parenthesis)

    # deal with the zero case
    if coeff_display == "0":
        if seriescoefftype=="literal":
            return "0"
        else:
            return ""

    if seriescoefftype=="literal":
        return coeff_display

    if seriescoefftype == "factor":
        if coeff_display == "1":
            return ""
        elif coeff_display == "-1":
            return "-"

    #add signs and fix spacing
    if seriescoefftype in ["series", "serieshtml"]:
        if coeff_display == "1":
            coeff_display = " + "
        elif coeff_display == "-1":
            coeff_display = " - "
        # purely real or complex number that starts with -
        elif coeff_display[0] == '-':
            # add spacings around the minus
            coeff_display = coeff_display.replace('-',' - ')
        else:
            ans += " + "
    elif seriescoefftype == 'signed' and coeff_display[0] != '-':
        # add the plus without the spaces
        ans += "+"

    ans += coeff_display


    if seriescoefftype == "serieshtml":
        ans = ans.replace('i',"<em>i</em>").replace('-',"&minus;")
        if coeff_display[-1] not in [')', ' ']:
            ans += "&middot;"
    if seriescoefftype in ["series", "serieshtml", "signed"]:
        ans += seriesvar(index, seriestype)

    return ans
开发者ID:koffie,项目名称:lmfdb,代码行数:73,代码来源:Lfunctionutilities.py


示例8: _sage_

 def _sage_(self):
     import sage.all as sage
     return sage.imag_part(self.args[0]._sage_())
开发者ID:asmeurer,项目名称:sympy,代码行数:3,代码来源:complexes.py


示例9: parse_complex_number

def parse_complex_number(z):
    z_parsed = "(" + str(real_part(z)) + "," + str(imag_part(z)) + ")"
    return z_parsed
开发者ID:am-github,项目名称:lmfdb,代码行数:3,代码来源:LfunctionLcalc.py


示例10: seriescoeff

def seriescoeff(coeff, index, seriescoefftype, seriestype, truncationexp, precision):
  # seriescoefftype can be: series, serieshtml, signed, literal, factor
    truncation = float(10 ** truncationexp)
    try:
        if isinstance(coeff,str) or isinstance(coeff,unicode):
            coeff = string2number(coeff)
        if type(coeff) == complex:
            rp = coeff.real
            ip = coeff.imag
        else:
            rp = real_part(coeff)
            ip = imag_part(coeff)
    except TypeError:     # mostly a hack for Dirichlet L-functions
        if seriescoefftype == "serieshtml":
            if coeff == "I":
                return " + " + "$i$" + "&middot;" + seriesvar(index, seriestype) 
            elif coeff == "-I":
                return "&minus;" + " $i$" + "&middot;" + seriesvar(index, seriestype)
            else:
                return " +" + coeff + "&middot;" + seriesvar(index, seriestype)
        else:
            return coeff
# below we use float(abs()) instead of abs() to avoid a sage bug
    if (float(abs(rp)) > truncation) & (float(abs(ip)) > truncation):  # has a real and an imaginary part
        ans = ""
        if seriescoefftype == "series" or seriescoefftype == "signed":
            ans += "+"
            ans += "("
            ans += truncatenumber(rp, precision)
        elif seriescoefftype == "serieshtml":
            ans += " + "
            ans += "("
            if rp > 0:
                ans += truncatenumber(rp, precision)
            else:
                ans += "&minus;"+truncatenumber(float(abs(rp)), precision)
        elif seriescoefftype == "factor":
            ans += "("
            ans += truncatenumber(rp, precision)
        else:
            ans += truncatenumber(rp, precision)
        if ip > 0:
            ans += " + "
        if seriescoefftype == "series" or seriescoefftype == "signed":
            ans += truncatenumber(ip, precision) + " i"
        elif seriescoefftype == "serieshtml":
            if ip > 0:
                ans += truncatenumber(ip, precision)
            else:
                ans += " &minus; "+truncatenumber(float(abs(ip)), precision)
            ans += "<em>i</em>"
        elif seriescoefftype == "factor":
            ans += truncatenumber(ip, precision) + "i" + ")"
        else:
            ans += truncatenumber(ip, precision) + "i"
        if seriescoefftype == "series" or seriescoefftype == "serieshtml" or seriescoefftype == "signed":
            return(ans + ")" + " " + seriesvar(index, seriestype))
        else:
            return(ans)

    elif (float(abs(rp)) < truncation) & (float(abs(ip)) < truncation):
        if seriescoefftype != "literal":
            return("")
        else:
            return("0")
# if we get this far, either pure real or pure imaginary
    ans = ""
#    if seriescoefftype=="series":
#        ans=ans+" + "
# commenting out the above "if" code so as to fix + - problem
#    logger.info("rp={0}".format(rp))
    if rp > truncation:
        if float(abs(rp - 1)) < truncation:
            if seriescoefftype == "literal":
                return("1")
            elif seriescoefftype == "signed":
                return("+1")
            elif seriescoefftype == "factor":
                return("")
            elif seriescoefftype == "series" or seriescoefftype == "serieshtml":
                return(ans + " + " + seriesvar(index, seriestype))
        else:
            if seriescoefftype == "series" or seriescoefftype == "serieshtml":
                return(" + " + ans + truncatenumber(rp, precision) + "&middot;" + seriesvar(index, seriestype))
            elif seriescoefftype == "signed":
                return(ans + "+" + truncatenumber(rp, precision))
            elif seriescoefftype == "literal" or seriescoefftype == "factor":
                return(ans + truncatenumber(rp, precision))
    elif rp < -1 * truncation:
        if float(abs(rp + 1)) < truncation:
            if seriescoefftype == "literal":
                return("-1" + seriesvar(index, seriestype))
            elif seriescoefftype == "signed":
                return("-1" + seriesvar(index, seriestype))
            elif seriescoefftype == "factor":
                return("-" + seriesvar(index, seriestype))
            elif seriescoefftype == "series":  # adding space between minus sign and value
                return(" - " + seriesvar(index, seriestype))
            elif seriescoefftype == "serieshtml":  # adding space between minus sign and value
                return(" &minus; " + seriesvar(index, seriestype))
#.........这里部分代码省略.........
开发者ID:JRSijsling,项目名称:lmfdb,代码行数:101,代码来源:Lfunctionutilities.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python all.latex函数代码示例发布时间:2022-05-27
下一篇:
Python all.gcd函数代码示例发布时间: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