-
Notifications
You must be signed in to change notification settings - Fork 1
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
Tests for multiply (R←X×Y) #76
base: main
Are you sure you want to change the base?
Conversation
sloorush
commented
Aug 9, 2024
- closes Tests for Multiply (X×Y) #74
Todo:
|
@pmikkelsen @definitelyprobably This PR is ready for review. Please LMK what you think about it and if I have missed anything. Thanks Note: I have skipped ⎕FR←1287 for Hcmplx because the model is not appropriate for it. I had a chat with @pmikkelsen about it and we decided it is better to skip it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apologies for the delay. I think, in general, I just want more testing for certain types of inputs. Multiply is a trivial primitive, but still...
⍝ model for multiply might not be completely accurate for floats | ||
⍝ because it uses reciprocal and divide and there might be a | ||
⍝ loss of precision | ||
model←{⍺{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use {*(⍟⍺)+⍟⍵} as the model (using logarithms instead)? This would remove the need to handle complex numbers specifically.
Or, alternatively, could you use multiple models for redundancy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a minor problem with the model that it gives complex answers from negative numbers. I changed the model to:
model←{⍺{
0≡⍵:0
0≡⍺:0
(⌹¨÷/×⍺ ⍵)×*(⍟|⍺)+⍟|⍵
}¨⍵
}
(it is a makeshift approach, i know the × should not be there to multiply the sign)
The problem with this now is the direction operator approach will not give me the sign of the for the complex numbers but the direction of the complex vector(i think). Is there a solution to this?
⍝ Hdbl is 645 but larger numbers to test for CT value | ||
⍝ intervals of 2 are chosen because CT for these numbers +1 and -1 | ||
⍝ come under the region of tolerant equality | ||
Hdbl←{⍵,-⍵}1E14+(2×⍳50) ⍝ 645: large numbers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, I would be testing more "interesting" values too. For mantis 21743 the test was using 9007199254740992, which was the largest float that can be expressed as an integer.
Perhaps also use inputs that you know will produce (close to) the largest resulting float answer (~1e154)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The more bigger values are supposed to be tested by the random number generator in RunVariations
but because of the limitations of the current model I had turned it off. I will move to your model and try it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way I can easily find these 'interesting values' in mantis? For now, are there any specific values you would want to include other than this?
⍝ intervals of 2 are chosen because CT for these numbers +1 and -1 | ||
⍝ come under the region of tolerant equality | ||
Hdbl←{⍵,-⍵}1E14+(2×⍳50) ⍝ 645: large numbers | ||
Sdbl←{⍵,-⍵}(⍳500)÷1000 ⍝ 645: Small numbers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, in general, testing more small numbers would be good. Including denormal values (e.g. 1e¯310). Not that it should cause any issues here, but still.
|
||
:EndFor | ||
|
||
⍝ tests for known errors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multiply is a trivial primitive, but I'd still like to see tests for more places where we expect failure. E.g., ×⍨1e155. We don't want this to generate a 1287 accidentally, for example (even though that's improbable, we should still treat the interpreter as a black box and create that test).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Want to confirm:
We don't want this to generate a 1287 accidentally
Should I test if this gives a domain error or not?