Sundance::MultipleDeriv Class Reference

Inheritance diagram for Sundance::MultipleDeriv:

Sundance::MultiSet< Deriv > multiset

List of all members.

Public Member Functions

 MultipleDeriv ()
 MultipleDeriv (const Deriv &d)
 MultipleDeriv (const Deriv &d1, const Deriv &d2)
int order () const
int spatialOrder () const
MultiIndex spatialDeriv () const
void productRulePermutations (ProductRulePerms &perms) const
MultipleDeriv product (const MultipleDeriv &other) const
MultipleDeriv factorOutDeriv (const Deriv &x) const
MultipleDeriv factorOutDeriv (const MultipleDeriv &x) const
bool containsDeriv (const MultipleDeriv &x) const
bool isInRequiredSet (const Set< MultiSet< int > > &funcCombinations, const Set< MultiIndex > &multiIndices) const
MultiSet< FunctionIdentifierfuncIDs () const
MultiSet< int > dofIDs () const

Static Public Member Functions

Utilities used in computing product rule permutations


static int pow2 (int n)
static Array< int > bitsOfAnInteger (int x, int n)


Detailed Description

Class MultipleDeriv is a multiple functional derivative operator represented as a multiset of first-order derivatives. The derivatives are each Deriv objects, so the multiple derivative can be an arbitrary mixture of spatial and functional derivatives.

Product rule application

Class MultipleDeriv contains a utility method for computing the derivatives that appear in the general product rule, as used in automatic differentiation of products and spatial derivatives. The arbitrary order, multivariable product rule gives the derivative of a product $L\cdot R$ with respect to a multiset of variables $\{u_1, u_2, \dots, u_N\}$ as the sum

\[ D_{u_1} D_{u_2} \cdots D_{u_N} (L \cdot R) =\sum_{i=1}^{2^N} \left[\prod_{j=1}^N D_{u_j}^{b_{i,j}}\right] L \times \left[\prod_{j=1}^N D_{u_j}^{1-b_{i,j}}\right] R\]

where $b_{i,j}$ is the $j$-th bit in the binary representation of $i$. Method productRulePermutations() enumerates all the permutations that apply to the left and right operands in this sum, and returns the arrays of left operators and right operators through non-const reference arguments. The left and right arguments return

\[ {\rm left = Array}_{i=1}^{2^N} \{\prod_{j=1}^N D_{u_j}^{b_{i,j}}\}\]

\[ {\rm right = Array}_{i=1}^{2^N} \{\prod_{j=1}^N D_{u_j}^{1-b_{i,j}}\}\]

Each element in these arrays is a multiple derivative, and is naturally represented with a MultipleDeriv object.

Definition at line 88 of file SundanceMultipleDeriv.hpp.


Constructor & Destructor Documentation

MultipleDeriv::MultipleDeriv (  ) 

Construct an empty multiple derivative

Definition at line 38 of file SundanceMultipleDeriv.cpp.

Referenced by factorOutDeriv().

MultipleDeriv::MultipleDeriv ( const Deriv d  ) 

Construct a first-order multiple deriv

Definition at line 42 of file SundanceMultipleDeriv.cpp.

References Sundance::MultiSet< Deriv >::put().

MultipleDeriv::MultipleDeriv ( const Deriv d1,
const Deriv d2 
)

Construct a second-order multiple deriv

Definition at line 47 of file SundanceMultipleDeriv.cpp.

References Sundance::MultiSet< Deriv >::put().


Member Function Documentation

Array< int > MultipleDeriv::bitsOfAnInteger ( int  x,
int  n 
) [static]

Compute the n bits of an integer x < 2^n. The bits are ordered least-to-most significant.

Definition at line 228 of file SundanceMultipleDeriv.cpp.

References pow2().

bool MultipleDeriv::containsDeriv ( const MultipleDeriv x  )  const

Return true is all single derivatives appearing in x also appear in this.

Definition at line 142 of file SundanceMultipleDeriv.cpp.

MultiSet< int > MultipleDeriv::dofIDs (  )  const

Definition at line 96 of file SundanceMultipleDeriv.cpp.

References Sundance::MultiSet< Key >::put().

MultipleDeriv MultipleDeriv::factorOutDeriv ( const MultipleDeriv x  )  const

Return a copy of this derivative, but with all single derivs in the the argument removed. For example, if <t>this</t> is $ \{u,v,w\} $, calling <t>factorOutDeriv(u,v)</t> will return $\{w\}$.

Definition at line 151 of file SundanceMultipleDeriv.cpp.

References MultipleDeriv().

MultipleDeriv MultipleDeriv::factorOutDeriv ( const Deriv x  )  const

Return a copy of this derivative, but with the specified single derivative removed. For example, if <t>this</t> is $ \{u,v,w\} $, calling <t>factorOutDeriv(v)</t> will return $\{u,w\}$.

Definition at line 127 of file SundanceMultipleDeriv.cpp.

References MultipleDeriv().

Referenced by Sundance::DiffOpEvaluator::backedDerivs(), and Sundance::DiffOpEvaluator::remainder().

MultiSet< FunctionIdentifier > MultipleDeriv::funcIDs (  )  const

Definition at line 81 of file SundanceMultipleDeriv.cpp.

References Sundance::MultiSet< Key >::put().

bool MultipleDeriv::isInRequiredSet ( const Set< MultiSet< int > > &  funcCombinations,
const Set< MultiIndex > &  multiIndices 
) const

int Sundance::MultipleDeriv::order (  )  const [inline]

int MultipleDeriv::pow2 ( int  n  )  [static]

Compute the n-th power of 2

Definition at line 244 of file SundanceMultipleDeriv.cpp.

Referenced by bitsOfAnInteger().

MultipleDeriv MultipleDeriv::product ( const MultipleDeriv other  )  const

return the product of two multiple derivatives, which is the union of the two multisets

Definition at line 112 of file SundanceMultipleDeriv.cpp.

References Sundance::MultiSet< Key >::put().

Referenced by Sundance::chainRuleTerms(), and Sundance::FunctionalPolynomial::multiplyPoly().

void MultipleDeriv::productRulePermutations ( ProductRulePerms perms  )  const

MultiIndex MultipleDeriv::spatialDeriv (  )  const

Return a multiindex representing the spatial derivs in this multiple derivative

Definition at line 67 of file SundanceMultipleDeriv.cpp.

int MultipleDeriv::spatialOrder (  )  const

Return the order of spatial differentiation in this derivative

Definition at line 54 of file SundanceMultipleDeriv.cpp.

Site Contact