GraphLab: Distributed Graph-Parallel API
2.1
|
GraphLab linear solver library is used for solving the linear system Ax = b.
The Jacobi algorithm is one of the simplest methods, it works by applying repeatedly the update rule:
x = (b-(A-diag(diag(A))*x) ./ diag(A)
The input folder is given using the command line –matrix=folder_name. Inside this folder should have a sparse matrix A file with the format, in each line.
row col val
Additional input vector b is given using the command –input_vector=filename, this file should be found inside the folder given by –matrix.
The output of the computation is a solution vector x. File name is x.out_1_of_1.
Assume we have the linear system
A=[ 1.8147 0.9134 0.2785 0.9058 1.6324 0.5469 0.1270 0.0975 1.9575 ]; b= [ 0.9649 0.1576 0.9706 ]';
The solution will be
x = A \ b = [ 0.6803 -0.4396 0.4736 ]';
To run it in GraphLab we preper a folder named jacobi_testA, inside it we have the input file for A named A:
1 1 1.8147 1 2 0.9134 1 3 0.2785 2 1 0.9058 2 2 1.6324 2 3 0.5469 3 1 0.127 3 2 0.0975 3 3 1.9575
And the input file for b (called vecB)
0.9649 0.1576 0.9706
Note: both A and vecB files are found under jacobi_testA/ folder.
Now we run:
./jacobi --matrix=jacobi_testA/ --initial_vec=vecB --rows=3 --cols=3 --debug=1 --max_iter=10 Running Jacobi (C) Code by Danny Bickson, CMU Please send bug reports to [email protected] Solution converged to residual: 0.00507232 ---------------------------------------------------------- Final Runtime (seconds): 0.649031 Updates executed: 33 Update Rate (updates/second): 50.845
We examine the output:
$ cat x.out_1_of_1 1 0.67806771486642969 2 -0.43984914015767995 3 0.47337333903573475