Ticket #386 (new enhancement)

Opened 5 years ago

Last modified 2 years ago

Make complex number type from typedef float

Reported by: dagss Owned by: somebody
Priority: minor Milestone: wishlist
Component: Parsing Keywords:
Cc:

Description (last modified by dagss) (diff)

It would seem natural to be able to do

ctypedef double mydouble
ctypedef mydouble complex mycomplex

Currently, this is not possible (only float, double and long double -- literally -- are before complex).

This requires changes in two areas:

  1. Parser currently is hard-coded to not support it
  2. Utility code is output to support complex numbers (before typedefs); this won't work if one has to output complex numbers based on typedefs. So rather than having ModuleNode? output type definitions, one should probably make a dependency tree out of the PyrexTypes? and ask them to declare themselves to code in a depth-first manner (PS: Must check whether a type is visited with ==, not is or an instance flag!)

Usecase: numpy.pxd would be slightly cleaner with

ctypedef np.float64_t complex np.complex128_t

...although in practice, double is 64-bit everywhere. So it is mostly for the cleanup.

Change History

Changed 5 years ago by dagss

  • description modified (diff)

Changed 4 years ago by dagss

  • milestone changed from 0.13 to 0.13.1

No way this will make it into 0.13....

Changed 4 years ago by robertwb

  • milestone changed from 0.14 to 0.14.1

Changed 3 years ago by dalcinl

Is this a feature available in C? See below:

$ cat tmp.c #include <complex.h> typedef float Float; typedef Float complex FloatComplex?;

$ gcc -c tmp.c tmp.c:3: error: two or more data types in declaration specifiers

Changed 2 years ago by scoder

  • milestone changed from 0.15 to wishlist
Note: See TracTickets for help on using tickets.