Here is a simple two's complement inverse inspired by Marshall's
tcinv =: ([: #. }. ,~ [: - {.)"1
tc i: 3
1 0 1
1 1 0
1 1 1
0 0 0
0 0 1
0 1 0
0 1 1
tcinv tc i: 3
_3 _2 _1 0 1 2 3
where
tc
#:~ (2 #~ [: >./ 1 + [: >. (2 ^. |)`(2 ^. >:)@.(0 <: ])"0)
On 12/16/2011 12:52 PM, Kip Murray wrote:
> You need to use Marshall's two's complement inverse
>
> tcinv
> [: #. (* (_1 ^ 0 = i.@#))"1
> tcinv tc i: 6
> _6 _5 _4 _3 _2 _1 0 1 2 3 4 5 6
> On 12/16/2011 2:40 AM, Linda Alvord wrote:
>> Here's what I get. The line will split but when I paste it back together:
>>
>> tc =: #:~ 2 #~ [:>./ 1 + [:>. (2 ^. |)`(2 ^.>:)@.(0<: ])"0
>> ]a=:tc i:6
>> 1 0 1 0
>> 1 0 1 1
>> 1 1 0 0
>> 1 1 0 1
>> 1 1 1 0
>> 1 1 1 1
>> 0 0 0 0
>> 0 0 0 1
>> 0 0 1 0
>> 0 0 1 1
>> 0 1 0 0
>> 0 1 0 1
>> 0 1 1 0
>> #.a
>> 10 11 12 13 14 15 0 1 2 3 4 5 6
>>
>> Not good. But your display does not have the first column, so maybe
>> you need
>> to post the function again.
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm