[Numpy-discussion] binary shift for ndarray
Robert Kern
robert.kern@gmail....
Wed May 20 14:34:55 CDT 2009
On Wed, May 20, 2009 at 14:24, dmitrey <dmitrey.kroshko@scipy.org> wrote:
> hi all,
>
> suppose I have A that is numpy ndarray of floats, with shape n x n.
>
> I want to obtain dot(A, b), b is vector of length n and norm(b)=1, but
> instead of exact multiplication I want to approximate b as a vector
> [+/- 2^m0, ± 2^m1, ± 2^m2 ,,, ± 2^m_n], m_i are integers, and then
> invoke left_shift(vector_m) for rows of A.
You don't shift floats. You only shift integers. For floats,
multiplying by an integer power of 2 should be fast because of the
floating point representation (the exponent just gets incremented or
decremented), so just do the multiplication.
> So, what is the simplest way to do it, without cycles of course? Or it
> cannot be implemented w/o cycles with current numpy version?
It might help if you showed us an example of an actual b vector
decomposed the way you describe. Your description is ambiguous.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
-- Umberto Eco
More information about the Numpy-discussion
mailing list