ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Fri, 28 Jan 2022 14:41:12 +0100Tensor product of exterior powerhttps://ask.sagemath.org/question/60841/tensor-product-of-exterior-power/I am trying to use the SageManifolds tensor modules package to work with the tensor power $T = E^{\otimes 2}$ where $E$ is itself the exterior power $E = \bigwedge^2 \mathbb{Z}$.
Here is what I have so far:
sage: M = FiniteRankFreeModule(ZZ, 3, name='M')
sage: E = M.exterior_power(2)
sage: T = E.tensor_module(2,0)
I then want to work with an element of $T$ by giving it coordinates. I can give an element of $E$ a coordinate by doing
sage: a = E([], name='a')
sage: a.set_comp()[0,1] = 3
sage: a.set_comp()[0,2] = 1
sage: a.display()
a = 3 e_0∧e_1 + e_0∧e_2
So I would have expected to be able to do the same for $T$:
sage: t = T([], name='t')
sage: t.set_comp()[0,0] = 1
but I get a `ValueError`:
ValueError: the None has not been defined on the 2nd exterior power of the Rank-3 free module M over the Integer Ring
The code in the source which prints `None` is `raise ValueError("the {} has not been ".format(basis) +...` and so the problem is that there is no basis for `E`.
sage: E.default_basis()
No default basis has been defined on the 2nd exterior power of the Rank-3 free module M over the Integer Ring
When I try to define a basis I get a type error:
sage: E.basis('e')
TypeError: __init__() missing 1 required positional argument: 'degree'
coming from the line
sage/tensor/modules/free_module_basis.py in __init__(self, fmodule, symbol, latex_symbol, indices, latex_indices, symbol_dual, latex_symbol_dual)
637 ring_one = fmodule._ring.one()
638 for i in fmodule.irange():
--> 639 v = fmodule.element_class(fmodule)
640 v.set_comp(self)[i] = ring_one
641 vl.append(v)
because `E.element_class()` has the init signature `E.element_class(fmodule, degree, name=None, latex_name=None)`. There is no default degree passed, and there is no option for `fmodule.element_class(fmodule)` to take an argument `degree`. Are there any workarounds to this problem?
Many thanks!!Thu, 27 Jan 2022 20:41:50 +0100https://ask.sagemath.org/question/60841/tensor-product-of-exterior-power/Answer by eric_g for <p>I am trying to use the SageManifolds tensor modules package to work with the tensor power $T = E^{\otimes 2}$ where $E$ is itself the exterior power $E = \bigwedge^2 \mathbb{Z}$. </p>
<p>Here is what I have so far:</p>
<pre><code>sage: M = FiniteRankFreeModule(ZZ, 3, name='M')
sage: E = M.exterior_power(2)
sage: T = E.tensor_module(2,0)
</code></pre>
<p>I then want to work with an element of $T$ by giving it coordinates. I can give an element of $E$ a coordinate by doing</p>
<pre><code>sage: a = E([], name='a')
sage: a.set_comp()[0,1] = 3
sage: a.set_comp()[0,2] = 1
sage: a.display()
a = 3 e_0∧e_1 + e_0∧e_2
</code></pre>
<p>So I would have expected to be able to do the same for $T$:</p>
<pre><code>sage: t = T([], name='t')
sage: t.set_comp()[0,0] = 1
</code></pre>
<p>but I get a <code>ValueError</code>:</p>
<pre><code>ValueError: the None has not been defined on the 2nd exterior power of the Rank-3 free module M over the Integer Ring
</code></pre>
<p>The code in the source which prints <code>None</code> is <code>raise ValueError("the {} has not been ".format(basis) +...</code> and so the problem is that there is no basis for <code>E</code>.</p>
<pre><code>sage: E.default_basis()
No default basis has been defined on the 2nd exterior power of the Rank-3 free module M over the Integer Ring
</code></pre>
<p>When I try to define a basis I get a type error:</p>
<pre><code>sage: E.basis('e')
TypeError: __init__() missing 1 required positional argument: 'degree'
</code></pre>
<p>coming from the line</p>
<pre><code>sage/tensor/modules/free_module_basis.py in __init__(self, fmodule, symbol, latex_symbol, indices, latex_indices, symbol_dual, latex_symbol_dual)
637 ring_one = fmodule._ring.one()
638 for i in fmodule.irange():
--> 639 v = fmodule.element_class(fmodule)
640 v.set_comp(self)[i] = ring_one
641 vl.append(v)
</code></pre>
<p>because <code>E.element_class()</code> has the init signature <code>E.element_class(fmodule, degree, name=None, latex_name=None)</code>. There is no default degree passed, and there is no option for <code>fmodule.element_class(fmodule)</code> to take an argument <code>degree</code>. Are there any workarounds to this problem?</p>
<p>Many thanks!!</p>
https://ask.sagemath.org/question/60841/tensor-product-of-exterior-power/?answer=60850#post-id-60850You are facing a shortcoming of the current implementation: the modules constructed upon `M`, like the exterior power `E`, are not endowed with their own bases; all their elements are expanded on wedge products of basis elements of `E`. For instance
sage: E.an_element().display()
e_0∧e_1
(By the way, the line `sage: e = M.basis('e')` seems to be missing in your code snippet). Hence `E` is not implemented as a finite rank free module on the same setting as `M`. This is reflected by the fact that it has a "base module":
sage: E.base_module()
Rank-3 free module M over the Integer Ring
and all its elements are expanded in terms of bases of this base module.
Such an implementation turned out to be convenient for tensor fields on manifolds. If one would like to extend it to allow for `E` to have its own bases, then one should make some choice about the storage of the components of the elements of `E` and the associated methods `display`, `comp` and `set_comp`.
Fri, 28 Jan 2022 14:41:12 +0100https://ask.sagemath.org/question/60841/tensor-product-of-exterior-power/?answer=60850#post-id-60850