Closed merl-dev closed 7 years ago
@merl-dev j
isn't a variable. In Python, 1j
represents the root of -1. So you can do the following in Python:
>>> 1j
1j
>>> x = 3 + 4j
>>> abs(x)
5.0
>>> type(x)
<class 'complex'>
Actually, any scalar coefficient $c$ followed by j
represents that coefficient times the root of -1 (Notice the 4j
in the snippet above). If you were to just type j
, then Python would complain that the variable isn't defined.
>>> j
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'j' is not defined
HTH
lol... sorry it should have clicked! Thanks for your quick response.
Oh, turns out that the same is true in MATLAB too, except MATLAB also allows i
.
I'm starting a Julia port of the tftb... Julia uses im
:
The global constant
im
is bound to the complex number i, representing the principal square root of -1. It was deemed harmful to co-opt the name i for a global constant, since it is such a popular index variable name.
I guess I fell into that hole being less familiar Python and having not written any Matlab in years
Wow, are you hosting it on your GitHub profile?
It will be once I've completed the core and tests, should take a week or so as I am also traveling
Quite a few methods in frequency_modulated.py contain
np.exp(1j *
... And I noticed this in the mfiles of the origina tftb source. Where isj
defined? Did I miss something?