solve


solve, a C++ code which implements a linear solver which makes it easy to create doubly-dimensioned arrays and solve associated linear systems.

The purpose of the library is to allow the user to declare a square matrix A of any size, access matrix entries using the usual double indexing formula A[i][j]=value;, and call a linear solver to solve A*x=b using a call like:

        x = solve ( n, A, b );
      

In C and C++, it can be awkward to set up matrices in a way that makes it easy to access them with the usual two index form, and to pass these matrices back and forth to other functions. This is because, when using the simplest interface to another function, it is necessary that the second dimension, that is, the number of columns, be declared as a fixed integer, not a variable. Such an interface is impossible to use with a general purpose linear solver.

These problems can be overcome by using a data structure known as a pointer to a pointer. However, creating and deleting such objects can be unfamiliar to the average user. This library hides the details behind an object called an R8RMAT, that is, a double precision real (R8) row-major (R) matrix (MAT). A set of functions, with the "r8rmat_" label, are provided to make it easy to create and delete such objects, and more importantly, to solve an associated linear system.

The code makes it possible to set up and solve linear systems in a natural way, as long as the user does the following:

The code can also be useful because:

Licensing:

The computer code and data files made available on this web page are distributed under the MIT license

Languages:

solve is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version.

Related Data and Programs:

allocatable_array_test, a C++ code which demonstrates how a C++ function can declare a pointer to an array, call a function, which can then allocate it and fill it with data, and then return the allocated and initialized array to the calling function through the argument list.

cpp_arrays_test, C++ codes which illustrate the use of vectors, matrices and tensors.

QR_SOLVE, a C++ code which computes the linear least squares (LLS) solution of a rectangular linear system A*x=b.

R8LIB, a C++ code which contains many utility routines using double precision real (R8) arithmetic.

solve_test

Source Code:


Last revised on 13 April 2020.