Closed Iainmon closed 4 years ago
Yes, this would be a great addition. I already override default crystal behavior for numbers, so I don't see a reason not to have it for arrays. This should be a very easy add, since I already have a from_array
method, so it would just be something like:
class Array(T)
def to_tensor
Tensor.from_array(self)
end
end
A PR would be welcome here!
Closed by #21
Would it be a good idea to add in a
[1, 2, 3].to_tensor
method for arrays? Maybe.to_vector
and.to_matrix
similar to this repository? It would be a lot easier and prettier thanTensor.from_array [1, 2, 3]
. https://github.com/ruivieira/crystal-gsl/blob/fa8ea796f06c77add4bb092be7bbdd93794027d6/src/gsl/base/array.cr