Opened 4 years ago

Closed 4 years ago

#18186 closed defect (fixed)

Add cardinality() to MatrixSpace

Reported by: jmantysalo Owned by:
Priority: major Milestone: sage-6.9
Component: linear algebra Keywords:
Cc: Merged in:
Authors: Vincent Delecroix Reviewers: Nathann Cohen
Report Upstream: N/A Work issues:
Branch: 164f80e (Commits) Commit: 164f80e6d9acd7a6d44f56f76c4774ac6bee55f8
Dependencies: Stopgaps:

Description

For example MatrixSpace(GF(2), 3, 4).cardinality() should return 2^(3*4), and matrix spaces over inifinite rings should return Infinity. Also MatrixSpace(GF(3),4,5) in FiniteSets() should return True.

Change History (11)

comment:1 Changed 4 years ago by vdelecroix

  • Authors set to vdelecroix

comment:2 Changed 4 years ago by vdelecroix

For the second point I would modify the constructor (i.e. the __init__ method) with the following just before the call to Parent.__init__:

if self.__nrows == 0 and self.__ncols == 0:
    is_finite = True
else:
    is_finite = None
    try:
        is_finite = base_ring.is_finite()
    except (AttributeError,NotImplementedError):
        pass

if is_finite is True:
    category = category.Finite()
elif is_finite is False:
    category = category.Infinite()

Vincent

Last edited 4 years ago by vdelecroix (previous) (diff)

comment:3 Changed 4 years ago by ncohen

Let's try a 'or' instead :-P

sage: MatrixSpace(GF(2),0,3)
Full MatrixSpace of 0 by 3 dense matrices over Finite Field of size 2
Last edited 4 years ago by ncohen (previous) (diff)

comment:4 Changed 4 years ago by jmantysalo

Uh, I just don't understand. foo in bar means bar.__contains__(foo). Where is __contains__ defined for FiniteSets? Someone else to do this?

comment:5 Changed 4 years ago by vdelecroix

  • Authors changed from vdelecroix to Vincent Delecroix
  • Branch set to u/vdelecroix/18186
  • Commit set to 9b5e55e57ab80d0a3713f5fa84def3d56fadcc5d
  • Milestone changed from sage-6.6 to sage-6.9
  • Status changed from new to needs_review

New commits:

1317130Trac 18186: fix finitude of matrix spaces
9b5e55eTrac 18186: cardinality for matrix spaces

comment:6 Changed 4 years ago by ncohen

  • Status changed from needs_review to needs_work
sage -t --long src/sage/combinat/tutorial.py  # 1 doctest failed
sage -t --long src/sage/structure/parent.pyx  # 1 doctest failed
sage -t --long src/sage/matrix/matrix_space.py  # 3 doctests failed
sage -t --long src/sage/rings/ring.pyx  # 1 doctest failed
sage -t --long src/doc/en/thematic_tutorials/coercion_and_categories.rst  # 4 doctests failed

comment:7 Changed 4 years ago by git

  • Commit changed from 9b5e55e57ab80d0a3713f5fa84def3d56fadcc5d to 164f80e6d9acd7a6d44f56f76c4774ac6bee55f8

Branch pushed to git repo; I updated commit sha1. New commits:

164f80eTrac 18186: fix doctests

comment:8 Changed 4 years ago by vdelecroix

Thanks! Fixed in my last commit.

comment:9 Changed 4 years ago by vdelecroix

  • Status changed from needs_work to needs_review

comment:10 Changed 4 years ago by ncohen

  • Reviewers set to Nathann Cohen
  • Status changed from needs_review to positive_review

Good !

comment:11 Changed 4 years ago by vbraun

  • Branch changed from u/vdelecroix/18186 to 164f80e6d9acd7a6d44f56f76c4774ac6bee55f8
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.