Sample#

File: samarium/math/sample.hpp

namespace sm
namespace math

Functions

template<typename Input, typename Output>
auto sample(FunctionRef<Output(Input)> function, Input from, Input to, u64 steps)

Sample a function at n values.

Template Parameters:
  • Input – Type of input to function

  • Output – Return type of function

Parameters:
  • function – Input function to sample

  • from – Start of range (inclusive)

  • to – End of range (exclusive)

  • steps – Number of times to sample

Returns:

std::vector<Output>

template<typename Output = f64, typename Input = f64>
auto integral(FunctionRef<Output(Input)> function, Input from, Input to, u64 steps)

Integrate a function by sampling at n values and summing.

Template Parameters:
  • Input – Type of input to function

  • Output – Return type of function

Parameters:
  • function – Input function to sample

  • from – Start of range (inclusive)

  • to – End of range (exclusive)

  • steps – Number of times to sample

Returns:

std::vector<Output>