| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (23 out of 28)

g2-sparse-add

Performs the operation X = X + alpha * Y, where X and Y are sparse arrays.

Synopsis

g2-sparse-add
(value-array-1: class quantity-array, index-array-1: class integer-array,
value-array-2: class quantity-array, index-array-2: class integer-array,
full-array: class quantity-array, alpha: quantity, range: class integer-array,
full-array-initialized: truth-value)
Argument Description
value-array-1
The value array of the first sparse array.
index-array-1
The index array of the first sparse array.
value-array-2
The value array of the second sparse array.
index-array-2
The index array of the second sparse array.
full-array
A dense array corresponding to the sparse array represented by value-array-2 and index-array-2.
alpha
A value by which to multiply each element of the second sparse array.
range
The range of elements in each sparse array to add. See Description below.
full-array-initialized
Specify true or false, to specify whether G2-sparse-add adds the two sparse arrays and modifies full-array. If true, and full-array initially contains non-zero elements, G2-sparse-add does not modify full-array. In this case, G2-sparse-add adds the two arrays. If false, G2-sparse-add adds the two arrays and then sets all elements of full-array to 0, regardless of the initial values of full-array. Note: If true, and all elements of full-array are initially set to 0, full-array is set to the original dense format representation of value-array-2 and index-array-2. In this case, G2-sparse-add does not add the two arrays.

Description

g2-sparse-add performs the operation X = X + alpha * Y, where X is the array represented in sparse format by value-array1 and index-array1, and Y is the array represented in sparse format by value-array2 and index-array2. The result is placed in the first sparse array (value-array1 and index-array1).

To perform the addition, g2-sparse-add follows these rules:

The range argument is an integer-array containing four elements that specify the range of elements in the two value arrays that can be added:

For example, to add the first five elements in each value array, specify range as:

To add all the elements of the two value arrays, specify:

Examples

Suppose that g2-sparse-add is called with the following arguments:

and that these arguments have the following values:

With these arguments, g2-sparse-add returns the following values to value-a:

To create this result, g2-sparse-add does the following:

| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (23 out of 28)

Copyright © 1997 Gensym Corporation, Inc.