On Jan 15, 2009, at 4:26 PM, William Stein wrote:
>
> On Thu, Jan 15, 2009 at 3:12 PM, Jason Grout
> <[email protected]> wrote:
>>
>> c mullan wrote:
>>> Hi,
>>>
>>> Suppose I compute the Jordan Normal Form of a matrix,
>>>
>>> A.jordan_form()
>>>
>>> Then in the output I can see that the block sizes are indicated (by
>>> subdivide='True'), but I can't extract this information. I would
>>> like
>>> a list of block sizes, (e.g. [2,2,1,1,1] for a 7x7 matrix).
>>>
>>> I cannot figure out how to do this, any ideas?
>>>
>>
>>
>> sage: a = matrix(ZZ,4,[1, 0, 0, 0, 0, 1, 0, 0, 1, -1, 1, 0, 1, -1,
>> 1, 2])
>> sage: b=a.jordan_form()
>> sage: b
>>
>> [2|0 0|0]
>> [-+---+-]
>> [0|1 1|0]
>> [0|0 1|0]
>> [-+---+-]
>> [0|0 0|1]
>> sage: b.subdivisions
>> ([0, 1, 3, 4], [0, 1, 3, 4])
>
> I just have to comment:
>
> sage: b.subdivisions = 10
> sage: b.subdivisions
> 10
>
> Notice that you can make the subdivisions nonsense because it can
> be changed.
Of course, not much special here
sage: x = polygen(QQ)
sage: f = x^3-x
sage: f.gcd = 3
sage: f.gcd?
???
> Also, of course,
> sage: b.subdivisions?
> ... The Integer class represents arbitrary precision
> integers. It derives from the Element class, so
> [other useless stuff]
>
> I don't like that at all either. I wish that subdivisions were a
> method with a proper docstring, doctests, etc., and that variable were
> hidden.
>
> Then one would do:
> sage: b.subdivisions?
> useful stuff (and also it would be in the reference manual)
> and
> sage: b.subdivisions()
> ([0, 1, 3, 4], [0, 1, 3, 4])
>
>
> One could argue that throughout Sage maybe we should use attributes
> for properties and function calls much less. However, there's no
> hundreds of thousands of lines of code, and it mostly uses the
> "b.subdivisions() style" instead of the "b.subdivisions" style, so for
> consistency at this point, I think we should just stick to that.
>
> Thoughts?
There is a method with a docstring and all
sage: b.get_subdivisions?
Returns the current subdivision of self.
EXAMPLES:
sage: M = matrix(5, 5, range(25))
sage: M.get_subdivisions()
([], [])
sage: M.subdivide(2,3)
sage: M.get_subdivisions()
([2], [3])
sage: N = M.parent()(1)
sage: N.subdivide(M.get_subdivisions()); N
[1 0 0|0 0]
[0 1 0|0 0]
[-----+---]
[0 0 1|0 0]
[0 0 0|1 0]
[0 0 0|0 1]
But it is inconsistently named with respect to the rest of sage (the
attribute should probably be _ subdivisions, with the method
subdivisions).
- Robert
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
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://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---