Tutorial for Sparse Matrices

This tutorial shows how to use sparse matrices. It also demonstrates how to include an existing application into NetSolve. The application to be used is called Pebbles and provides a solver for large sparse linear systems. It was developed at the University of Linz, Austria and you have to obtain a copy of this software. But even if you don't have Pebbles you should be able after reading through this tutorial to handle sparse matrices within NetSolve. The tutorial includes the following steps:

  1. Building and configuring the library

  2. Installing the problem to the NetSolve repository

  3. Testing the software from C and Matlab

Requirements on each server:

Requirements on the client:

Instructions

1. Building the Library

First install and compile Pebbles as described in the documentation. Then copy the file outback.cc to your /pebbles/libsrc/prepro directory. Next, replace the file pebbles/pebbles/extern.hh with the version of extern.hh provided here. In the following it is assumed that Pebbles is installed in ~/pebbles, i.e., the statically linked libraries after compiling Pebbles should be in ~/pebbles/lib/$MACHINE/

Build libpebbles.a within the Pebbles source tree
UNIX> cp interface.cc ~/pebbles/pebbles; cd ~/pebbles/pebbles
UNIX> c++ -c -fpic -o interface.o -I$HOME/pebbles/libsrc  \
    -DFORTRANDOUBLEUNDERSCORE -w interface.cc
UNIX> mkdir ~/pebbles/libpebbles
UNIX> cp ~/pebbles/libsrc/*/*.o ~/pebbles/libpebbles
UNIX> cp ~/pebbles/pebbles/interface.o ~/pebbles/libpebbles
UNIX> cd ~/pebbles/libpebbles; ar rc libpebbles.a *.o

You should now have a file ~/pebbles/libpebbles/libpebbles.a

NOTES:

2. Installing the Problem to the NetSolve Repository

Use idltopdf to convert pebbles.idl to pebbles.pdf and add the function to the problems list in the file $NETSOLVE_ROOT/server_config. Set NSPEBBLES_LIB to $HOME/pebbles/libpebbles and recompile the server with the command
UNIX> make server

3. Testing the Software from C and Matlab The file test_pebbles.c, demonstrates how to invoke the newly created function pebbles via NetSolve. Compile it with with the following command:
UNIX> gcc test_pebbles.c -o test_pebbles -I$NETSOLVE_ROOT/include -lnetsolve \
      -L$NETSOLVE_ROOT/lib/$NETSOLVE_ARCH
Running
UNIX> ./test_pebbles
Should give the following output:
Initializing NetSolve...
Initializing NetSolve Complete
Sending Input to Server visitor1.cs.utk.edu
Downloading Output from Server visitor1.cs.utk.edu
+++ PEBBLES started
size: 4
nnz:  4
maxrowsize: 1
$$$ setup phase
$$$ solution phase
$$$ writting the solution
+++ PEBBLES finished
Solution:
--> 1.000000
--> 0.500000
--> 0.333333
--> 0.250000

In Matlab run the follwing commnds (assuming you have compiled the Matlab libraries with "make matlab"):
MATLAB>> addpath /path/to/$NETSOLVE_ROOT/bin/$NETSOLVE_ARCH
(e.g., /home/user/NetSolve/bin/i686_pc_linux_gnu)
MATLAB>> x=netsolve('pebbles',A,b,x,'EPS_PCG=1e-6;SOLVE=1;ELEMENT_PRECOND=0');
(with A a positive definite sparse matrix, b the right hand side vector and x the solution vector)