diff --git a/ex1/epsilon.cpp b/ex1/epsilon.cpp index c6a209ccc42eafc737390c43157710dbecb8a967..440f5e2468e7bd4fe89cf207beae9046b4c329f7 100644 --- a/ex1/epsilon.cpp +++ b/ex1/epsilon.cpp @@ -1,3 +1,15 @@ +/* + Pascal: Looks good to me, albeit not necessarily precise. + + Note that python's import is very different from preprocessor directives. + In python, there is a whole import machinery, while the #include directive + merely instructs the preprocessor to copy-paste a specific file. + + Personally, I'm not a fan of 'using namespace xxx'. At the very least, you + pollute the global namespace and make it harder to keep track of where specific + functions and classes are actually coming from. +*/ + // "include" is like the import in Python #include <iostream> // namespace allow us to group named entities into narrower scopes, that otherwise @@ -5,7 +17,7 @@ using namespace std; void machineEpsilon(float EPS) { - + float prev_epsilon = EPS; while ((1+EPS) != 1){ @@ -20,4 +32,3 @@ void machineEpsilon(float EPS) { int main(){ machineEpsilon(0.5); } - diff --git a/ex1/main.cpp b/ex1/main.cpp index c6cb9d29741fc061ffbd97ca5b0492c062bde00a..0d8eedaabdfde94cf6251b9fef80205902698227 100644 --- a/ex1/main.cpp +++ b/ex1/main.cpp @@ -1,3 +1,7 @@ +/* + Pascal: Looks good to me. +*/ + # include <iostream> using namespace std; diff --git a/ex1/simpson.cpp b/ex1/simpson.cpp index 183612271855d047871a46c80ab06e56312251f2..e19a0c57d038eb3f6440a459df1249eeac78ba17 100644 --- a/ex1/simpson.cpp +++ b/ex1/simpson.cpp @@ -1,3 +1,12 @@ +/* + Pascal: Looks good to me. + + You could still optimize the number of mathematical operations. For example, + per call to calculateSimpsonIntegral, you only need one multiplication with + binSize/6, as opposed to the N you are performing. You are also calling f + more often than necessary. +*/ + //Simpson's integration method #include <iostream> #include <cmath>