Changes between Initial Version and Version 1 of Ticket #10262, comment 12


Ignore:
Timestamp:
03/15/14 14:48:48 (7 years ago)
Author:
mmezzarobba
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #10262, comment 12

    initial v1  
    24241831.33203125
    2525}}}
     26Possible quick fix, with some code duplication:
     27{{{
     28#!diff
     29diff --git a/src/sage/modules/free_module.py b/src/sage/modules/free_module.py
     30index a61b433..81a626c 100644
     31--- a/src/sage/modules/free_module.py
     32+++ b/src/sage/modules/free_module.py
     33@@ -4409,6 +4409,14 @@ class FreeModule_ambient(FreeModule_generic):
     34         """
     35         return self
     36 
     37+    def gen(self, i):
     38+        if i < 0 or i >= self.rank():
     39+            raise ValueError, "Generator %s not defined."%i
     40+        v = self.zero().__copy__()
     41+        v[i] = self.base_ring()(1)
     42+        v.set_immutable()
     43+        return v
     44+
     45     def basis(self):
     46         """
     47         Return a basis for this ambient free module.
     48}}}
     49But I am not convinced it is such a good idea in general to cache the basis of a `FreeModule_ambient`...