Ticket #10553: 10553-DiamondBrackedSpeedup

File 10553-DiamondBrackedSpeedup, 2.1 KB (added by mderickx, 8 years ago)
Line 
1# HG changeset patch
2# Parent 7355629bff99eed5e749f460dce3faec6d50a6e5
3#10553 Speeds up the creation of diamond bracket operators for cuspidal subspaces significantly
4
5diff -r 7355629bff99 sage/modular/modsym/subspace.py
6--- a/sage/modular/modsym/subspace.py   Wed Dec 29 10:22:24 2010 -0800
7+++ b/sage/modular/modsym/subspace.py   Tue Jan 04 12:33:38 2011 +0100
8@@ -500,4 +500,6 @@
9             [1 0]
10             [0 1]
11         """
12-        return self.ambient_hecke_module().diamond_bracket_operator(d).restrict(self)
13+        #Don't check since the theory already tells us that we don't need
14+        #to do it. And it provides a large speedup (ticket #10553)
15+        return self.ambient_hecke_module().diamond_bracket_operator(d).restrict(self,check=False)
16diff -r 7355629bff99 sage/modules/matrix_morphism.py
17--- a/sage/modules/matrix_morphism.py   Wed Dec 29 10:22:24 2010 -0800
18+++ b/sage/modules/matrix_morphism.py   Tue Jan 04 12:33:38 2011 +0100
19@@ -619,6 +619,7 @@
20         
21         The resulting morphism has the same domain as before, but a new
22         codomain.
23+       
24 
25         EXAMPLES::
26         
27@@ -684,12 +685,19 @@
28         return H(self.matrix().restrict_codomain(V))
29 
30 
31-    def restrict(self, sub):
32+    def restrict(self, sub, check=None):
33         """
34         Restrict this matrix morphism to a subspace sub of the domain.
35         
36         The codomain and domain of the resulting matrix are both sub.
37+       
38+        INPUT:
39 
40+            - `sub`   -- a subspace of the domain
41+            - `check` -- bool (optional) - if set to false it will not
42+                         check if the restriction defines a valid morphism
43+                         but it is significantly faster in some cases 
44+                                                       
45         EXAMPLES::
46 
47             sage: V = ZZ^2; phi = V.hom([3*V.0, 2*V.1])
48@@ -735,7 +743,7 @@
49             V = D.coordinate_module(sub)
50         else:
51             V = sub.free_module()
52-        A = self.matrix().restrict(V)
53+        A = self.matrix().restrict(V,check=check)
54         H = sage.categories.homset.End(sub, self.domain().category())
55         return H(A)
56