This tutorial demonstrates how to use example codes in the wn_sparse_solve distribution examples/ directory.

Example 1: Solve a sparse matrix equation without preconditioning.

The example code is basic_solve_sparse.c

To run basic_solve_sparse, type the following on the command line:


./basic_solve_sparse ../data_pub/matrix.xml ../data_pub/rhs.xml gmres 10 1.e-4 1.e-4 > ex1_output.txt

The result is ex1_output.txt

Try other solvers. For example, to use the biconjugate gradient solver instead of the gmres solver, type


./basic_solve_sparse ../data_pub/matrix.xml ../data_pub/rhs.xml bcg 10 1.e-4 1.e-4 > ex1_output_bcg.txt

The result is ex1_output_bcg.txt

In this example, and all subsequent ones, you can also print out information about the solution iterations. For example, type


./basic_solve_sparse ../data_pub/matrix.xml ../data_pub/rhs.xml bcg 10 1.e-4 1.e-4 debug > ex1_output_debug.txt

The result is ex1_output_debug.txt

Example 2: Solve a sparse matrix equation using a user-supplied convergence tester.

The example code is solve_sparse_with_user_supplied_convergence_tester.c

To run solve_sparse_with_user_supplied_convergence_tester, type the following on the command line:


./solve_sparse_with_user_supplied_convergence_tester ../data_pub/matrix.xml ../data_pub/rhs.xml bcg 20 1.e-4 1.e-4 > ex2_output.txt

The result is ex2_output.txt

Example 3: Solve a sparse matrix equation using a user-supplied preconditioner matrix.

The example code is solve_sparse_with_user_supplied_preconditioner.c

To run solve_sparse_with_user_supplied_preconditioner, type the following on the command line:


./solve_sparse_with_user_supplied_preconditioner ../data_pub/matrix.xml ../data_pub/preconditioner.xml ../data_pub/rhs.xml gmres 20 1.e-4 1.e-4 > ex3_output.txt

The result is ex3_output.txt

Example 4: Solve a sparse matrix equation using SPARSKIT's incomplete lu decompositon routines for the preconditioner solves.

The example code is solve_sparse_with_ilu_preconditioner.c

To run solve_sparse_with_ilu_preconditioner, type the following on the command line:


./solve_sparse_with_ilu_preconditioner ../data_pub/matrix.xml ../data_pub/rhs.xml gmres 10 1.e-4 1.e-4 > ex4_output.txt

The result is ex4_output.txt

Example 5: Solve the linear matrix equation dY/dt = AY with Sparskit.

The example code is solve_sparse_with_exppro.c

To run solve_sparse_with_exppro, type the following on the command line:


./solve_sparse_with_exppro ../data_pub/exp_matrix.xml ../data_pub/exp_initial_vector.xml 1 10 20 1.e-4 > ex5_output.txt

The result is ex5_output.txt

Example 6: Solve the linear matrix equation dY/dt = AY + P with Sparskit.

The example code is solve_sparse_with_phipro.c

To run solve_sparse_with_phipro, type the following on the command line:


./solve_sparse_with_phipro ../data_pub/phi_matrix.xml ../data_pub/phi_initial_vector.xml ../data_pub/phi_constant_vector.xml 1 10 20 1.e-4 > ex6_output.txt

The result is ex6_output.txt