Index Module

Overview

freud.index.Index2D freud-style indexer for flat arrays.
freud.index.Index3D freud-style indexer for flat arrays.

Details

The index module exposes the \(1\)-dimensional indexer utilized in freud at the C++ level. At the C++ level, freud utilizes flat arrays to represent multidimensional arrays. \(N\)-dimensional arrays with \(n_i\) elements in each dimension \(i\) are represented as \(1\)-dimensional arrays with \(\prod_{i=1}^N n_i\) elements.

Index2D

class freud.index.Index2D(*args)

freud-style indexer for flat arrays.

Once constructed, the object provides direct access to the flat index equivalent:

  • Constructor Calls:

    Initialize with all dimensions identical:

    freud.index.Index2D(w)
    

    Initialize with each dimension specified:

    freud.index.Index2D(w, h)
    

Note

freud indexes column-first i.e. Index2D(i, j) will return the \(1\)-dimensional index of the \(i^{th}\) column and the \(j^{th}\) row. This is the opposite of what occurs in a numpy array, in which array[i, j] returns the element in the \(i^{th}\) row and the \(j^{th}\) column.

Module author: Joshua Anderson <joaander@umich.edu>

Parameters:
  • w (unsigned int) – Width of 2D array (number of columns).
  • h (unsigned int) – Height of 2D array (number of rows).
Variables:

num_elements (unsigned int) – Number of elements in the array.

Example:

index = Index2D(10)
i = index(3, 5)
__call__(self, i, j)
Parameters:
  • i (unsigned int) – Column index.
  • j (unsigned int) – Row index.
Returns:

Index in flat (e.g. \(1\)-dimensional) array.

Return type:

unsigned int

getNumElements

Index3D

class freud.index.Index3D(*args)

freud-style indexer for flat arrays.

Once constructed, the object provides direct access to the flat index equivalent:

  • Constructor Calls:

    Initialize with all dimensions identical:

    freud.index.Index3D(w)
    

    Initialize with each dimension specified:

    freud.index.Index3D(w, h, d)
    

Note

freud indexes column-first i.e. Index3D(i, j, k) will return the \(1\)-dimensional index of the \(i^{th}\) column, \(j^{th}\) row, and the \(k^{th}\) frame. This is the opposite of what occurs in a numpy array, in which array[i, j, k] returns the element in the \(i^{th}\) frame, \(j^{th}\) row, and the \(k^{th}\) column.

Module author: Joshua Anderson <joaander@umich.edu>

Parameters:
  • w (unsigned int) – Width of 2D array (number of columns).
  • h (unsigned int) – Height of 2D array (number of rows).
  • d (unsigned int) – Depth of 2D array (number of frames).
Variables:

num_elements (unsigned int) – Number of elements in the array.

Example:

index = Index3D(10)
i = index(3, 5, 4)
__call__(self, i, j, k)
Parameters:
  • i (unsigned int) – Column index.
  • j (unsigned int) – Row index.
  • k (unsigned int) – Frame index.
Returns:

Index in flat (e.g. \(1\)-dimensional) array.

Return type:

unsigned int

getNumElements