TensorSpace.lincomb

TensorSpace.lincomb(self, a, x1, b=None, x2=None, out=None)

Implement out[:] = a * x1 + b * x2.

This function implements

out[:] = a * x1

or, if b and x2 are given,

out = a * x1 + b * x2.

Parameters
afield element

Scalar to multiply x1 with.

x1LinearSpaceElement

First space element in the linear combination.

bfield element, optional

Scalar to multiply x2 with. Required if x2 is provided.

x2LinearSpaceElement, optional

Second space element in the linear combination.

outLinearSpaceElement, optional

Element to which the result is written.

Returns
outLinearSpaceElement

Result of the linear combination. If out was provided, the returned object is a reference to it.

Notes

The elements out, x1 and x2 may be aligned, thus a call

space.lincomb(2, x, 3.14, x, out=x)

is (mathematically) equivalent to

x = x * (2 + 3.14).