Revision 6c9b2bd7dc6837bf459c9ceaa80114d0cbc15f10 authored by Dmitry Yu. Naumov on 23 March 2021, 15:07:49 UTC, committed by Dmitry Yu. Naumov on 23 March 2021, 15:07:49 UTC
[CMake] Third-party license, ccache setup and msvc folder See merge request ogs/ogs!3535
WeightedSum.h
/**
* \file
* \copyright
* Copyright (c) 2012-2021, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#pragma once
namespace MathLib
{
namespace detail {
template <unsigned I, typename Method>
struct SUM
{
template <typename F>
static
double
add(F const& f)
{
return f(Method::X[I - 1]) * Method::W[I - 1] + SUM<I - 1, Method>::add(f);
}
};
/// Anchor for the SUM recursion always returning 0.
/// \tparam Method Integration method.
template <typename Method>
struct SUM<0, Method>
{
template <typename F>
static double add(F const& /*unused*/)
{
return 0;
}
};
} // namespace detail
/// Computes weighted sum using given integration method.
/// The weighted sum over all positions x_i in the integration method is computed
/// as follows:
/// \\sum_{i = 0..Method::Order} (f(x_i) * w_i).
///
/// \tparam Method Integration method.
template <typename Method>
struct WeightedSum
{
/// \tparam Func Function type.
template <typename Func>
static
double
add(Func const& f)
{
return detail::SUM<Method::Order, Method>::add(f);
}
};
} // namespace MathLib
Computing file changes ...