Go to the documentation of this file.
27 #include <type_traits>
46 template<
class Distribution,
class Generator>
73 Sampler(Distribution&& dist, Generator&& gen):
84 template<
class...Args>
115 template<
class RealType>
133 template<
class Iterator,
class Generator>
134 void operator()(
const Iterator& first,
const Iterator& last, Generator& gen)
138 for (
auto it = first; it != last; ++it)
141 length += std::pow(*it, 2.0);
146 for (
auto it = first; it != last; ++it)
163 template<
class RealType>
185 template<
class Iterator,
class Generator>
186 void operator()(
const Iterator& first,
const Iterator& last, Generator& gen)
191 for (
auto it = first; it != last; ++it)
194 length += std::pow(*it, 2.0);
198 const auto scalingFactor = std::pow(
radDist(gen), 1.0 / dim);
200 for (
auto it = first; it != last; ++it)
202 *it = ((*it) / length) * scalingFactor;
213 std::uniform_real_distribution<RealType>
radDist;
219 template<
class RealType>
234 template<
class Iterator>
239 for (; boundsFirst != boundsLast; ++boundsFirst)
242 volume *= (boundsFirst->second - boundsFirst->first);
258 template<
class Iterator,
class Generator>
261 for (std::size_t i = 0; i <
spaceDist.size(); ++i, ++first)
273 template<
class Iterator>
276 for (std::size_t i = 0; i <
spaceDist.size(); ++i, ++first)
300 template<
class T = std::
size_t>
313 std::vector<std::uniform_real_distribution<RealType>>
spaceDist;
320 template<
class RealType =
float>
341 template<
class ValIter>
343 ValIter focalAFirst, ValIter focalALast,
369 template<
class ValIter>
371 ValIter focalAFirst, ValIter focalALast,
373 const std::vector<RealType>& rotationMatrix
398 template<
class Generator>
402 Eigen::Map<VecType> tmpVec {
tmpVal.data(), getDimensionality<long int>()};
412 template<
class T = std::
size_t>
415 return static_cast<T>(
tmpVal.size());
465 Eigen::Map<VecType> tmpVec {
tmpVal.data(), getDimensionality<long int>()};
466 tmpVec(0) = newPolarDiameter / 2.0;
468 const auto polarDiameterQuad = std::pow(newPolarDiameter, 2.0);
470 const auto equatorialRadius =
std::sqrt(polarDiameterQuad - distanceFocalPointsQuad) / 2.0;
474 tmpVec(i) = equatorialRadius;
501 template<
class IteratorType>
502 void setFocalPoints(IteratorType focalAFirst, IteratorType focalBFirst,
bool updateRotationMatrix =
true)
504 Eigen::Map<VecType> tmpVec {
tmpVal.data(), getDimensionality<long int>()};
508 for (std::size_t i = 0; i <
getDimensionality(); ++i, ++focalAFirst, ++focalBFirst)
517 tmpVec(i) = focalPointsDelta;
523 if (updateRotationMatrix)
558 Eigen::JacobiSVD<MatType, Eigen::NoQRPreconditioner> jacoby(
561 Eigen::ComputeFullV | Eigen::ComputeFullU
565 VecType diag = VecType::Ones(n);
567 diag(n - 1) = jacoby.matrixU().determinant() * jacoby.matrixV().determinant();
570 rotation = jacoby.matrixU() * diag.asDiagonal() * jacoby.matrixV().transpose();
625 template<
class RealType =
float>
641 template<
class ValIter,
class BoundsIter>
643 BoundsIter boundsFirst, BoundsIter boundsLast,
644 ValIter focalAFirst, ValIter focalALast,
646 const std::vector<RealType>& rotationMatrix
650 cMax {std::numeric_limits<RealType>::infinity()}
654 throw std::logic_error {
"differend bounds for spheroid and cuboid"};
668 template<
class ValIter,
class BoundsIter>
670 BoundsIter boundsFirst, BoundsIter boundsLast,
671 ValIter focalAFirst, ValIter focalALast,
676 cMax {std::numeric_limits<RealType>::infinity()}
680 throw std::logic_error {
"differend bounds for spheroid and cuboid"};
689 template<
class Generator>
692 if (
cMax < std::numeric_limits<RealType>::infinity())
762 template<
class T = std::
size_t>
VectorXD< D, T > sqrt(const VectorXD< D, T > &a)
Distribution & getDistribution()
Returns the stored distribution.
auto operator()(Args &&...args) -> decltype(distribution(std::forward< Args >(args)..., generator))
Passes all arguments followed by the generator to the distribution.
Sampler(Distribution &&dist, Generator &&gen)
Ctor.
std::vector< T > max(const std::vector< T > &v1, const std::vector< T > &v2)
Stores a distribution and a generator.
Generator generator
The stored generator.
void Identity(MatrixXX< N, N, T > *a)
Generator & getGenerator()
Returns the stored generator.
Use of this software is granted under one of the following two to be chosen freely by the user Boost Software License Version Marcin Kalicinski Permission is hereby free of to any person or organization obtaining a copy of the software and accompanying documentation covered by this and transmit the and to prepare derivative works of the and to permit third parties to whom the Software is furnished to do all subject to the including the above license this restriction and the following must be included in all copies of the in whole or in and all derivative works of the unless such copies or derivative works are solely in the form of machine executable object code generated by a source language processor THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF FITNESS FOR A PARTICULAR TITLE AND NON INFRINGEMENT IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN TORT OR ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE The MIT Marcin Kalicinski Permission is hereby free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to copy
Distribution DistributionType
Type of the stored distribution.
#define ARMARX_CHECK_EXPRESSION(expression)
This macro evaluates the expression and if it turns out to be false it will throw an ExpressionExcept...
Distribution distribution
The stored distribution.
double distance(const Point &a, const Point &b)
Generator GeneratorType
Type of the stored generator.
std::vector< std::vector< T > > transpose(const std::vector< std::vector< T >> &src, Thrower thrower)
This file offers overloads of toIce() and fromIce() functions for STL container types.
double norm(const Point &a)