xtensor-stack / xtensor-blas

BLAS extension to xtensor
BSD 3-Clause "New" or "Revised" License
155 stars 54 forks source link

xcontainer objects should accept xcontainers in operator() #235

Closed spectre-ns closed 10 months ago

spectre-ns commented 10 months ago

In numpy you can perform operations that look like this:

arr = np.array([[1,2,3],[4,5,6]])
ind = np.array([[0],[1]])
value = arr[ind]

I think it makes sense to implement an overload of operator() such that when an xcontainer is passed as the argument it returns an xexpression that looks the same as the value object in the example above. I think this would really help for instances where the dimensionality of the problem is dynamic. I have implemented the simple case where you provide have n dimensions and provide a single array that is 1xn resulting in 1 integral value using by calculating the linear index location I want from a stride and accessing through the raw pointer. I was previously using a strided view but it was too slow and seemed like over kill for my use case of access one value (rather than a range of values) in a multidimensional object where I know what index I want.

Thoughts?

spectre-ns commented 10 months ago

Wrong repo