Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F63809382
Function.hpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, May 22, 15:20
Size
1 KB
Mime Type
text/x-c++
Expires
Fri, May 24, 15:20 (2 d)
Engine
blob
Format
Raw Data
Handle
17822048
Attached To
R7917 Guggisberg-Liardon - Numerical integration
Function.hpp
View Options
/*
* Created by Tristan Liardon on 02.12.2018.
*
* A function object that needs a pointer to a user defined function. This allows the user defined function to be called
* using a simple syntax FunctionObject.GetResult(input) from everywhere without risking mistakes in the complex
* writing of the function pointer argument.
*
* For using a function-object :
* - Create a method that accepts vector<double> and return a double
* - Create a pointer to the method created above. You can use the following syntax :
* double (*functionPointer)(vector<double>) = &myFunction;
* - Gives functionPointer as arguments to the Function's constructor
*
*/
#ifndef PCSC_PROJET_FUNCTION_HPP
#define PCSC_PROJET_FUNCTION_HPP
#include <vector>
#include <cmath>
#include "OutOfRangeException.hpp"
#include "Exception.hpp"
using
namespace
std
;
class
Function
{
public
:
// Constructor and destructor
Function
();
explicit
Function
(
double
(
*
functionPointer_
)(
vector
<
double
>
));
virtual
~
Function
();
// Get result function
double
GetResult
(
vector
<
double
>
input
);
private
:
double
(
*
functionPointer
)(
vector
<
double
>
);
// Pointer to the user-defined function
};
#endif
//PCSC_PROJET_FUNCTION_HPP
Event Timeline
Log In to Comment