35 lines
1.7 KiB
C++
35 lines
1.7 KiB
C++
/// @file
|
|
/// @brief Task2: function declarations
|
|
|
|
#pragma once
|
|
|
|
#include <functional> // std::function
|
|
#include <vector> // std::vector
|
|
|
|
/// @brief Creates a sequence of equidistant values in a given interval (inclusive).
|
|
/// @param start Start of the interval
|
|
/// @param end End of the interval
|
|
/// @param N Number of values; assumption: N >= 2
|
|
/// @return Sequence of equidistant values in increasing order
|
|
std::vector<double> range(double start, double end, unsigned int N);
|
|
|
|
/// @brief Evaluates a one-dimensional scalar function at the provided discrete locations
|
|
/// @param values Sequence of discrete locations
|
|
/// @param func Callable with a signature compatible with f(double) -> double
|
|
/// @return Sequence of function values
|
|
std::vector<double> sample(std::vector<double> values, std::function<double(double)> func);
|
|
|
|
/// @brief Performs a numerical differentiation using a combined forward/center/backward difference scheme
|
|
/// @param x Discrete sequence of locations; assumption: two or more values, ascending, and equally spaced
|
|
/// @param y Discrete sequence of function values; assumption: same size as 'x'
|
|
/// @return Sequence of function values of the numerical derivative
|
|
std::vector<double> numdiff(std::vector<double> x, std::vector<double> y);
|
|
|
|
/// @brief Performs a numerical integration using the trapezoidal rule
|
|
/// @param x Discrete sequence of locations; assumption: two or more values, ascending, and equally spaced
|
|
/// @param y Discrete sequence of function values; assumption: same size as 'x'
|
|
/// @param C Constant of integration
|
|
/// @return Sequence of function values of the numerical antiderivative
|
|
std::vector<double> numint(std::vector<double> x, std::vector<double> y, double C);
|
|
|