Package ffx.numerics.atomic
Class AdderDoubleArray
java.lang.Object
ffx.numerics.atomic.AdderDoubleArray
- All Implemented Interfaces:
AtomicDoubleArray
AdderDoubleArray implements the AtomicDoubleArray interface using an array of
java.util.concurrent.atomic.DoubleAdder.- Since:
- 1.0
- Author:
- Michael J. Schnieders
-
Nested Class Summary
Nested classes/interfaces inherited from interface ffx.numerics.atomic.AtomicDoubleArray
AtomicDoubleArray.AtomicDoubleArrayImpl -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(int threadID, int index, double value) Add a value to the double array at the specified index.voidalloc(int size) Ensure the AtomicDoubleArray instance has at least the specified size.doubleget(int index) Get the value of the array at the specified index.voidreduce(int lb, int ub) The AtomicDoubleArray handles the reduction automatically, so this method does nothing.voidreduce(ParallelTeam parallelTeam, int lb, int ub) The AtomicDoubleArray handles the reduction automatically, so this method does nothing.voidreset(int threadID, int lb, int ub) Reset the double array values to zero within the specified bounds.voidreset(ParallelTeam parallelTeam, int lb, int ub) Reset the double array values to zero within the specified bounds using a ParallelTeam.voidscale(int threadID, int index, double value) Scale the value of the double array at the specified index.voidset(int threadID, int index, double value) Set the value of the double array at the specified index.intsize()Get the current size of the array.voidsub(int threadID, int index, double value) Subtract a value from the double array at the specified index.
-
Constructor Details
-
AdderDoubleArray
public AdderDoubleArray(int size) Construct an AdderDoubleArray.- Parameters:
size- Size of the array.
-
-
Method Details
-
add
public void add(int threadID, int index, double value) Add a value to the double array at the specified index.- Specified by:
addin interfaceAtomicDoubleArray- Parameters:
threadID- The thread ID.index- The index of the array.value- The value to add.
-
alloc
public void alloc(int size) Ensure the AtomicDoubleArray instance has at least the specified size.- Specified by:
allocin interfaceAtomicDoubleArray- Parameters:
size- The required size of the array.
-
get
public double get(int index) Get the value of the array at the specified index. Note: The `reduce` method should be called first when using the MULTI implementation.- Specified by:
getin interfaceAtomicDoubleArray- Parameters:
index- The index of the array.- Returns:
- The value at the specified index.
-
reduce
public void reduce(int lb, int ub) The AtomicDoubleArray handles the reduction automatically, so this method does nothing.- Specified by:
reducein interfaceAtomicDoubleArray- Parameters:
lb- The lower bound of the range.ub- The upper bound of the range.
-
reduce
The AtomicDoubleArray handles the reduction automatically, so this method does nothing.- Specified by:
reducein interfaceAtomicDoubleArray- Parameters:
parallelTeam- The ParallelTeam to use.lb- The lower bound of the range.ub- The upper bound of the range.
-
reset
public void reset(int threadID, int lb, int ub) Reset the double array values to zero within the specified bounds.- Specified by:
resetin interfaceAtomicDoubleArray- Parameters:
threadID- The thread ID.lb- The lower bound of the reset range.ub- The upper bound of the reset range.
-
reset
Reset the double array values to zero within the specified bounds using a ParallelTeam.- Specified by:
resetin interfaceAtomicDoubleArray- Parameters:
parallelTeam- The ParallelTeam to use.lb- The lower bound of the reset range.ub- The upper bound of the reset range.
-
scale
public void scale(int threadID, int index, double value) Scale the value of the double array at the specified index.- Specified by:
scalein interfaceAtomicDoubleArray- Parameters:
threadID- The thread ID.index- The index of the array.value- The value to scale by.
-
set
public void set(int threadID, int index, double value) Set the value of the double array at the specified index.- Specified by:
setin interfaceAtomicDoubleArray- Parameters:
threadID- The thread ID.index- The index of the array.value- The value to set.
-
size
public int size()Get the current size of the array.- Specified by:
sizein interfaceAtomicDoubleArray- Returns:
- The size of the array.
-
sub
public void sub(int threadID, int index, double value) Subtract a value from the double array at the specified index.- Specified by:
subin interfaceAtomicDoubleArray- Parameters:
threadID- The thread ID.index- The index of the array.value- The value to subtract.
-