-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
df7b1b5
commit 9083bb0
Showing
20 changed files
with
498 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,4 @@ | |
^\.docs | ||
^\.development | ||
^index.html | ||
^compile_flags.txt |
Empty file.
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,12 @@ | ||
#define STANDALONE_ETR | ||
// #define DERIV_ETR | ||
#include "../inst/include/etr.hpp" | ||
using namespace etr; | ||
|
||
int main() { | ||
Vec<double> v = coca(1, 2, 3, 4); | ||
Evaluate(v); | ||
Evaluate(coca(1, 2, 3)); | ||
auto res = Evaluate(v + v); | ||
print(res); | ||
} |
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,66 @@ | ||
#include <optional> | ||
#include <stdexcept> | ||
#include <type_traits> | ||
#define STANDALONE_ETR | ||
// #define DERIV_ETR | ||
#include "../inst/include/etr.hpp" | ||
using namespace etr; | ||
|
||
// TODO: | ||
// 1. Place SubsetClass in Vec --> done | ||
// 2. Add tests in subset_test --> done | ||
// a. is rvalue --> done | ||
// b. is arithmetic value --> done | ||
// 3. Dependent on the second test the arguments to subset_test are moved or not | ||
// --> done | ||
// 4. To ponder over: | ||
// a. How to subset matrices --> overload subset function. Calculate indices | ||
// and put them in SubsetClass | ||
// b. Is it maybe a good idea to calculate the | ||
// indices once and use them afterwards? | ||
|
||
// TODO: missing subset of subset: auto five = subset_test(v, subset_test(v, | ||
// coca(1, 3))); | ||
|
||
// TODO: missing subset a 'subset of subset' with something | ||
// Or subset a calculation with something | ||
|
||
void test_subset_test_with_scalar() { | ||
Vec<int> l = coca(1, 2, 3, 4); | ||
int scalar = 2; | ||
auto result1 = subset_test(l, scalar); | ||
static_assert(std::is_same_v<decltype(result1), int>); | ||
auto result2 = subset_test(l, 2.4); | ||
static_assert(std::is_same_v<decltype(result2), int>); | ||
ass<"Expected 2">(result1 == 2); | ||
ass<"Expected 2">(result2 == 2); | ||
auto result3 = subset_test(l, true); | ||
ass<"Expected length 4">(result3.size() == 4); | ||
auto result4 = subset_test(l, false); | ||
ass<"Expected length 4">(result4.size() == 0); | ||
try { | ||
auto result = subset_test(l, 0); | ||
} catch (std::exception &e) { | ||
std::string expected = | ||
"Error: out of boundaries --> value beyond size of vector"; | ||
ass(e.what() == expected, "Expected out of boundary error"); | ||
} | ||
try { | ||
auto result = subset_test(l, 0.4); | ||
std::cout << result << std::endl; | ||
} catch (std::exception &e) { | ||
std::string expected = | ||
"Error: out of boundaries --> value beyond size of vector"; | ||
ass(e.what() == expected, "Expected out of boundary error"); | ||
} | ||
auto result5 = subset_test(l + l, 2); | ||
ass<"Expected 4">(result5 == 4); | ||
auto result6 = subset_test(l + 1, 2); | ||
ass<"Expected 3">(result6 == 3); | ||
auto result7 = subset_test(subset_test(l + 1, coca(1, 2)), 1); | ||
ass<"Expected 2">(result7 == 2); | ||
// auto result8 = subset_test(subset_test(l + 1, 1), 1); // Catched by static | ||
// assert | ||
} | ||
|
||
int main() { test_subset_test_with_scalar(); } |
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 |
---|---|---|
@@ -1,8 +1,7 @@ | ||
[ | ||
{ | ||
"directory": "/home/konrad/Documents/GitHub/RProjects/ast2ast_supplement/ast2ast", | ||
"command": "clang++ -std=c++20 -DSTANDALONE_ETR -DDERIV_ETR ./src/BaseStore_Tests.cpp -I ./inst/include/", | ||
"file": "./src/BaseStore_Tests.cpp" | ||
"command": "clang++ -std=c++20 -DSTANDALONE_ETR ./.development/test_lazy_subsetting.cpp -I ./inst/include/ -I./inst/include/etr_bits/", | ||
"file": "./.development/test_lazy_subsetting.cpp" | ||
} | ||
] | ||
|
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,3 @@ | ||
-Iinst/include | ||
-std=c++20 | ||
|
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
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
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
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,33 @@ | ||
#include "BufferVector.hpp" | ||
#include "Core.hpp" | ||
#include <cstddef> | ||
|
||
#ifndef EVALUATE_HPP | ||
#define EVALUATE_HPP | ||
|
||
|
||
namespace etr { | ||
// NOTE: evaluates a Subset or a calculation and returns the result | ||
// If something else is passed as argument it is forwarded | ||
|
||
template<typename T> | ||
inline auto Evaluate(T && obj) { | ||
using CaseTrait = | ||
typename std::remove_reference<decltype(obj.d)>::type::CaseTrait; | ||
if constexpr(std::is_same_v<CaseTrait, UnaryTrait> || | ||
std::is_same_v<CaseTrait, BinaryTrait> || | ||
std::is_same_v<CaseTrait, SubsetClassTrait>) { | ||
using RetType = typename std::remove_reference<decltype(obj)>::type::RetType; | ||
Vec<RetType, Buffer<RetType, BufferTrait>, VectorTrait> res(SI{obj.size()}); | ||
for (size_t i = 0; i < res.size(); i++) { | ||
res[i] = obj.d[i]; | ||
} | ||
return res; | ||
} else { | ||
return std::forward<decltype(obj)>(obj); | ||
} | ||
} | ||
|
||
} | ||
|
||
#endif |
Oops, something went wrong.