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

add Vector (a,b) -> (Vector a, Vector b) et al to Unboxed Vector and MVector #63

Closed
cartazio opened this issue Dec 9, 2014 · 10 comments
Milestone

Comments

@cartazio
Copy link
Contributor

cartazio commented Dec 9, 2014

I'd like this for Unboxed Vectors and MVector

roughly

Unbox (a,b) =>Vector (a,b) -> (Vector a,Vector b)
Unbox (a,b) => (Vector a,Vector b) -> Vector (a,b)
Unbox (a,b) => (MVector s a,MVector s b) -> MVector s (a,b)
Unbox (a,b) =>MVector (a,b) -> (MVector a,MVector b)

should do this for (,)...(,,,) and Complex at least

@cartazio
Copy link
Contributor Author

cartazio commented Dec 9, 2014

https://github.com/wellposed/numerical/blob/d133ff5d982c5e83e711e1f364678a5455fe9b2b/src/Numerical/Array/Shape.hs#L481-L527
is some code i wrote that uses this, and I actually crucially need these sorts of transformations in another module of my code

or just export the constructors, because its totally type safe

@ttuegel
Copy link
Member

ttuegel commented Dec 9, 2014

If there is any concern about exporting the constructors, there should at least be zero-copy versions of these functions.

@cartazio
Copy link
Contributor Author

cartazio commented Dec 9, 2014

Looking at how the unboxed tuples instances are defined, I think these have to be zero copy helper functions

eg

data instance Vector (a, b)    
      = V_2 {-# UNPACK #-} !Int  !(Vector a)  !(Vector b)

@cartazio
Copy link
Contributor Author

cartazio commented Dec 9, 2014

and I guess in the tuple of (Vector a, Vector b) -> Vector (a,b) direction, they need to validate that the lenghts are the same

@neongreen
Copy link

unzip* and zip* are already provided for unboxed vectors and they are O(1): https://github.com/haskell/vector/blob/master/internal/unbox-tuple-instances

This issue should probably be closed.

@ttuegel
Copy link
Member

ttuegel commented Jan 21, 2015

We also need the same for Complex.

@yongqli
Copy link

yongqli commented Jan 25, 2015

It would be great if there was a way to expose the underlying "structure of arrays". It might be too much to ask for though. See ekmett/linear#61

@cartazio
Copy link
Contributor Author

@yongqli i have something like that in my numerical repo
https://github.com/wellposed/numerical/blob/master/src/Numerical/Data/Vector/Pair.hs

@ekmett
Copy link
Member

ekmett commented Mar 7, 2015

I personally would have no problem with exporting the constructors from somewhere.

@lehins
Copy link
Contributor

lehins commented Jun 19, 2022

Constructors for unboxed vectors have been exported from Data.Vector.Unboxed.Base from the beginning of time. It is an internal module as it very much should be, but it does not prevent others to shoot themselves in the foot.

@lehins lehins closed this as completed Jun 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants