You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.3 KiB
46 lines
1.3 KiB
#pragma once
|
|
|
|
#include <functional>
|
|
|
|
#include <algorithm/fast_power.hpp>
|
|
#include <macros.h>
|
|
|
|
struct integrand_handle_base {
|
|
virtual ~integrand_handle_base() = default;
|
|
|
|
virtual double f(double x, double y, double z) const = 0;
|
|
virtual double w() const = 0;
|
|
virtual double w_without_grad() const = 0;
|
|
|
|
virtual bool strict_polynomial() const = 0;
|
|
};
|
|
|
|
// struct SIv2_API common_integrand_handle final : public integrand_handle_base {
|
|
// virtual ~common_integrand_handle() = default;
|
|
|
|
// virtual double f(double x, double y, double z) const { return handle(x, y, z); }
|
|
|
|
// virtual double w() const { return 1.; }
|
|
|
|
// virtual bool strict_polynomial() const { return false; }
|
|
|
|
// std::function<double(double, double, double)> handle{};
|
|
// };
|
|
|
|
struct SIv2_API polynomial_integrand_handle final : public integrand_handle_base {
|
|
virtual ~polynomial_integrand_handle() = default;
|
|
|
|
virtual double f(double x, double y, double z) const
|
|
{
|
|
return algorithm::fast_power(x, p1) * algorithm::fast_power(y, p2) * algorithm::fast_power(z, p3);
|
|
}
|
|
|
|
virtual double w() const { return coeff / (p1 + p2 + p3 + 3); }
|
|
|
|
virtual double w_without_grad() const { return coeff; }
|
|
|
|
virtual bool strict_polynomial() const { return true; }
|
|
|
|
double coeff{};
|
|
uint8_t p1{}, p2{}, p3{};
|
|
};
|