Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Complex floating issue
#3
(Nov-04-2019, 04:18 PM)DeaD_EyE Wrote: Please use Code-Tags for code, otherwise the indentation is lost. You have to chose the right data type. Use numpy.complex128 as dtype. The real part is a 64 bit float and the imaginary part is a 64 bit float. In addition you can use product from itertools, to get rid of the nested loop. You can also access more than one axis in a multidimensional array. Last thing is: You can reuse the range object.
 import numpy as np from itertools import product n = 5 alpha = 0.7 A = np.zeros([n+1,n+1], dtype=np.complex128) B = np.zeros([n+1], dtype=np.complex128) r = range(n+1) for i,j in product(r, r): A[i,j] = (i-j) ** alpha print(A) 

Thanks for the suggestion
Why you choose n+1 instead of n=5 in array ?
Reply


Messages In This Thread
Complex floating issue - by arshad - Nov-04-2019, 03:55 PM
RE: Complex floating issue - by DeaD_EyE - Nov-04-2019, 04:18 PM
RE: Complex floating issue - by arshad - Nov-05-2019, 03:26 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  floating point not increasing properly rakeshpe43 4 2,408 Apr-30-2020, 05:37 AM
Last Post: rakeshpe43
  floating point arithmetic exDeveloper 2 2,114 Sep-25-2019, 04:33 PM
Last Post: DeaD_EyE
  finding the closest floating point number in a list Skaperen 17 8,295 Sep-19-2019, 10:39 PM
Last Post: Skaperen
  finding the next higher representable floating point value Skaperen 0 1,944 Sep-13-2019, 11:16 PM
Last Post: Skaperen
  Subtracting values between two dictionaries/ floating point numbers FloppyPoppy 5 5,921 Mar-04-2019, 01:00 PM
Last Post: snippsat
  Conversion needed from bytearray to Floating point braveYug 1 4,118 May-07-2018, 12:23 PM
Last Post: snippsat
  print floating point number Regulus 19 11,209 Aug-14-2017, 02:42 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020