Class AtomicDoubleArray3D

java.lang.Object
ffx.numerics.atomic.AtomicDoubleArray3D

public class AtomicDoubleArray3D extends Object
Implementation of maintaining a 3D double array that is operated on by multiple threads.
Since:
1.0
Author:
Michael J. Schnieders
  • Constructor Summary

    Constructors
    Constructor
    Description
    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.
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    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(int threadID, int index, Double3 d3)
    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 the reduce method.
    double
    getX(int index)
    Get the X-value of the array at the specified index after calling the reduce method.
    double
    getY(int index)
    Get the Y-value of the array at the specified index after calling the reduce method.
    double
    getZ(int index)
    Get the Z-value of the array at the specified index after calling the reduce 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(int threadID, int index, Double3 d3)
    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
    sub(int threadID, int index, Double3 d3)
    Subtracts from the double arrays at the specified index the given Double3.
    Return a String for entire Array, with one 3D vector per line.
    toString(int index)
    Return a string for given index.
    toString(int index, String label)
    Return a string for given index.
    Return a String for entire Array, with one 3D vector per line.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • AtomicDoubleArray3D

      public AtomicDoubleArray3D(AtomicDoubleArray.AtomicDoubleArrayImpl atomicDoubleArrayImpl, int size)
      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

      public AtomicDoubleArray3D(AtomicDoubleArray x, AtomicDoubleArray y, AtomicDoubleArray z)
  • 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

      public void add(int threadID, int index, Double3 d3)
      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 the reduce method.
      Parameters:
      dim - Dimension [0, 1, 2]
      index - the index.
      Returns:
      the value.
    • get

      public Double3 get(int index)
      Get the Double3 at the specified index. This is usually after calling the reduce 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 the reduce 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 the reduce 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 the reduce 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

      public void reduce(ParallelTeam parallelTeam)
      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

      public void reset(ParallelTeam parallelTeam)
      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

      public void set(int threadID, int index, Double3 d3)
      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

      public void sub(int threadID, int index, Double3 d3)
      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

      public String toString(int index)
      Return a string for given index.
      Parameters:
      index - Index.
      Returns:
      Returns a String for 3D vector at the given index.
    • toString

      public String toString(int index, String label)
      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

      public String toString()
      Return a String for entire Array, with one 3D vector per line.
      Overrides:
      toString in class Object
      Returns:
      Returns a String for the 3D array.
    • toString

      public String toString(String label)
      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.