Skip to content

Commit

Permalink
Using Gaalet cpp0x.
Browse files Browse the repository at this point in the history
  • Loading branch information
laffernandes committed Feb 3, 2020
1 parent d619805 commit ceef0dc
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 103 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ Here, we assume that `ga-benchmark` is the current folder and Linux operating sy
```bash
svn checkout https://svn.code.sf.net/p/gaalet/code/trunk libs/Gaalet/repository
mkdir -p libs/Gaalet/install/include/gaalet
cp libs/Gaalet/repository/include/cpp/* libs/Gaalet/install/include/gaalet
cp libs/Gaalet/repository/include/cpp0x/* libs/Gaalet/install/include/gaalet
```

### Gaalop
Expand Down
1 change: 0 additions & 1 deletion Types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include <random>
#include <vector>

#include <execinfo.h>
#include <benchmark/benchmark.h>

namespace gabm {
Expand Down
91 changes: 12 additions & 79 deletions gabm_results.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {
"scrolled": true
},
Expand All @@ -52,7 +52,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {
"scrolled": true
},
Expand All @@ -73,17 +73,9 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Reading JSON files: 100%|█████████████████████████████████████████████████████████| 1161/1161 [00:01<00:00, 705.95it/s]\n"
]
}
],
"outputs": [],
"source": [
"input_path = path.join(path.abspath(getcwd()), 'build') # Assuming that the working directory is '<path-to>/ga-benchmark' and input data is in '<path-to>/ga-benchmark/build' folder.\n",
"data = read_data(folder=input_path, verbose=False)"
Expand All @@ -98,7 +90,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"metadata": {
"scrolled": true
},
Expand Down Expand Up @@ -134,40 +126,11 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "d981a37777354152bdd2c84328278ca3",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HTML(value='<p style=\"line-height: 1.5\"><b>Context:</b> Build using GNU Compiler Collection (version 7.4.0) in…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "2d9866d1878642de8ee882a3edd7e5f4",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Tab(children=(VBox(children=(Checkbox(value=True, description='GATL', indent=False), Checkbox(value=True, desc…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"def make_configuration_gui(given_data: dict) -> dict:\n",
" given_solutions, given_models, given_operations = available_data(given_data)\n",
Expand Down Expand Up @@ -270,26 +233,11 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "859dfdebeaa74583a06260b30faa901f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HTML(value='<!DOCTYPE html><html><head><style>.verticalTableHeader {text-align: center; line-height: 1.0; whit…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"display(widgets.HTML(value=make_table_of_features(data=filter_data(data), solutions=SOLUTIONS), placeholder='Table of Features'))"
]
Expand All @@ -309,29 +257,14 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The following tables classify the compared solutions using the \"gold first method\", *i.e.,* based first on the number of gold medals, then silver, and so on. The medals are distributed among the solutions for testing cases implemented by all of them."
"The following tables classify the compared solutions using the gold first method, *i.e.,* based first on the number of gold medals, then silver, and so on. The medals are distributed among the solutions for testing cases implemented by all of them."
]
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ed41b905f4954f7bb7ffe84526ffc713",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HTML(value='<!DOCTYPE html><html><head><style>table, th, td {border: 1px solid black; border-collapse: collaps…"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"tables = make_ranking(data=filter_data(data), solutions=SOLUTIONS)\n",
"for table in tables:\n",
Expand Down
25 changes: 9 additions & 16 deletions source/Gaalet/SpecializedAlgebra.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
#include <utility>
#include <gaalet.h>

using namespace gaalet;

#if GABM_CHECK_MODEL(ConformalModel)

// Gaalet requires mapping from Minkoski to Conformal and vice-versa.
Expand All @@ -37,21 +35,21 @@ using namespace gaalet;

#else

using space = algebra<signature<(GABM_D_DIMENSIONS) + 1, 1>, gabm::real_t>;
using space = gaalet::algebra<gaalet::signature<(GABM_D_DIMENSIONS) + 1, 1>, gabm::real_t>;

#endif

#elif GABM_CHECK_MODEL(EuclideanModel)

using space = algebra<signature<GABM_D_DIMENSIONS, 0>, gabm::real_t>;
using space = gaalet::algebra<gaalet::signature<GABM_D_DIMENSIONS, 0>, gabm::real_t>;

#elif GABM_CHECK_MODEL(HomogeneousModel)

using space = algebra<signature<(GABM_D_DIMENSIONS) + 1, 0>, gabm::real_t>;
using space = gaalet::algebra<gaalet::signature<(GABM_D_DIMENSIONS) + 1, 0>, gabm::real_t>;

#elif GABM_CHECK_MODEL(MinkowskiModel)

using space = algebra<signature<(GABM_D_DIMENSIONS) + 1, 1>, gabm::real_t>;
using space = gaalet::algebra<gaalet::signature<(GABM_D_DIMENSIONS) + 1, 1>, gabm::real_t>;

#endif

Expand All @@ -67,14 +65,14 @@ using namespace gaalet;
template<typename Type>
inline decltype(auto) svalue(Type const &value) noexcept {
using result_t = typename space::mv<0>::type;
return result_t(value);
return result_t({value});
}

// Helper function to define unit basis vectors (the first index is 1).
template<std::size_t Index>
inline decltype(auto) e() noexcept {
using result_t = typename space::mv<(1 << (Index - 1))>::type;
return result_t(1);
return result_t({1});
}

// Helper function to define vectors.
Expand All @@ -90,7 +88,7 @@ using namespace gaalet;
inline decltype(auto) vector(Types &&... coords) noexcept {
static_assert(GABM_N_DIMENSIONS == sizeof...(Types), "The number of coordinates must be equal to the number of dimensions of the vector space.");
using result_t = typename _gaalet_vector_impl<std::make_index_sequence<GABM_N_DIMENSIONS> >::type;
return result_t(std::move(coords)...);
return result_t({std::move(coords)...});
}

// Other constant values and helper functions.
Expand Down Expand Up @@ -122,7 +120,7 @@ using namespace gaalet;

inline decltype(auto) pseudoscalar() noexcept {
using result_t = typename space::mv<(1 << GABM_N_DIMENSIONS) - 1>::type;
return result_t(1);
return result_t({1});
}

static auto const I = pseudoscalar();
Expand All @@ -132,7 +130,7 @@ using namespace gaalet;
inline decltype(auto) euclidean_vector(Types &&... coords) noexcept {
static_assert(GABM_D_DIMENSIONS == sizeof...(Types), "The number of coordinates must be equal to the number of dimensions of the Euclidean vector space.");
using result_t = typename _gaalet_vector_impl<std::make_index_sequence<GABM_D_DIMENSIONS> >::type;
return result_t(std::move(coords)...);
return result_t({std::move(coords)...});
}

template<typename... Types>
Expand All @@ -141,11 +139,6 @@ using namespace gaalet;
return vector(std::move(coords)..., (aux - 1) * 0.5, (aux + 1) * 0.5);
}

template<typename ArgumentType>
inline decltype(auto) dual(ArgumentType const &arg) noexcept {
return eval(arg * invI);
}

template<typename ArgumentType>
inline decltype(auto) undual(ArgumentType const &arg) noexcept {
return eval(arg * I);
Expand Down
10 changes: 5 additions & 5 deletions source/Gaalet/SpecializedAlgorithmInverseKinematics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,31 +41,31 @@ GABM_DEFINE_ALGORITHM_INVERSE_KINEMATICS(ang1, ang2, ang3, ang4, ang5) {
auto Jg = point(Jg_x, Jg_y, Jg_z);

auto Pz = point(0.0, 0.0, 1.0);
auto Lz = dual(no ^ Pz ^ ni);
auto Lz = eval(dual(no ^ Pz ^ ni));
auto R1 = expp((ang1 * 0.5) * Lz);

auto P2_help = point(J1_x, J1_y + 1.0, J1_z);
auto L2init = dual(J1 ^ P2_help ^ ni);
auto L2init = eval(dual(J1 ^ P2_help ^ ni));
auto L2 = apply_rotor(R1, L2init);
auto R2 = expp((ang2 * 0.5) * L2);

auto J2_f = apply_rotor(R2 * R1, J2);

auto P3_help = point(J2_x, J2_y + 1.0, J2_z);
auto L3init = dual(J2 ^ P3_help ^ ni);
auto L3init = eval(dual(J2 ^ P3_help ^ ni));
auto L3 = apply_rotor(R2 * R1, L3init);
auto R3 = expp((ang3 * 0.5) * L3);

auto J2_rot1 = apply_rotor(R1, J2);
auto t2 = euclidean_vector(element<1>(J2_f) - element<1>(J2_rot1), element<2>(J2_f) - element<2>(J2_rot1), element<3>(J2_f) - element<3>(J2_rot1));
auto T2 = expp(-0.5 * (t2 ^ ni));

auto L4init = dual(J3 ^ Jg ^ ni);
auto L4init = eval(dual(J3 ^ Jg ^ ni));
auto L4 = apply_rotor(R3 * T2 * R1, unit(L4init));
auto R4 = expp((ang4 * 0.5) * L4);

auto Pg_help = point(J3_x, J3_y + 1.0, J3_z);
auto Lginit = dual(J3 ^ Pg_help ^ ni);
auto Lginit = eval(dual(J3 ^ Pg_help ^ ni));
auto Lg = apply_rotor(R4 * R3 * T2 * R1, Lginit);
auto Rg = expp((ang5 * 0.5) * Lg);

Expand Down
4 changes: 3 additions & 1 deletion source/Gaalet/SpecializedUnaryOperations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@

GABM_REPORT_UNARY_OPERATION_IS_NOT_IMPLEMENTED(CliffordConjugation)

GABM_REPORT_UNARY_OPERATION_IS_NOT_IMPLEMENTED(Dualization)
GABM_DEFINE_UNARY_OPERATION(Dualization, arg) {
return eval(dual(arg));
}

GABM_REPORT_UNARY_OPERATION_IS_NOT_IMPLEMENTED(GradeInvolution)

Expand Down

0 comments on commit ceef0dc

Please sign in to comment.