Public Member Functions
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 99 of file SundanceMultipleDeriv.hpp.


Constructor & Destructor Documentation

Construct an empty multiple derivative

Definition at line 49 of file SundanceMultipleDeriv.cpp.

Referenced by factorOutDeriv().

Construct a first-order multiple deriv

Definition at line 53 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 58 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 239 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 153 of file SundanceMultipleDeriv.cpp.

MultiSet< int > MultipleDeriv::dofIDs ( ) const

Definition at line 107 of file SundanceMultipleDeriv.cpp.

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

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 138 of file SundanceMultipleDeriv.cpp.

References MultipleDeriv().

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

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 162 of file SundanceMultipleDeriv.cpp.

References MultipleDeriv().

Definition at line 92 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 255 of file SundanceMultipleDeriv.cpp.

Referenced by bitsOfAnInteger().

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

Definition at line 123 of file SundanceMultipleDeriv.cpp.

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

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

Return a multiindex representing the spatial derivs in this multiple derivative

Definition at line 78 of file SundanceMultipleDeriv.cpp.

Return the order of spatial differentiation in this derivative

Definition at line 65 of file SundanceMultipleDeriv.cpp.

Site Contact