Package ffx.numerics.atomic
Class AtomicDoubleArray3D
java.lang.Object
ffx.numerics.atomic.AtomicDoubleArray3D
Implementation of maintaining a 3D double array that is operated on by multiple threads.
- Since:
- 1.0
- Author:
- Michael J. Schnieders
-
Constructor Summary
ConstructorDescriptionAtomicDoubleArray3D
(AtomicDoubleArray.AtomicDoubleArrayImpl atomicDoubleArrayImpl, int size) Construct an atomic 3D double array of the specified size using the specified implementation.AtomicDoubleArray3D
(AtomicDoubleArray.AtomicDoubleArrayImpl atomicDoubleArrayImpl, int size, int nThreads) Construct an atomic 3D double array of the specified size, using the specified implementation, and the requested number of threads.Construct an atomic 3D double array using the specified AtomicDoubleArray instances. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(int threadID, int index, double x, double y, double z) Add to the double arrays at the specified index the given values.void
Add to the double arrays at the specified index the given Double3.void
alloc
(int size) Ensure the AtomicDoubleArray3D instance is greater than or equal to size.get
(int index) Get the Double3 at the specified index.double
get
(int dim, int index) Get the value of the array at the specified index after calling thereduce
method.double
getX
(int index) Get the X-value of the array at the specified index after calling thereduce
method.double
getY
(int index) Get the Y-value of the array at the specified index after calling thereduce
method.double
getZ
(int index) Get the Z-value of the array at the specified index after calling thereduce
method.void
reduce
(int lb, int ub) Perform reduction between the given lower bound (lb) and upper bound (up) if necessary.void
reduce
(ParallelTeam parallelTeam) Perform a reduction on the entire array.void
reset
(int threadID, int lb, int ub) Reset the double array to Zero.void
reset
(ParallelTeam parallelTeam) Reset the double array to Zero.void
scale
(int threadID, int index, double scale) Scale the double arrays at the specified index to the given values.void
set
(int threadID, int index, double x, double y, double z) Set the double arrays at the specified index to the given values.void
Set the double arrays at the specified index to the given Double3.void
sub
(int threadID, int index, double x, double y, double z) Subtracts from the double arrays at the specified index the given values.void
Subtracts from the double arrays at the specified index the given Double3.toString()
Return a String for entire Array, with one 3D vector per line.toString
(int index) Return a string for given index.Return a string for given index.Return a String for entire Array, with one 3D vector per line.
-
Constructor Details
-
AtomicDoubleArray3D
Construct an atomic 3D double array of the specified size using the specified implementation.- Parameters:
atomicDoubleArrayImpl
- Implementation.size
- Size of each dimension.
-
AtomicDoubleArray3D
public AtomicDoubleArray3D(AtomicDoubleArray.AtomicDoubleArrayImpl atomicDoubleArrayImpl, int size, int nThreads) Construct an atomic 3D double array of the specified size, using the specified implementation, and the requested number of threads.- Parameters:
atomicDoubleArrayImpl
- Implementation.size
- Size of each dimension.nThreads
- Requested number of threads (only used by the MULTI implementation).
-
AtomicDoubleArray3D
Construct an atomic 3D double array using the specified AtomicDoubleArray instances.- Parameters:
x
- AtomicDoubleArray for the X dimension.y
- AtomicDoubleArray for the Y dimension.z
- AtomicDoubleArray for the Z dimension.
-
-
Method Details
-
add
public void add(int threadID, int index, double x, double y, double z) Add to the double arrays at the specified index the given values.- Parameters:
threadID
- the thread ID.index
- the index.x
- the x value.y
- the y value.z
- the z value.
-
add
Add to the double arrays at the specified index the given Double3.- Parameters:
threadID
- the thread ID.index
- the index.d3
- the Double3 containing the values to add.
-
alloc
public void alloc(int size) Ensure the AtomicDoubleArray3D instance is greater than or equal to size.- Parameters:
size
- the size of the array.
-
get
public double get(int dim, int index) Get the value of the array at the specified index after calling thereduce
method.- Parameters:
dim
- Dimension [0, 1, 2]index
- the index.- Returns:
- the value.
-
get
Get the Double3 at the specified index. This is usually after calling thereduce
method.- Parameters:
index
- the index.- Returns:
- a new Double3 with the values at the specified index.
-
getX
public double getX(int index) Get the X-value of the array at the specified index after calling thereduce
method.- Parameters:
index
- the index.- Returns:
- the X value.
-
getY
public double getY(int index) Get the Y-value of the array at the specified index after calling thereduce
method.- Parameters:
index
- the index.- Returns:
- the Y value.
-
getZ
public double getZ(int index) Get the Z-value of the array at the specified index after calling thereduce
method.- Parameters:
index
- the index.- Returns:
- the Z value.
-
reduce
public void reduce(int lb, int ub) Perform reduction between the given lower bound (lb) and upper bound (up) if necessary.- Parameters:
lb
- the lower bound.ub
- the upper bound.
-
reduce
Perform a reduction on the entire array.- Parameters:
parallelTeam
- ParallelTeam to use.
-
reset
public void reset(int threadID, int lb, int ub) Reset the double array to Zero.- Parameters:
threadID
- the thread ID.lb
- the lower bound.ub
- the upper bound.
-
reset
Reset the double array to Zero.- Parameters:
parallelTeam
- a ParallelTeam.
-
scale
public void scale(int threadID, int index, double scale) Scale the double arrays at the specified index to the given values.- Parameters:
threadID
- the thread ID.index
- the index.scale
- The value to scale by.
-
set
public void set(int threadID, int index, double x, double y, double z) Set the double arrays at the specified index to the given values.- Parameters:
threadID
- the thread ID.index
- the index.x
- the X value.y
- the Y value.z
- the Z value.
-
set
Set the double arrays at the specified index to the given Double3.- Parameters:
threadID
- the thread ID.index
- the index.d3
- the Double3 containing the values.
-
sub
public void sub(int threadID, int index, double x, double y, double z) Subtracts from the double arrays at the specified index the given values.- Parameters:
threadID
- the thread ID.index
- the index.x
- the X value.y
- the Y value.z
- the Z value.
-
sub
Subtracts from the double arrays at the specified index the given Double3.- Parameters:
threadID
- the thread ID.index
- the index.d3
- the Double3 containing the values.
-
toString
Return a string for given index.- Parameters:
index
- Index.- Returns:
- Returns a String for 3D vector at the given index.
-
toString
Return a string for given index.- Parameters:
index
- Index.label
- Label to use for the String.- Returns:
- Returns a String for 3D vector at the given index.
-
toString
Return a String for entire Array, with one 3D vector per line. -
toString
Return a String for entire Array, with one 3D vector per line.- Parameters:
label
- Label may include one "%d" format conversion to include for the index of each entry.- Returns:
- Returns a String for the 3D array.
-