[sage-support] Re: bug in matrix

2007-10-13 Thread William Stein

On 10/12/07, adrianmatematico [EMAIL PROTECTED] wrote:

 Maybe I have something wrong with my installation.
 But Thanks a lot

 This is what sage told me (I erased the email addresses):

 sage: hg_sage.patch('/home/soto/Desktop/856.patch')


You have to do

   hg_sage.import_patch('/home/soto/Desktop/856.patch', '-f')

then from the command line

   sage -br

or just wait for sage-2.8.7 (it won't be that long from now).



 WARNING:
 Make sure to create a ~/.hgrc file:
 --
 [ui]
 username = William Stein @gmail.com
 --


 cd /usr/local/sage-u2.8.3-ubuntu-7.04-32bit-i686-Linux/devel/sage 
 hg status

 WARNING:
 Make sure to create a ~/.hgrc file:
 --
 [ui]
 username = William Stein @gmail.com
 --


 cd /usr/local/sage-u2.8.3-ubuntu-7.04-32bit-i686-Linux/devel/sage 
 hg status

 WARNING:
 Make sure to create a ~/.hgrc file:
 --
 [ui]
 username = William Stein @gmail.com
 --


 cd /usr/local/sage-u2.8.3-ubuntu-7.04-32bit-i686-Linux/devel/sage 
 hg import   /home/soto/Desktop/856.patch
 abort: outstanding uncommitted changes


 On Oct 11, 11:08 pm, Mike Hansen [EMAIL PROTECTED] wrote:
  Hello,
 
  I've attached a patch that fixes the issues that you've mentioned.  To
  apply it, run hg_sage.patch('/path/to/856.patch') from SAGE, exit
  SAGE, and then run ./sage -br .
 
  There still is some work to be done with numpy support -- for example,
  getting the numpy integer types to play well with the SAGE integers:
 
  sage: import numpy
  sage: a = numpy.array([[1,2],[3,4]],'int32')
  sage: matrix(a)
  Traceback (most recent call last):
  ...
  TypeError: cannot convert numpy matrix to SAGE matrix
 
  I'll try to get that taken care of in the near future.
 
  --Mike
 
  On 10/11/07, adrianmatematico [EMAIL PROTECTED] wrote:
 
 
 
   First of all:  Sorry, I duplicated the bug...
 
   Things change when instead of a 'f' I write float:
 
   sage: a=numpy.array([[1,2,3],[4,5,6],[7,8,9]],float)
   sage: a
 
   array([[ 1.,  2.,  3.],
  [ 4.,  5.,  6.],
  [ 7.,  8.,  9.]])
   sage: matrix(a)
 
   [1.0 2.0 3.0]
   [4.0 5.0 6.0]
   [7.0 8.0 9.0]
   sage:
 
   Things should be such that matrix(matrix(2,2,[1,2,3,4]).numpy()),
   should return matrix(2,2,[1,2,3,4]).  Following the documentation one
   is tempted to write matrix(matrix(2,2,[1,2,3,4]).numpy('f')) which
   does not work.  One should write matrix(matrix(2,2,
   [1,2,3,4]).numpy(float)) which works but is not so well documented in
   matrix.numpy?
 
   sage: matrix(matrix(2,2,[1,2,3,4]).numpy(float))
 
   [1.0 2.0]
   [3.0 4.0]
   sage: matrix(matrix(2,2,[1,2,3,4]).numpy('f'))
 
   [ 2.0047311  512.000122547]
   [8.33944345861e-312 1.58292085852e-264]
 
   sage: matrix(matrix(2,2,[1,2,3,4]).numpy())
   ---
   type 'exceptions.UnboundLocalError' Traceback (most recent call
   last)
 
   /home/soto/ipython console in module()
 
   /usr/local/sage-u2.8.3-ubuntu-7.04-32bit-i686-Linux/local/lib/
   python2.5/site-packages/sage/matrix/constructor.py in matrix(arg0,
   arg1, arg2, arg3, sparse)
   371 sparse = False
   372
   -- 373 return matrix_space.MatrixSpace(ring, nrows, ncols,
   sparse=sparse)(entries)
   374
   375
 
   type 'exceptions.UnboundLocalError': local variable 'ring'
   referenced before assignment
 
   On Oct 11, 8:23 pm, adrianmatematico [EMAIL PROTECTED]
   wrote:
When I call matrix(a) and a is a numpy array, things do not work:
 
sage: import numpy
sage: a=numpy.array([[1,2,3],[4,5,6],[7,8,9]],'f')
sage: a
 
array([[ 1.,  2.,  3.],
   [ 4.,  5.,  6.],
   [ 7.,  8.,  9.]], dtype=float32)
sage: matrix(a)
 
[ 2.0047311  512.000122547   8192.0019722]
[ 131072.031677 6.64723988631e-312 9.63032207325e-270]
[   nan 6.01334411715e-154 1.20061630269e+195]
sage: b=matrix(a)
sage: b
 
[ 2.0047311  512.000122547   8192.0019722]
[ 131072.031677 6.64723988631e-312 9.63032207325e-270]
[   nan 6.01334411715e-154 1.20061630269e+195]
sage:
 
 
 
   856.patch
  11KDownload


 



-- 
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@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-support
URLs: http://sage.math.washington.edu/sage/ and 

[sage-support] #if in cython?

2007-10-13 Thread Simon King

Dear sage-supporters,

a question on pyrex/cython: 
I have type definitions depending on an environment variable, such as

#if ZZZ==zzz
typedef unsigned char FEL;
#elif ZZZ==bigzzz
typedef unsigned short FEL;

Is there a way to do a similar thing in pyrex/cython?

Yours sincerely
Simon


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@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-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~--~~~~--~~--~--~---



[sage-support] Re: #if in cython?

2007-10-13 Thread William Stein

On 10/13/07, Simon King [EMAIL PROTECTED] wrote:

 Dear sage-supporters,

 a question on pyrex/cython:
 I have type definitions depending on an environment variable, such as

 #if ZZZ==zzz
 typedef unsigned char FEL;
 #elif ZZZ==bigzzz
 typedef unsigned short FEL;

 Is there a way to do a similar thing in pyrex/cython?

 Yours sincerely

This question belongs in the cython or pyrex mailing lists,
rather than sage-support, so I've forwarded it there.

William

--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@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-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~--~~~~--~~--~--~---



[sage-support] Re: #if in cython?

2007-10-13 Thread mabshoff



On Oct 14, 2:37 am, Simon King [EMAIL PROTECTED] wrote:
 Dear William,

 you wrote:
  This question belongs in the cython or pyrex mailing lists,
  rather than sage-support, so I've forwarded it there.

 After posting my question, i found an answer to my question in the
 web:
 Pyrex 0.9.6 provides conditional compilation. 
 Seehttp://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/version/Doc/...

 (However, i didn't succeed to make it work on some easy examples, so
 it seems i need more information)

 I do think that my question remains a question for sage, since sage -
 cython apparently does not provide that new pyrex functionality. The
 line
 DEF VARI = Value
 is accepted by pyrexc, but not by sage -cython.


There has been a very recent release of pyrex and the changes/updates
from that release haven't made it into Cython's latest release yet (at
least not the one in the official tree)

 Can you tell me the web address of the pyrex or cython mailin lists,
 so that i can read answers?


See http://developer.berlios.de/projects/cython/
 Yours
Simon

Cheers,

Michael


--~--~-~--~~~---~--~~
To post to this group, send email to sage-support@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-support
URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/
-~--~~~~--~~--~--~---