Dan

>The large (as opposed to machine) case is very useful/interesting also. So i 
>would second Pascals call for eXtended support.

>i wrote my undergraduate thesis (in APL) using the manipulation of Boolean 
>matrices (categories, and many other algebra objects - with arbitrarily large 
>sizes). i always disliked J because of its avowed anti-Boolean typology. 
>Another thing to be worked around.

greg
~krsnadas.org

--

from: Dan Bron <[email protected]>
to: J Programming <[email protected]>
date: 13 August 2015 at 12:10
subject: Re: [Jprogramming] Bitwise operations utility

Pascal wrote:
> |.!.0 NB. unsigned
> |.!.1 NB. signed

>Ah, this is helpful. Thanks. These definitions will allow me to simplify some 
>of the normalization functions.

> signed_shift is undefined,

That’s because I didn’t know how to define it, until now ;)

> an extra that would be cool is versions that work
> with extended integers.


>The primary use case here is to manipulate memory and low-abstraction objects. 
>For example:

 1: bw 12345
 _1

>Makes sense from a machine integer level, but not on a J level. Similarly, I’d 
>expect bw to be used to manipulate the *machine integers* underlying extended 
>J integers, not the highly-abstract J extended integers themselves.

--

from: Raul Miller <[email protected]>
to: Programming forum <[email protected]>
date: 13 August 2015 at 11:38
subject: Re: [Jprogramming] Bitwise operations utility

You can also use set +H to make bash understand that ! means !

--

from: David Lambert <[email protected]>
to: programming <[email protected]>
date: 13 August 2015 at 11:28
subject: Re: [Jprogramming] Bitwise operations utility

>I see the bitwise codes as great language design. Write in base 2 the desired 
>truth table for
 #:i.4
0 0
0 1
1 0
1 1
>remembering, of course, to add 16, and that's the bitwise code. So 
>(16+2b0101)b. ought to be the same as right same for integers.

 ((]-:2b10101 b.)&:i. -)16
1

>bash in emacs shell is unfriendly toward j foreigns, which I overcome by 
>naming the foreigns then loaded from a file. I haven't yet matched my names to 
>your sentences. Without patches, cut&paste from 
>http://www.jsoftware.com/svn/DanBron/trunk/general/bitwise.ijs gives me a 
>partial directory list and some errors.

--

from: 'Pascal Jasmin' via Programming <[email protected]>
to: "[email protected]" <[email protected]>
date: 13 August 2015 at 11:13
subject: Re: [Jprogramming] Bitwise operations utility

its nice, just small fixed overhead

 timespacex '2147483647 *. bw/ 100000 $ 1234132123123 3123123123123
55123231234423'
0.00132 2.10202e6
 timespacex '2147483647 (17 b.)/ 100000 $ 1234132123123 3123123123123
55123231234423'
0.00120416 2.10176e6

overhead you get back easily in paren savings :)

>a small nitpick, There are very cool extra features, but even though the 
>overhead is very small, there should probably be a streamlined version that 
>only handles primitives and named shifts

speaking of the shifts

signed_shift is undefined,

and my impression is that both the shifts should be defined as

|.!.0 NB. unsigned
|.!.1 NB. signed

>After nitpicking to remove extras, an extra that would be cool is versions 
>that work with extended integers.

#: inv x: (22 bw)/&#: 4294967295123123123 23423423423419238121x
27564983555545902426

#: inv x: (22 bw)/&#:
23423423423419238122342342342330918282198066387871
23423423423419238122342342342342342342342342342341x

ab2 =: #: :. ([: #. x:^:(62 < #))


 ~:/&.ab2 27564983555545902426 4294967295123123123x
23423423423419238121

--

from: Dan Bron <[email protected]>
to: J Programming <[email protected]>
date: 13 August 2015 at 08:40
subject: [Jprogramming] Bitwise operations utility

>I’ve been fiddling with J internals recently, and finding the need to twiddle 
>bits. I have a hard time maintaining the numeric b. codes in head, so I threw 
>together a little utility that lets you say things like:

 2b00001000 +. bw 2b11110111
 255
 2b00001000 *. bw 2b11110111
 0
 2b00001000 > bw 2b11110111
 8
 2b00001000 -.@[ bw 2b11110111
 _9
 3 |. bw 2b11110111
 1976

>It’s also got a bunch of other features I threw in as I was building it: 
>primarily other ways of specifying which operation you want, and a way of 
>looking up the details of any given operation. For details, see the Note 
>‘EXAMPLES’ at the bottom of the script.

Get it here:

 http://www.jsoftware.com/svn/DanBron/trunk/general/bitwise.ijs

>Let me know if you find it useful - if enough people can make use of it, I’ll 
>go through the effort of figuring out how to package and release it as a JAL 
>addon.

>I’m also interested in feedback on the coding style (which will be relevant if 
>I release it as an addon; public code is held to higher standards).

-Dan
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to