Skip to content
Snippets Groups Projects
Commit a7d1db2f authored by Kevin Höllring's avatar Kevin Höllring
Browse files

Add lambda wrapper from exercise 3

parent 09db76ef
No related branches found
No related tags found
No related merge requests found
#ifndef __LAMBDA_WRAPPER_H__
#define __LAMBDA_WRAPPER_H__
#include <cassert>
#include <vector>
#include <cmath>
#include <cstdint>
#include <iostream>
#include "function.h"
#include <functional>
namespace numerics {
template <typename argtype, typename valtype>
class LambdaWrapper : public Function<argtype, valtype> {
public:
LambdaWrapper(std::function<valtype(argtype)> func, size_t indim, size_t outdim) : input_dim(indim), output_dim(outdim), f(func) {}
virtual valtype operator()(argtype arg) const override {
return f(arg);
};
virtual size_t input_dimension() const override {
return input_dim;
}
virtual size_t output_dimension() const override {
return output_dim;
}
protected:
size_t input_dim, output_dim;
std::function < valtype(argtype)> f;
};
}; // namespace numerics
#endif
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment