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

Tests for multiply (R←X×Y) #76

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open

Tests for multiply (R←X×Y) #76

wants to merge 24 commits into from

Conversation

sloorush
Copy link
Member

@sloorush sloorush commented Aug 9, 2024

@sloorush sloorush marked this pull request as draft August 9, 2024 10:06
@sloorush sloorush marked this pull request as ready for review September 2, 2024 13:30
@sloorush sloorush requested review from pmikkelsen and removed request for pmikkelsen November 21, 2024 18:59
@sloorush
Copy link
Member Author

sloorush commented Nov 26, 2024

Todo:

  • fix cases with model not working with complex multiplication of the order 1E10 J 1E10

@sloorush sloorush requested a review from pmikkelsen November 26, 2024 15:36
@sloorush
Copy link
Member Author

@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.

Copy link
Collaborator

@pmikkelsen pmikkelsen left a 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 👍

readme.md Outdated Show resolved Hide resolved
tests/multiply.apln Show resolved Hide resolved
Copy link
Collaborator

@definitelyprobably definitelyprobably left a 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←{⍺{
Copy link
Collaborator

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?

Copy link
Member Author

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?

tests/multiply.apln Show resolved Hide resolved
⍝ 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
Copy link
Collaborator

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)?

Copy link
Member Author

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.

Copy link
Member Author

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
Copy link
Collaborator

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
Copy link
Collaborator

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).

Copy link
Member Author

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?

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

Successfully merging this pull request may close these issues.

Tests for Multiply (X×Y)
3 participants