Sun S3L 3.0 Programming and Reference Guide

S3L_rand_fib

Description

S3L_rand_fib initializes a parallel array using a Lagged-Fibonacci random number generator (LFG). The LFG's parameters are fixed to l = 17, k = 5, and m = 32.

Random numbers are produced by the following iterative equation:

x[n] = (x[n-e]
+ x[n-k]) mod 2m

The result of S3L_rand_fib depends on how the parallel array a is distributed.

When the parallel array is of type integer, its elements are filled with nonnegative integers in the range 0 . . . 231 -1. When the parallel array is single- or double-precision real, its elements are filled with random nonnegative numbers in the range 0 . . . 1. For complex arrays, the real and imaginary parts are initialized to random real numbers.

Syntax

The C and Fortran syntax for S3L_rand_fib are shown below.

C/C++ Syntax


Example 8-71

#include <s3l/s3l-c.h>
#include <s3l/s3l_errno-c.h>
int
S3L_rand_fib(a, setup_id, seed)
    S3L_array_t        a
    int                setup_id

F77/F90 Syntax


Example 8-72

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

Input

Output

This function uses the following argument for output:

Error Handling

On success, S3L_rand_fib returns S3L_SUCCESS.

S3L_rand_fib 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_fib/rand_fib.c
../examples/s3l/rand_fib-f/rand_fib.f

Related Functions

S3L_free_rand_fib(3)
S3L_setup_rand_fib(3)