ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 16 Jul 2012 11:38:37 -0500How to reference algebra monomials?https://ask.sagemath.org/question/9130/how-to-reference-algebra-monomials/Hello. My questions are relatively easy to phrase, but first, some background.
If I have an algebra like
H = IwahoriHeckeAlgebraT("A3",1,prefix = "s")
and I ask for `H(H.basis().keys()[1])` I get s1, which is the correct ewaulr and the same result as `H.monomial(H.basis().keys()[1])`. However, with an algebra such as
A = CombinatorialFreeModule(QQ, ['a','b','c'])
`A(A.basis().keys()[1])` returns an error, whereas `A.monomial(A.basis().keys()[1])` returns B[b], which is the correct answer.
So, my question is, what is the difference between calling an Algebra Object (like A or H from above) versus calling that Algebra Object's monomial method? Furthermore, if they are different, (which they appear to be,) what method is A(x) or H(x) calling? Finally, is there any documentation on this A(x) method? Calling the documentation from the notebook interface gets me the docstring for the class.
Thank you for your help!Mon, 16 Jul 2012 10:25:26 -0500https://ask.sagemath.org/question/9130/how-to-reference-algebra-monomials/Answer by John Palmieri for <p>Hello. My questions are relatively easy to phrase, but first, some background.</p>
<p>If I have an algebra like </p>
<pre><code>H = IwahoriHeckeAlgebraT("A3",1,prefix = "s")
</code></pre>
<p>and I ask for <code>H(H.basis().keys()[1])</code> I get s1, which is the correct ewaulr and the same result as <code>H.monomial(H.basis().keys()[1])</code>. However, with an algebra such as</p>
<pre><code>A = CombinatorialFreeModule(QQ, ['a','b','c'])
</code></pre>
<p><code>A(A.basis().keys()[1])</code> returns an error, whereas <code>A.monomial(A.basis().keys()[1])</code> returns B[b], which is the correct answer.</p>
<p>So, my question is, what is the difference between calling an Algebra Object (like A or H from above) versus calling that Algebra Object's monomial method? Furthermore, if they are different, (which they appear to be,) what method is A(x) or H(x) calling? Finally, is there any documentation on this A(x) method? Calling the documentation from the notebook interface gets me the docstring for the class.</p>
<p>Thank you for your help!</p>
https://ask.sagemath.org/question/9130/how-to-reference-algebra-monomials/?answer=13825#post-id-13825When you do `A(x)`, it uses the method `A.__call__(x)`, so you can get help by evaluating `A.__call__?`. For both of these algebras, this turns out to be the same method (both inherited from another class), which tries to coerce the argument `x` into `A`. In the case of `H`, `H.basis().keys()[1]` returns a matrix, and apparently there is a coercion map from matrices to `H`. In the case of `A`, you get a string, and there is no predefined way to coerce strings to elements of `A`.
For `A`, as you note, you can use `A.monomial(x)`, but I think the preferred method is `A.term(x)`. Look at its documentation; it constructs an element of `A` corresponding to the basis element indexed by `x`.Mon, 16 Jul 2012 11:38:37 -0500https://ask.sagemath.org/question/9130/how-to-reference-algebra-monomials/?answer=13825#post-id-13825