Vocabulary/jdot

From J Wiki
Jump to: navigation, search

>> <<   Down to: Dyad   Back to: Vocabulary Thru to: Dictionary

j. y Imaginary

Rank 0 -- operates on individual atoms of y, producing a result of the same shape -- WHY IS THIS IMPORTANT?



Multiplies y by 0j1, which represents the imaginary unit i.

This turns a real y into a pure imaginary result, same as 0 j. y

   j. 3j4
_4j3
   j. 99
0j99


x j. y Complex

Rank 0 0 -- operates on individual atoms of x and y, producing a result of the same shape -- WHY IS THIS IMPORTANT?



Combines x and y into a complex number having x as its real part and y as its imaginary part

Equivalent to x + 0j1 * y

   3 j. 4
3j4

Common uses

1. Work with complex arithmetic.

2. Some primitives use a complex argument as a way of putting two numbers into one atom

   12j10 ": 1p1       NB. (":)  x is w j. d, here 10 digits of pi
3.1415926536
   0 1j1 1 # 1 2 3    NB. (#)  x is n j. f, specifying n copies followed by f fills
2 0 3
   i: 2j3             NB. (i:)  y is a j. b calling for b steps between -a and a
_2 _0.666667 0.666667 2

3. Handle x/y screen coordinates as complex numbers instead of pairs of reals.

   j4xy=: _2 j./\ ]   NB. a list of xy-coords --> a list of complex nos
   xy4j=: [: , +.     NB. a list of complex nos --> a list of xy-coords
   j4xy 3 4 _2 3
3j4 _2j3
   xy4j 3j4 _2j3
3 4 _2 3

Related primitives

Real/Imag (+. y), Signum (Unit Circle) (* y), Length/Angle (*. y), Magnitude (* y), Circle Functions (x o. y), Angle * Polar (r.)