Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Does cmath operate on arrays?

Status
Not open for further replies.

rj771972

Programmer
May 17, 2013
10
US
Hello,
In Matlab I can do in one line: c=a+j*b where j=sqrt(-1) and a,b,c are arrays.
Can I do this in python using cmath?

Thanks

Robert
 
I don't think cmath works on arrays, only on scalars (or length-1 arrays).

The thing is that you don't need cmath for what you want to do, all you need are numpy arrays; you operation would than look like this:

c = a + b*1j

j is already defined in python and it can be best used with the accompanying 1, i.e., "1j"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top