-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Did some stuff with quads and watched Simpson
- Loading branch information
Showing
3 changed files
with
73 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#ifndef QM_QUADRATURE_H_ | ||
#define QM_QUADRATURE_H_ | ||
#include <functional> | ||
|
||
namespace QM{ | ||
|
||
template <size_t N> | ||
constexpr float quadrature(const std::function<float(float)>& f, float a, float b) | ||
{ | ||
const float alpha{(b-a)/N}; | ||
float sum=0.5f*(f(a)+f(b)); | ||
for(size_t i=1; i< N-1;++i)sum+=f(a+i*alpha); | ||
|
||
return alpha*sum; | ||
} | ||
|
||
|
||
|
||
} | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#ifndef QUICK_MATH_H_ | ||
#define QUICK_MATH_H_ | ||
|
||
#include <cstdint> | ||
|
||
|
||
namespace QM{ | ||
|