# dcgmrhs

Computes the approximate solution vectors.

## Syntax

dcgmrhs(n, x, nrhs, b, RCI_request, ipar, dpar, tmp)

## Description

The routine dcgmrhs computes the approximate solution vectors using the CG with multiple right hand sides (MRHS) method [Young71]. The routine dcgmrhs uses the value that was in the x before the first call as an initial approximation to the solution. The parameter RCI_request informs the user about task completion status and requests results of certain operations that are required by the solver.

Note that lengths of all vectors are assumed to have been defined in a previous call to the dcgmrhs_init routine.

### Note

To use this routine with the name dcg, the user must switch on the compiler's preprocessor and include the files mkl_solver.h for C/C++, or mkl_solver.f77 for FORTRAN.

## Input Parameters

n

  INTEGER. Contains the size of the problem, and the sizes of arrays x and b.

x

  DOUBLE PRECISION matrix of size n-by-nrhs. Contains the initial approximation to the solution vectors.

nrhs

  INTEGER. This parameter sets the number of right-hand sides.

b

  DOUBLE PRECISION matrix of size `(nrhs,n)`. Contains the right-hand side vectors.

tmp

  DOUBLE PRECISION array of size `(n, 3+nrhs)`. Refer to the CG Common Parameters.

## Output Parameters

RCI_request

  INTEGER. Informs about result of work of the routine.

x

  DOUBLE PRECISION matrix of size n-by-nrhs. Contains the updated approximation to the solution vectors.

ipar

  INTEGER array of size (128+2*nrhs). Refer to the CG Common Parameters.

dpar

  DOUBLE PRECISION array of size (128+2*nrhs). Refer to the CG Common Parameters.

tmp

  DOUBLE PRECISION array of size `(n, 3+nrhs)`. Refer to the CG Common Parameters.

## Return Values

RCI_request=0

  The routine completes task normally, the solution is found and stored in the matrix x. This occurs only if the stopping tests are fully automatic. For the user defined stopping tests, see the comments to the RCI_request= 2.

RCI_request=-1

  The routine is interrupted because the maximal number of iterations is reached, but the relative stopping criterion is not satisfied. This situation occurs only if both tests are requested by the user.

RCI_request=-2

  The routine is interrupted because attempt to divide by zero occurs. This happens if the matrix is (almost) non-positive definite.

RCI_request=- 10

  The routine is interrupted because the residual norm is invalid. Probably, the value dpar(6) was altered outside of the routine, or the routine dcgmrhs_check was not called.

RCI_request=-11

  The routine is interrupted because it enters the infinite cycle. Probably, the values ipar(8), ipar(9), ipar(10) were altered outside of the routine, or the routine dcgmrhs_check was not called.

RCI_request= 1

  Requests the user to multiply the matrix by tmp(1:n,1), put the result in the tmp(1:n,2), and return the control back to the routine dcgmrhs.

RCI_request= 2

  Requests the user to perform the stopping tests. If they fail, the control must be returned back to the routine dcgmrhs. Otherwise, the solution is found and stored in the matrix x.

RCI_request= 3

  Requests the user to apply the preconditioner to tmp`(:,3+ipar(3))`, put the result in tmp`(:,3)`, and return the control back to the routine dcgmrhs.

Parent topic: Iterative Sparse Solvers based on Reverse Communication Interface (RCI ISS)