Extract a part of GPU matrix.
resMat = gpuExtract(A, row, col)
resMat = gpuExtract(A, positions)
resMat = A(row, col)
resMat = A(positions)
Can be :
Pointer on the matrix stored in device memory (GPU).
Pointer on the matrix stored in host memory (CPU).
A scalar or row vector stored in device or host memory.
In the case of extraction overloaded row can be a matrix.
A scalar or colomn vector stored in device or host memory.
In the case of extraction overloaded col can be a matrix.
A matrix stored in device or host memory.
Positions where items will be extracted.
The part of matrix A stored in device memory.
gpuExtract
allow the user to extract a part of matrix stored in device.
Only the overload allow the use of :
a = matrix(1:12, 3, 4) da = gpuSetData(a); // extract a scalar db = gpuExtract(da,3,3); gpuGetData(db) dc = da(3,3); gpuGetData(dc) a(3,3) gpuFree(db); gpuFree(dc); // extract a part db = gpuExtract(da,[1 6 8 12]); gpuGetData(db) dc = da([1 6 8 12]); gpuGetData(dc) a([1 6 8 12]) gpuFree(db); gpuFree(dc); gpuFree(da); // extraction only allowed with overload a = matrix(1:100, 10, 10) da = gpuSetData(a); dc = da(:); gpuGetData(dc) gpuFree(dc); a(:) dc = da(2,:); gpuGetData(dc) gpuFree(dc); a(2,:) dc = da([1 2; 4 5], [1 2 3]); gpuGetData(dc) gpuFree(dc); a([1 2; 4 5], [1 2 3]) gpuFree(da); | ![]() | ![]() |