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

Fast partitioned sum could be more general #101

Open
rikedyp opened this issue Oct 3, 2022 · 2 comments
Open

Fast partitioned sum could be more general #101

rikedyp opened this issue Oct 3, 2022 · 2 comments
Assignees
Labels
addition Request additional content

Comments

@rikedyp
Copy link
Collaborator

rikedyp commented Oct 3, 2022

The fast partitioned sum does not return the same results as +/¨⍺⊂⍵ if does not start with a 1

      0 1 0 1 0 0 0 {¯2-0(1)+} 1 3 2 4 4 4 4
1 5
      0 1 0 1 0 0 0 {+/¨} 1 3 2 4 4 4 4
5 16

This can be rectified with some conditional modification of the partition vector

      0 1 0 1 0 0 0 {¯2-(0/)(1@()1)+} 1 3 2 4 4 4 4
5 16
@rikedyp rikedyp added the addition Request additional content label Oct 3, 2022
@abrudz
Copy link
Owner

abrudz commented Oct 3, 2022

{¯2-⌿(0/⍨⊃⍺)⍪(1⌽1@1⊢⍺)⌿+⍀⍵} is better but it is very rare to actually need this, and it makes the code much more involved (though at next to no performance cost). I think it better to stipulate that all the fast partitioned algorithms require Av beginning with 1.

@rikedyp
Copy link
Collaborator Author

rikedyp commented Oct 3, 2022

Yeah I agree, the original is much simpler. Might be nice to add comments to aplcart examples.
Here is a prototype format: APLCart description in the header, main example in code, comments in the footer:

TiO flat partitioned sum example

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

No branches or pull requests

2 participants