Opened 5 years ago

Closed 3 years ago

#392 closed defect (fixed)

Inplace operators on complex numbers

Reported by: dagss Owned by: robertwb
Priority: major Milestone: 0.16
Component: Parsing Keywords:
Cc:

Description

This is not allowed:

cdef complex z = 1
z += 1j

Trivially done in a transform.

Change History (7)

comment:1 Changed 5 years ago by dagss

  • Milestone changed from 0.12 to 0.12.1

If #441 doesn't make it, this shouldn't :-)

comment:2 Changed 5 years ago by robertwb

We need to be sure that

x[f(i)] += 1

has the right semantics, which are different than

x[f(i)] = x[f(i)] + 1

(Same for attribute access.)
}}}

comment:3 Changed 5 years ago by robertwb

  • Milestone changed from 0.12.1 to wishlist

comment:4 Changed 4 years ago by robertwb

  • Owner changed from somebody to robertwb

comment:5 Changed 4 years ago by robertwb

  • Milestone changed from wishlist to 0.14
  • Resolution set to fixed
  • Status changed from new to closed

comment:6 follow-up: Changed 3 years ago by dagss

  • Milestone changed from 0.14 to 0.14.2
  • Resolution fixed deleted
  • Status changed from closed to reopened

Mike T on ML complained that it still doesn't work with buffers:

no problem-- it occurred to me that the compiler flags might help. They're pasted below, too

import numpy as np
cimport numpy as cnp
def copy_vec(
    cnp.ndarray[cnp.complex128_t] z_arr
    ):

    cdef cnp.ndarray[cnp.complex128_t] b = np.zeros((len(z_arr),),np.complex128)
    for i in xrange(len(z_arr)):
        b[i] += z_arr[i]


C compiler: /usr/bin/gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -pipe -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes

The error raised in the C compiler is (another source file)

pmri_opt/sensemap.c: In function ‘__pyx_pf_8pmri_opt_8sensemap_2poly_vecc’:
pmri_opt/sensemap.c:2781: error: invalid operands to binary + (have ‘__pyx_t_double_complex’ and ‘__pyx_t_double_complex’)

comment:7 in reply to: ↑ 6 Changed 3 years ago by mark

  • Milestone changed from 0.14.2 to 0.16
  • Resolution set to fixed
  • Status changed from reopened to closed

Replying to dagss:

Mike T on ML complained that it still doesn't work with buffers:

no problem-- it occurred to me that the compiler flags might help. They're pasted below, too

import numpy as np
cimport numpy as cnp
def copy_vec(
    cnp.ndarray[cnp.complex128_t] z_arr
    ):

    cdef cnp.ndarray[cnp.complex128_t] b = np.zeros((len(z_arr),),np.complex128)
    for i in xrange(len(z_arr)):
        b[i] += z_arr[i]


C compiler: /usr/bin/gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -pipe -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes

The error raised in the C compiler is (another source file)

pmri_opt/sensemap.c: In function ‘__pyx_pf_8pmri_opt_8sensemap_2poly_vecc’:
pmri_opt/sensemap.c:2781: error: invalid operands to binary + (have ‘__pyx_t_double_complex’ and ‘__pyx_t_double_complex’)

Inplace buffer operators were fixed in one of the commits for buffers and memoryviews, this should work now.

Note: See TracTickets for help on using tickets.