#Look at available GPU devices (use setDevice to change the device)
listDevices()
#Creating GPU objects
g_x=g(1:10) #transfer a sequence to the GPU
g_y=gseq(1,10) #create a sequence on the GPU
g_A=gmatrix(grnorm(100),10,10,dup=FALSE) #create a random 10x10 matrix
#look at and change the properties of these objects
type(g_x)
type(g_A)
type(g_x)="d" #'d' may be used as short form of"double"
length(g_x)
dim(g_A)
nrow(g_A)
#Perform some simple calculations
g_ans=g_x %*% log(abs(g_A)) %*% sin(-g_y)
g_rowsum= rowSums(g_A)
#Move data back to the host
h_ans=h(g_x)
h_roswum =h(g_A)
Run the code above in your browser using DataLab