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

g2-sparse-get

Returns the quantity value of a specified element of a sparse array.

Synopsis

g2-sparse-get
(value-array: class quantity-array, index-array: class integer-array,
index: integer)
-> value-of-index: quantity
Argument Description
value-array
The value array component of the sparse array.
index-array
The index array component of the sparse array.
index
The index value, in the original dense array, of the element whose quantity value is returned. This index value can refer to an element whose value is zero as well as to a non-zero element. Note: A element whose value is 0 is not included in value-array, and its index value is not included in index-array.

Return Value Description
value-of-index
A quantity value of the array element specified by index.

Description

g2-sparse-get returns the quantity in the sparse array represented by value-array and index-array whose index in the sparse array is given by index. This is accomplished by indexing value-array with the integer resulting from indexing index-array by index.

Example

The following call to g2-sparse-get returns to element the quantity value of the element whose index is ind:

Suppose that v-array and i-array represent a dense array with the following values:

The following table lists values returned to elements with different values of ind:

Value of ind Value returned to elements
0
0
1
1
2
0
3
2
4
0
5
0
6
3

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

Copyright © 1997 Gensym Corporation, Inc.