Hi John,

On 2016-10-27, John H Palmieri <jhpalmier...@gmail.com> wrote:
>>    The OOP way would be to have a mix-in class and subclasses for square 
>> matrices that implement these methods.

The category's parent_class resp. element_class are such mix-in classes.

>> This would mean setting the Element 
>> attribute in the initialization of the parent, but that's not so bad IMO. 
>> This would be my fix; it just takes a bit more work.
>>
>
> Or plug (square) matrices into the category framework? Would that be too 
> slow? I see that there is a file categories/matrix_algebras.py, but there 
> is not much in it.

More relevant (I guess) is this:
  sage: Matrix(QQ, [[1,2],[3,4]]).parent() in Monoids()
  True
  sage: Matrix(QQ, [[1,2,3],[4,5,6]]).parent() in Monoids()
  False

It is true that the matrices themselves aren't instances of
Monoids().element_class, but they still inherit the methods from the
category.

  sage: dir(Monoids().ElementMethods)
  ['__doc__', '__module__', '__pow__', '_pow_naive', 'is_one', 'powers']
  sage: Matrix(QQ, [[1,2],[3,4]]).powers
  <bound method JoinCategory.element_class.powers of [1 2]
  [3 4]>
  sage: Matrix(QQ, [[1,2,3],[4,5,6]]).powers
  Traceback (...):
  ...
  AttributeError: ...

Cheers,
Simon

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to