# scalar multiplication of module element fails

51 views
Skip to first unread message

### Martin R

unread,
May 10, 2024, 9:20:07 AMMay 10
to sage-devel

Briefly:

sage: h = SymmetricFunctions(QQ).h()
sage: v = vector([h[3]+h[2,1]])
sage: v * (-111)
({[3]: 1, [2, 1]: 1})

One reason for this is possibly

sage: a = coercion_model.get_action(v.parent(), ZZ, operator.mul, v, -111)
sage: a
Right scalar multiplication by Integer Ring on Ambient free module of rank 1 over the integral domain Symmetric Functions over Rational Field in the homogeneous basis
sage: a.op
<built-in function mul>

Help is greatly appreciated, as always,

Martin

### Martin R

unread,
May 10, 2024, 12:39:21 PMMay 10
to sage-devel
Update: I'm afraid I misunderstood <built-in function mul> - this does call __mul__, right?

### Martin R

unread,
May 10, 2024, 1:30:46 PMMay 10
to sage-devel
I think I've got it.  In `free_module_element.pyx` the method `FreeModuleElement_generic_dense._lmul_` does the following:

cpdef _lmul_(self, Element right):
"""
EXAMPLES::

sage: v = vector([-1,0,3,pi])                                               # needs sage.symbolic
sage: v._lmul_(2/3)                                                         # needs sage.symbolic
(-2/3, 0, 2, 2/3*pi)
sage: v * (2/3)                                                             # needs sage.symbolic
(-2/3, 0, 2, 2/3*pi)
"""
if right._parent is self._parent._base:
v = [(<RingElement>x)._mul_(right) for x in self._entries]
else:
v = [x * right for x in self._entries]
return self._new_c(v)

However, symmetric function do not inherit from `RingElement`, which implies that the wrong method is called.

What can we do about that?

Martin
Reply all
Reply to author
Forward
0 new messages