Learn R Programming

gputools (version 0.1-1)

gpuSolve: Estimate the solution to a matrix vector equation

Description

This function estimates the solution to an equation of the form x * b = y where x is a matrix, b is an unkown vector, and y is a known vector. It does much calculation on a GPU.

Usage

gpuSolve(x, y)

Arguments

x
a matrix of floating point numbers.
y
a vector of floating point numbers of length nrow(x).

Value

  • a vector of floating point numbers of length ncol(x) which is an estimate of the b from x * b = y.

References

Bjorck, Ake (1996) Numerical methods for least squares problems. SIAM.

Examples

Run this code
# get some random data of any shape at all
	x <- matrix(runif(1000), 50, 20)
	y <- runif(50)
	b <- gpuSolve(x, y)
	cat("Solution:
")
	print(b)
	cat("x * b
")
	print(x %*% b)
	cat("original y
")
	print(y)

Run the code above in your browser using DataLab