SRMGEN(3)

SYNOPSIS
SUBROUTINE SRMGEN (NELTMX, FACTOR, IERR, N, NELT, ISYM, IA, JA, A, $ F, SOLN, DSUM, ITMP, IDIAG)

NAME
srmgen - This routine generates a "Random" symmetric or non-symmetric matrix of size N for use in the SLAP Quick Checks.

LIBRARY
SLATEC (SLAP)

TYPE
SINGLE PRECISION (SRMGEN-S, DRMGEN-D)

AUTHOR
Seager, Mark K., (LLNL) seager@llnl.gov Lawrence Livermore National Laboratory PO BOX 808, L-300 Livermore, CA 94550 (510) 423-3141

DESCRIPTION
*Usage: INTEGER NELTMX, IERR, N, NELT, ISYM, INTEGER IA(NELTMX), JA(NELTMX), ITMP(N), IDIAG(N) REAL FACTOR, A(NELTMX), F(N), SOLN(N), DSUM(N) CALL SRMGEN( NELTMX, FACTOR, IERR, N, NELT, ISYM, $ IA, JA, A, F, SOLN, DSUM, ITMP, IDIAG ) *Arguments: NELTMX :IN Integer. Maximum number of non-zeros that can be created by this routine for storage in the IA, JA, A arrays, see below. FACTOR :IN Real. Non-zeros in the upper triangle are set to FACTOR times the corresponding entry in the lower triangle when a non- symmetric matrix is requested (See ISYM, below). IERR :OUT Integer. Return error flag. IERR = 0 => everything went OK. = 1 => Ran out of space trying to create matrix. Set NELTMX to something larger and retry. N :IN Integer. Size of the linear system to generate (number of unknowns). NELT :OUT Integer. Number of non-zeros stored in the IA, JA, A arrays, see below. ISYM :IN Integer. Flag to indicate the type of matrix to generate: ISYM = 0 => Non-Symmetric Matrix (See FACTOR, above). = 1 => Symmetric Matrix. IA :OUT Integer IA(NELTMX). Stores the row indices for the non-zeros. JA :OUT Integer JA(NELTMX). Stores the column indices for the non-zeros. A :OUT Real A(NELTMX). Stores the values of the non-zeros. F :OUT Real F(N). The right hand side of the linear system. Obtained by multiplying the matrix times SOLN, see below. SOLN :OUT Real SOLN(N). The true solution to the linear system. Each component is chosen at random (0.0<SOLN(I)<1.0, I=1,N) DSUM :WORK Real DSUM(N). ITMP :WORK Integer ITMP(N). IDIAG :WORK Integer IDIAG(N). *Description The matrix is generated by choosing a random number of entries for each column and then chosing negative random numbers for each off diagonal. The diagonal elements are chosen to be positive and large enough so the matrix is slightly diagonally dominant. The lower triangle of the matrix is generated and if isym.eq.0 (all matrix elements stored) the upper triangle elements are chosen so that they are FACTOR times the corresponding lower triangular element.

ROUTINES CALLED
ISMPL, RAND

REVISION HISTORY (YYMMDD)
881120 DATE WRITTEN
890919 Replaced SMPL with ISMPL. (MKS)
890920 Minor changes to reduce single/double differences. (FNF)
920511 Added complete declaration section. (WRB)