MultiIndex#

class MultiIndex#

A class for working with vectors of nonnnegative integers.

Public Functions

MultiIndex()#
MultiIndex(unsigned int lengthIn, unsigned int val = 0)#

Constructor that creates a multiindex with some default value.

Parameters:
  • lengthIn[in] The length (i.e., number of components) in the multiindex.

  • val[in] The value to be set for all entries.

inline MultiIndex(std::vector<unsigned int> const &indIn)#

Takes a dense vector description of the multiindex and extracts the nonzero components.

Parameters:

indIn[in] Row vector of unsigned integers defining the multiindex.

template<typename Derived>
inline MultiIndex(Eigen::MatrixBase<Derived> const &multi)#

Constructs a multiindex from an Eigen vector.

MultiIndex(Kokkos::View<unsigned int*, Kokkos::HostSpace> const &nzIndsIn, Kokkos::View<unsigned int*, Kokkos::HostSpace> const &nzValsIn, unsigned int lengthIn)#

Construct a new Multi Index object from a set of nonzero indices and values.

Parameters:
  • nzIndsIn – indices of the nonzero values

  • nzValsIn – values that are nonzero

  • lengthIn – dimension of the index (numNz==lengthIn iff all values are nonzero)

MultiIndex(const unsigned int *fullVec, unsigned int length)#

Uses a dense vector description of the multiindex, defined through a pointer, and extracts the nonzero components.

Parameters:
  • fullVec[in] A pointer the memory containing the dense multiindex.

  • length[in] The length of the multiindex.

MultiIndex(std::initializer_list<unsigned int> const &indIn)#

Allows users to intiailize the multiindex with curly braces. For example,

MultiIndex temp{1,0,2,3} 
would create a multiindex with length four and values 1, 0, 2, and 3.

std::vector<unsigned int> Vector() const#

Get the dense representation of this multiindex.

Returns:

A std::vector of unsigned integers containing the multiindex.

inline unsigned int Sum() const#

Get the total order of this multiindex: the \(\ell_1\) norm.

Returns:

The sum of the nonzero components: the total order of this multiindex.

inline unsigned int Max() const#

This function returns the maximum degree of this multiindex: the \(\ell_\infty\) norm.

Returns:

The maximum value of the multiindex.

bool Set(unsigned int ind, unsigned int val)#

Use this function to set the value of the an entry in the multiindex.

Parameters:
  • ind[in] The component of the multiindex to set (starting with 0).

  • val[in] A non-negative value for the dim component of the multiindex.

Returns:

True if this function updated an already nonzero component, or false if this function added a new nonzero entry.

unsigned int Get(unsigned int ind) const#

Obtain a particular component of the multiindex. Notice that this function can be slow for multiindices with many nonzero components. The worst case performance requires \(O(|\mathbf{j}|_0)\) integer comparisons, where \(|\mathbf{j}|_0\) denotes the number of nonzero entries in the multiindex.

Parameters:

ind[in] The component to return.

Returns:

The integer stored in component dim of the multiindex.

unsigned int NumNz() const#

Returns the number of nonzero components in the multiindex.

Returns:

An unsigned integer with the number of nonzero entries in the multiindex.

std::string String() const#

Return a string representation of the Multiindex.

Returns:

A string showing the dense representation of the multiindex, e.g., “[0,1,4,2]”

inline unsigned int Length() const#

Get the number of components in the index. When used to define a multivariate polynomial, this will return the dimension of the polynomial.

Returns:

The length of the multiindex. When used for defining multivariate polynomials, this will be the dimension of the polynomial.

bool operator==(const MultiIndex &b) const#

Check for equality of the multiindices.

Parameters:

b[in] The multiindex to compare with *this.

Returns:

true if both multiindices have the same lengths, nonzero indices, and nonzero values. Returns false otherwise.

bool operator!=(const MultiIndex &b) const#

Check if two multiindices are different.

Parameters:

b[in] The multiindex to compare with *this.

Returns:

false if both multiindices have the same lengths, nonzero indices, and nonzero values. true otherwise.

bool operator<(const MultiIndex &b) const#

Check if this multiindex is less than b. The multiindices are ordered such that:

a<b if:

  • the length of a is less than the length of b OR

  • the lengths are the same, but the total order of “a” is less than the total order of “b” OR

  • the length and total orders are the same, but the max value of “a” is less than the max value of “b” OR

  • the lengths, total orders, and max values are the same, but “a” is lexicographically less than “b”

Parameters:

b[in] The multiindex to compare with *this.

Returns:

true if *this < b according to the ordering described above. false otherwise.

bool operator>(const MultiIndex &b) const#

Check if this multiindex is greather than b. The multiindices are ordered such that:

a<b if:

  • the length of a is less than the length of b OR

  • the lengths are the same, but the total order of “a” is less than the total order of “b” OR

  • the length and total orders are the same, but the max value of “a” is less than the max value of “b” OR

  • the lengths, total orders, and max values are the same, but “a” is lexicographically less than “b”

Parameters:

b[in] The multiindex to compare with *this.

Returns:

true if *this > b according to the ordering described above. false otherwise.

bool operator>=(const MultiIndex &b) const#

Check if this multiindex is greater than or equal to b. This is checked by returning “not (a<b)”

Parameters:

b[in] The multiindex to compare with *this.

Returns:

true if *this >= b, false otherwise.

bool operator<=(const MultiIndex &b) const#

Check if this multiindex is greater than or equal to b. This is checked by returning “not (a>b)”

Parameters:

b[in] The multiindex to compare with *this.

Returns:

true if *this <= b, false otherwise.

bool AnyBounded(const MultiIndex &bound) const#

Similar to operator>=, but bound must same length or longer. Further, it only returns false if every value in this is less than every value in bound.

Parameters:

bound – bound for this multiindex

Returns:

true if any value this[j] is at or above bound[j]

Returns:

false else

bool HasNonzeroEnd() const#

Whether this index has a nonzero entry at the end.

Returns:

true if this has a nonzero entry at the end