6

I'm working in Python with NumPy arrays of complex numbers that extend well past the normal floating point limits of NumPy’s default Complex type (numbers greater than 10^500). I wanted to know if there was some way I could extend NumPy so that it will be able to handle complex numbers with this sort of magnitude. For example, is there a way to make a NumPy complex type that uses functionality from the Decimal module?

I know there are resources available such as mpmath that could probably do what I need. However, it is a requirement of my project that I use NumPy.

For anyone that's interested in why I need these enormous numbers, it's because I'm working on a numerical relativity simulation of the early universe.

3
  • Did you try to create a numpy array of mpmath objects? Commented Feb 13, 2014 at 9:32
  • There's some info about user-defined data types in NumPy docs Commented Feb 13, 2014 at 9:33
  • I hadn't thought about making an array of mpmath objects, I'l give it a try. Also that user-defined types article looks promising. Thank you both, I'll get back to you with the results. Commented Feb 13, 2014 at 10:12

1 Answer 1

2

Depending on your platform, you may have support for complex192 and/or complex256. These are generally not available on Intel platforms under Windows, but they are on some others—if your code is running on Solaris or on a supercomputer cluster, it may support one of these types. On Linux, you may even find them available or you could create your array using dtype=object and then use bigfloat or gmpy2.mpc.

  1. complex256 numbers up to 104932 + 104932j
  2. complex192 ditto, but with less precision
  3. I have even seen mention of NumPy and complex512...
Sign up to request clarification or add additional context in comments.

1 Comment

Hmmm, my work is currently being split across both a windows machine and a Linux box...either I'll have to make both machines Linux, or find another solution. Thank you though, it gives me a nice avenue of investigation to look into.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.