Skip to content

Commit 6bacecc

Browse files
author
Release Manager
committed
sagemathgh-39693: Added the rank method under ModulesWithBasis.ParentMethod. sagemath#34445 It is based on the understanding that dimension is equal rank under the context, assuming rank defined for infinite dimensional space. <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on. For example, --> <!-- - sagemath#12345: short description why this is a dependency --> <!-- - sagemath#34567: ... --> URL: sagemath#39693 Reported by: Henry Wu Reviewer(s): Henry Wu, Travis Scrimshaw
2 parents b1e6aa7 + 49f22e9 commit 6bacecc

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/sage/categories/modules_with_basis.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,6 +1309,30 @@ def dimension(self):
13091309
from sage.rings.integer_ring import ZZ
13101310
return ZZ(len(self.basis()))
13111311

1312+
def rank(self):
1313+
"""
1314+
Return the rank of ``self``.
1315+
1316+
Since there is a (distinguished) basis, the rank of ``self``
1317+
is equal to the cardinality of the basis (which equals
1318+
the :meth:`dimension` of ``self``).
1319+
1320+
EXAMPLES::
1321+
1322+
sage: A.<x,y> = algebras.DifferentialWeyl(QQ) # needs sage.modules
1323+
sage: A.rank() # needs sage.modules
1324+
+Infinity
1325+
1326+
sage: R.<x,y> = QQ[]
1327+
sage: R.rank()
1328+
+Infinity
1329+
1330+
sage: F = CombinatorialFreeModule(QQ, ['a','b','c'])
1331+
sage: F.rank()
1332+
3
1333+
"""
1334+
return self.dimension()
1335+
13121336
def _from_dict(self, d, coerce=True, remove_zeros=True):
13131337
"""
13141338
Construct an element of ``self`` from the dictionary ``d``.

0 commit comments

Comments
 (0)