>>
<<
Usr
Pri
JfC
LJ
Phr
Dic
Voc
!:
Help
Dictionary
u .. v ↔ (u + u&v) % 2:
u .: v ↔ (u - u&v) % 2:
|
In the most commonly used case, v is arithmetic negation,
and f=: u .. v is therefore f=: (u + u&-) % 2: ;
that is, one-half the sum of u y and u -y .
The resulting function is therefore even in the sense
that f y ↔ f -y for any y ;
its graph is reflected in the vertical axis. Similarly, u .: -
is odd (f y ↔ -f-y), and its
graph is reflected in the origin. Less commonly, v is
matrix transpose (|:), and may
be any monadic function.
y=: _2 _1 0 1 2
1 2 3 4 5 & p. y NB. Polynomial with odd and even terms
57 3 1 15 129
1 2 3 4 5 & p. .. - y NB. Even part of polynomial
93 9 1 9 93
1 0 3 0 5 & p. y NB. Polynomial with even terms only
93 9 1 9 93
E=: .. - NB. Even adverb
O=: .: - NB. Odd adverb
d=: 5j2&":@,.&.> NB. Display as columns with two digits
d (5&o. ; ^O ; 6&o. ; ^E ; ^ ; (^E + ^O) ; 2&o. ; ^@j.E) y
+-----+-----+-----+-----+-----+-----+-----+-----+
|_3.63|_3.63| 3.76| 3.76| 0.14| 0.14|_0.42|_0.42|
|_1.18|_1.18| 1.54| 1.54| 0.37| 0.37| 0.54| 0.54|
| 0.00| 0.00| 1.00| 1.00| 1.00| 1.00| 1.00| 1.00|
| 1.18| 1.18| 1.54| 1.54| 2.72| 2.72| 0.54| 0.54|
| 3.63| 3.63| 3.76| 3.76| 7.39| 7.39|_0.42|_0.42|
+-----+-----+-----+-----+-----+-----+-----+-----+
m=: ?. 4 4 $ 9
(] ; (] .. |:) ; (] .: |:)) m
+-------+-----------+-------------+
|3 8 8 4| 3 5 6 2.5| 0 3 2 1.5|
|2 0 2 7| 5 0 2 4| _3 0 0 3|
|4 2 3 5| 6 2 3 6| _2 0 0 _1|
|1 1 7 2|2.5 4 6 2|_1.5 _3 1 0|
+-------+-----------+-------------+
>>
<<
Usr
Pri
JfC
LJ
Phr
Dic
Voc
!:
Help
Dictionary