![]() |
|
Used to perform math operations on VdfIndexedWeights. More...
#include <indexedWeightsOperand.h>
Inherits VdfIndexedData< T >.
Public Types | |
| enum | SetOperation { Union , Intersection } |
| The set operation used by binary operations. More... | |
Public Member Functions | |
| VDF_API | VdfIndexedWeightsOperand (SetOperation setOperation, const VdfIndexedWeights *externalWeights=NULL) |
Creates an indexed weights operand with the given setOperation and optional external weights. | |
| VDF_API void | Swap (VdfIndexedWeights *v) |
| Swaps the indexed weights held by this opernad with the given indexed weights. | |
| VDF_API void | PruneZeros (const std::vector< This > &operands) |
Prunes zeros according to the set operation and the indices in operands. | |
| VDF_API void | Fill (const std::vector< This > &operands, double fillWeight, bool nonZeroSetOperation) |
Fills this operand with fillWeight according to the set operation and the indices in operands. | |
| VDF_API size_t | GetNumMathErrors () const |
Returns the number of math errors (weights which are inf or NaN). | |
| VDF_API void | ClearMathErrors () |
| Clears any pending math errors. | |
| This | operator- () const |
| Returns a new VdfIndexedWeightsOperand having the weights of this object negated. | |
| This | operator+ (double s) const |
Returns a new VdfIndexedWeightsOperand having the scalar s added to the weights of this object. | |
| This | operator- (double s) const |
Returns a new VdfIndexedWeightsOperand having the scalar s subtracted from the weights of this object. | |
| This | operator* (double s) const |
Returns a new VdfIndexedWeightsOperand having the weights of this object multiplied by scalar s. | |
| This | operator/ (double s) const |
Returns a new VdfIndexedWeightsOperand having the weights of this object divided by scalar s. | |
| This | operator+ (const This &v) const |
Returns a new VdfIndexedWeightsOperand having the weights of VdfIndexedWeightsOperand v added to the weights of this object. | |
| This | operator- (const This &v) const |
Returns a new VdfIndexedWeightsOperand having the weights of VdfIndexedWeightsOperand v subtracted from the weights of this object. | |
| This | operator* (const This &v) const |
Returns a new VdfIndexedWeightsOperand having the weights of this object multiplied by the weights of VdfIndexedWeightsOperand v. | |
| This | operator/ (const This &v) const |
Returns a new VdfIndexedWeightsOperand having the weights of this object divided by the weights of VdfIndexedWeightsOperand v. | |
| VDF_API This | operator< (const This &v) const |
| Component-wise comparisons. | |
| VDF_API This | operator<= (const This &v) const |
| VDF_API This | operator> (const This &v) const |
| VDF_API This | operator>= (const This &v) const |
| VDF_API This | operator== (const This &v) const |
| VDF_API This | operator!= (const This &v) const |
| VDF_API This | operator< (double x) const |
| VDF_API This | operator<= (double x) const |
| VDF_API This | operator> (double x) const |
| VDF_API This | operator>= (double x) const |
| VDF_API This | operator== (double x) const |
| VDF_API This | operator!= (double x) const |
| VDF_API This | acos () const |
| Standard math library functions. | |
| VDF_API This | acosh () const |
| VDF_API This | asin () const |
| VDF_API This | asinh () const |
| VDF_API This | atan () const |
| VDF_API This | atanh () const |
| VDF_API This | atan2 (const This &v) const |
| VDF_API This | ceil () const |
| VDF_API This | cos () const |
| VDF_API This | cosh () const |
| VDF_API This | exp () const |
| VDF_API This | fabs () const |
| VDF_API This | floor () const |
| VDF_API This | fmod (float denominator) const |
| VDF_API This | log () const |
| VDF_API This | log10 () const |
| VDF_API This | pow (float exponent) const |
| VDF_API This | sin () const |
| VDF_API This | sinh () const |
| VDF_API This | sqrt () const |
| VDF_API This | tan () const |
| VDF_API This | tanh () const |
| VDF_API This | min (const This &v) const |
| Range-of-weights methods. | |
| VDF_API This | max (const This &v) const |
Returns a new VdfIndexedWeightsOperand where each indexed weight is the maximum of that weight in this object and the corresponding weight in VdfIndexedWeightsOperand v. | |
| VDF_API This | min (float min) const |
Returns a new VdfIndexedWeightsOperand where each indexed weight is the minimum of that weight in this object and the scalar min. | |
| VDF_API This | max (float max) const |
Returns a new VdfIndexedWeightsOperand where each indexed weight is the minimum of that weight in this object and the scalar min. | |
| VDF_API This | clamp (float min, float max) const |
Returns a new VdfIndexedWeightsOperand where each indexed weight is clamped between the scalars min and max. | |
| VDF_API This | smoothstep (float min, float max, float slope0=0, float slope1=0) const |
Returns a new VdfIndexedWeightsOperand where each indexed weight is smoothsteped between the scalars min and max with slopes slope0 and slope1. | |
| VDF_API This | smoothramp (float min, float max, float shoulder0, float shoulder1) const |
Returns a new VdfIndexedWeightsOperand where each indexed weight is smoothramped between the scalars min and max with "shoulder lengths" shoulder0 and shoulder1. | |
| VDF_API This | lerp (const This &v, float a) const |
Returns a new VdfIndexedWeightsOperand where each indexed weight is lerped from itself and a corresponding weight in VdfIndexedWeightsOperand v using scalar a. | |
| VDF_API This | lerp (const This &v, const This &a) const |
Returns a new VdfIndexedWeightsOperand where each indexed weight is lerped from itself and a corresponding weight in VdfIndexedWeightsOperand v using VdfIndexedWeightsOperand a. | |
Debugging API | |
| bool | HasExternalWeights () const |
| Returns whether or not this object references external weights. | |
Friends | |
| VDF_API This | operator- (double, const This &) |
| VDF_API This | operator/ (double, const This &) |
Used to perform math operations on VdfIndexedWeights.
This class adds functionality for adding, multiplying, dividing, comparing, etc. VdfIndexedWeights with other VdfIndexedWeights or scalars. The weights data can be externally referenced, in which case the lifetime of the operand object must not exceed the lifetime of the referenced weights. The reason for allowing externally referenced weights is to avoid unnecessary copies of VdfIndexedWeights. VdfIndexedWeightsOperand are typically transient objects that only exist during a computation and the result is stored as a VdfIndexedWeights.
XXX:exec BE VERY CAREFUL NOT TO USE THESE AS YOU WOULD A VdfIndexedWeights. The API here can be tightened to make it harder for client code to misuse this class. This class has very unusual read/write semantics.
Definition at line 39 of file indexedWeightsOperand.h.
| enum SetOperation |
The set operation used by binary operations.
When applying a binary operator to two indexed weights operands there are really two (independent) operations that get applied to compute the resulting indexed weights. The first is the operation that is applied to the weights (this is typically an arithmetic or comparison operation), and then there is the set operation that gets applied to the operand index sets to determine which indices should be part of the result.
For convenience the set operation is for now not specified when invoking an operator, but instead it is part of the operand. This requires that all operands in an expression have the same set operations. If we ever want to allow more general expressions we would need to come up with new operators, e.g. operator +& could mean addition of weight with index set union, and *| could mean multiplication of weights with index set intersection.
Definition at line 62 of file indexedWeightsOperand.h.
|
explicit |
Creates an indexed weights operand with the given setOperation and optional external weights.
Note that the indexed weights operand does not take over ownership of the external weights, see class documentation for details.
| VDF_API This acos | ( | ) | const |
Standard math library functions.
Each of these functions returns a new VdfIndexedWeightsOperand in which the specified math function is applied to the weights of this object.
| VDF_API This clamp | ( | float | min, |
| float | max | ||
| ) | const |
Returns a new VdfIndexedWeightsOperand where each indexed weight is clamped between the scalars min and max.
| VDF_API void ClearMathErrors | ( | ) |
Clears any pending math errors.
Note that this sets all weights with math errors to 0.
| VDF_API void Fill | ( | const std::vector< This > & | operands, |
| double | fillWeight, | ||
| bool | nonZeroSetOperation | ||
| ) |
Fills this operand with fillWeight according to the set operation and the indices in operands.
All operands must have the same set operation as this operand, and note that the previous indices of this operand are discarded. If the set operation is union, indices that have at least one corresponding index in operands are set (and if nonZeroSetOperation is true at least one of the corresponding weights must also be non-zero). If the set operation is intersection, indices that are in all operands are set (and if nonZeroSetOperation is true all their weights must be non-zero).
| VDF_API size_t GetNumMathErrors | ( | ) | const |
Returns the number of math errors (weights which are inf or NaN).
|
inline |
Returns whether or not this object references external weights.
Definition at line 336 of file indexedWeightsOperand.h.
Returns a new VdfIndexedWeightsOperand where each indexed weight is lerped from itself and a corresponding weight in VdfIndexedWeightsOperand v using VdfIndexedWeightsOperand a.
Returns a new VdfIndexedWeightsOperand where each indexed weight is lerped from itself and a corresponding weight in VdfIndexedWeightsOperand v using scalar a.
Returns a new VdfIndexedWeightsOperand where each indexed weight is the maximum of that weight in this object and the corresponding weight in VdfIndexedWeightsOperand v.
| VDF_API This max | ( | float | max | ) | const |
Returns a new VdfIndexedWeightsOperand where each indexed weight is the minimum of that weight in this object and the scalar min.
Range-of-weights methods.
Returns a new VdfIndexedWeightsOperand where each indexed weight is the minimum of that weight in this object and the corresponding weight in VdfIndexedWeightsOperand v.
| VDF_API This min | ( | float | min | ) | const |
Returns a new VdfIndexedWeightsOperand where each indexed weight is the minimum of that weight in this object and the scalar min.
Returns a new VdfIndexedWeightsOperand having the weights of this object multiplied by the weights of VdfIndexedWeightsOperand v.
Definition at line 191 of file indexedWeightsOperand.h.
|
inline |
Returns a new VdfIndexedWeightsOperand having the weights of this object multiplied by scalar s.
Definition at line 158 of file indexedWeightsOperand.h.
Returns a new VdfIndexedWeightsOperand having the weights of VdfIndexedWeightsOperand v added to the weights of this object.
Definition at line 174 of file indexedWeightsOperand.h.
|
inline |
Returns a new VdfIndexedWeightsOperand having the scalar s added to the weights of this object.
Definition at line 142 of file indexedWeightsOperand.h.
|
inline |
Returns a new VdfIndexedWeightsOperand having the weights of this object negated.
Definition at line 134 of file indexedWeightsOperand.h.
Returns a new VdfIndexedWeightsOperand having the weights of VdfIndexedWeightsOperand v subtracted from the weights of this object.
Definition at line 183 of file indexedWeightsOperand.h.
|
inline |
Returns a new VdfIndexedWeightsOperand having the scalar s subtracted from the weights of this object.
Definition at line 150 of file indexedWeightsOperand.h.
Returns a new VdfIndexedWeightsOperand having the weights of this object divided by the weights of VdfIndexedWeightsOperand v.
Definition at line 199 of file indexedWeightsOperand.h.
|
inline |
Returns a new VdfIndexedWeightsOperand having the weights of this object divided by scalar s.
Definition at line 166 of file indexedWeightsOperand.h.
Component-wise comparisons.
Each of these functions returns a new VdfIndexedWeightsOperand in which the weight value at at each index is 1.0 if the comparison holds true for the corresponding weights in this and the compared object (or the weight in this object and the provided scalar value) and 0.0 if not. In effect, the returned object consists of the boolean result of the comparison at each indexed weight, cast to floating-point values.
| VDF_API void PruneZeros | ( | const std::vector< This > & | operands | ) |
Prunes zeros according to the set operation and the indices in operands.
All operands must have the same set operation as this operand. If the set operation is union, this removes all indices whose corresponding weights from operands are all zero. If the set operation is intersection, this removes all indices that has a single corresponding weight from operands which is zero. Note that this removes indices regardless of actual weight values in the operand itself.
| VDF_API This smoothramp | ( | float | min, |
| float | max, | ||
| float | shoulder0, | ||
| float | shoulder1 | ||
| ) | const |
Returns a new VdfIndexedWeightsOperand where each indexed weight is smoothramped between the scalars min and max with "shoulder lengths" shoulder0 and shoulder1.
| VDF_API This smoothstep | ( | float | min, |
| float | max, | ||
| float | slope0 = 0, |
||
| float | slope1 = 0 |
||
| ) | const |
Returns a new VdfIndexedWeightsOperand where each indexed weight is smoothsteped between the scalars min and max with slopes slope0 and slope1.
| VDF_API void Swap | ( | VdfIndexedWeights * | v | ) |
Swaps the indexed weights held by this opernad with the given indexed weights.
If this indexed weights operand has external weights these will get copied before the swap.