Tutorial for Matrix and Vector Operations

This tutorial shows how to use matrices and vectors within NetSolve by developing a little program which either invokes a custom function to perform the multiplication or uses the BLAS routine dgemm. This includes the following steps:

  1. Building the library

  2. Installing the problem and adding BLAS to the NetSolve repository

  3. Invoking the function via NetSolve

Requirements, the following files are needed (they should be in the current directory):


1. Building the Library NetSolve provides all functions through statically linked libraries. Execute the following steps on the server to build libmatmul.a
UNIX> gcc -c libmatmul.c
UNIX> ar rc libmatmul.a libmatmul.o

2. Installing the Problem and Adding BLAS to the NetSolve Repository

To invoke a new function from the NetSolve client you have to add the function to the problems list in a NetSolve server and recompile the server. Perform the following steps to include 'matmul':

To include the function 'dgemm' provided by the BLAS package you only have to uncomment the line
In the file $NETSOLVE_ROOT/server_config. NetSolve provides a subset of the BLAS package in the NetSolve directory; $NETSOLVE_ROOT/src/SampleNumericalSoftware/BLAS.


NetSolve also provides a subset of LaPack. If you want to include the complete LaPack uncomment:
In $NETSOLVE_ROOT/server_config and rerun configure with the following additional options;
--with-blaslib=/path/to/libblas.a --with-lapack-lib=/path/to/liblapack.a


All these steps have to be performed at the machine where your server is running. Also make sure to kill the server if it is currently running.

3. Invoking the Function Via NetSolve

The file myprog.c demonstrates how to invoke the function calc via NetSolve in C. When you compile it you have to provide the include and library directory of NetSolve. If you have set the NETSOLVE_ROOT environment variable to your NetSolve directory and running this tutorial on x86 under Linux the command would be:
UNIX> gcc myprog.c -o myprog -I$NETSOLVE_ROOT/include -lnetsolve \

Invoking myprog uses 3 arguments:


Be sure to have an agent and your newly compiled server running. Also check that the NETSOLVE_AGENT enironment variable is set on your client (it should be the same value as the @AGENT: line in server_config in the NETSOLVE_ROOT directory).