Package ‘gmatrix’ August 29, 2016 Type Package Title GPU Computing in R Version 0.3 Date 2015-11-23 Author Nathan Morris Maintainer Nathan Morris <njm18@case.edu> Description A general framework for utilizing R to harness the power of NVIDIA GPU's. The ``gmatrix'' and ``gvector'' classes allow for easy management of the separate device and host memory spaces. Numerous numerical operations are implemented for these objects on the GPU. These operations include matrix multiplication, addition, subtraction, the kronecker product, the outer product, comparison operators, logical operators, trigonometric functions, indexing, sorting, random number generation and many more. License GPL-3 | file LICENSE SystemRequirements Nvidia's CUDA toolkit (>= release 5.0) and Nvidia GPU with compute capibility >=2.0 OS_type unix URL https://github.com/njm18/gmatrix Depends methods, stats NeedsCompilation yes Repository CRAN Date/Publication 2015-12-01 08:01:12 R topics documented: gmatrix-package . . . . . . . . . . . . . . . . . . . . . as.gmatrix, as.gvector . . . . . . . . . . . . . . . . . . . as.numeric, as.integer, as.logical, as.vector and as.matrix checkDevice . . . . . . . . . . . . . . . . . . . . . . . . chol . . . . . . . . . . . . . . . . . . . . . . . . . . . . colMeans . . . . . . . . . . . . . . . . . . . . . . . . . colnames . . . . . . . . . . . . . . . . . . . . . . . . . 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 4 5 6 6 7 7 R topics documented: 2 convertType . . . . . . . . . crossprod,tcrossprod . . . . device . . . . . . . . . . . . diag . . . . . . . . . . . . . dim . . . . . . . . . . . . . dimnames . . . . . . . . . . elementwise binary operators elementwise functions . . . g . . . . . . . . . . . . . . . g.rep . . . . . . . . . . . . . gBasicHMC . . . . . . . . . gdbeta . . . . . . . . . . . . gdbinom . . . . . . . . . . . gdgamma . . . . . . . . . . gdpois . . . . . . . . . . . . gdup . . . . . . . . . . . . . ggc . . . . . . . . . . . . . . gident . . . . . . . . . . . . gkroneckerProd . . . . . . . gmatrix . . . . . . . . . . . gmatrix-class . . . . . . . . gmatTimesDiagVec . . . . . gmm . . . . . . . . . . . . . gnamestrip . . . . . . . . . . gorder . . . . . . . . . . . . gouter . . . . . . . . . . . . gqr-class . . . . . . . . . . . gRowLogSums . . . . . . . grunif . . . . . . . . . . . . gseq . . . . . . . . . . . . . gset.seed . . . . . . . . . . . gsumby . . . . . . . . . . . gsvd-class . . . . . . . . . . gtest . . . . . . . . . . . . . gvector . . . . . . . . . . . gvector-class . . . . . . . . ifelse . . . . . . . . . . . . . indexing . . . . . . . . . . . length . . . . . . . . . . . . lpgr-class . . . . . . . . . . matrix multiplication . . . . max . . . . . . . . . . . . . mean, sum . . . . . . . . . . names . . . . . . . . . . . . ncol . . . . . . . . . . . . . normal . . . . . . . . . . . . rsample . . . . . . . . . . . setDevice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 8 10 10 10 11 11 12 12 13 14 16 17 18 19 20 21 22 23 23 24 32 33 34 34 35 36 37 38 39 40 40 41 42 42 43 50 50 51 51 52 52 53 53 53 54 55 56 gmatrix-package setTuningPameters show . . . . . . . . sort . . . . . . . . t . . . . . . . . . . type . . . . . . . . which . . . . . . . 3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Index gmatrix-package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 57 58 58 58 59 60 Making GPU power available in R Description This package implements a general framework for utilizing R to harness the power of NVIDIA GPU’s. The gmatrix and gvector classes allow for easy management of the separate device and host memory spaces. Numerous numerical operations are implemented for these objects on the GPU. These operations include matrix multiplication, addition, subtraction, the kronecker product, the outer product, comparison operators, logical operators, trigonometric functions, indexing, sorting, random number generation and many more. Details Package: Type: Version: Date: License: LazyLoad: Depends: gmatrix Package 0.1 2013-5-10 GPL-2 yes methods To move an R object to the GPU use the g function. To move the object back the the host use the h function. Standard operations such as matrix multiplication or addition may be performed on GPU objects as with any matrix or vector object in R. The gmatrix and gvector classes contain a type slot which determines if the data is stored as a "double", "single", "integer" or "logical." The gmatrix and gvector objects store only a pointer to an object on the GPU device. Thus, a line such as y<-x will duplicate the pointer but not the actual data on the GPU. One should use instead y<-gdup(x). Numerous random number generators such as grnorm have been implemented in this package. This package is intended to work with the companion package rcula which implements matrix factorization and inversions methods. Author(s) Nathan Morris 4 as.gmatrix, as.gvector References None See Also rcula-package, g, h, gmatrix-class, gvector-class Examples #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) as.gmatrix, as.gvector Methods for coercing an object to a GPU class Description The as.gmatrix and as.gvector methods may be used to coerce an object to a given GPU class (i.e. gmatrix or gvector). Arguments x, data object to be coerced type The type to convert the object to. There are three different ways to specify this. One may use the "double", "single", "integer" or "logical" notation. Alternatively the short form "d", "s", "i" or "s" notation may be used. Finally the internal integer representation of 0L, 1L, 2L or 3L may be used. as.numeric, as.integer, as.logical, as.vector and as.matrix 5 dup This may be set to ’FALSE’ to avoid duplicating x in the event that it is on the GPU allready and the original type is the same as the type argument. nrow,ncol,byrow,dimnames these attributes should generally only be set by a direct call to gmatrix Details The as.gmatrix and as.gvector methods may be used to move an R object to the current GPU device and returns an object of class gmatrix or gvector respectively. The methods have the following arguments: as.gmatrix(data = NA, nrow = 1L, ncol = 1L, byrow = FALSE, dimnames = NULL, type = NULL, dup = TRUE) as.gvector(x, type=NULL, dup=TRUE) The dup argument is used only when the input argument (data) is all ready on the GPU. dup=FALSE will return the original data without duplicating it on the GPU. Value An object of type gmatrix or gvector Author(s) Nathan Morris See Also g, gmatrix and gvector Examples A=matrix(1:10,2,5) B=as.gmatrix(A) as.numeric, as.integer, as.logical, as.vector and as.matrix Methods to coerce a GPU object to an R object Description The functions as.numeric, as.integer, as.matrix and as.vector are intended to bring a GPU object to the main host memory and coerce it into the given type. Methods signature(x = "gmatrix") signature(x = "gvector") 6 chol See Also h checkDevice Check that the specified integer is the current device. Description Mostly for internal uses. Usage checkDevice(x) Arguments x A vector of integers Details Errors out if x is not the current device. Value Returns TRUE or errors out. Author(s) Nathan Morris See Also getDevice, setDevice and device chol Method to calculate the Choleski decomposition square symmetric posative definite matrix Description Takes a square symmetric posative definite gmatrix object. Note that no checking for symmetry is done. An error will be thrown if the the matrix is not posative definite. Returns a gmatrix object that is upper triangular. Methods signature(x = "ANY") signature(x = "gmatrix") colMeans colMeans 7 Methods to Form Row and Column Sums and Means Description This documents the colMeans, rowMeans, colSums and rowSums methods for objects of class gmatrix. These functions form row and column sums and means for an object of class gmatrix. This is implement very similarly to the base package (see rowSums, but the na.rm and dims arguments are not implemented). Methods signature(x = "ANY") signature(x = "gmatrix") colnames Methods to get and set the ’rownames’ and ’colnames’ of a matrix. Description This documents the functions rownames and colnames for objects of class gmatrix. These methods are very similar to those defined in R base (see rownames in R base). Methods signature(x = "ANY") signature(x = "gmatrix") convertType Convert the type of a GPU object Description This function is used to convert the type (i.e. "double", "single", "integer" or "logical") of a gmatrix or gvector object. Usage convertType(x, to, dup = TRUE) 8 crossprod,tcrossprod Arguments x A GPU object of class gvector or gmatrix to The type to convert the object to. There are three different ways to specify this. One may use the "double", "single", "integer" or "logical" notation. Alternatively the short form "d", "s", "i" or "s" notation may be used. Finally the internal integer representation of 0L, 1L, 2L or 3L may be used. dup This may be set to ’FALSE’ to avoid duplicating x in the event the original type and the to type are the same Value Returns the x after converting it to a new type. Author(s) Nathan Morris See Also type Examples x=gseq(1,10) y=convertType(x,'d') type(y) crossprod,tcrossprod Matrix Crossproduct Description Given matrices x and y as arguments, return a matrix cross-product. This is formally equivalent to (but usually slightly faster than) the call t(x) %*% y (crossprod) or x %*% t(y) (tcrossprod). Methods signature(x = "ANY", y = "ANY") signature(x = "gmatrix", y = "gmatrix") signature(x = "gmatrix", y = "gvector") signature(x = "gmatrix", y = "logical") signature(x = "gmatrix", y = "matrix") signature(x = "gmatrix", y = "missing") crossprod,tcrossprod signature(x = "gmatrix", y = "numeric") signature(x = "gvector", y = "gmatrix") signature(x = "gvector", y = "gvector") signature(x = "gvector", y = "logical") signature(x = "gvector", y = "missing") signature(x = "gvector", y = "numeric") signature(x = "logical", y = "gmatrix") signature(x = "logical", y = "gvector") signature(x = "matrix", y = "gmatrix") signature(x = "numeric", y = "gmatrix") signature(x = "numeric", y = "gvector") signature(x = "ANY", y = "ANY") signature(x = "gmatrix", y = "gmatrix") signature(x = "gmatrix", y = "gvector") signature(x = "gmatrix", y = "logical") signature(x = "gmatrix", y = "matrix") signature(x = "gmatrix", y = "missing") signature(x = "gmatrix", y = "numeric") signature(x = "gvector", y = "gmatrix") signature(x = "gvector", y = "gvector") signature(x = "gvector", y = "logical") signature(x = "gvector", y = "missing") signature(x = "gvector", y = "numeric") signature(x = "logical", y = "gmatrix") signature(x = "logical", y = "gvector") signature(x = "matrix", y = "gmatrix") signature(x = "numeric", y = "gmatrix") signature(x = "numeric", y = "gvector") 9 10 dim device Get and set methods for the device slot of a gvector or gmatrix object Description The device methods can be used to find what GPU device an object is stored on. The device<- can be used to move the object to a different GPU. Note that this is currently implemented by moving the object to host memory first. Methods signature(x = "gmatrix") signature(x = "gvector") See Also gdup and setDevice diag Matrix Diagonals Description Extract or replace the diagonal of a matrix, or construct a diagonal matrix. Implemented much the same as in R base. Methods signature(x = "ANY") signature(x = "gmatrix") dim Dimensions of an Object Description Retrieve or set the dimension of an object. Implemented much the same as in R base. However, any redimensioning of a matrix must result in a matrix with the same number of elements. Methods signature(x = "gmatrix") See Also dim dimnames dimnames 11 Dimnames of an Object Description Retrieve or set the dimnames of an object. Implemented much the same as R base. Methods signature(x = "gmatrix") See Also dimnames, colnames elementwise binary operators Binary Operators Description This page documents the operators "*", "+", "-", "/", "^", "%%", "=", "<", ">", ">=", "<=", "!=", "&" and "|". These are all element-wise binary operations that can be performed on a gmatrix or gvector object. Operators work in much that same way as in R base. The command e1 %lgspadd% e2 yields the vector log(exp(e1)+exp(e2)) calculated in a numericaly stable way. If one object is shorter than the other, items in the shorter object are recycled as in R base. All operations return a GPU object (i.e. a gmatrix or gvector). Methods signature(e1 = "gmatrix", e2 = "gmatrix") signature(e1 = "gmatrix", e2 = "gvector") signature(e1 = "gmatrix", e2 = "logical") signature(e1 = "gmatrix", e2 = "matrix") signature(e1 = "gmatrix", e2 = "numeric") signature(e1 = "gvector", e2 = "gmatrix") signature(e1 = "gvector", e2 = "gvector") signature(e1 = "gvector", e2 = "logical") signature(e1 = "gvector", e2 = "matrix") signature(e1 = "gvector", e2 = "numeric") signature(e1 = "logical", e2 = "gmatrix") signature(e1 = "logical", e2 = "gvector") 12 g signature(e1 = "matrix", e2 = "gmatrix") signature(e1 = "matrix", e2 = "gvector") signature(e1 = "numeric", e2 = "gmatrix") signature(e1 = "numeric", e2 = "gvector") Warning The operator %% is known to be numericaly instable compared to the R version. elementwise functions Elementwise functions/operators Description This is the documentation for the functions abs, exp, expm1, log, log2, log10, log1p, sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, asinh, acosh, atanh, abs, lgamma, gamma, sign, round, ceiling, is.na, is.nan, is.finite, is.infinite and !. These functions are elementwise functions/operators which are defined much the same as the functions the R base package. When operation on object of class gmatrix or gvector the work will be performed by the GPU and will return a GPU object of the same dimension as the input. Methods signature(x = "gmatrix") Returns an object of type gmatrix with the same dimensions as the input. signature(x = "gvector") Returns an object of type gvector with the same dimensions as the input. g Transfer and R object to and from the GPU. Description The function g transfers the object to the GPU. The function h transfers it back to the host. Usage g(x, type = NULL, dup = TRUE) h(x) g.rep 13 Arguments x The object to be transfered. type The type to convert the object to. There are three different ways to specify this. One may use the "double", "single", "integer" or "logical" notation. Alternatively the short form "d", "s", "i" or "s" notation may be used. Finally the internal integer representation of 0L, 1L, 2L or 3L may be used. dup This may be set to ’FALSE’ to avoid duplicating x in the event that it is on the GPU allready and the original type is the same as the type argument. Details These functions may be more convenient than functions such as ’as.gmatrix’ or ’as.gvector’. In addition to having a very short name, one does not need to consider whether the object is a vector or matrix. Value The ’h’ function transfers device data back to the host and returns a matrix or vector, while the ’g’ function returns an object of class gmatrix or gvector storing the data on the GPU. Author(s) Nathan Morris See Also as.gmatrix and as.numeric Examples h_x=1:10 g_x=g(h_x) #Transfer to the device g_ans=crossprod(g_x) #Do a a calculation h_ans=h(g_ans) #Transfer back to the host g.rep Replicate Elements of a vector or gvector, Description g.rep replicates the ’vector’ or gvector. Usage g.rep(x, times = 1L, each = 1L, type = NULL) 14 gBasicHMC Arguments x a ’vector’ or ’gvector.’ times a single integer representing the number of times the object should be replicated. each a single integer representing the number of times each element should be replicated. If each is specified, the times will be ignored. type coerce the output to the given type (i.e "double", "single", "integer" or "logical"). Details g.rep is somewhat simplified from the R base rep function. It is called g.rep to avoid conflict with the grep function. It can replicate in two different ways. If times is specified then the entire vector is replicated, while when each is specified each element is replicated one at a time. Value a gvector object with the replicated information Author(s) Nathan Morris See Also rep Examples x=g.rep(1:2, 2) #returns (1,2,1,2) x=g.rep(1:2, each=2) #returns (1,1,2,2) gBasicHMC Performing Hamiltonian MCMC Description This function performs Hamiltonian MCMC for continuous distributions. Usage gBasicHMC(lpgrf, initial, nsims, nsteps, step, burnin = 1, nstepsburnin = nsteps, stepburnin = step, Tstart = 1, r = 1, keep=keep, thin = 1, report = 100) gBasicHMC 15 Arguments lpgrf This lpgrf input must be a function which takes as its input a list of parameters and gives as its output the log probability (lp) excluding the normalization constant and a first derivative of the log probability (gr). Both the lp and gr information must be returned as slots in an object of class lpgr. See details. initial Starting values as a list. Again each element of the starting value must be a matrix on the CPU or GPU. The number columns of each matrix is the number of parrallel runs. nsims Total number of simulations includeing burnin. nsteps Tuning parameter for HMC representing the number of leepfrog steps for each iteration. step Tuning parameter for HMC controls the length of each leepfrog steps for each iteration. nstepsburnin Tuning parameter for HMC representing the number of leepfrog steps for each iteration. This parameter is used only during burnin. stepburnin Tuning parameter for HMC controls the length of each leepfrog steps for each iteration. This parameter is used only during burnin. Tstart During the burnin phase only tempering is used to get the simulation moving. Tstart is the starting temperature. r The temperature during the burning phase is exponentially decreased at a rate r. The temperature is set to 1 if it drops below 1. Also, the temperature is set to 1 once the burnin phas is done. burnin The number of iterations used for burnin. All burnin samples are discarded. keep Function to extract samples to keep. If defualt keep function is defined as keep = function(q) lapply(q, function(x) if(any(class(x) %in% c("gmatrix","gvector"))) thin Selects the number of samples to keep. thin=1 keeps all the samples. thin=5 keeps only ever fifth sample. report Controls how often an update of the progress is printed out. Details The most important input of gBasicHMC() is the lpgrf parameter. This lpgrf input must be a function which takes as its input a list of parameters and gives as its output the log probability (lp) excluding the normalization constant and a first derivative of the log probability (gr). Both the lp and gr information must be returned as slots in an object of class lpgrf. The lp slot must be a numberic CPU vector while gr slot must be a list with elements either on the CPU or GPU.The function gBasicHMC() is designed to run multiple chains simultaneously. Thus each element in the input is expected to be a matrix where the number of columns is the number of parallel chains and the number of rows is the dimension of the random variable being simulated. The input is assumed to be a list of parameters because in many cases there are different types of parameters such as hyper-parameters. Tracking the current stated of the chain using a list is therefore often quite natural. As a result of this convention, the gr slot for lpgr object returned by the lpgrf function must also be a list. 16 gdbeta Value Output is a list: sims A list with the simulation results from each iteration as elements. lp A matrix with the simulation log probabilities for all simulations. AcceptanceRate Acceptence rate for each parallel chain. BurninAcceptanceRate Acceptence rate during the burnin phase for each parallel chain. Author(s) Nathan Morris (this is actually a significantly modified version of an HMC implementation created by Radford Neal: http://www.cs.utoronto.ca/~radford/GRIMS.html) References Neal, Radford M. "MCMC using Hamiltonian dynamics." Handbook of Markov Chain Monte Carlo 2 (2011). Beam, Andrew L., Sujit K. Ghosh, and Jon Doyle. "Fast hamiltonian monte carlo using gpu computing." Journal of Computational and Graphical Statistics just-accepted (2015): 00-00. See Also lpgr-class gdbeta The Beta Distribution Description Density and random generation for the Beta distribution with parameters shape1 and shape2. Usage gdbeta(x, shape1, shape2, ncp = 0, log = FALSE, type = "d") grbeta(n, shape1, shape2, ncp = 0, type = "d") Arguments x vector of quantiles n number of random values to return shape1, shape2 positive parameters of the Beta distribution ncp must be 0 at this point log logical; if TRUE, probabilities p are given as log(p) type specify the type; may be "double", "single" (or short form "d" or "s") gdbinom 17 Details Very similar to the R stats functionality. Value gdbeta gives the density and grbeta generates random deviates. Author(s) Nathan Morris See Also dbeta Examples myRndNums = grbeta(10,c(1,2), c(1,2,3,4,5)) gdbinom The Binomial Distribution Description Density and random generation for the binomial distribution with parameters size and prob. Usage gdbinom(x, size, prob, log = FALSE, type = "d") grbinom(n, size, prob) Arguments x vector of quantiles. n number of observations size number of trials (zero or more) prob probability of success on each trial log logical; if TRUE, probabilities p are given as log(p). type specify the type; may be "double", "single" (or short form "d" or "s") Details Very similar to the R stats functionality. Value gdbinom gives the density and grbinom generates random deviates 18 gdgamma Note The algorythm for simulating from the poisson distribution was modified from the GSL library which uses the modified from the GSL library which uses the Knuth method. Author(s) Nathan Morris See Also dbinom Examples myRndNums = grbinom(10,10,.6) gdgamma The Gamma Distribution Description Density, and random generation for the Gamma distribution with parameters shape and scale. Usage gdgamma(x, shape, rate = 1, scale = 1/rate, log = FALSE, type = "d") grgamma(n, shape, rate = 1, scale = 1/rate, type = "d") Arguments x vector of quantiles n number of random values to return shape,scale shape and scale parameters. Must be positive, scale strictly rate an alternative way to specify the scale log logical; if TRUE, probabilities/densities p are returned as log(p) type specify the type; may be "double", "single" (or short form "d" or "s") Details Works in much the same way as the R base functions. Value gdgamma gives the density and grgamma generates random deviates. gdpois 19 Author(s) Nathan Morris References Random gamma simulation was implemented using the algorithm described in: Marsaglia and Tsang (2000) A Simple Method for Generating Gamma Variables. ACM Transactions on Mathematical Software. Volume 26 Issue 3, Pages 363-372. See Also dgamma Examples myRndNums = grgamma(10, c(1,2)) gdpois The Poisson Distribution Description Density and random generation for the Poisson distribution with parameter lambda. Usage gdpois(x, lambda, log = FALSE, type = "d") grpois(n, lambda) Arguments x vector of (non-negative integer) quantiles n number of random values to return lambda vector of (non-negative) means log logical; if TRUE, probabilities p are given as log(p) type specify the type; may be "double", "single" (or short form "d" or "s") Details Very similar to the R stats functionality. Value gdpois gives the (log) density, and grpois generates random deviates. 20 gdup Note The algorithm for simulating from the poisson distribution was modified from the GSL library which uses the Knuth method. Author(s) Nathan Morris See Also dpois Examples myRndNums = grpois(10,4) gdup Duplicate a GPU object Description This function duplicates a gmatrix or gvector object on the specified device. Usage gdup(x, dev=getDevice()) Arguments x object to duplicate dev device to duplicate the object on Details This function is very important because the gmatrix and gvector classes store only a pointer to an object on the GPU device. Thus, a line such as y<-x will duplicate the pointer but not the actual data on the GPU. One should use instead y<-gdup(x). The gdup function is also useful for copying the data to a different GPU device. Value a gmatrix or gvector object. Author(s) Nathan Morris ggc 21 See Also To move data to a different device instead of copying it see device Examples #problematic code x=gseq(1,10) y=x x[1]=1000 show(y)#changes to x also change y #correct x=gseq(1,10) y=gdup(x) x[1]=1000 show(y) #changes to x do not change y #copy to a different device #y=gdup(x, dev=2L) ggc GPU Garbage Collection Description Performs Garbage Collection and reports the available memory. Usage ggc(silent=FALSE) Arguments silent If silent is TRUE then nothing will be printed out. Details Used for garbage collection, and also used to discover the amount of memory on the graphics card which is still available. Value returns TRUE, but prints the amount of memory left. Author(s) Nathan Morris 22 gident See Also gc Examples ggc() gident Create an identity matrix on the GPU. Description Create an identity matrix on the GPU size Usage gident(n,val=1, type="d") Arguments n Integer specifying the dimensions of the matrix. val The constant number to put on the diagonal. 1 leads to an identity matrix type The type of matrix to return Value Returns and n x n matrix with zeros on the of diagonals. Author(s) Nathan Morris See Also as.gmatrix and as.numeric Examples ga = gident(40) da = diag(40) sum(h(ga) == da) gkroneckerProd 23 gkroneckerProd Kronecker Product Description Calculates the kronecker product of two matrices. Usage gkroneckerProd(A, B) A Arguments A A gmatrix, gvector, matrix or vector B A gmatrix, gvector, matrix or vector Value A GPU object storing the Kronecker product. Author(s) Nathan Morris gmatrix Create and object of class gmatrix Description This function creates a gmatrix object from an input value. Usage gmatrix(data = NA, nrow = 1L, ncol = 1L, byrow = FALSE, dimnames = NULL, type = NULL, dup = TRUE) Arguments data The input data. Must be a vector or gvector. nrow the desired number of rows ncol the desired number of rows. byrow logical. If FALSE (the default) the matrix is filled by columns, otherwise the matrix is filled by rows. 24 gmatrix-class dimnames A dimnames attribute for the matrix: NULL or a list of length 2 giving the row and column names respectively. An empty list is treated as NULL. type The type (i.e. "double", "single", "integer" or "logical") dup dup=FALSE will return the original data without duplicating it on the GPU. The dup=FALSE should only be used if the data in the input will not be used in it’s original form again. Details This is implemented in a very similar fashion to the matrix function in R base. Value returns a gmatrix object. Author(s) Nathan Morrris See Also matrix Examples x=gmatrix(grnorm(100),10,10, type='d') #this makes an unneeded duplication x=gmatrix(grnorm(100),10,10, dup=FALSE) #this avoids the duplication #problematic code x=grnorm(100) y=as.gmatrix(x,10,10, dup=FALSE) #don't do this y[1,1]=100 #this changes both y and x because both point to the same spot in GPU memory x gmatrix-class Class "gmatrix" Description This object contains a pointer to a matrix on a NVIDIA GPU. Objects from the Class Objects should NOT be created by calls of the form new("gmatrix", ...). Instead use the gmatrix, ’as.gmatrix’ or ’g’ functions. gmatrix-class 25 Slots ptr: Represents an external pointer to the data on the GPU nrow: Object of class "integer" representing the number of rows for the matrix ncol: Object of class "integer" representing the number of cols for the matrix rownames: Should be a character vector with length equal nrow colnames: Should be a character vector with length equal nrow type: Must be 0L, 1L, 2L or 3L. These integers represent the types "double", "single", "integer" or "logical" respectively. device: Object of class "integer" representing the device Methods - signature(e1 = "gmatrix", e2 = "gmatrix"): subtraction operator - signature(e1 = "gmatrix", e2 = "gvector"): subtraction operator - signature(e1 = "gmatrix", e2 = "logical"): subtraction operator - signature(e1 = "gmatrix", e2 = "matrix"): subtraction operator - signature(e1 = "gmatrix", e2 = "missing"): subtraction operator - signature(e1 = "gmatrix", e2 = "numeric"): subtraction operator - signature(e1 = "gvector", e2 = "gmatrix"): subtraction operator - signature(e1 = "logical", e2 = "gmatrix"): subtraction operator - signature(e1 = "matrix", e2 = "gmatrix"): subtraction operator - signature(e1 = "numeric", e2 = "gmatrix"): subtraction operator ! signature(x = "gmatrix"): not operator != signature(e1 = "gmatrix", e2 = "gmatrix"): not equal operator != signature(e1 = "gmatrix", e2 = "gvector"): not equal operator != signature(e1 = "gmatrix", e2 = "logical"): not equal operator != signature(e1 = "gmatrix", e2 = "matrix"): not equal operator != signature(e1 = "gmatrix", e2 = "numeric"): not equal operator != signature(e1 = "gvector", e2 = "gmatrix"): not equal operator != signature(e1 = "logical", e2 = "gmatrix"): not equal operator != signature(e1 = "matrix", e2 = "gmatrix"): not equal operator != signature(e1 = "numeric", e2 = "gmatrix"): not equal operator %% signature(e1 = "gmatrix", e2 = "gmatrix"): mod operator %% signature(e1 = "gmatrix", e2 = "gvector"): mod operator %% signature(e1 = "gmatrix", e2 = "logical"): mod operator %% signature(e1 = "gmatrix", e2 = "matrix"): mod operator %% signature(e1 = "gmatrix", e2 = "numeric"): mod operator %% signature(e1 = "gvector", e2 = "gmatrix"): mod operator 26 gmatrix-class %% signature(e1 = "logical", e2 = "gmatrix"): mod operator %% signature(e1 = "matrix", e2 = "gmatrix"): mod operator %% signature(e1 = "numeric", e2 = "gmatrix"): mod operator %*% signature(x = "gmatrix", y = "gmatrix"): matrix multiplication operator %*% signature(x = "gmatrix", y = "gvector"): matrix multiplication operator %*% signature(x = "gmatrix", y = "logical"): matrix multiplication operator %*% signature(x = "gmatrix", y = "matrix"): matrix multiplication operator %*% signature(x = "gmatrix", y = "numeric"): matrix multiplication operator %*% signature(x = "gvector", y = "gmatrix"): matrix multiplication operator %*% signature(x = "logical", y = "gmatrix"): matrix multiplication operator %*% signature(x = "matrix", y = "gmatrix"): matrix multiplication operator %*% signature(x = "numeric", y = "gmatrix"): matrix multiplication operator %x% signature(X = "gmatrix", Y = "gmatrix"): kronecker product %x% signature(X = "gmatrix", Y = "gvector"): kronecker product %x% signature(X = "gmatrix", Y = "numeric"): kronecker product %x% signature(X = "gvector", Y = "gmatrix"): kronecker product %x% signature(X = "numeric", Y = "gmatrix"): kronecker product & signature(e1 = "gmatrix", e2 = "gmatrix"): and operator & signature(e1 = "gmatrix", e2 = "gvector"): and operator & signature(e1 = "gmatrix", e2 = "logical"): and operator & signature(e1 = "gmatrix", e2 = "matrix"): and operator & signature(e1 = "gmatrix", e2 = "numeric"): and operator & signature(e1 = "gvector", e2 = "gmatrix"): and operator & signature(e1 = "logical", e2 = "gmatrix"): and operator & signature(e1 = "matrix", e2 = "gmatrix"): and operator. & signature(e1 = "numeric", e2 = "gmatrix"): and operator. * signature(e1 = "gmatrix", e2 = "gmatrix"): elementwise multiplication * signature(e1 = "gmatrix", e2 = "gvector"): elementwise multiplication * signature(e1 = "gmatrix", e2 = "logical"): elementwise multiplication * signature(e1 = "gmatrix", e2 = "matrix"): elementwise multiplication * signature(e1 = "gmatrix", e2 = "numeric"): elementwise multiplication * signature(e1 = "gvector", e2 = "gmatrix"): elementwise multiplication * signature(e1 = "logical", e2 = "gmatrix"): elementwise multiplication * signature(e1 = "matrix", e2 = "gmatrix"): elementwise multiplication * signature(e1 = "numeric", e2 = "gmatrix"): elementwise multiplication / signature(e1 = "gmatrix", e2 = "gmatrix"): division operator / signature(e1 = "gmatrix", e2 = "gvector"): division operator gmatrix-class 27 / signature(e1 = "gmatrix", e2 = "logical"): division operator / signature(e1 = "gmatrix", e2 = "matrix"): division operator / signature(e1 = "gmatrix", e2 = "numeric"): division operator / signature(e1 = "gvector", e2 = "gmatrix"): division operator / signature(e1 = "logical", e2 = "gmatrix"): division operator / signature(e1 = "matrix", e2 = "gmatrix"): division operator / signature(e1 = "numeric", e2 = "gmatrix"): division operator [ signature(x = "gmatrix", i = "gvector", j = "gvector"): indexing [ signature(x = "gmatrix", i = "gvector", j = "missing"): indexing [ signature(x = "gmatrix", i = "gvector", j = "numeric"): indexing [ signature(x = "gmatrix", i = "numeric", j = "gvector"): indexing [ signature(x = "gmatrix", i = "numeric", j = "missing"): indexing [ signature(x = "gmatrix", i = "numeric", j = "numeric"): indexing [ signature(x = "gmatrix", i = "missing", j = "missing", k = "missing"): indexing [<- signature(x = "gmatrix", i = "gvector", j = "gvector"): indexing [<- signature(x = "gmatrix", i = "gvector", j = "missing"): indexing [<- signature(x = "gmatrix", i = "gvector", j = "numeric"): indexing . [<- signature(x = "gmatrix", i = "numeric", j = "gvector"): indexing [<- signature(x = "gmatrix", i = "numeric", j = "missing"): indexing [<- signature(x = "gmatrix", i = "numeric", j = "numeric"): indexing [<- signature(x = "gmatrix", i = "missing", j = "missing", k = "missing"): indexing ^ signature(e1 = "gmatrix", e2 = "gmatrix"): power operator ^ signature(e1 = "gmatrix", e2 = "gvector"): power operator ^ signature(e1 = "gmatrix", e2 = "logical"): power operator ^ signature(e1 = "gmatrix", e2 = "matrix"): power operator ^ signature(e1 = "gmatrix", e2 = "numeric"): power operator ^ signature(e1 = "gvector", e2 = "gmatrix"): power operator ^ signature(e1 = "logical", e2 = "gmatrix"): power operator ^ signature(e1 = "matrix", e2 = "gmatrix"): power operator ^ signature(e1 = "numeric", e2 = "gmatrix"): power operator | signature(e1 = "gmatrix", e2 = "gmatrix"): or operator | signature(e1 = "gmatrix", e2 = "gvector"): or operator | signature(e1 = "gmatrix", e2 = "logical"): or operator | signature(e1 = "gmatrix", e2 = "matrix"): or operator | signature(e1 = "gmatrix", e2 = "numeric"): or operator | signature(e1 = "gvector", e2 = "gmatrix"): or operator | signature(e1 = "logical", e2 = "gmatrix"): or operator 28 gmatrix-class | signature(e1 = "matrix", e2 = "gmatrix"): or operator | signature(e1 = "numeric", e2 = "gmatrix"): or operator + signature(e1 = "gmatrix", e2 = "gmatrix"): plus operator + signature(e1 = "gmatrix", e2 = "gvector"): plus operator + signature(e1 = "gmatrix", e2 = "logical"): plus operator + signature(e1 = "gmatrix", e2 = "matrix"): plus operator + signature(e1 = "gmatrix", e2 = "missing"): plus operator + signature(e1 = "gmatrix", e2 = "numeric"): plus operator + signature(e1 = "gvector", e2 = "gmatrix"): plus operator + signature(e1 = "logical", e2 = "gmatrix"): plus operator + signature(e1 = "matrix", e2 = "gmatrix"): plus operator + signature(e1 = "numeric", e2 = "gmatrix"): plus operator < signature(e1 = "gmatrix", e2 = "gmatrix"): less than operator < signature(e1 = "gmatrix", e2 = "gvector"): less than operator < signature(e1 = "gmatrix", e2 = "logical"): less than operator < signature(e1 = "gmatrix", e2 = "matrix"): less than operator < signature(e1 = "gmatrix", e2 = "numeric"): less than operator < signature(e1 = "gvector", e2 = "gmatrix"): less than operator < signature(e1 = "logical", e2 = "gmatrix"): less than operator < signature(e1 = "matrix", e2 = "gmatrix"): less than operator < signature(e1 = "numeric", e2 = "gmatrix"): less than operator <= signature(e1 = "gmatrix", e2 = "gmatrix"): less than or equal operator <= signature(e1 = "gmatrix", e2 = "gvector"): less than or equal operator <= signature(e1 = "gmatrix", e2 = "logical"): less than or equal operator <= signature(e1 = "gmatrix", e2 = "matrix"): less than or equal operator <= signature(e1 = "gmatrix", e2 = "numeric"): less than or equal operator <= signature(e1 = "gvector", e2 = "gmatrix"): less than or equal operator <= signature(e1 = "logical", e2 = "gmatrix"): less than or equal operator <= signature(e1 = "matrix", e2 = "gmatrix"): less than or equal operator <= signature(e1 = "numeric", e2 = "gmatrix"): less than or equal operator == signature(e1 = "gmatrix", e2 = "gmatrix"): equal operator == signature(e1 = "gmatrix", e2 = "gvector"): equal operator == signature(e1 = "gmatrix", e2 = "logical"): equal operator == signature(e1 = "gmatrix", e2 = "matrix"): equal operator == signature(e1 = "gmatrix", e2 = "numeric"): equal operator == signature(e1 = "gvector", e2 = "gmatrix"): equal operator == signature(e1 = "logical", e2 = "gmatrix"): equal operator gmatrix-class == signature(e1 = "matrix", e2 = "gmatrix"): equal operator == signature(e1 = "numeric", e2 = "gmatrix"): equal operator > signature(e1 = "gmatrix", e2 = "gmatrix"): greater than operator > signature(e1 = "gmatrix", e2 = "gvector"): greater than operator > signature(e1 = "gmatrix", e2 = "logical"): greater than operator > signature(e1 = "gmatrix", e2 = "matrix"): greater than operator > signature(e1 = "gmatrix", e2 = "numeric"): greater than operator > signature(e1 = "gvector", e2 = "gmatrix"): greater than operator > signature(e1 = "logical", e2 = "gmatrix"): greater than operator > signature(e1 = "matrix", e2 = "gmatrix"): greater than operator > signature(e1 = "numeric", e2 = "gmatrix"): greater than operator >= signature(e1 = "gmatrix", e2 = "gmatrix"): greater than or equal operator >= signature(e1 = "gmatrix", e2 = "gvector"): greater than or equal operator >= signature(e1 = "gmatrix", e2 = "logical"): greater than or equal operator >= signature(e1 = "gmatrix", e2 = "matrix"): greater than or equal operator >= signature(e1 = "gmatrix", e2 = "numeric"): greater than or equal operator >= signature(e1 = "gvector", e2 = "gmatrix"): greater than or equal operator >= signature(e1 = "logical", e2 = "gmatrix"): greater than or equal operator >= signature(e1 = "matrix", e2 = "gmatrix"): greater than or equal operator >= signature(e1 = "numeric", e2 = "gmatrix"): greater than or equal operator as.gmatrix signature(data = "gmatrix"): coersion function as.gvector signature(x = "gmatrix"): coersion function as.integer signature(x = "gmatrix"): coersion function as.logical signature(x = "gmatrix"): coersion function as.matrix signature(x = "gmatrix"): coersion function as.numeric signature(x = "gmatrix"): coersion function as.vector signature(x = "gmatrix"): coersion function abs signature(x = "gmatrix"): absolute value acos signature(x = "gmatrix"): inverse cosine acosh signature(x = "gmatrix"): inverse hyperbolic cosine asin signature(x = "gmatrix"): inverse sin asinh signature(x = "gmatrix"): inverse hyperbolic sin atan signature(x = "gmatrix"): inverse tangent atanh signature(x = "gmatrix"): inverse hyperbolic tangent ceiling signature(x = "gmatrix"): ceiling function colMeans signature(x = "gmatrix"): mean of each column colnames signature(x = "gmatrix"): column names 29 30 gmatrix-class colnames<- signature(x = "gmatrix"): set column names colSums signature(x = "gmatrix"): sum of each column cos signature(x = "gmatrix"): cos function cosh signature(x = "gmatrix"): hyperbolic cos crossprod signature(x = "gmatrix", y = "gmatrix"): calculates: t(x) %*% y crossprod signature(x = "gmatrix", y = "gvector"): calculates: t(x) %*% y crossprod signature(x = "gmatrix", y = "logical"): calculates: t(x) %*% y crossprod signature(x = "gmatrix", y = "matrix"): calculates: t(x) %*% y crossprod signature(x = "gmatrix", y = "missing"): calculates: t(x) %*% y crossprod signature(x = "gmatrix", y = "numeric"): calculates: t(x) %*% y crossprod signature(x = "gvector", y = "gmatrix"): calculates: t(x) %*% y crossprod signature(x = "logical", y = "gmatrix"): calculates: t(x) %*% y crossprod signature(x = "matrix", y = "gmatrix"): calculates: t(x) %*% y crossprod signature(x = "numeric", y = "gmatrix"): calculates: t(x) %*% y tcrossprod signature(x = "gmatrix", y = "gmatrix"): calculates: x %*% t(y) tcrossprod signature(x = "gmatrix", y = "gvector"): calculates: x %*% t(y) tcrossprod signature(x = "gmatrix", y = "logical"): calculates: x %*% t(y) tcrossprod signature(x = "gmatrix", y = "matrix"): calculates: x %*% t(y) tcrossprod signature(x = "gmatrix", y = "missing"): calculates: x %*% t(y) tcrossprod signature(x = "gmatrix", y = "numeric"): calculates: x %*% t(y) tcrossprod signature(x = "gvector", y = "gmatrix"): calculates: x %*% t(y) tcrossprod signature(x = "logical", y = "gmatrix"): calculates: x %*% t(y) tcrossprod signature(x = "matrix", y = "gmatrix"): calculates: x %*% t(y) tcrossprod signature(x = "numeric", y = "gmatrix"): calculates: x %*% t(y) device signature(x = "gmatrix"): get device property device<- signature(x = "gmatrix"): set device property diag signature(x = "gmatrix"): diagonal diag<- signature(x = "gmatrix"): set the diagonal of a matrix dim signature(x = "gmatrix"): dimension dim<- signature(x = "gmatrix"): set dimension dimnames signature(x = "gmatrix"): get dimnames dimnames<- signature(x = "gmatrix"): set dimnames exp signature(x = "gmatrix"): exponentiate function expm1 signature(x = "gmatrix"): computes exp(x) - 1 floor signature(x = "gmatrix"): floor function gamma signature(x = "gmatrix"): gamma function ifelse signature(test = "gmatrix"): conditional selection gmatrix-class is.finite signature(x = "gmatrix"): finite status is.infinite signature(x = "gmatrix"): infinite status is.na signature(x = "gmatrix"): missing status is.nan signature(x = "gmatrix"): not a number status length signature(x = "gmatrix"): total number of elements in object lgamma signature(x = "gmatrix"): log gamma function log signature(x = "gmatrix"): logarithm function log10 signature(x = "gmatrix"): base 10 log log1p signature(x = "gmatrix"): log(1+x) log2 signature(x = "gmatrix"): base 2 log max signature(x = "gmatrix"): maximum of all elements mean signature(x = "gmatrix"): mean of all elements min signature(x = "gmatrix"): min of all elements ncol signature(x = "gmatrix"): number of columns nrow signature(x = "gmatrix"): number of rows round signature(x = "gmatrix"): round function (only to nearest whole number) rowMeans signature(x = "gmatrix"): mean of each row rownames signature(x = "gmatrix"): names of rows rownames<- signature(x = "gmatrix"): set row names rowSums signature(x = "gmatrix"): sum of each row show signature(object = "gmatrix"): show the data sign signature(x = "gmatrix"): return the sign sin signature(x = "gmatrix"): sin function sinh signature(x = "gmatrix"): hyperbolic sin sqrt signature(x = "gmatrix"): square root sum signature(x = "gmatrix"): sum t signature(x = "gmatrix"): transpose tan signature(x = "gmatrix"): tangent tanh signature(x = "gmatrix"): hyperbolic tangent type signature(x = "gmatrix"): get type (e.g "double") type<- signature(x = "gmatrix"): set type solve signature(a = "gmatrix", b="ANY"): set type Author(s) Nathan Morris See Also gvector Examples showClass("gmatrix") 31 32 gmatTimesDiagVec gmatTimesDiagVec Multiply a matrix times the ’diag’ of a vector quickly. Description This function calculates A %*% diag(v). It is much faster than the direct calculation as it avoids the huge matrix multiplication problem. Usage gmatTimesDiagVec(A, v) Arguments A An object of class gmatrix or ’matrix’. v An object of class ’gvecotr’ or a ’vector’. Value Returns a gmatrix Note Note that to calculate the diag(v) %*% A one may use the efficient formula v*A. Author(s) Nathan Morris See Also diag Examples v=grnorm(10) A=gmatrix(grnorm(100),10,10,dup=FALSE) gmatTimesDiagVec(A, v) gmm 33 gmm Multiply two matrices with the output matrix allready allocated. Description In effect this function sets C <- A %*% B. This makes it possible to avoid repeated allocation and deallocation steps which are very computationaly costly. Usage gmm(A, B, C, trA=FALSE, trB=FALSE, accum=FALSE) Arguments A, B Matrices to multiply together. C Matrices where output will be saved. trA, trB Should A or B be transposed. accum if accum is set to TRUE, the multiplied matrix will be added to C (i.e. C<-C+A %*% B). Details This function takes advantage of the fact that gmatrix objects are stored as pointers making it posible modify the input to a function. Thus the area of memory on the GPU pointed to by the C object is modified to contain A %*% B. Value Returns C invisibly. Author(s) Nathan Morris Examples A=gmatrix(rnorm(10), 2, 5) B=gmatrix(rnorm(10), 5, 2) C=gmatrix(0,2,2) gmm(A,B,C) gmm(B,A,C,TRUE,TRUE) 34 gorder gnamestrip Strip a GPU object of it names, or row/colnames. Description Returns a GPU object without any names or row/colnames. This may speed up certian operations. Usage gnamestrip(x, dup = TRUE) Arguments x input object to be stripped of names dup if FALSE then don’t duplicate x on the GPU. Return object will point to the same GPU memory as the original object. Value Returns the original object with no names. Author(s) Nathan Morris See Also names, colnames and dimnames Examples x=gseq(1,2) names(x)=c("bill","joe") gnamestrip(x) gorder Ordering Permutation Description gorder returns a permutation which rearranges its first argument into ascending or descending order. Usage gorder(x, decreasing = FALSE, stable = TRUE, sortx=FALSE) gouter 35 Arguments x decreasing stable sortx object to be ordered logical to specify sort order make sure that ties are in the original order if sortx=TRUE, then x will be modified by sorting it. This avoids an extra duplication of the x. By leaving sortx=FALSE, an extra duplication of x is performed to avoid changing the input value. Details Unlike the base R function, only one input column may be given. The thrust library is used for this operation. Value a gvector of type "integer" which will permute the input vector to the proper sort order. Author(s) Nathan Morris See Also order Examples x=grnorm(10) i=gorder(x) x[i] #sort x gouter GPU generalized outer product. Description This function calculates the outer product of two gvectors. Usage gouter(x, y, FUN = "*", normalOrder = TRUE) Arguments x y FUN normalOrder a ’vector’ or gvector object a ’vector’ or gvector object one of the following characters ’*’, ’+’, ’-’, ’/’ or ’^’ logical input determining which order the operation should be performed in. 36 gqr-class Details This function is similar to the outer function in R base. It performs the specified operation on all posible combinations of elements from the first vector with the second. This function does not behave the same as R base when operating on matrices. Also, the operator %o% may be used as in the R base package. Value returns a gmatrix with the specified operation performed Author(s) Nathan Morris See Also outer, %o% Examples gouter(grnorm(10), grnorm(10), FUN="-") gqr-class Class "gqr" Description Contains the results of a QR decomposition from using the qr() method on a gmatrix object. Note that the gmatrix solve function uses QR decompostion. Also, qr.coef can act on the gqr object. The qr method does not use pivoting or check the matrix rank. The QR and related methods are only available for cuda v7.0 or greater. Objects from the Class Objects can be created by calls of the qr() method. Slots qr: Information about the Q and R matrices stored as and bject of class "gmatrix". qraux: Information about the Q matrix stored as an object of class "gvector". Methods qr.coef Simular to the qr.coef function. solve Simular to the solve.qr function. gRowLogSums 37 Author(s) Nathan Morris See Also qr, qr.coef, solve.qr, solve Examples M=gmatrix(grnorm(25), 5,5,dup=FALSE) y=grnorm(5) solve(M) solve(M,y) myqr =qr(M) solve(myqr,y) gRowLogSums Sum the up the rows in log space. Description Sum up the rows in log space. Usage gRowLogSums(x, startCol=1, endCol=ncol(x)) Arguments x A matrix startCol May be used to perform the log sum on only selected columns endCol May be used to perform the log sum on only selected columns Details Calculates for each row vector v the value log(sum(exp(v))) in a way that avoids overflow. This function may be useful for mixture models. This function is only efficient for a large number of rows and a smaller number of columns. Value Returns a vector with a value for each row. Author(s) Nathan Morris 38 grunif See Also %lgspadd%-methods grunif The Uniform Distribution Description These functions provide information about the uniform distribution on the interval from min to max. dunif gives the density and runif generates random deviates. Usage gdunif(x, min = 0, max = 1, log = FALSE, type = "d") grunif(n, min = 0, max = 1, type = "d") Arguments x vector of quantiles. n number of observations min, max lower and upper limits of the distribution log logical; if TRUE, probabilities/densities p are returned as log(p) type specify the type; may be "double", "single" (or short form "d" or "s") Details If min or max are not specified they assume the default values of 0 and 1 respectively. Works very similarly to the R stats functions. Note Random number generation implemented with the cuRAND library. Author(s) Nathan Morris See Also runif Examples myRndNums = grunif(10) gseq gseq 39 Sequence Description Create a sequence on the GPU. Usage gseq(from = 1, to = 1, by = ((to - from)/(length.out - 1)), length.out = NULL, along.with = NULL, type = NULL) Arguments from, to the starting and (maximal) end value of the sequence. by number: increment of the sequence. length.out desired length of the sequence. A non-negative number, which for seq and seq.int will be rounded up if fractional. along.with take the length from the length of this argument type output type (i.e. "double", "single", "integer" or "logical") Value returns a gvector with the specified sequence. In addition the operator %to% mimics the R base oporator :. Author(s) Nathan Morris See Also seq Examples gseq(1,100) 1%to%10 40 gsumby gset.seed Set the seed values, and number of states for the GPU. Description This function enables the user to set a seed value for reproducible random number generation. It also allows the user to set the number of states to tune the efficiency of random number generator for the GPU. Usage gset.seed(seed=unclass(Sys.time()), total_states=as.integer(32*14*16), silent=TRUE) Arguments seed Must be a positive integer. total_states Random numbers are generated from separate streams in parallel with each stream having a current state. This variable must be a positive integer. It is recommended that the integer be a multiple of 32. If the number of states are two small or two large the GPU efficiency may be poor. silent Don’t print any messages besides errors. Author(s) Nathan Morris gsumby Sumby Description Find sub-sums of a gvector Usage gsumby(v, startPos, stopPos) Arguments v a gvector startPos a vector of start positions stopPos a vector of stop positions gsvd-class 41 Details startPos and stopPos must be of the same length. Value returns a gvector object of the same length as startPos and stopPos. Each element is the sum of elements in v. Author(s) Nathan Morris Examples gsumby(g(1:10), c(1,6), c(5,10)) # g(c(15,40)) gsvd-class Class "gsvd" Description Contains the results of an SVD decomposition as returned by the svd method. The SVD method is only available for cuda v7.0 or greater. Objects from the Class Objects should be created by a call to the svd() method on a gmatrix object. The slots of this object are essentually the same as those created by the base svd function. However the VT is the transpose of the v slot in R base. The gmatrix svd function does not allow the user to select the number of singular values. Slots U: Object of class "gmatrix" whose columns contain the left singular vectors. S: Object of class "gvector" containing the singular values. VT: Object of class "gmatrix" whose columns contain the TRANSPOSE of the left singular vectors. Author(s) Nathan Morris See Also svd 42 gvector Examples M=gmatrix(grnorm(25), 5,5,dup=FALSE) mysvd=svd(M) mysvd@U gtest Testing Description This function performs a large number of tests to determine if the package is working properly. Any problems are printed to the screen. It is recomended to be run at least once after installation. Usage gtest() Value TRUE Author(s) Nathan Morris gvector Create a gvector object Description Creates a gvector object of given length and initializes all elements to 0. Usage gvector(length, type = "d") Arguments length length of the object type The type (i.e. "double", "single", "integer" or "logical") Value Returns a gvector object. gvector-class 43 Author(s) Nathan Morris See Also vector gvector-class Class "gvector" Description This object contains a pointer to a vector on a NVIDIA GPU. Objects from the Class Objects should NOT be created by calls of the form new("gmatrix", ...). Instead use the gvector, as.gvector or g functions. Slots ptr: Represents an external pointer to the data on the GPU length: Object of class "integer" representing the number of elements in the vector names: Should be a character vector with length equal nrow type: Must be 0L, 1L, 2L or 3L. These integers represent the types "double", "single", "integer" or "logical" respectively. device: Object of class "integer" representing the device Methods - signature(e1 = "gmatrix", e2 = "gvector"): subtraction operator - signature(e1 = "gvector", e2 = "gmatrix"): subtraction operator - signature(e1 = "gvector", e2 = "gvector"): subtraction operator - signature(e1 = "gvector", e2 = "logical"): subtraction operator - signature(e1 = "gvector", e2 = "matrix"): subtraction operator - signature(e1 = "gvector", e2 = "missing"): subtraction operator - signature(e1 = "gvector", e2 = "numeric"): subtraction operator - signature(e1 = "logical", e2 = "gvector"): subtraction operator - signature(e1 = "matrix", e2 = "gvector"): subtraction operator. - signature(e1 = "numeric", e2 = "gvector"):subtraction operator ! signature(x = "gvector"): not operator != signature(e1 = "gmatrix", e2 = "gvector"): not equal operator 44 gvector-class != signature(e1 = "gvector", e2 = "gmatrix"): not equal operator != signature(e1 = "gvector", e2 = "gvector"): not equal operator != signature(e1 = "gvector", e2 = "logical"): not equal operator != signature(e1 = "gvector", e2 = "matrix"): not equal operator != signature(e1 = "gvector", e2 = "numeric"): not equal operator != signature(e1 = "logical", e2 = "gvector"): not equal operator != signature(e1 = "matrix", e2 = "gvector"): not equal operator != signature(e1 = "numeric", e2 = "gvector"): not equal operator %% signature(e1 = "gmatrix", e2 = "gvector"): mod operator %% signature(e1 = "gvector", e2 = "gmatrix"): mod operator %% signature(e1 = "gvector", e2 = "gvector"): mod operator %% signature(e1 = "gvector", e2 = "logical"): mod operator %% signature(e1 = "gvector", e2 = "matrix"): mod operator %% signature(e1 = "gvector", e2 = "numeric"): mod operator %% signature(e1 = "logical", e2 = "gvector"): mod operator %% signature(e1 = "matrix", e2 = "gvector"): mod operator %% signature(e1 = "numeric", e2 = "gvector"): mod operator %*% signature(x = "gmatrix", y = "gvector"): matrix multiplication operator %*% signature(x = "gvector", y = "gmatrix"): matrix multiplication operator %*% signature(x = "gvector", y = "gvector"): matrix multiplication operator %*% signature(x = "gvector", y = "logical"): matrix multiplication operator %*% signature(x = "gvector", y = "matrix"): matrix multiplication operator %*% signature(x = "gvector", y = "numeric"): matrix multiplication operator %*% signature(x = "logical", y = "gvector"): matrix multiplication operator %*% signature(x = "matrix", y = "gvector"): matrix multiplication operator %*% signature(x = "numeric", y = "gvector"): matrix multiplication operator %o% signature(X = "gvector", Y = "gvector"): outer product %o% signature(X = "gvector", Y = "logical"): outer product %o% signature(X = "gvector", Y = "numeric"): outer product %o% signature(X = "logical", Y = "gvector"): outer product %o% signature(X = "numeric", Y = "gvector"): outer product %x% signature(X = "gmatrix", Y = "gvector"): kronecker product %x% signature(X = "gvector", Y = "gmatrix"): kronecker product. %x% signature(X = "gvector", Y = "gvector"): kronecker product %x% signature(X = "gvector", Y = "numeric"): kronecker product %x% signature(X = "numeric", Y = "gvector"): kronecker product & signature(e1 = "gmatrix", e2 = "gvector"): and operator gvector-class & signature(e1 = "gvector", e2 = "gmatrix"): and operator & signature(e1 = "gvector", e2 = "gvector"): and operator & signature(e1 = "gvector", e2 = "logical"): and operator & signature(e1 = "gvector", e2 = "matrix"): and operator & signature(e1 = "gvector", e2 = "numeric"): and operator & signature(e1 = "logical", e2 = "gvector"): and operator & signature(e1 = "matrix", e2 = "gvector"): and operator & signature(e1 = "numeric", e2 = "gvector"): and operator * signature(e1 = "gmatrix", e2 = "gvector"): elementwise multiplication * signature(e1 = "gvector", e2 = "gmatrix"): elementwise multiplication * signature(e1 = "gvector", e2 = "gvector"): elementwise multiplication * signature(e1 = "gvector", e2 = "logical"): elementwise multiplication * signature(e1 = "gvector", e2 = "matrix"): elementwise multiplication * signature(e1 = "gvector", e2 = "numeric"): elementwise multiplication * signature(e1 = "logical", e2 = "gvector"): elementwise multiplication * signature(e1 = "matrix", e2 = "gvector"): elementwise multiplication * signature(e1 = "numeric", e2 = "gvector"): elementwise multiplication / signature(e1 = "gmatrix", e2 = "gvector"): division operator / signature(e1 = "gvector", e2 = "gmatrix"): division operator / signature(e1 = "gvector", e2 = "gvector"): division operator / signature(e1 = "gvector", e2 = "logical"): division operator / signature(e1 = "gvector", e2 = "matrix"): division operator / signature(e1 = "gvector", e2 = "numeric"): division operator / signature(e1 = "logical", e2 = "gvector"): division operator / signature(e1 = "matrix", e2 = "gvector"): division operator / signature(e1 = "numeric", e2 = "gvector"): division operator [ signature(x = "gmatrix", i = "gvector", j = "gvector"): indexing [ signature(x = "gmatrix", i = "gvector", j = "missing"): indexing [ signature(x = "gmatrix", i = "gvector", j = "numeric"): indexing [ signature(x = "gmatrix", i = "numeric", j = "gvector"): indexing [ signature(x = "gvector", i = "ANY", j = "ANY"): indexing [<- signature(x = "gmatrix", i = "gvector", j = "gvector"): indexing [<- signature(x = "gmatrix", i = "gvector", j = "missing"): indexing [<- signature(x = "gmatrix", i = "gvector", j = "numeric"): indexing [<- signature(x = "gmatrix", i = "numeric", j = "gvector"): indexing [<- signature(x = "gvector", i = "ANY", j = "ANY"): indexing ^ signature(e1 = "gmatrix", e2 = "gvector"): power operator 45 46 gvector-class ^ signature(e1 = "gvector", e2 = "gmatrix"): power operator ^ signature(e1 = "gvector", e2 = "gvector"): power operator ^ signature(e1 = "gvector", e2 = "logical"): power operator ^ signature(e1 = "gvector", e2 = "matrix"): power operator ^ signature(e1 = "gvector", e2 = "numeric"): power operator ^ signature(e1 = "logical", e2 = "gvector"): power operator ^ signature(e1 = "matrix", e2 = "gvector"): power operator ^ signature(e1 = "numeric", e2 = "gvector"): power operator | signature(e1 = "gmatrix", e2 = "gvector"): or operator | signature(e1 = "gvector", e2 = "gmatrix"): or operator | signature(e1 = "gvector", e2 = "gvector"): or operator | signature(e1 = "gvector", e2 = "logical"): or operator | signature(e1 = "gvector", e2 = "matrix"): or operator | signature(e1 = "gvector", e2 = "numeric"): or operator | signature(e1 = "logical", e2 = "gvector"): or operator | signature(e1 = "matrix", e2 = "gvector"): or operator | signature(e1 = "numeric", e2 = "gvector"): or operator + signature(e1 = "gmatrix", e2 = "gvector"): plus operator + signature(e1 = "gvector", e2 = "gmatrix"): plus operator + signature(e1 = "gvector", e2 = "gvector"): plus operator + signature(e1 = "gvector", e2 = "logical"): plus operator + signature(e1 = "gvector", e2 = "matrix"): plus operator + signature(e1 = "gvector", e2 = "missing"): plus operator + signature(e1 = "gvector", e2 = "numeric"): plus operator + signature(e1 = "logical", e2 = "gvector"): plus operator + signature(e1 = "matrix", e2 = "gvector"): plus operator + signature(e1 = "numeric", e2 = "gvector"): plus operator < signature(e1 = "gmatrix", e2 = "gvector"): less than operator < signature(e1 = "gvector", e2 = "gmatrix"): less than operator < signature(e1 = "gvector", e2 = "gvector"): less than operator < signature(e1 = "gvector", e2 = "logical"): less than operator < signature(e1 = "gvector", e2 = "matrix"): less than operator < signature(e1 = "gvector", e2 = "numeric"): less than operator < signature(e1 = "logical", e2 = "gvector"): less than operator < signature(e1 = "matrix", e2 = "gvector"): less than operator < signature(e1 = "numeric", e2 = "gvector"): less than operator <= signature(e1 = "gmatrix", e2 = "gvector"): less than or equal operator gvector-class <= signature(e1 = "gvector", e2 = "gmatrix"): less than or equal operator <= signature(e1 = "gvector", e2 = "gvector"): less than or equal operator <= signature(e1 = "gvector", e2 = "logical"): less than or equal operator <= signature(e1 = "gvector", e2 = "matrix"): less than or equal operator <= signature(e1 = "gvector", e2 = "numeric"): less than or equal operator <= signature(e1 = "logical", e2 = "gvector"): less than or equal operator <= signature(e1 = "matrix", e2 = "gvector"): less than or equal operator <= signature(e1 = "numeric", e2 = "gvector"): less than or equal operator == signature(e1 = "gmatrix", e2 = "gvector"): equal operator == signature(e1 = "gvector", e2 = "gmatrix"): equal operator == signature(e1 = "gvector", e2 = "gvector"): equal operator == signature(e1 = "gvector", e2 = "logical"): equal operator == signature(e1 = "gvector", e2 = "matrix"): equal operator == signature(e1 = "gvector", e2 = "numeric"): equal operator == signature(e1 = "logical", e2 = "gvector"): equal operator == signature(e1 = "matrix", e2 = "gvector"): equal operator == signature(e1 = "numeric", e2 = "gvector"): equal operator > signature(e1 = "gmatrix", e2 = "gvector"): greater than operator > signature(e1 = "gvector", e2 = "gmatrix"): greater than operator > signature(e1 = "gvector", e2 = "gvector"): greater than operator > signature(e1 = "gvector", e2 = "logical"): greater than operator > signature(e1 = "gvector", e2 = "matrix"): greater than operator > signature(e1 = "gvector", e2 = "numeric"): greater than operator > signature(e1 = "logical", e2 = "gvector"): greater than operator > signature(e1 = "matrix", e2 = "gvector"): greater than operator > signature(e1 = "numeric", e2 = "gvector"): greater than operator >= signature(e1 = "gmatrix", e2 = "gvector"): greater than or equal operator >= signature(e1 = "gvector", e2 = "gmatrix"): greater than or equal operator >= signature(e1 = "gvector", e2 = "gvector"): greater than or equal operator >= signature(e1 = "gvector", e2 = "logical"): greater than or equal operator >= signature(e1 = "gvector", e2 = "matrix"): greater than or equal operator >= signature(e1 = "gvector", e2 = "numeric"): greater than or equal operator >= signature(e1 = "logical", e2 = "gvector"): greater than or equal operator >= signature(e1 = "matrix", e2 = "gvector"): greater than or equal operator >= signature(e1 = "numeric", e2 = "gvector"): greater than or equal operator abs signature(x = "gvector"): absolute value acos signature(x = "gvector"): inverse cosine 47 48 gvector-class acosh signature(x = "gvector"): inverse hyperbolic cosine as.gmatrix signature(data = "gvector"):coersion function as.gvector signature(x = "gvector"): coersion function as.integer signature(x = "gvector"): coersion function as.logical signature(x = "gvector"): coersion function as.matrix signature(x = "gvector"): coersion function as.numeric signature(x = "gvector"): coersion function as.vector signature(x = "gvector"): coersion function asin signature(x = "gvector"): inverse sine function asinh signature(x = "gvector"): inverse hyperbolic sine function atan signature(x = "gvector"): inverse tangent function atanh signature(x = "gvector"): inverse hyperbolic tangent function ceiling signature(x = "gvector"): ceiling function cos signature(x = "gvector"): cosine function cosh signature(x = "gvector"): hyperbolic cosine crossprod signature(x = "gmatrix", y = "gvector"): calculates: t(x) %*% y crossprod signature(x = "gvector", y = "gmatrix"): calculates: t(x) %*% y crossprod signature(x = "gvector", y = "gvector"): calculates: t(x) %*% y crossprod signature(x = "gvector", y = "logical"): calculates: t(x) %*% y crossprod signature(x = "gvector", y = "missing"): calculates: t(x) %*% y crossprod signature(x = "gvector", y = "numeric"): calculates: t(x) %*% y crossprod signature(x = "logical", y = "gvector"): calculates: t(x) %*% y crossprod signature(x = "numeric", y = "gvector"): calculates: t(x) %*% y device signature(x = "gvector"): get device device<- signature(x = "gvector"): set device exp signature(x = "gvector"): exponential function expm1 signature(x = "gvector"): computes exp(x) - 1 floor signature(x = "gvector"): floor function gamma signature(x = "gvector"): gamma function ifelse signature(test = "gvector"): conditional selection is.finite signature(x = "gvector"): finite status is.infinite signature(x = "gvector"): infinite status is.na signature(x = "gvector"): missing status is.nan signature(x = "gvector"): not a number status length signature(x = "gvector"): total number of elements in object lgamma signature(x = "gvector"): log gamma function log signature(x = "gvector"): logarithm function gvector-class log10 signature(x = "gvector"): base 10 log log1p signature(x = "gvector"): log(1+x) log2 signature(x = "gvector"): base 2 log max signature(x = "gvector"): maximum of all elements mean signature(x = "gvector"): mean of all elements min signature(x = "gvector"): minimum of all elements names signature(x = "gvector"): get element names names<- signature(x = "gvector"): set element names round signature(x = "gvector"): round to neares integer show signature(object = "gvector"): display object sign signature(x = "gvector"): sign sin signature(x = "gvector"): sine function sinh signature(x = "gvector"): hyperbolic sine function sort signature(x = "gvector"): sort sqrt signature(x = "gvector"): square root sum signature(x = "gvector"): sum of all elements t signature(x = "gvector"): transpose tan signature(x = "gvector"): tangent function tanh signature(x = "gvector"): hyperbolic tangent function tcrossprod signature(x = "gmatrix", y = "gvector"): calculates: tcrossprod signature(x = "gvector", y = "gmatrix"): calculates: tcrossprod signature(x = "gvector", y = "gvector"): calculates: tcrossprod signature(x = "gvector", y = "logical"): calculates: tcrossprod signature(x = "gvector", y = "missing"): calculates: tcrossprod signature(x = "gvector", y = "numeric"): calculates: tcrossprod signature(x = "logical", y = "gvector"): calculates: tcrossprod signature(x = "numeric", y = "gvector"): calculates: type signature(x = "gvector"): get type type<- signature(x = "gvector"): set type which signature(x = "gvector"): index list of TRUE positions Author(s) Nathan Morris See Also gmatrix Examples showClass("gvector") 49 x x x x x x x x %*% %*% %*% %*% %*% %*% %*% %*% t(y) t(y) t(y) t(y) t(y) t(y) t(y) t(y) 50 indexing ifelse Conditional Element Selection Description ifelse returns a value with the same shape as test which is filled with elements selected from either yes or no depending on whether the element of test is TRUE or FALSE. Methods signature(test = "ANY") signature(test = "gmatrix") signature(test = "gvector") indexing Indexing Methods Description These methods are used to perform indexing operations. They work in much the same way as the base R functions. However, if the indexes involve very random numbers, it maybe very difficult for the GPU to coalesce the memory operations. Therefore it may be faster to move the object back to the host befor the indexing operations are performed. Methods signature(x = "gvector", i = "ANY", j = "ANY") signature(x = "ANY", i = "ANY", j = "ANY") signature(x = "gmatrix", i = "index", j = "index") signature(x = "gmatrix", i = "index", j = "missing") signature(x = "gmatrix", i = "missing", j = "index") signature(x = "gmatrix", i = "missing", j = "missing") signature(x = "gvector", i = "ANY", j = "ANY") signature(x = "nonStructure", i = "ANY", j = "ANY") length length 51 Length of an Object Description Get the length of a gvector or gmatrix. Methods signature(x = "gmatrix") returns total number of elements in the matrix. signature(x = "gvector") returns the length of the gvector lpgr-class Class "lpgr" Description Objects of this class must be returned by any " lprf" function which is used by the gBasicHMC() function. Objects from the Class Objects can be created by calls of the form new("lpgr", ...). Slots gr: Object of class "list". Must contain a list of matrices representing the first derivative of the log probility of a distribution with respect to the random variables. Each column of the matrices is for a different parrallel run. All matrices may be either on the gpu or cpu lp: Object of class "numeric". Represent the log probability (without the normalizing constan) of a distribution. MUST be on the CPU. Methods No methods defined with class "lpgr" in the signature. Author(s) Nathan Morris See Also gBasicHMC 52 max matrix multiplication Matrix Multiplication Description Multiply two matrices together. Methods signature(x = "gmatrix", y = "gmatrix") signature(x = "gmatrix", y = "gvector") signature(x = "gmatrix", y = "logical") signature(x = "gmatrix", y = "matrix") signature(x = "gmatrix", y = "numeric") signature(x = "gvector", y = "gmatrix") signature(x = "gvector", y = "gvector") signature(x = "gvector", y = "logical") signature(x = "gvector", y = "matrix") signature(x = "gvector", y = "numeric") signature(x = "logical", y = "gmatrix") signature(x = "logical", y = "gvector") signature(x = "matrix", y = "gmatrix") signature(x = "matrix", y = "gvector") signature(x = "numeric", y = "gmatrix") signature(x = "numeric", y = "gvector") max Maxima and Minima Description Returns the maxima and minima of the input values. The na.rm=TRUE option has NOT been implemented. Methods signature(x = "gmatrix") signature(x = "gvector") mean, sum mean, sum 53 mean and sum methods Description These methods are implement very similarly to the corresponding R base methods. Methods signature(x = "ANY") signature(x = "gmatrix") signature(x = "gvector") names Get and set names Description Gets and sets the names slot of a gvector object. Methods signature(x = "gvector") ncol Mumber of rows/columns Description Get the number of rows/columns of a ’gmatrix.’ Methods signature(x = "ANY") signature(x = "gmatrix") 54 normal normal GPU Normal Distribution Description Density, distribution function, quantile function and random generation for the normal distribution with mean equal to mean and standard deviation equal to sd. All functions performed on the GPU. Usage gdnorm(x, mean = 0, grnorm(n, mean = 0, gqnorm(q, mean = 0, warn = TRUE, gpnorm(p, mean = 0, warn = TRUE, sd = sd = sd = type sd = type 1, log = FALSE, type = "d") 1, type = "d") 1, lower.tail = TRUE, log.p = FALSE, = "d") 1, lower.tail = TRUE, log.p = FALSE, = "d") Arguments x,q vector of quantiles p vector of probabilities n number of observations mean vector of means sd vector of standard deviations log, log.p logical; if TRUE, probabilities p are given as log(p) lower.tail logical; if TRUE (default), probabilities are P[X < x] otherwise, P[X > x]. warn logical; if FALSE then additional warnings are disabled. type specify the type; may be "double", "single" (or short form "d" or "s") Details Very similar to the R stats functionality. However, gqnorm and gpnorm are implement currently in a way that is NOT numerically precise in the deep tails. Future releases may fix this problem. Value gdnorm gives the density, gpnorm gives the distribution function, gqnorm gives the quantile function, and grnorm generates random deviates. Author(s) Nathan Morris See Also dnorm rsample 55 Examples myRndNums1 = grnorm(100) #standard normals myRndNums2 = grnorm(100, mean=c(1,2), sd=c(1,2,4,6)) rsample Sample and integer for each row of a gmatrix object. Description Sample an integer with the unormalized (log) probabilities specified for each row. Usage rsample(P, log=TRUE) Arguments P A matrix conaining unormalizes (log) probabilities in each row. log Specifies if the input is on a log scale. Details Conceptually, each row is first normalized to sum to one, and then an integer is sampled for each row under the specified probablility. Value Returns a gvector with an integer value for each row. Author(s) Nathan Morris See Also gRowLogSums 56 setDevice setDevice Get and set the current device. Description On systems with multiple GPUs the current device may be set or investigated with these functions. Usage setDevice(device,force=FALSE,silent=FALSE,...) getDevice() listDevices() Arguments device Device number to set the device to force Force reset of the tuning parameters even if they have already been set silent Prints a message if TRUE ... Arguments to set the tuning parameters. It’s not a good idea to mess with these at this point. Details All operations are performed on the current GPU device only. An error will be returned if the user attempts to perform an operation on a device that is not the current device. Details of the available devices can be obtained with the ’listDevices’ function. Value setDevice returns TRUE. getDevice returns the current device number. listDevices returns a data.frame with information about the available devices. Author(s) Nathan Morris See Also device, gdup Examples listDevices() getDevice() #setDevice(1) setTuningPameters setTuningPameters 57 Set tuning parameters Description This function tunes the kernal calls to a specific GPU if the user is working with CUDA versions older than 6.5. At this point, these parameters are not well documented and should only be changed by users who can read the source code. Usage setTuningPameters(force = TRUE, threads_per_block = as.integer(2^8), total_states = as.integer(32 * 14 * 16), state = unclass(Sys.time())) Arguments force logical - force the change even if the parameters have been previously set. threads_per_block number of threads per block total_states total states for random number generations state starting state for random number generation Author(s) Nathan Morris show Methods for displaying GPU objects Description These methods may be used to display objects of class gmatrix and ’gvector.’ Methods signature(object = "gmatrix") signature(object = "gvector") 58 type sort Sorting Description Sorts a vector Methods signature(x = "ANY") signature(x = "gvector") t Transpose Description Methods to traspose a gmatrix or gvector. Methods signature(x = "ANY") signature(x = "gmatrix") signature(x = "gvector") type Get or set the type of a GPU object Description These functions may be used to get or set the type of a GPU object. May be used as type(x) type(x)<-value Arguments x A GPU object of class gvector or gmatrix value The type to convert the object to. There are three different ways to specify this. One may use the "double", "single", "integer" or "logical" notation. Alternatively the short form "d", "s", "i" or "s" notation may be used. Finally the internal integer representation of 0L, 1L, 2L or 3L may be used. which 59 Value type(x) returns the type of x type(x)<-value change the type of x Author(s) Nathan Morris See Also convertType Examples x=g(1:4) type(x)="d" #change the type from "integer" to "double" which Which indices are TRUE? Description Give the TRUE indices of a logical gvector. Methods signature(x = "ANY") signature(x = "gvector") Index !,gmatrix-method (elementwise functions), 12 !,gvector-method (elementwise functions), 12 !-methods (elementwise functions), 12 !=,gmatrix,gmatrix-method (elementwise binary operators), 11 !=,gmatrix,gvector-method (elementwise binary operators), 11 !=,gmatrix,logical-method (elementwise binary operators), 11 !=,gmatrix,matrix-method (elementwise binary operators), 11 !=,gmatrix,numeric-method (elementwise binary operators), 11 !=,gvector,gmatrix-method (elementwise binary operators), 11 !=,gvector,gvector-method (elementwise binary operators), 11 !=,gvector,logical-method (elementwise binary operators), 11 !=,gvector,matrix-method (elementwise binary operators), 11 !=,gvector,numeric-method (elementwise binary operators), 11 !=,logical,gmatrix-method (elementwise binary operators), 11 !=,logical,gvector-method (elementwise binary operators), 11 !=,matrix,gmatrix-method (elementwise binary operators), 11 !=,matrix,gvector-method (elementwise binary operators), 11 !=,numeric,gmatrix-method (elementwise binary operators), 11 !=,numeric,gvector-method (elementwise binary operators), 11 !=-methods (elementwise binary operators), 11 ∗Topic GPU gmatrix-package, 3 ∗Topic Garbage ggc, 21 ∗Topic HMC gBasicHMC, 14 ∗Topic MCMC gBasicHMC, 14 ∗Topic NVIDIA gmatrix-package, 3 ∗Topic Normal normal, 54 ∗Topic Trig elementwise functions, 12 ∗Topic beta gdbeta, 16 ∗Topic binomial gdbinom, 17 ∗Topic classes gmatrix-class, 24 gqr-class, 36 gsvd-class, 41 gvector-class, 43 ∗Topic copy gdup, 20 ∗Topic device checkDevice, 6 setDevice, 56 ∗Topic gamma gdgamma, 18 ∗Topic gmatrix gmatrix, 23 ∗Topic methods as.numeric, as.integer, as.logical, as.vector and as.matrix, 5 chol, 6 colMeans, 7 colnames, 7 60 INDEX crossprod,tcrossprod, 8 device, 10 diag, 10 dim, 10 dimnames, 11 elementwise binary operators, 11 elementwise functions, 12 ifelse, 50 indexing, 50 length, 51 matrix multiplication, 52 max, 52 mean, sum, 53 names, 53 ncol, 53 show, 57 sort, 58 t, 58 which, 59 ∗Topic multiplication gmatTimesDiagVec, 32 gmm, 33 ∗Topic names gnamestrip, 34 ∗Topic outer gouter, 35 ∗Topic poisson gdpois, 19 ∗Topic replicate g.rep, 13 ∗Topic transfer g, 12 gident, 22 ∗Topic type convertType, 7 type, 58 ∗Topic uniform grunif, 38 *,gmatrix,gmatrix-method (elementwise binary operators), 11 *,gmatrix,gvector-method (elementwise binary operators), 11 *,gmatrix,logical-method (elementwise binary operators), 11 *,gmatrix,matrix-method (elementwise binary operators), 11 *,gmatrix,numeric-method (elementwise binary operators), 11 61 *,gvector,gmatrix-method (elementwise binary operators), 11 *,gvector,gvector-method (elementwise binary operators), 11 *,gvector,logical-method (elementwise binary operators), 11 *,gvector,matrix-method (elementwise binary operators), 11 *,gvector,numeric-method (elementwise binary operators), 11 *,logical,gmatrix-method (elementwise binary operators), 11 *,logical,gvector-method (elementwise binary operators), 11 *,matrix,gmatrix-method (elementwise binary operators), 11 *,matrix,gvector-method (elementwise binary operators), 11 *,numeric,gmatrix-method (elementwise binary operators), 11 *,numeric,gvector-method (elementwise binary operators), 11 *-methods (elementwise binary operators), 11 +,gmatrix,gmatrix-method (elementwise binary operators), 11 +,gmatrix,gvector-method (elementwise binary operators), 11 +,gmatrix,logical-method (elementwise binary operators), 11 +,gmatrix,matrix-method (elementwise binary operators), 11 +,gmatrix,missing-method (elementwise binary operators), 11 +,gmatrix,numeric-method (elementwise binary operators), 11 +,gvector,gmatrix-method (elementwise binary operators), 11 +,gvector,gvector-method (elementwise binary operators), 11 +,gvector,logical-method (elementwise binary operators), 11 +,gvector,matrix-method (elementwise binary operators), 11 +,gvector,missing-method (elementwise binary operators), 11 +,gvector,numeric-method (elementwise binary operators), 11 62 +,logical,gmatrix-method (elementwise binary operators), 11 +,logical,gvector-method (elementwise binary operators), 11 +,matrix,gmatrix-method (elementwise binary operators), 11 +,matrix,gvector-method (elementwise binary operators), 11 +,numeric,gmatrix-method (elementwise binary operators), 11 +,numeric,gvector-method (elementwise binary operators), 11 +-methods (elementwise binary operators), 11 -,gmatrix,gmatrix-method (elementwise binary operators), 11 -,gmatrix,gvector-method (elementwise binary operators), 11 -,gmatrix,logical-method (elementwise binary operators), 11 -,gmatrix,matrix-method (elementwise binary operators), 11 -,gmatrix,missing-method (elementwise binary operators), 11 -,gmatrix,numeric-method (elementwise binary operators), 11 -,gvector,gmatrix-method (elementwise binary operators), 11 -,gvector,gvector-method (elementwise binary operators), 11 -,gvector,logical-method (elementwise binary operators), 11 -,gvector,matrix-method (elementwise binary operators), 11 -,gvector,missing-method (elementwise binary operators), 11 -,gvector,numeric-method (elementwise binary operators), 11 -,logical,gmatrix-method (elementwise binary operators), 11 -,logical,gvector-method (elementwise binary operators), 11 -,matrix,gmatrix-method (elementwise binary operators), 11 -,matrix,gvector-method (elementwise binary operators), 11 -,numeric,gmatrix-method (elementwise binary operators), 11 INDEX -,numeric,gvector-method (elementwise binary operators), 11 --methods (elementwise binary operators), 11 /,gmatrix,gmatrix-method (elementwise binary operators), 11 /,gmatrix,gvector-method (elementwise binary operators), 11 /,gmatrix,logical-method (elementwise binary operators), 11 /,gmatrix,matrix-method (elementwise binary operators), 11 /,gmatrix,numeric-method (elementwise binary operators), 11 /,gvector,gmatrix-method (elementwise binary operators), 11 /,gvector,gvector-method (elementwise binary operators), 11 /,gvector,logical-method (elementwise binary operators), 11 /,gvector,matrix-method (elementwise binary operators), 11 /,gvector,numeric-method (elementwise binary operators), 11 /,logical,gmatrix-method (elementwise binary operators), 11 /,logical,gvector-method (elementwise binary operators), 11 /,matrix,gmatrix-method (elementwise binary operators), 11 /,matrix,gvector-method (elementwise binary operators), 11 /,numeric,gmatrix-method (elementwise binary operators), 11 /,numeric,gvector-method (elementwise binary operators), 11 /-methods (elementwise binary operators), 11 <,gmatrix,gmatrix-method (elementwise binary operators), 11 <,gmatrix,gvector-method (elementwise binary operators), 11 <,gmatrix,logical-method (elementwise binary operators), 11 <,gmatrix,matrix-method (elementwise binary operators), 11 <,gmatrix,numeric-method (elementwise binary operators), 11 INDEX <,gvector,gmatrix-method (elementwise binary operators), 11 <,gvector,gvector-method (elementwise binary operators), 11 <,gvector,logical-method (elementwise binary operators), 11 <,gvector,matrix-method (elementwise binary operators), 11 <,gvector,numeric-method (elementwise binary operators), 11 <,logical,gmatrix-method (elementwise binary operators), 11 <,logical,gvector-method (elementwise binary operators), 11 <,matrix,gmatrix-method (elementwise binary operators), 11 <,matrix,gvector-method (elementwise binary operators), 11 <,numeric,gmatrix-method (elementwise binary operators), 11 <,numeric,gvector-method (elementwise binary operators), 11 <=,gmatrix,gmatrix-method (elementwise binary operators), 11 <=,gmatrix,gvector-method (elementwise binary operators), 11 <=,gmatrix,logical-method (elementwise binary operators), 11 <=,gmatrix,matrix-method (elementwise binary operators), 11 <=,gmatrix,numeric-method (elementwise binary operators), 11 <=,gvector,gmatrix-method (elementwise binary operators), 11 <=,gvector,gvector-method (elementwise binary operators), 11 <=,gvector,logical-method (elementwise binary operators), 11 <=,gvector,matrix-method (elementwise binary operators), 11 <=,gvector,numeric-method (elementwise binary operators), 11 <=,logical,gmatrix-method (elementwise binary operators), 11 <=,logical,gvector-method (elementwise binary operators), 11 <=,matrix,gmatrix-method (elementwise binary operators), 11 63 <=,matrix,gvector-method (elementwise binary operators), 11 <=,numeric,gmatrix-method (elementwise binary operators), 11 <=,numeric,gvector-method (elementwise binary operators), 11 <=-methods (elementwise binary operators), 11 ==,gmatrix,gmatrix-method (elementwise binary operators), 11 ==,gmatrix,gvector-method (elementwise binary operators), 11 ==,gmatrix,logical-method (elementwise binary operators), 11 ==,gmatrix,matrix-method (elementwise binary operators), 11 ==,gmatrix,numeric-method (elementwise binary operators), 11 ==,gvector,gmatrix-method (elementwise binary operators), 11 ==,gvector,gvector-method (elementwise binary operators), 11 ==,gvector,logical-method (elementwise binary operators), 11 ==,gvector,matrix-method (elementwise binary operators), 11 ==,gvector,numeric-method (elementwise binary operators), 11 ==,logical,gmatrix-method (elementwise binary operators), 11 ==,logical,gvector-method (elementwise binary operators), 11 ==,matrix,gmatrix-method (elementwise binary operators), 11 ==,matrix,gvector-method (elementwise binary operators), 11 ==,numeric,gmatrix-method (elementwise binary operators), 11 ==,numeric,gvector-method (elementwise binary operators), 11 ==-methods (elementwise binary operators), 11 >,gmatrix,gmatrix-method (elementwise binary operators), 11 >,gmatrix,gvector-method (elementwise binary operators), 11 >,gmatrix,logical-method (elementwise binary operators), 11 64 >,gmatrix,matrix-method (elementwise binary operators), 11 >,gmatrix,numeric-method (elementwise binary operators), 11 >,gvector,gmatrix-method (elementwise binary operators), 11 >,gvector,gvector-method (elementwise binary operators), 11 >,gvector,logical-method (elementwise binary operators), 11 >,gvector,matrix-method (elementwise binary operators), 11 >,gvector,numeric-method (elementwise binary operators), 11 >,logical,gmatrix-method (elementwise binary operators), 11 >,logical,gvector-method (elementwise binary operators), 11 >,matrix,gmatrix-method (elementwise binary operators), 11 >,matrix,gvector-method (elementwise binary operators), 11 >,numeric,gmatrix-method (elementwise binary operators), 11 >,numeric,gvector-method (elementwise binary operators), 11 >-methods (elementwise binary operators), 11 >=,gmatrix,gmatrix-method (elementwise binary operators), 11 >=,gmatrix,gvector-method (elementwise binary operators), 11 >=,gmatrix,logical-method (elementwise binary operators), 11 >=,gmatrix,matrix-method (elementwise binary operators), 11 >=,gmatrix,numeric-method (elementwise binary operators), 11 >=,gvector,gmatrix-method (elementwise binary operators), 11 >=,gvector,gvector-method (elementwise binary operators), 11 >=,gvector,logical-method (elementwise binary operators), 11 >=,gvector,matrix-method (elementwise binary operators), 11 >=,gvector,numeric-method (elementwise binary operators), 11 INDEX >=,logical,gmatrix-method (elementwise binary operators), 11 >=,logical,gvector-method (elementwise binary operators), 11 >=,matrix,gmatrix-method (elementwise binary operators), 11 >=,matrix,gvector-method (elementwise binary operators), 11 >=,numeric,gmatrix-method (elementwise binary operators), 11 >=,numeric,gvector-method (elementwise binary operators), 11 >=-methods (elementwise binary operators), 11 [,ANY,ANY,ANY-method (indexing), 50 [,gmatrix,index,index-method (indexing), 50 [,gmatrix,index,missing-method (indexing), 50 [,gmatrix,missing,index-method (indexing), 50 [,gmatrix,missing,missing-method (indexing), 50 [,gvector,ANY,ANY-method (indexing), 50 [,nonStructure,ANY,ANY-method (indexing), 50 [-methods (indexing), 50 [<-,ANY,ANY,ANY-method (indexing), 50 [<-,gmatrix,index,index-method (indexing), 50 [<-,gmatrix,index,missing-method (indexing), 50 [<-,gmatrix,missing,index-method (indexing), 50 [<-,gmatrix,missing,missing-method (indexing), 50 [<-,gvector,ANY,ANY-method (indexing), 50 [<--methods (indexing), 50 %*%,gmatrix,gmatrix-method (matrix multiplication), 52 %*%,gmatrix,gvector-method (matrix multiplication), 52 %*%,gmatrix,logical-method (matrix multiplication), 52 %*%,gmatrix,matrix-method (matrix multiplication), 52 %*%,gmatrix,numeric-method (matrix INDEX multiplication), 52 %*%,gvector,gmatrix-method (matrix multiplication), 52 %*%,gvector,gvector-method (matrix multiplication), 52 %*%,gvector,logical-method (matrix multiplication), 52 %*%,gvector,matrix-method (matrix multiplication), 52 %*%,gvector,numeric-method (matrix multiplication), 52 %*%,logical,gmatrix-method (matrix multiplication), 52 %*%,logical,gvector-method (matrix multiplication), 52 %*%,matrix,gmatrix-method (matrix multiplication), 52 %*%,matrix,gvector-method (matrix multiplication), 52 %*%,numeric,gmatrix-method (matrix multiplication), 52 %*%,numeric,gvector-method (matrix multiplication), 52 %*%-methods (matrix multiplication), 52 %%,gmatrix,gmatrix-method (elementwise binary operators), 11 %%,gmatrix,gvector-method (elementwise binary operators), 11 %%,gmatrix,logical-method (elementwise binary operators), 11 %%,gmatrix,matrix-method (elementwise binary operators), 11 %%,gmatrix,numeric-method (elementwise binary operators), 11 %%,gvector,gmatrix-method (elementwise binary operators), 11 %%,gvector,gvector-method (elementwise binary operators), 11 %%,gvector,logical-method (elementwise binary operators), 11 %%,gvector,matrix-method (elementwise binary operators), 11 %%,gvector,numeric-method (elementwise binary operators), 11 %%,logical,gmatrix-method (elementwise binary operators), 11 %%,logical,gvector-method (elementwise binary operators), 11 65 %%,matrix,gmatrix-method (elementwise binary operators), 11 %%,matrix,gvector-method (elementwise binary operators), 11 %%,numeric,gmatrix-method (elementwise binary operators), 11 %%,numeric,gvector-method (elementwise binary operators), 11 %%-methods (elementwise binary operators), 11 %lgspadd% (elementwise binary operators), 11 %lgspadd%,gmatrix,gmatrix-method (elementwise binary operators), 11 %lgspadd%,gmatrix,gvector-method (elementwise binary operators), 11 %lgspadd%,gmatrix,logical-method (elementwise binary operators), 11 %lgspadd%,gmatrix,matrix-method (elementwise binary operators), 11 %lgspadd%,gmatrix,numeric-method (elementwise binary operators), 11 %lgspadd%,gvector,gmatrix-method (elementwise binary operators), 11 %lgspadd%,gvector,gvector-method (elementwise binary operators), 11 %lgspadd%,gvector,logical-method (elementwise binary operators), 11 %lgspadd%,gvector,matrix-method (elementwise binary operators), 11 %lgspadd%,gvector,numeric-method (elementwise binary operators), 11 %lgspadd%,logical,gmatrix-method (elementwise binary operators), 11 %lgspadd%,logical,gvector-method (elementwise binary operators), 11 66 %lgspadd%,matrix,gmatrix-method (elementwise binary operators), 11 %lgspadd%,matrix,gvector-method (elementwise binary operators), 11 %lgspadd%,numeric,gmatrix-method (elementwise binary operators), 11 %lgspadd%,numeric,gvector-method (elementwise binary operators), 11 %lgspadd%-methods (elementwise binary operators), 11 %o% (gouter), 35 %o%,ANY,ANY-method (gouter), 35 %o%,gvector,gvector-method (gouter), 35 %o%,gvector,logical-method (gouter), 35 %o%,gvector,numeric-method (gouter), 35 %o%,logical,gvector-method (gouter), 35 %o%,numeric,gvector-method (gouter), 35 %o%-methods (gouter), 35 %to% (gseq), 39 %to%,numeric,numeric-method (gseq), 39 %x%,ANY,ANY-method (gkroneckerProd), 23 %x%,gmatrix,gmatrix-method (gkroneckerProd), 23 %x%,gmatrix,gvector-method (gkroneckerProd), 23 %x%,gmatrix,matrix-method (gkroneckerProd), 23 %x%,gmatrix,numeric-method (gkroneckerProd), 23 %x%,gvector,gmatrix-method (gkroneckerProd), 23 %x%,gvector,gvector-method (gkroneckerProd), 23 %x%,gvector,matrix-method (gkroneckerProd), 23 %x%,gvector,numeric-method (gkroneckerProd), 23 %x%,matrix,gmatrix-method (gkroneckerProd), 23 %x%,matrix,gvector-method (gkroneckerProd), 23 %x%,numeric,gmatrix-method (gkroneckerProd), 23 %x%,numeric,gvector-method INDEX (gkroneckerProd), 23 %x%-methods (gkroneckerProd), 23 &,gmatrix,gmatrix-method (elementwise binary operators), 11 &,gmatrix,gvector-method (elementwise binary operators), 11 &,gmatrix,logical-method (elementwise binary operators), 11 &,gmatrix,matrix-method (elementwise binary operators), 11 &,gmatrix,numeric-method (elementwise binary operators), 11 &,gvector,gmatrix-method (elementwise binary operators), 11 &,gvector,gvector-method (elementwise binary operators), 11 &,gvector,logical-method (elementwise binary operators), 11 &,gvector,matrix-method (elementwise binary operators), 11 &,gvector,numeric-method (elementwise binary operators), 11 &,logical,gmatrix-method (elementwise binary operators), 11 &,logical,gvector-method (elementwise binary operators), 11 &,matrix,gmatrix-method (elementwise binary operators), 11 &,matrix,gvector-method (elementwise binary operators), 11 &,numeric,gmatrix-method (elementwise binary operators), 11 &,numeric,gvector-method (elementwise binary operators), 11 &-methods (elementwise binary operators), 11 %o%, 36 ^,gmatrix,gmatrix-method (elementwise binary operators), 11 ^,gmatrix,gvector-method (elementwise binary operators), 11 ^,gmatrix,logical-method (elementwise binary operators), 11 ^,gmatrix,matrix-method (elementwise binary operators), 11 ^,gmatrix,numeric-method (elementwise binary operators), 11 ^,gvector,gmatrix-method (elementwise INDEX binary operators), 11 ^,gvector,gvector-method (elementwise binary operators), 11 ^,gvector,logical-method (elementwise binary operators), 11 ^,gvector,matrix-method (elementwise binary operators), 11 ^,gvector,numeric-method (elementwise binary operators), 11 ^,logical,gmatrix-method (elementwise binary operators), 11 ^,logical,gvector-method (elementwise binary operators), 11 ^,matrix,gmatrix-method (elementwise binary operators), 11 ^,matrix,gvector-method (elementwise binary operators), 11 ^,numeric,gmatrix-method (elementwise binary operators), 11 ^,numeric,gvector-method (elementwise binary operators), 11 ^-methods (elementwise binary operators), 11 abs,gmatrix-method (elementwise functions), 12 abs,gvector-method (elementwise functions), 12 abs-methods (elementwise functions), 12 acos,gmatrix-method (elementwise functions), 12 acos,gvector-method (elementwise functions), 12 acos-methods (elementwise functions), 12 acosh,gmatrix-method (elementwise functions), 12 acosh,gvector-method (elementwise functions), 12 acosh-methods (elementwise functions), 12 as.gmatrix, 13, 22 as.gmatrix (as.gmatrix, as.gvector), 4 as.gmatrix, as.gvector, 4 as.gmatrix,ANY-method (as.gmatrix, as.gvector), 4 as.gmatrix,gmatrix-method (as.gmatrix, as.gvector), 4 as.gmatrix,gvector-method (as.gmatrix, as.gvector), 4 67 as.gmatrix,matrix-method (as.gmatrix, as.gvector), 4 as.gmatrix-methods (as.gmatrix, as.gvector), 4 as.gvector (as.gmatrix, as.gvector), 4 as.gvector,ANY-method (as.gmatrix, as.gvector), 4 as.gvector,gmatrix-method (as.gmatrix, as.gvector), 4 as.gvector,gvector-method (as.gmatrix, as.gvector), 4 as.gvector-methods (as.gmatrix, as.gvector), 4 as.integer,gmatrix-method (as.numeric, as.integer, as.logical, as.vector and as.matrix), 5 as.integer,gvector-method (as.numeric, as.integer, as.logical, as.vector and as.matrix), 5 as.integer-methods (as.numeric, as.integer, as.logical, as.vector and as.matrix), 5 as.logical,gmatrix-method (as.numeric, as.integer, as.logical, as.vector and as.matrix), 5 as.logical,gvector-method (as.numeric, as.integer, as.logical, as.vector and as.matrix), 5 as.logical-methods (as.numeric, as.integer, as.logical, as.vector and as.matrix), 5 as.matrix,ANY-method (as.numeric, as.integer, as.logical, as.vector and as.matrix), 5 as.matrix,gmatrix-method (as.numeric, as.integer, as.logical, as.vector and as.matrix), 5 as.matrix,gvector-method (as.numeric, as.integer, as.logical, as.vector and as.matrix), 5 as.matrix-methods (as.numeric, as.integer, as.logical, as.vector and as.matrix), 5 as.matrix.gmatrix (as.numeric, as.integer, as.logical, as.vector and as.matrix), 5 as.matrix.gvector (as.numeric, as.integer, as.logical, 68 as.vector and as.matrix), 5 as.numeric, 13, 22 as.numeric, as.integer, as.logical, as.vector and as.matrix, 5 as.numeric,gmatrix-method (as.numeric, as.integer, as.logical, as.vector and as.matrix), 5 as.numeric,gvector-method (as.numeric, as.integer, as.logical, as.vector and as.matrix), 5 as.numeric-methods (as.numeric, as.integer, as.logical, as.vector and as.matrix), 5 as.vector,ANY-method (as.numeric, as.integer, as.logical, as.vector and as.matrix), 5 as.vector,gmatrix-method (as.numeric, as.integer, as.logical, as.vector and as.matrix), 5 as.vector,gvector-method (as.numeric, as.integer, as.logical, as.vector and as.matrix), 5 as.vector-methods (as.numeric, as.integer, as.logical, as.vector and as.matrix), 5 as.vector.gmatrix (as.numeric, as.integer, as.logical, as.vector and as.matrix), 5 as.vector.gvector (as.numeric, as.integer, as.logical, as.vector and as.matrix), 5 asin,gmatrix-method (elementwise functions), 12 asin,gvector-method (elementwise functions), 12 asin-methods (elementwise functions), 12 asinh,gmatrix-method (elementwise functions), 12 asinh,gvector-method (elementwise functions), 12 asinh-methods (elementwise functions), 12 atan,gmatrix-method (elementwise functions), 12 atan,gvector-method (elementwise functions), 12 atan-methods (elementwise functions), 12 atanh,gmatrix-method (elementwise INDEX functions), 12 atanh,gvector-method (elementwise functions), 12 atanh-methods (elementwise functions), 12 ceiling,gmatrix-method (elementwise functions), 12 ceiling,gvector-method (elementwise functions), 12 ceiling-methods (elementwise functions), 12 checkDevice, 6 chol, 6 chol,ANY-method (chol), 6 chol,gmatrix-method (chol), 6 chol-methods (chol), 6 colMeans, 7 colMeans,ANY-method (colMeans), 7 colMeans,gmatrix-method (colMeans), 7 colMeans-methods (colMeans), 7 colnames, 7, 11, 34 colnames,ANY-method (colnames), 7 colnames,gmatrix-method (colnames), 7 colnames-methods (colnames), 7 colnames<-,ANY-method (colnames), 7 colnames<-,gmatrix-method (colnames), 7 colnames<--methods (colnames), 7 colSums,ANY-method (colMeans), 7 colSums,gmatrix-method (colMeans), 7 colSums-methods (colMeans), 7 convertType, 7, 59 cos,gmatrix-method (elementwise functions), 12 cos,gvector-method (elementwise functions), 12 cos-methods (elementwise functions), 12 cosh,gmatrix-method (elementwise functions), 12 cosh,gvector-method (elementwise functions), 12 cosh-methods (elementwise functions), 12 crossprod,ANY,ANY-method (crossprod,tcrossprod), 8 crossprod,gmatrix,gmatrix-method (crossprod,tcrossprod), 8 crossprod,gmatrix,gvector-method (crossprod,tcrossprod), 8 INDEX crossprod,gmatrix,logical-method (crossprod,tcrossprod), 8 crossprod,gmatrix,matrix-method (crossprod,tcrossprod), 8 crossprod,gmatrix,missing-method (crossprod,tcrossprod), 8 crossprod,gmatrix,numeric-method (crossprod,tcrossprod), 8 crossprod,gvector,gmatrix-method (crossprod,tcrossprod), 8 crossprod,gvector,gvector-method (crossprod,tcrossprod), 8 crossprod,gvector,logical-method (crossprod,tcrossprod), 8 crossprod,gvector,matrix-method (crossprod,tcrossprod), 8 crossprod,gvector,missing-method (crossprod,tcrossprod), 8 crossprod,gvector,numeric-method (crossprod,tcrossprod), 8 crossprod,logical,gmatrix-method (crossprod,tcrossprod), 8 crossprod,logical,gvector-method (crossprod,tcrossprod), 8 crossprod,matrix,gmatrix-method (crossprod,tcrossprod), 8 crossprod,matrix,gvector-method (crossprod,tcrossprod), 8 crossprod,numeric,gmatrix-method (crossprod,tcrossprod), 8 crossprod,numeric,gvector-method (crossprod,tcrossprod), 8 crossprod,tcrossprod, 8 crossprod-methods (crossprod,tcrossprod), 8 dbeta, 17 dbinom, 18 device, 6, 10, 21, 56 device,gmatrix-method (device), 10 device,gvector-method (device), 10 device-methods (device), 10 device<- (device), 10 device<-,gmatrix-method (device), 10 device<-,gvector-method (device), 10 device<--methods (device), 10 dgamma, 19 diag, 10, 32 diag,ANY-method (diag), 10 69 diag,gmatrix-method (diag), 10 diag,gvector-method (diag), 10 diag-methods (diag), 10 diag<-,ANY-method (diag), 10 diag<-,gmatrix-method (diag), 10 diag<--methods (diag), 10 dim, 10, 10 dim,gmatrix-method (dim), 10 dim-methods (dim), 10 dim<-,gmatrix-method (dim), 10 dim<--methods (dim), 10 dimnames, 11, 11, 34 dimnames,gmatrix-method (dimnames), 11 dimnames-methods (dimnames), 11 dimnames<-,gmatrix-method (dimnames), 11 dimnames<--methods (dimnames), 11 dnorm, 54 dpois, 20 elementwise binary operators, 11 elementwise functions, 12 exp,gmatrix-method (elementwise functions), 12 exp,gvector-method (elementwise functions), 12 exp-methods (elementwise functions), 12 expm1,gmatrix-method (elementwise functions), 12 expm1,gvector-method (elementwise functions), 12 expm1-methods (elementwise functions), 12 floor,gmatrix-method (elementwise functions), 12 floor,gvector-method (elementwise functions), 12 floor-methods (elementwise functions), 12 g, 4, 5, 12 g.rep, 13 gamma,gmatrix-method (elementwise functions), 12 gamma,gvector-method (elementwise functions), 12 gamma-methods (elementwise functions), 12 gBasicHMC, 14, 51 70 gc, 22 gdbeta, 16 gdbinom, 17 gdgamma, 18 gdnorm (normal), 54 gdpois, 19 gdunif (grunif), 38 gdup, 10, 20, 56 getDevice, 6 getDevice (setDevice), 56 ggc, 21 gident, 22 gkroneckerProd, 23 gmatrix, 5, 23, 49 gmatrix-class, 24 gmatrix-package, 3 gmatTimesDiagVec, 32 gmm, 33 gnamestrip, 34 gorder, 34 gouter, 35 gpnorm (normal), 54 gqnorm (normal), 54 gqr-class, 36 gqr.coef (gqr-class), 36 gqr.coef,ANY-method (gqr-class), 36 gqr.coef,gqr-method (gqr-class), 36 gqr.coef-methods (gqr-class), 36 grbeta (gdbeta), 16 grbinom (gdbinom), 17 grgamma (gdgamma), 18 grnorm (normal), 54 gRowLogSums, 37, 55 grpois (gdpois), 19 grunif, 38 gseq, 39 gset.seed, 40 gsumby, 40 gsvd-class, 41 gtest, 42 gvector, 5, 31, 42 gvector-class, 43 h, 4, 6 h (g), 12 ifelse, 50 ifelse,ANY-method (ifelse), 50 ifelse,gmatrix-method (ifelse), 50 INDEX ifelse,gvector-method (ifelse), 50 ifelse-methods (ifelse), 50 indexing, 50 is.finite,gmatrix-method (elementwise functions), 12 is.finite,gvector-method (elementwise functions), 12 is.finite-methods (elementwise functions), 12 is.infinite,gmatrix-method (elementwise functions), 12 is.infinite,gvector-method (elementwise functions), 12 is.infinite-methods (elementwise functions), 12 is.na,gmatrix-method (elementwise functions), 12 is.na,gvector-method (elementwise functions), 12 is.na-methods (elementwise functions), 12 is.nan,gmatrix-method (elementwise functions), 12 is.nan,gvector-method (elementwise functions), 12 is.nan-methods (elementwise functions), 12 keep (gBasicHMC), 14 length, 51 length,gmatrix-method (length), 51 length,gvector-method (length), 51 length-methods (length), 51 lgamma,gmatrix-method (elementwise functions), 12 lgamma,gvector-method (elementwise functions), 12 lgamma-methods (elementwise functions), 12 listDevices (setDevice), 56 log,gmatrix-method (elementwise functions), 12 log,gvector-method (elementwise functions), 12 log-methods (elementwise functions), 12 log10,gmatrix-method (elementwise functions), 12 INDEX log10,gvector-method (elementwise functions), 12 log10-methods (elementwise functions), 12 log1p,gmatrix-method (elementwise functions), 12 log1p,gvector-method (elementwise functions), 12 log1p-methods (elementwise functions), 12 log2,gmatrix-method (elementwise functions), 12 log2,gvector-method (elementwise functions), 12 log2-methods (elementwise functions), 12 lpgr-class, 16, 51 matrix, 24 matrix multiplication, 52 max, 52 max,gmatrix-method (max), 52 max,gvector-method (max), 52 max-methods (max), 52 mean, sum, 53 mean,ANY-method (mean, sum), 53 mean,gmatrix-method (mean, sum), 53 mean,gvector-method (mean, sum), 53 mean-methods (mean, sum), 53 min,gmatrix-method (max), 52 min,gvector-method (max), 52 min-methods (max), 52 names, 34, 53 names,gvector-method (names), 53 names-methods (names), 53 names<-,gvector-method (names), 53 names<--methods (names), 53 ncol, 53 ncol,ANY-method (ncol), 53 ncol,gmatrix-method (ncol), 53 ncol-methods (ncol), 53 normal, 54 nrow,ANY-method (ncol), 53 nrow,gmatrix-method (ncol), 53 nrow-methods (ncol), 53 order, 35 outer, 36 qr, 37 71 qr,ANY-method (gqr-class), 36 qr,gmatrix-method (gqr-class), 36 qr-methods (gqr-class), 36 qr.coef, 36, 37 rep, 14 round,gmatrix-method (elementwise functions), 12 round,gvector-method (elementwise functions), 12 round-methods (elementwise functions), 12 rowMeans,ANY-method (colMeans), 7 rowMeans,gmatrix-method (colMeans), 7 rowMeans-methods (colMeans), 7 rownames, 7 rownames,ANY-method (colnames), 7 rownames,gmatrix-method (colnames), 7 rownames-methods (colnames), 7 rownames<-,ANY-method (colnames), 7 rownames<-,gmatrix-method (colnames), 7 rownames<--methods (colnames), 7 rowSums, 7 rowSums,ANY-method (colMeans), 7 rowSums,gmatrix-method (colMeans), 7 rowSums-methods (colMeans), 7 rsample, 55 runif, 38 seq, 39 setDevice, 6, 10, 56 setTuningPameters, 57 show, 57 show,gmatrix-method (show), 57 show,gvector-method (show), 57 show-methods (show), 57 sign,gmatrix-method (elementwise functions), 12 sign,gvector-method (elementwise functions), 12 sign-methods (elementwise functions), 12 sin,gmatrix-method (elementwise functions), 12 sin,gvector-method (elementwise functions), 12 sin-methods (elementwise functions), 12 sinh,gmatrix-method (elementwise functions), 12 72 sinh,gvector-method (elementwise functions), 12 sinh-methods (elementwise functions), 12 solve, 37 solve (gqr-class), 36 solve,ANY-method (gqr-class), 36 solve,gmatrix-method (gqr-class), 36 solve,gqr-method (gqr-class), 36 solve-methods (gqr-class), 36 solve.qr, 36, 37 sort, 58 sort,ANY-method (sort), 58 sort,gvector-method (sort), 58 sort,jarrayRef-method (sort), 58 sort,jrectRef-method (sort), 58 sort-methods (sort), 58 sqrt,gmatrix-method (elementwise functions), 12 sqrt,gvector-method (elementwise functions), 12 sqrt-methods (elementwise functions), 12 sum,gmatrix-method (mean, sum), 53 sum,gvector-method (mean, sum), 53 sum-methods (mean, sum), 53 svd, 41 svd (gsvd-class), 41 svd,ANY-method (gsvd-class), 41 svd,gmatrix-method (gsvd-class), 41 svd-methods (gsvd-class), 41 t, 58 t,ANY-method (t), 58 t,gmatrix-method (t), 58 t,gvector-method (t), 58 t-methods (t), 58 t.gmatrix (t), 58 t.gvector (t), 58 tan,gmatrix-method (elementwise functions), 12 tan,gvector-method (elementwise functions), 12 tan-methods (elementwise functions), 12 tanh,gmatrix-method (elementwise functions), 12 tanh,gvector-method (elementwise functions), 12 tanh-methods (elementwise functions), 12 tcrossprod,ANY,ANY-method (crossprod,tcrossprod), 8 INDEX tcrossprod,gmatrix,gmatrix-method (crossprod,tcrossprod), 8 tcrossprod,gmatrix,gvector-method (crossprod,tcrossprod), 8 tcrossprod,gmatrix,logical-method (crossprod,tcrossprod), 8 tcrossprod,gmatrix,matrix-method (crossprod,tcrossprod), 8 tcrossprod,gmatrix,missing-method (crossprod,tcrossprod), 8 tcrossprod,gmatrix,numeric-method (crossprod,tcrossprod), 8 tcrossprod,gvector,gmatrix-method (crossprod,tcrossprod), 8 tcrossprod,gvector,gvector-method (crossprod,tcrossprod), 8 tcrossprod,gvector,logical-method (crossprod,tcrossprod), 8 tcrossprod,gvector,matrix-method (crossprod,tcrossprod), 8 tcrossprod,gvector,missing-method (crossprod,tcrossprod), 8 tcrossprod,gvector,numeric-method (crossprod,tcrossprod), 8 tcrossprod,logical,gmatrix-method (crossprod,tcrossprod), 8 tcrossprod,logical,gvector-method (crossprod,tcrossprod), 8 tcrossprod,matrix,gmatrix-method (crossprod,tcrossprod), 8 tcrossprod,matrix,gvector-method (crossprod,tcrossprod), 8 tcrossprod,numeric,gmatrix-method (crossprod,tcrossprod), 8 tcrossprod,numeric,gvector-method (crossprod,tcrossprod), 8 tcrossprod-methods (crossprod,tcrossprod), 8 type, 8, 58 type,gmatrix-method (type), 58 type,gvector-method (type), 58 type-methods (type), 58 type<- (type), 58 type<-,gmatrix-method (type), 58 type<-,gvector-method (type), 58 type<--methods (type), 58 vector, 43 INDEX which, 59 which,ANY-method (which), 59 which,gvector-method (which), 59 which-methods (which), 59 73