
12.7. SOLVING SYSTEMS OF LINEAR EQUATIONS 271
reduces the problem to one of matrix multiplication, and thus we can par-
allelize the Jacobi algorithm by utilizing a method for doing parallel matrix
multiplication.
12.7.3 Example: R/gputools Implementation of Ja-
cobi
Here’s the R code, using gputools:
jc b <− function ( a , b , eps ) {
n <− length ( b )
d <− diag ( a ) # a ve c t o r , not a m atrix
tmp <− diag ( d ) # a matrix , not a v e c t o r
o <− a − diag ( d )
di <− 1/d
x <− b # i n i t i a l guess , co u l d be b e t t e r
repeat {
oldx <− x
tmp <− gpuMatMult ( o , x )
tmp <− b − tmp
x <− di ∗ tmp # e l e m e ntwise m u l t i p l i c a t i o n
i f (s