On May 29, 9:33 am, "William Stein" <[EMAIL PROTECTED]> wrote:
> OSX PPC:
> The new matrix mod2 code is *all wrong* there.  Endianess?
>
> sage -t  devel/sage/sage/matrix/matrix_mod2_dense.pyx
> **********************************************************************
> File "/Users/was/build/sage-3.0.3.alpha0/tmp/matrix_mod2_dense.py", line 873:
>     sage: A.randomize(); A
> Expected:
>     [0 0 1 1 0]
>     [1 1 0 0 1]
>     [1 1 1 1 0]
>     [1 1 1 1 1]
>     [0 0 1 1 0]
> Got:
>     [0 1 0 0 1]
>     [1 0 1 1 0]
>     [1 1 1 1 1]
>     [0 0 1 0 1]
>     [0 1 1 1 0]
> **********************************************************************
...

Yes, there is an endianness problem in that code.  The values are
stored with (basically) "unsigned long long *values", but in
randomize(), this pointer is cast to an "unsigned int *".  Probably
the fix is to leave the pointer as an "unsigned long long *", and do
something like this instead:
cdef unsigned int low = gmp_urandomb_ui(rstate.gmp_state, 32)
cdef unsigned int high = gmp_urandomb_ui(rstate.gmp_state, 32)
cdef unsigned long long combined = ((<unsigned long long>high)<<32)|
(<unsigned long long>low)
values[j] = combined

I can create an official patch to do this on Saturday, if nobody beats
me to it.

Carl
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-devel@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/sage-devel
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to