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

l3fp: sign() and ? #346

Closed
wspr opened this issue Mar 10, 2017 · 5 comments
Closed

l3fp: sign() and ? #346

wspr opened this issue Mar 10, 2017 · 5 comments
Labels
enhancement New feature or request l3fp

Comments

@wspr
Copy link
Contributor

wspr commented Mar 10, 2017

From Andrew on LaTeX-L:

Two functions which I think could be beneficially added to l3fp without straining its role as a kernel module (in the way that, say, the gamma function would) are the signature function (sgn) and a unit step function (Heaviside? -- the difficulty is what value to assign at 0). Given the numerical values assigned to true and false in l3fp, it is easy to mimic these with simple inequalities (e.g. (#1 > 0) - (#1 < 0) for sgn) but perhaps the functions should be there in the first place?

I found myself wanting these when considering a table of fp values where it made sense to blank cells containing negative values which "got in the way". The code creating the table contained the option of blanking zero-value cells, so I multiplied the tabulated formula by 1 - (#1 < 0).

@wspr
Copy link
Contributor Author

wspr commented Mar 10, 2017

sign() or sgn() definitely makes sense to me, but I’m not sure about step() / heaviside() / whatever. Can you give another example for the use case there?

@blefloch
Copy link
Member

blefloch commented Mar 11, 2017

I'm adding sign as soon as tests finish running. I'm not adding step/heaviside because it will be impossible to decide whether +0 and -0 should give 1 or 0. Also, there is already #1>0, or the more explicit #1>0?1:0.

@wspr
Copy link
Contributor Author

wspr commented Mar 11, 2017 via email

@aparsloe
Copy link

The use case instanced was the one that prompted the suggestion. For that, the step function was more relevant, but the mathematician in me felt uncomfortable including a relation like (#1 < 0) in a formula, where it is an accident of implementation that it gives the right values. I had overlooked the ?: operation, but I see it could ease my discomfort.
Andrew

@blefloch
Copy link
Member

@aparsloe I suppose I can close the issue, then.

@josephwright josephwright added enhancement New feature or request l3fp labels Sep 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request l3fp
Projects
None yet
Development

No branches or pull requests

4 participants