Sun S3L 3.0 Programming and Reference Guide

S3L_rand_lcg

Description

S3L_rand_lcg initializes a parallel array a, using a Linear Congruential random number generator (LCG). It produces random numbers that are independent of the distribution of the parallel array.

Arrays of type S3L_integer (integer4) are initialized to random integers in the range 0 . . . 231-1. Arrays of type S3L_long_integer are initialized with integers in the range 0 . . . 263-1. Arrays of type S3L_float or S3L_double are initialized in the range 0 . . . 1. The real and imaginary parts of type S3L_complex and S3L_double_complex are also initialized in the range 0 . . . 1.

The random numbers are initialized by an internal iterative equation of the type:

x[n] = a*x[n-1]
+ c

Syntax

The C and Fortran syntax for S3L_rand_lcg are shown below.

C/C++ Syntax


Example 8-73

#include <s3l/s3l-c.h>
#include <s3l/s3l_errno-c.h>
int
S3L_rand_lcg(a, iseed)
    S3L_array_t        a
    int                iseed

F77/F90 Syntax


Example 8-74

include `s3l/s3l-f.h'
include `s3l/s3l_errno-f.h'
subroutine
S3L_rand_lcg(a, iseed, ier)
    integer*8          a
    integer*4          iseed
    integer*4          ier

Input

Output

This function uses the following argument for output:

Error Handling

On success, S3L_rand_lcg returns S3L_SUCCESS.

S3L_rand_lcg checks the validity of the arrays it accepts as arguments. If an array argument contains an invalid or corrupted value, the function terminates and an error code indicating which value of the array handle was invalid is returned. See Appendix A of this manual for a detailed list of these error codes.

In addition, the following condition will cause the function to terminate and return the associated error code.

Examples

../examples/s3l/rand_lcg/rand_lcg.c
../examples/s3l/rand_lcg-f/rand_lcg.f

Related Functions

S3L_free_rand_fib(3)
S3L_setup_rand_fib(3)