Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inplace operators on complex numbers #955

Closed
robertwb opened this issue Oct 5, 2009 · 7 comments
Closed

Inplace operators on complex numbers #955

robertwb opened this issue Oct 5, 2009 · 7 comments

Comments

@robertwb
Copy link
Contributor

robertwb commented Oct 5, 2009

This is not allowed:

cdef complex z = 1
z += 1j

Trivially done in a transform.

Migrated from http://trac.cython.org/ticket/392

@robertwb
Copy link
Contributor Author

robertwb commented Nov 2, 2009

@dagss changed milestone from 0.12 to 0.12.1
commented

If http://trac.cython.org/ticket/441 doesn't make it, this shouldn't :-)

@robertwb
Copy link
Contributor Author

robertwb commented Nov 3, 2009

@robertwb commented

We need to be sure that

x[+= 1

has the right semantics, which are different than

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

(Same for attribute access.)

@robertwb
Copy link
Contributor Author

@robertwb changed milestone from 0.12.1 to wishlist
commented

@robertwb
Copy link
Contributor Author

@robertwb changed owner from somebody to robertwb
commented

@robertwb
Copy link
Contributor Author

@robertwb changed milestone from wishlist to 0.14
resolution to fixed
status from new to closed
commented

http://hg.cython.org/cython-devel/rev/c8e87c5b2b58

@robertwb
Copy link
Contributor Author

@dagss changed milestone from 0.14 to 0.14.2
resolution from fixed to empty
status from closed to reopened
commented

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[z_arr
    ):

    cdef cnp.ndarray[cnp.complex128_t](cnp.complex128_t]) b = np.zeros((len(z_arr),),np.complex128)
    for i in xrange(len(z_arr)):
        b[+= z_arr[i](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’)

@robertwb
Copy link
Contributor Author

@markflorisson changed milestone from 0.14.2 to 0.16
resolution to fixed
status from reopened to closed
commented

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[z_arr
    ):

    cdef cnp.ndarray[cnp.complex128_t](cnp.complex128_t]) b = np.zeros((len(z_arr),),np.complex128)
    for i in xrange(len(z_arr)):
        b[+= z_arr[i](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.

@robertwb robertwb added this to the 0.16 milestone Aug 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant