clifford icon indicating copy to clipboard operation
clifford copied to clipboard

Come up with a better way to get the scalar

Open eric-wieser opened this issue 3 years ago • 2 comments

As discussed in https://github.com/pygae/clifford/pull/371#r549158697.

We find ourself using 1 + 0*x a lot of the time to obtain the scalar element.

Right, now, there is no great alternative to this spelling. The obvious choice of x.layout.scalar results in a multivector of int type, which is fine for most code, but is awkward for jitted code where really we want a scalar with the same coefficient type as x.

eric-wieser avatar Dec 27 '20 22:12 eric-wieser

Maybe x.unit_scalar or something similar might be a good spelling

hugohadfield avatar Dec 28 '20 11:12 hugohadfield

cf.one_like(x) or cf.scalar_like(x) is another option, sort of like np.zeros_like.

eric-wieser avatar Dec 28 '20 11:12 eric-wieser