- Thank you received: 0
Complex vector operations, absolute value & phase
5 years 7 months ago #1545
by NilsHM
Complex vector operations, absolute value & phase was created by NilsHM
Hi!
I am working with complex vectors.
Is there any fast way to get the element wise absolute value and phase of the vector entries?
Getting the real and imaginary values with vector.real and vector.imag is helpful but I could not find such functions for the absolute or phase.
Thank You
I am working with complex vectors.
Is there any fast way to get the element wise absolute value and phase of the vector entries?
Getting the real and imaginary values with vector.real and vector.imag is helpful but I could not find such functions for the absolute or phase.
Thank You
- christopher
- Offline
- Administrator
Less
More
- Thank you received: 101
5 years 7 months ago - 5 years 7 months ago #1547
by christopher
Replied by christopher on topic Complex vector operations, absolute value & phase
You can use numpy for that. You can get a view of the vector as a numpy array by
Best
Christopher
Code:
vec.FV().NumPy()
Christopher
Last edit: 5 years 7 months ago by christopher.
The following user(s) said Thank You: NilsHM
5 years 7 months ago #1551
by NilsHM
Replied by NilsHM on topic Complex vector operations, absolute value & phase
Hi Christopher.
Thank you. Using numpy for complex vector operations is useful.
But is there a way to convert numpy vectors back into a GridFunction so I can plot results onto the mesh?
Best regards,
Nils
Thank you. Using numpy for complex vector operations is useful.
But is there a way to convert numpy vectors back into a GridFunction so I can plot results onto the mesh?
Best regards,
Nils
- christopher
- Offline
- Administrator
Less
More
- Thank you received: 101
5 years 7 months ago #1552
by christopher
Replied by christopher on topic Complex vector operations, absolute value & phase
You can assign to that vector as well:
Best
Christopher
Code:
npvec = gf.vec.FV().NumPy()
npvec[:] = some_array
Christopher
The following user(s) said Thank You: NilsHM
Time to create page: 0.115 seconds