Opened 7 years ago

Last modified 4 years ago

#386 new enhancement

Make complex number type from typedef float

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

Description (last modified by dagss)

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 (5)

comment:1 Changed 7 years ago by dagss

  • Description modified (diff)

comment:2 Changed 6 years ago by dagss

  • Milestone changed from 0.13 to 0.13.1

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

comment:3 Changed 5 years ago by robertwb

  • Milestone changed from 0.14 to 0.14.1

comment:4 Changed 5 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

comment:5 Changed 4 years ago by scoder

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