File math/vector_math.hpp

struct SequentialVectorMath
#include <vector_math.hpp>

Implements basic operations for calculating with numerical arrays by applying the respective operations to each element in the arrays sequentially.

Public Static Functions

template<typename T>
static inline void copy(const T *from, T *to, uint32 numElements)

Copy all elements from one array to another.

Template Parameters:

T – The type of the elements

Parameters:
  • from – A pointer to the beginning of the array to copy from

  • to – A pointer to the beginning of the array to copy to

  • numElements – The number of elements to be copied

template<typename T>
static inline void add(T *a, const T *b, uint32 numElements)

Adds the elements in an array b to the elements in another array a, such that a = a + b.

Template Parameters:

T – The type of the values in the array a and b

Parameters:
  • a – A pointer to the beginning of the array a

  • b – A pointer to the beginning of the array b

  • numElements – The number of elements in the arrays a and b

template<typename T, typename Weight>
static inline void addWeighted(T *a, const T *b, uint32 numElements, Weight weight)

Adds the elements in an array b to the elements in another array a. The elements in the array b are multiplied by a given weight, such that a = a + (b * weight).

Template Parameters:
  • T – The type of the values in the arrays a and b

  • Weight – The type of the weight

Parameters:
  • a – A pointer to the beginning of the array a

  • b – A pointer to the beginning of the array b

  • numElements – The number of elements in the arrays a and b

  • weight – The weight, the elements in the array b should be multiplied by

template<typename T>
static inline void add(T *a, const T *b, const uint32 *indices, uint32 numElements)

Adds the elements in an array b to the elements in another array a, such that a = a + b. The indices of the elements in the array b that correspond to the elements in the array a are given as an additional array.

Template Parameters:

T – The type of the values in the arrays a and b

Parameters:
  • a – A pointer to the beginning of the array a

  • b – A pointer to the beginning of the array b

  • numElements – The number of elements in the arrays a and b

  • indices – A pointer to the beginning of an array that stores the indices of the elements in the array b that correspond to the elements in the array a

template<typename T, typename Weight>
static inline void addWeighted(T *a, const T *b, const uint32 *indices, uint32 numElements, Weight weight)

Adds the elements in an array b to the elements in another array a. The elements in the array b are multiplied by a given weight, such that a = a + (b * weight). The indices of the elements in the array b that correspond to the elements in the array a are given as an additional array.

Template Parameters:
  • T – The type of the values in the arrays a and b

  • Weight – The type of the weight

Parameters:
  • a – A pointer to the beginning of the array a

  • b – A pointer to the beginning of the array b

  • numElements – The number of elements in the arrays a and b

  • weight – The weight, the elements in the array b should be multiplied by

  • indices – A pointer to the beginning of a array that stores the indices of the elements in the array b that correspond to the elements in the array a

template<typename T, typename Constant>
static inline void addConstantToSubset(T *array, Constant constant, const uint32 *indices, uint32 numIndices)

Adds a specific constant to the elements in a given array array that correspond to the indices in another array indices.

Template Parameters:
  • T – The type of the values in the array array

  • Constant – The type of the constant

Parameters:
  • array – A pointer to the beginning of the array array

  • constant – The constant

  • indices – A pointer to the beginning of the array indices

  • numIndices – The number of elements in the array indices

template<typename T>
static inline void subtract(T *a, const T *b, uint32 numElements)

Removes the elements in an array b from the elements in another array a, such that a = a - b.

Template Parameters:

T – The type of the values in the arrays a and b

Parameters:
  • a – A pointer to the beginning of the array a

  • b – A pointer to the beginning of the array b

  • numElements – The number of elements in the arrays a and b

template<typename T, typename Weight>
static inline void subtractWeighted(T *a, const T *b, uint32 numElements, Weight weight)

Removes the elements in an array b from the elements in another array a. The elements in the array b are multiplied by a given weight, such that a = a - (b * weight).

Template Parameters:
  • T – The type of the values in the arrays a and b

  • Weight – The type of the weight

Parameters:
  • a – A pointer to the beginning of the array a

  • b – A pointer to the beginning of the array b

  • numElements – The number of elements in the arrays a and b

  • weight – The weight, the elements in the array b should be multiplied by

template<typename T, typename Constant>
static inline void subtractConstantFromSubset(T *array, Constant constant, const uint32 *indices, uint32 numIndices)

Subtracts a specific constant from the elements in a given array array that correspond to the indices in another array indices.

Template Parameters:
  • T – The type of the values in the array array

  • Constant – The type of the constant

Parameters:
  • array – A pointer to the beginning of the array array

  • constant – The constant

  • indices – A pointer to the beginning of the array indices

  • numIndices – The number of elements in the array indices

template<typename T>
static inline void difference(T *a, const T *b, const T *c, uint32 numElements)

Sets all elements in an array a to the difference between the elements in two other arrays b and c, such that a = b - c.

Template Parameters:

T – The type of the values in the arrays a, b and c

Parameters:
  • a – A pointer to the beginning of the array a

  • b – A pointer to the beginning of the array b

  • c – A pointer to the beginning of the array c

  • numElements – The number of elements in the arrays a, b and c

template<typename T>
static inline void difference(T *a, const T *b, const T *c, const uint32 *indices, uint32 numElements)

Sets all elements in an array a to the difference between the elements in two other arrays b and c, such that a = b - c. The indices of elements in the array b that correspond to the elements in the arrays a and c are obtained from an additional array.

Template Parameters:

T – The type of the values in the arrays a, b and c

Parameters:
  • a – A pointer to the beginning of the array a

  • b – A pointer to the beginning of the array b

  • c – A pointer to the beginning of the array c

  • indices – A pointer to the beginning of the array that provides access to the indices of the elements in the array b that correspond to the elements in the arrays a and c

  • numElements – The number of elements in the array a, b and c