Vocabulary/stardot

From J Wiki
Jump to navigation Jump to search

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

*. y Length/Angle

Rank 0 -- operates on individual atoms of y, producing a result of higher rank -- WHY IS THIS IMPORTANT?


Converts x-y coordinates (given as a complex number) to r-theta coordinates ("theta" being in radians). The angle is in the range (-π,π]

   *. 3j4   NB. x and y of 3-4-5 triangle
5 0.927295

Common uses

To convert (x,y) to polar coordinates

   polar=: 4 : '*. x j. y'
   30 polar 40
50 0.927295

Related Primitives

Real/Imag (+. y), Imaginary * Complex (j.), Circle Functions (x o. y), Angle * Polar (r.)


x *. y LCM (And)

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


The logical operation And between two Boolean nouns x and y.

In the more general case where x or y are not Boolean, the result is the Least Common Multiple (LCM) of x and y.

   0 0 1 1 *. 0 1 0 1
0 0 0 1
   (0 1) *./ (0 1)      NB. Truth-table of: *.
0 0
0 1
   (0 1) *.table (0 1)  NB. Truth-table with borders
+--+---+
|*.|0 1|
+--+---+
|0 |0 0|
|1 |0 1|
+--+---+
   *. table i.13        NB. table defaults x to: y
+--+----------------------------------------+
|*.|0  1  2  3  4  5  6  7  8  9  10  11  12|
+--+----------------------------------------+
| 0|0  0  0  0  0  0  0  0  0  0   0   0   0|
| 1|0  1  2  3  4  5  6  7  8  9  10  11  12|
| 2|0  2  2  6  4 10  6 14  8 18  10  22  12|
| 3|0  3  6  3 12 15  6 21 24  9  30  33  12|
| 4|0  4  4 12  4 20 12 28  8 36  20  44  12|
| 5|0  5 10 15 20  5 30 35 40 45  10  55  60|
| 6|0  6  6  6 12 30  6 42 24 18  30  66  12|
| 7|0  7 14 21 28 35 42  7 56 63  70  77  84|
| 8|0  8  8 24  8 40 24 56  8 72  40  88  24|
| 9|0  9 18  9 36 45 18 63 72  9  90  99  36|
|10|0 10 10 30 20 10 30 70 40 90  10 110  60|
|11|0 11 22 33 44 55 66 77 88 99 110  11 132|
|12|0 12 12 12 12 60 12 84 24 36  60 132  12|
+--+----------------------------------------+

Common uses

To form a conditional statement

if. (0=#y) *. (0=#x) do.
  ...

Note that both sides of x *. y are always evaluated. There is no primitive that suppresses evaluation of one side if the other side is 0.


More Information

And video

Related Primitives

Or (x +. y), Not-Or (x +: y), Not-And (x *: y), Not (-. y), Boolean Functions (m b.)


Use These Combinations

Combinations using x *. y that have exceptionally good performance include:

What It Does Type;

Precisions;
Ranks

Syntax Primitives permitted in place of f Variants;

Restrictions

Benefits;

Bug Warnings

Is  x f y true everywhere? Permitted: Boolean, integer, floating point, byte, symbol (not unicode).


x and y need not be the same precision.

x ([: *./ f) y x *./@:f y = ~: < <: > >: e. Permitted: (f!:0) (parentheses obligatory!) to force exact comparison.


J recognizes FLO only if f returns an atom or list.

Avoids computing entire  x f y


Bug warning: if f is e. it does (,@e.) rather than e. regardless of ranks of arguments

What it does Type;

Precisions;
Ranks

Syntax Variants;

Restrictions

Benefits;

Bug Warnings

Do all cells of y match an m-item? *./@e.&m y Bug warning: it does (,@e.) rather than e.
Boolean reductions on infixes Boolean x +./\ y x positive

*. = ~: in place of +.

much faster than alternatives
Mean on infixes integer and floating-point x (+/%#)\ y x positive

*. = ~: in place of +

much faster than alternatives
Boolean reductions on partitions Boolean x +//. y = <. >. +. * *. ~: in place of + avoids building argument cells
Polynomial Multiplication (Boolean) Boolean x ~://.@(*./) y

x ~://.@(+./) y
x +//.@(*./) y
x +//.@(+./) y

avoids building argument cells
Boolean reductions along diagonals Boolean +.//. y *. = ~: < <: > >: in place of +. avoids building argument cells