# Make sure this is not a declaration of a variable or function.
if s.sy == '(':
s.next()
- if s.sy == '*' or s.sy == '**':
+ if s.sy == '*' or s.sy == '**' or s.sy == '&':
s.put_back('(', '(')
else:
s.put_back('(', '(')
s.put_back('IDENT', name)
name = None
- elif s.sy not in ('*', '**', '['):
+ elif s.sy not in ('*', '**', '[', '&'):
s.put_back('IDENT', name)
name = None
+from cython.operator cimport dereference as d
+
cdef extern from "<vector>" namespace "std":
cdef cppclass vector[T]:
void push_back(T)
size_t size()
- T operator[](size_t)
+ T& operator[](size_t)
def simple_test(double x):
"""
>>> simple_test(55)
3
"""
- cdef vector[double] *v
try:
v = new vector[double]()
v.push_back(1.0)
>>> list_test([-1] * 1000)
(1000, 1000)
"""
- cdef vector[int] *v
try:
v = new vector[int]()
for a in L:
>>> index_test([1.25])
(1.25, 1.25)
"""
- cdef vector[double] *v
try:
v = new vector[double]()
for a in L:
return v[0][0], v[0][len(L)-1]
finally:
del v
+
+
+def index_set_test(L):
+ """
+ >>> index_set_test([1,2,4,8])
+ (-1.0, -8.0)
+ >>> index_set_test([1.25])
+ (-1.25, -1.25)
+ """
+ try:
+ v = new vector[double]()
+ for a in L:
+ v.push_back(a)
+ for i in range(v.size()):
+ d(v)[i] = -d(v)[i]
+ return d(v)[0], d(v)[v.size()-1]
+ finally:
+ del v