Added the ability to generate a tensor from a custom user defined 'generator'. This simplifies the creation of constant tensors initialized using specific regular patterns.

Created a gaussian window generator as a first use case.
This commit is contained in:
Benoit Steiner
2015-04-22 11:14:58 -07:00
parent 8838ed39f4
commit 91359e1d0a
7 changed files with 307 additions and 0 deletions

View File

@@ -57,6 +57,13 @@ class TensorBase<Derived, ReadOnlyAccessors>
return nullaryExpr(gen);
}
// Tensor generation
template <typename Generator> EIGEN_DEVICE_FUNC
EIGEN_STRONG_INLINE const TensorGeneratorOp<Generator, const Derived>
generate(const Generator& generator) const {
return TensorGeneratorOp<Generator, const Derived>(derived(), generator);
}
// Generic unary operation support.
template <typename CustomUnaryOp> EIGEN_DEVICE_FUNC
EIGEN_STRONG_INLINE const TensorCwiseUnaryOp<CustomUnaryOp, const Derived>