Chemistry · class
SpeciesElementMatrix
Explained in Chemistry.
class SpeciesElementMatriximport { SpeciesElementMatrix } from '@driftengine/chemistry';Accessors
| Name | Type | Description |
|---|---|---|
rowsget | number |
Methods
addRow
addRow(): numberAppend a zeroed row and return its index.
set
set(row: number, element: number, moles: number): void| Parameter | Type | Description |
|---|---|---|
row | number | |
element | number | |
moles | number |
at
at(row: number, element: number): number| Parameter | Type | Description |
|---|---|---|
row | number | |
element | number |
rowView
rowView(row: number): Float64ArrayA row as a view of fifteen, sharing storage rather than copying.
| Parameter | Type | Description |
|---|---|---|
row | number |
More
A view is invalidated by a later addRow that grows the table, because growth reallocates.
Every caller in this package takes a view inside a loop that registers nothing, which is the
only safe pattern and is why this is not handed out as a promise.
addScaledRow
addScaledRow(row: number, scale: number, out: Float64Array): voidout[e] += scale * this[row][e], for all fifteen. Allocates nothing.
| Parameter | Type | Description |
|---|---|---|
row | number | |
scale | number | |
out | Float64Array |
More
The primitive every conservation check is built from, and it exists rather than a loop over
at for one reason: rowView would be the natural way to write that loop and subarray
allocates a view object per call, which is an allocation per species per tick. It adds rather
than replaces so a caller sums a whole world into one vector without a second accumulator.