[sage-support] Re: Random sparse matrices over finite fields

2007-02-21 Thread didier deshommes

On 2/21/07, Iftikhar Burhanuddin [EMAIL PROTECTED] wrote:

 Hi folks,

 Random sparse matrices over finite fields generated by SAGE do not look 
 sparse to me. Bug?

 sage: Mat(GF(17), 10, sparse=True).random_element()

Ifti,
looking at the docs for random_element(), it looks like you need to
specify another argument to get a sparse matrix:

{{{
sage: MS = MatrixSpace(ZZ,10,sparse=True); MS.random_element (density=0.4)

[ 0  0  0  0  0  0 -2 -1  0  0]
[ 0  0  0  1 -2  0  0  0  0  0]
[-2  1  0  0  0  0  0  0  2  0]
[ 0 -2  1  2 -2  0  0  0  0  0]
[ 2  0  0  2  0  0  2  0 -1  0]
[ 0  0  0  0  1  0 -2 -1 -1  0]
[ 2  0  2  0  0  0  0  2  0 -2]
[ 0 -1  0  0  0  2 -2  0 -1  0]
[ 0  0  0  0  0  2  0  0  0  2]
[ 0  0  0 -2  0 -2  0  2 -1  1]

}}}

This seems somewhat counter-intuitive to me. Maybe there should be a
self._density that gets set to something like 0.3 when
self.__is_sparse is True?

Another idea: maybe we should be able to set the density directly:

{{{
MS = MatrixSpace(ZZ,10,sparse=True,density=0.4)
}}}

although this seems redundant to me...

didier

--~--~-~--~~~---~--~~
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] Creating table of values in SAGE

2007-02-21 Thread Timothy Clemans

I'm trying to pass in an expression to my class Table and use i in the
for loop for the x variable. How can I do that?

class Table:
def __init__(self,range_start,range_end,step,expression):
self.range = range(range_start,range_end+1,step)
self.expression = expression
def __repr__(self):
return 'Table of values of %s for %s' %
(str(self.expression),str(self.range))
def __str__(self):
string = 'x| y\n\n\n\n'
for x in self.range:
string += '%5d|%6d\n\n' % (x,self.expression)
return string
table1 = Table(0,10,1,2*x+3)
print table1

x| y

0|21
1|21
2|21
3|21
4|21
5|21
6|21
7|21
8|21
9|21
   10|21

I created a for loop outside of my class:
for i in range(11):
x = i
print '%5d|%6d\n\n' % (x,2*x+3)
0| 3
1| 5
2| 7
3| 9
4|11
5|13
6|15
7|17
8|19
9|21
   10|23

I don't know why x in self.expression equals 10. I have done several
tests and found that in my class x always equals 10. You can check
that in SAGE notebook 1 history.

--~--~-~--~~~---~--~~
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] sage-2.1.4 on pentium4-pc-linux-gnu question

2007-02-21 Thread Kate Minola

After building sage-2.1.4 on pentium4-pc-linux-gnu,
I run 'make test' and get

[stuff deleted]
sage -t  devel/sage-main/sage/rings/real_double.pyx gsl:
exp.c:111: ERROR: overfl
ow
Default GSL error handler invoked.
[stuff deleted]

Is this a problem?  Sage keeps on testing and at the end says
All tests passed.  But the word ERROR  (in capital letters!) has
me worried.

Kate Minola
University of Maryland, College Park

--~--~-~--~~~---~--~~
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: Creating table of values in SAGE

2007-02-21 Thread Justin C. Walker

I'm not sure whether you've gotten an anwser (my mail feeds are  
working at cross-purposes right now), but:

On Feb 21, 2007, at 10:42 AM, Timothy Clemans wrote:


 I'm trying to pass in an expression to my class Table and use i in the
 for loop for the x variable. How can I do that?

 class Table:
 def __init__(self,range_start,range_end,step,expression):
 self.range = range(range_start,range_end+1,step)
   self.expression = expression
 def __repr__(self):
 return 'Table of values of %s for %s' %
 (str(self.expression),str(self.range))
 def __str__(self):
 string = 'x| y\n\n\n\n'
   for x in self.range:
   string += '%5d|%6d\n\n' % (x,self.expression)
   return string
 table1 = Table(0,10,1,2*x+3)

I believe that you should treat the 'expression' as a function, in  
that the string you are building up should be done thusly:

string += '%5d|%6d\n\n' % (x,self.expression(x))

Hope that works for you.

I got a complaint when I tried your example, so I'm not sure how you  
got this output:

 print table1

 x| y
 
 0|21
[snip]

Justin

--
Justin C. Walker, Curmudgeon at Large
Institute for the Absorption of Federal Funds
---
My wife 'n kids 'n dogs are gone,
I can't get Jesus on the phone,
But Ol' Milwaukee's Best is my best friend.
---



--~--~-~--~~~---~--~~
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: Creating table of values in SAGE

2007-02-21 Thread Timothy Clemans

Thanks

On 2/21/07, Justin C. Walker [EMAIL PROTECTED] wrote:

 I'm not sure whether you've gotten an anwser (my mail feeds are
 working at cross-purposes right now), but:

 On Feb 21, 2007, at 10:42 AM, Timothy Clemans wrote:

 
  I'm trying to pass in an expression to my class Table and use i in the
  for loop for the x variable. How can I do that?
 
  class Table:
  def __init__(self,range_start,range_end,step,expression):
  self.range = range(range_start,range_end+1,step)
self.expression = expression
  def __repr__(self):
  return 'Table of values of %s for %s' %
  (str(self.expression),str(self.range))
  def __str__(self):
  string = 'x| y\n\n\n\n'
for x in self.range:
string += '%5d|%6d\n\n' % (x,self.expression)
return string
  table1 = Table(0,10,1,2*x+3)

 I believe that you should treat the 'expression' as a function, in
 that the string you are building up should be done thusly:

 string += '%5d|%6d\n\n' % (x,self.expression(x))

 Hope that works for you.

 I got a complaint when I tried your example, so I'm not sure how you
 got this output:

  print table1
 
  x| y
  
  0|21
 [snip]

 Justin

 --
 Justin C. Walker, Curmudgeon at Large
 Institute for the Absorption of Federal Funds
 ---
 My wife 'n kids 'n dogs are gone,
 I can't get Jesus on the phone,
 But Ol' Milwaukee's Best is my best friend.
 ---



 


--~--~-~--~~~---~--~~
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/
-~--~~~~--~~--~--~---