本文整理汇总了Python中sympy.printing.ccode.CCodePrinter._not_c方法的典型用法代码示例。如果您正苦于以下问题:Python CCodePrinter._not_c方法的具体用法?Python CCodePrinter._not_c怎么用?Python CCodePrinter._not_c使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sympy.printing.ccode.CCodePrinter
的用法示例。
在下文中一共展示了CCodePrinter._not_c方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_ccode_Indexed
# 需要导入模块: from sympy.printing.ccode import CCodePrinter [as 别名]
# 或者: from sympy.printing.ccode.CCodePrinter import _not_c [as 别名]
def test_ccode_Indexed():
from sympy.tensor import IndexedBase, Idx
from sympy import symbols
s, n, m, o = symbols('s n m o', integer=True)
i, j, k = Idx('i', n), Idx('j', m), Idx('k', o)
x = IndexedBase('x')[j]
A = IndexedBase('A')[i, j]
B = IndexedBase('B')[i, j, k]
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=SymPyDeprecationWarning)
p = CCodePrinter()
p._not_c = set()
assert p._print_Indexed(x) == 'x[j]'
assert p._print_Indexed(A) == 'A[%s]' % (m*i+j)
assert p._print_Indexed(B) == 'B[%s]' % (i*o*m+j*o+k)
assert p._not_c == set()
A = IndexedBase('A', shape=(5,3))[i, j]
assert p._print_Indexed(A) == 'A[%s]' % (3*i + j)
A = IndexedBase('A', shape=(5,3), strides='F')[i, j]
assert ccode(A) == 'A[%s]' % (i + 5*j)
A = IndexedBase('A', shape=(29,29), strides=(1, s), offset=o)[i, j]
assert ccode(A) == 'A[o + s*j + i]'
Abase = IndexedBase('A', strides=(s, m, n), offset=o)
assert ccode(Abase[i, j, k]) == 'A[m*j + n*k + o + s*i]'
assert ccode(Abase[2, 3, k]) == 'A[3*m + n*k + o + 2*s]'
示例2: test_ccode_Indexed
# 需要导入模块: from sympy.printing.ccode import CCodePrinter [as 别名]
# 或者: from sympy.printing.ccode.CCodePrinter import _not_c [as 别名]
def test_ccode_Indexed():
from sympy.tensor import IndexedBase, Idx
from sympy import symbols
n, m, o = symbols('n m o', integer=True)
i, j, k = Idx('i', n), Idx('j', m), Idx('k', o)
p = CCodePrinter()
p._not_c = set()
x = IndexedBase('x')[j]
assert p._print_Indexed(x) == 'x[j]'
A = IndexedBase('A')[i, j]
assert p._print_Indexed(A) == 'A[%s]' % (m*i+j)
B = IndexedBase('B')[i, j, k]
assert p._print_Indexed(B) == 'B[%s]' % (i*o*m+j*o+k)
assert p._not_c == set()
示例3: test_ccode_Indexed
# 需要导入模块: from sympy.printing.ccode import CCodePrinter [as 别名]
# 或者: from sympy.printing.ccode.CCodePrinter import _not_c [as 别名]
def test_ccode_Indexed():
from sympy.tensor import IndexedBase, Idx
from sympy import symbols
i, j, k, n, m, o = symbols('i j k n m o', integer=True)
p = CCodePrinter()
p._not_c = set()
x = IndexedBase('x')[Idx(j, n)]
assert p._print_Indexed(x) == 'x[j]'
A = IndexedBase('A')[Idx(i, m), Idx(j, n)]
assert p._print_Indexed(A) == 'A[%s]' % str(j + n*i)
B = IndexedBase('B')[Idx(i, m), Idx(j, n), Idx(k, o)]
assert p._print_Indexed(B) == 'B[%s]' % str(k + i*n*o + j*o)
assert p._not_c == set()
示例4: test_ccode_Indexed
# 需要导入模块: from sympy.printing.ccode import CCodePrinter [as 别名]
# 或者: from sympy.printing.ccode.CCodePrinter import _not_c [as 别名]
def test_ccode_Indexed():
from sympy.tensor import IndexedBase, Idx
from sympy import symbols
n, m, o = symbols('n m o', integer=True)
i, j, k = Idx('i', n), Idx('j', m), Idx('k', o)
x = IndexedBase('x')[j]
A = IndexedBase('A')[i, j]
B = IndexedBase('B')[i, j, k]
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=SymPyDeprecationWarning)
p = CCodePrinter()
p._not_c = set()
assert p._print_Indexed(x) == 'x[j]'
assert p._print_Indexed(A) == 'A[%s]' % (m*i+j)
assert p._print_Indexed(B) == 'B[%s]' % (i*o*m+j*o+k)
assert p._not_c == set()