Ticket #392 (closed defect: fixed)

Opened 5 years ago

Last modified 2 years ago

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

  Changed 4 years ago by dagss

  • milestone changed from 0.12 to 0.12.1

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

  Changed 4 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.) }}}

  Changed 4 years ago by robertwb

  • milestone changed from 0.12.1 to wishlist

  Changed 3 years ago by robertwb

  • owner changed from somebody to robertwb

  Changed 3 years ago by robertwb

  • status changed from new to closed
  • resolution set to fixed
  • milestone changed from wishlist to 0.14

follow-up: ↓ 7   Changed 3 years ago by dagss

  • status changed from closed to reopened
  • resolution fixed deleted
  • milestone changed from 0.14 to 0.14.2

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’)

in reply to: ↑ 6   Changed 2 years ago by mark

  • status changed from reopened to closed
  • resolution set to fixed
  • milestone changed from 0.14.2 to 0.16

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.