Description Usage Arguments Details Value Warning Examples
The function will get a reference of the matrix subset. This is a 0-copy method, which means any change in the reference variable will cause the change in the original matrix. The function is useful when the GPU memory is limited or you do not want to create a copy the data. DO NOT call this function in R, this is for openCL code only(eg. gpuSapply).
1 | subRef(variable, i = "", j = "")
|
variable |
the matrix you want to subset |
i |
the index of a vector or the row index of a matrix |
j |
(Optional) The column index of a matrix |
The package implement this function purely using the code. it will not actually be called on device side. For example, if we have the following code:
1 2 3 | #Alternative of B=A[ind]
B=subRef(A,ind)
a=B[2]
|
In the compilation stage, the code will be changed to
1 | a=A[ind[2]]
|
The variable B does not exist in the code after the compilation and therefore no memory is allocated for it.
A reference to the subset of a matrix
Since this feature is implemented like a macro,
so it is possible to change the value of ind
after the matrix B is created and before you modify the matrix B.
In such case, it may cause an unexpected error.
It is a good practice to keep the ind
same while using the subset reference.
1 2 3 4 5 6 7 8 9 10 11 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.