python-cmath

Count the number of complex, real and pure imaginary numbers in a numpy matrix

Count the number of complex, real and pure imaginary numbers in a numpy matrix Question: Given a Numpy array/matrix, what is pythonic way to count the number of complex, pure real and pure imaginary number: [[ 1. +0.j 1. +0.j 1. +0.j 1. +0.j 1. +0.j ] [ 1. +0.j 0.309+0.951j -0.809+0.588j -0.809-0.588j 0.309-0.951j] [ …

Total answers: 1

is cmath.square working for numpy arrays?

Can cmath.sqrt be applied to a NumPy array? Question: I want to calculate the square root of a numpy array of negative numbers. I tried with np.sqrt() but it gives error beacuse the domain. Then, I found that for complex numbers you can use cmath.sqrt(x) but it also gives me an error. Here’s my code …

Total answers: 2