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

map/reduce algorithms for heterogeneous arrays #114

Open
marcrasi opened this issue Jul 7, 2020 · 2 comments
Open

map/reduce algorithms for heterogeneous arrays #114

marcrasi opened this issue Jul 7, 2020 · 2 comments
Assignees

Comments

@marcrasi
Copy link
Collaborator

marcrasi commented Jul 7, 2020

We already have multiple algorithms defined on arrays of factors and arrays of variable values that may be implementable in terms of map or reduce algorithms:

We probably want to write more such algorithms in the future.

It is currently very tedious and boilerplatey to implement these algorithms. You have to implement the algorithm on the ArrayStorage, then you have to add a method to the appropriate dispatch classes, and finally you need to write a method on the heterogeneous collection that invokes the algorithm on all its homogeneous collections.

It would probably be easier to implement these algorithms if we could write them in terms of generic "map" or "reduce" algorithms on the heterogeneous collections.

@marcrasi
Copy link
Collaborator Author

marcrasi commented Jul 9, 2020

Oh I forgot to mention the reduce-like one: errorVectors_linearComponent_adjoint(_ y: AllVectors) is like factors.reduce(zero) { (r, factor) in r + factor.errorVector_linearComponent_adjoint(y) }.

@marcrasi
Copy link
Collaborator Author

Also possibly relevant: A few weeks ago I experimented with eliminating ensureUniqueStorage() from add and scale in AnyArrayBuffer where Dispatch: VectorArrayDispatch. This gave a 5-10% performance boost in the benchmarks, but it was a lot of extra code. I thought that a generic "in place map" might be able to handle this, so I decided to wait until we investigated that possibility before adding all the extra code. Therefore, it might make sense to investigate that while working on this.

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