How can i repeat a CuArray in a fast way? I have a 3 vector that is supposed to be subtracted from every row in a n x 3 matrix. The CPU code just transposes and repeats it, but this takes up to 3 seconds on GPU and takes up 1.7 GB. for a 100000x3 matrix while only taking 12 ms on cpu and allocating 22.9 mb.
Well ill be damned. Thanks, that solves my problem at this time. I think i need to read up a little more on that. How would it work if i would have it apply to the middle dimension of my mx3xn array A? What is the default behavior for the . operator, when the arrays don’t have the same dimensions? I assumed it was only for arrays of the same size.
Nvm found the docs:
so Julia provides broadcast, which expands singleton dimensions in array arguments to match the corresponding dimension in the other array without using extra memory, and applies the given function elementwise:
A=rand(1:10,4,3,2)
A.-[ 1;; 2;;3] # 3-element array for dim 2 (2 ';') ;; between elements
A.-[ 1;;;2] # 2-element array for dim 3 (3';') ;;; between elements