paleolimbot commented on issue #691:
URL: 
https://github.com/apache/arrow-nanoarrow/issues/691#issuecomment-2537673734

   Reopening because matrix support is a great idea! Unfortunately the 
column-majorness of matrices in R makes some of the ways we can deal with this 
not be zero copy, but I think we should still track this even if we don't get 
to it right away.
   
   For a matrix column in an Array, I think the natural mapping would be a 
`fixed_size_list()` (i.e., each row is a fixed size list of whatever matrix 
type we're dealing with). Maybe:
   
   ```r
   mat <- matrix(1:6, ncol = 2, byrow = TRUE)
   infer_nanoarrow_type(mat)  # would be na_fixed_size_list(na_int32())
   array <- as_nanoarrow_array(mat)  # would be logically [[1, 2], [3, 4], [5, 
6]]
   
   # We already have a mapping for list-like things, so the default would still 
come back as a list()
   convert_array(array). # -> list(1:2, 3:4, 5:6)
   
   # ...but we can request a type from convert_array(), so we can implement the 
conversion
   convert_array(array, matrix(integer())  # -> matrix(1:6, ncol = 2, byrow = 
TRUE)
   ```
   
   The "fixed shape tensor" extension would perhaps map to an `array()`, but 
unfortunately an `array()` with two dimensions is indistinguishable from a 
`matrix()` in all recent Rs. This is also less common to have an `array` 
column, so perhaps we could punt on that for now.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to