Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Come up with a better way to get the scalar #385

Open
eric-wieser opened this issue Dec 27, 2020 · 2 comments
Open

Come up with a better way to get the scalar #385

eric-wieser opened this issue Dec 27, 2020 · 2 comments

Comments

@eric-wieser
Copy link
Member

As discussed in #371 (comment).

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.

@hugohadfield
Copy link
Member

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

@eric-wieser
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants