[Maxima] Maxima interface to Lisp bit-functions
van.nek at arcor.de
Sat Mar 22 17:52:07 CDT 2008
> It appears that right-shift has gone away.
> I recommend that we bring it back, with just one rule which
> simplifies bit_rsh(a, b) => bit_lsh(a, - b).
That can be done easily.
> I think I see which rule each example above is supposed to
> but I'm pretty sure the specification for bitwise functions ought to
> phrased in general terms, e.g. bit_lsh(x, y) => 2^y*x where y is a
> literal integer, y > 0, and x is any expression. Maxima lacks such
> specifications for most built-in operators, so the usual way to
> determine which identities are implemented by simplification
> functions is to read the code. I think that is a major defect, and
> that we are inventing some new operators, we should try to avoid
I understand, what you mean here. We all wish to have understandable and well
documented and defined code. I can do that, but I need some assistance. I am far away of
being an English native speaker.
So for clarification:
'literal integer' means a number like 1, 7 or 13 ?
x can be a 'declared integer' if it is declared by declare(x,integer) ?
As a test for a declared integer I can use featurep(x,integer) ?
> About bit_lsh(x,-3) => bit_lsh(x,-3), I would expect from bit_lsh(x,
> => 2^3*x that bit_lsh(x, - 3) => x/2^(- 3). It appears that
> operations are simplfiied but not right-shift; I don't see why.
The simplification bit_lsh(x, - 3) => x/2^(- 3) is wrong!
bit_lsh(31, - 3) = 3
31*2^(-3) = 31/8 (assumed you meant * not /)
> > Meanwhile I couldn't resist to code bit_and, bit_or and
> > I assumed agreement concerning their specifications.
> Already I'm not sure what we did or did not agree on. When the
> time comes to write the code, we'll want to paste the
> specification (if we have one) into the comments, so we
> may as well write it out now.
I already wrote about 200 lines of code. All functions we talk about here I have defined. I
think I can easily modify the definitions to what we agree here.
> I'm probably making too much noise about the process of
> developing these bitwise operators, since historically speaking
> the vast majority of the Maxima code has been written without
> any definite specification. But it would certainly strengthen the
> bitwise stuff to write out and record a specification, and,
> help us get in the habit of it for other projects.
Like I said above: It is some work for me now, but it is certainly the best way.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Maxima