Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
b5b94a4
Moved interpolant coefficients into an aligned struct with aligned el…
May 28, 2020
4386d2b
fixed memory usage calculation
May 28, 2020
68aba22
Arma messages no longer show if you opt out of using it
May 28, 2020
9bdc7b5
ALIGN is now of type std::size_t
May 29, 2020
5c73aab
Added a failureproof table that wraps any UniformLookupTable and made…
Jun 19, 2020
5c5a7d3
Made ArgumentRecord threadsafe
Jun 19, 2020
744a19c
small revisions
Jun 20, 2020
34ac1e6
test
Jun 20, 2020
f0ccb8d
Added autodiff types
Jun 22, 2020
d4e64b7
Initial AutoDiffTable
Jun 25, 2020
bbdafa0
Templated ZeroFunction
Jun 25, 2020
f79dbf0
Failed experimental version of func. Will rework into a better implem…
Jun 26, 2020
8b649ae
Added a FunctionContainer class to EvaluationFunctor which can hold o…
Jun 29, 2020
a69e3ec
Table generation takes advantage of automatic differentiation
Jun 29, 2020
a973f56
Now takes FunctionContainer as an arg, plus better exceptions added
Jun 29, 2020
be302bc
Now take FunctionContainer instead of EvaluationFunctor as constructo…
Jun 29, 2020
f6b32a3
Currently unused. Will most likely delete
Jun 29, 2020
7a69f28
Re-enabled generation of every table type
Jun 29, 2020
b83a458
Now build a FunctionContainer to pass to the UniformLookupTableGenerator
Jun 29, 2020
bc1f268
Added a comment about the classes inheriting from EvaluationImplement…
Jun 29, 2020
fcc99c7
Now use FunctionContainer to pass around a user generated function
Jun 29, 2020
3551486
Replaced EvaluationFunctor with FunctionContainer
Jul 3, 2020
55c8f08
tables now include FunctionContainer and use std::function
Jul 3, 2020
306890b
Examples now use std::function
Jul 3, 2020
7289eed
commented on the log's base
Jul 8, 2020
8b3486f
Added optional vector of special points
Jul 8, 2020
5442804
Moved failure proof tables
Jul 8, 2020
17e1882
added CompositeLookupTables
Jul 8, 2020
410e9ac
Better comments
Jul 11, 2020
64694d3
Fixed get_nth_func for gcc
Jul 11, 2020
f91b5c8
Moved files again
Jul 22, 2020
677e89c
Added a pp macro to build faster
Jul 22, 2020
3610a9f
added nonuniform tables and transfer function classes
Jul 23, 2020
be3517a
Better comments
Jul 23, 2020
25e918f
Public header is slightly easier to work with
Jul 24, 2020
c8ff832
fixed some includes
Jul 24, 2020
f5ad502
added member variables needed for function evaluation
Jul 24, 2020
abf67f6
More sensible parameters and added more methods of approximating g_inv
Jul 26, 2020
477409f
Fixed the interpolation
Jul 26, 2020
ce9d55f
NULUTs no longer own g and g_inv, and get them through their transfer…
Jul 27, 2020
1ea24dc
ULUT parameters uses a shared pointer for transfer function
Jul 27, 2020
907929b
Fixed hermite approx
Jul 27, 2020
9fe54b8
Added generation of nonuniform LUTs
Jul 27, 2020
728b3ef
removed function pair object
Jul 27, 2020
de6eb2f
Small changes to organization
Jul 27, 2020
5a216df
First draft check of Pade tables for roots in the denominators
Jul 28, 2020
71592c2
Every Pade table now checks its denominators for root
Jul 28, 2020
8f92610
Templated classes generating random numbers
Jul 30, 2020
af01860
Moved Timer to template only
Jul 30, 2020
1a30638
Changed usage of SpecialPoint
Jul 30, 2020
298b275
Easier to make if your function is inconvenient to template
Jul 30, 2020
65321af
Initial redesigned for CompositeLUT
Jul 30, 2020
9f255e5
Renamed and templated failure proof tables
Jul 31, 2020
4086ca1
Initial templating of LUTs before moving to header files
Jul 31, 2020
d68381a
Templated base classes
Jul 31, 2020
a9d017b
fixed examples
Jul 31, 2020
c60361b
temporary include files
Jul 31, 2020
1257332
Made 3 classes header only
Aug 3, 2020
1982202
moved some method declarations outside of the class
Aug 3, 2020
9006612
Simplified table registration macros
Aug 3, 2020
3ab72c3
Moved UniformLookupTableGenerator to header only
Aug 4, 2020
a9115bf
Better comments
Aug 4, 2020
569ddf2
Moved nontrivial function definitions out of the class definition
Aug 4, 2020
0a93614
Moved SpecialPoint to CompositeLookkupTable (Not 100% on this decisio…
Aug 4, 2020
bd2cdeb
Moved Armadillo tables to header only
Aug 4, 2020
be4a15a
Added macros to make inheriting from these templated base classes mor…
Aug 5, 2020
b1c2e37
Moved to header only
Aug 5, 2020
6f88081
removed cpp files
Aug 5, 2020
668b188
Small changes
Aug 5, 2020
be4da82
Config CMakeLists and other small changes
Aug 5, 2020
6896b4d
Changed CMakeLists such that our public header files still get put in…
Aug 7, 2020
002ab85
Optimized transfer functions
Aug 7, 2020
1235009
Added nonuniform cubic PI table and other small changes
Aug 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions examples/ZeroFunction.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once
#define FUNC(x) 0.0
#define FUNCNAME "Zero"

template <typename T>
T ZeroFunction(T x) { return FUNC(X); }
37 changes: 3 additions & 34 deletions examples/chaste_log_function.hpp
Original file line number Diff line number Diff line change
@@ -1,39 +1,8 @@
#pragma once
#include "EvaluationFunctor.hpp"
#include <cmath>
// base e
#define FUNC(x) (7.7-13.0287*log(x))
#define FUNCNAME "(7.7-13.0287*log(x))"

class MyFunction final : public EvaluationFunctor<double,double>
{
public:
double operator()(double x) override { return FUNC(x); }
double deriv(double x) override
{
return -13.0287/x;
}
double deriv2(double x) override
{
return 13.0287/x/x;
}
double deriv3(double x) override
{
return -26.0574/x/x/x;
}
double deriv4(double x) override
{
return 78.1722/x/x/x/x;
}
double deriv5(double x) override
{
return -312.6888/x/x/x/x/x;
}
double deriv6(double x) override
{
return 1563.444/x/x/x/x/x/x;
}
double deriv7(double x) override
{
return -9380.664/x/x/x/x/x/x/x;
}
};
template <typename T>
T MyFunction(T x) { return FUNC(x); }
4 changes: 2 additions & 2 deletions examples/compute_max_err_of_tables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ int main()
{
using namespace std;

MyFunction func;
FunctionContainer<double> func_container{SET_F(MyFunction,double)};

/* Which implementations to use */
std::vector<std::string> implNames {"UniformLinearInterpolationTable",
Expand All @@ -24,7 +24,7 @@ int main()
"UniformQuadraticTaylorTable",
"UniformCubicTaylorTable"};

UniformLookupTableGenerator gen(&func, MIN_ARG, MAX_ARG);
UniformLookupTableGenerator<double> gen(&func_container, MIN_ARG, MAX_ARG);

cout << "# Function: " << FUNCNAME << endl;
cout << "# h ";
Expand Down
76 changes: 52 additions & 24 deletions examples/experiment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,48 +44,76 @@ int main(int argc, char* argv[])
int nEvals = std::stoi(argv[5]);
unsigned int seed = std::stoi(argv[6]);

MyFunction func;
FunctionContainer<double> func_container{SET_F(MyFunction,double)};

double stepSize;

/* Check which implementations are available */
std::cout << "# Registered uniform tables: \n# ";
for (auto it : UniformLookupTableFactory::get_registry_keys() ) {
for (auto it : UniformLookupTableFactory<double>::get_registry_keys() ) {
std::cout << it << "\n# ";
}
std::cout << "\n";

/* Fill in the implementations */
std::vector<unique_ptr<EvaluationImplementation>> impls;
std::vector<unique_ptr<EvaluationImplementation<double>>> impls;

/* Which LUT implementations to use */
std::vector<std::string> implNames {"UniformLinearInterpolationTable",
"UniformLinearPrecomputedInterpolationTable",
"UniformQuadraticPrecomputedInterpolationTable",
"UniformCubicPrecomputedInterpolationTable",
"UniformArmadilloPrecomputedInterpolationTable<4>",
"UniformArmadilloPrecomputedInterpolationTable<5>",
"UniformArmadilloPrecomputedInterpolationTable<6>",
"UniformArmadilloPrecomputedInterpolationTable<7>",
"UniformPadeTable<1,1>",
"UniformPadeTable<2,2>",
"UniformPadeTable<3,3>",
"UniformPadeTable<4,3>",
"UniformLinearTaylorTable",
"UniformQuadraticTaylorTable",
"UniformCubicTaylorTable"};

UniformLookupTableGenerator gen(&func, tableMin, tableMax);
std::vector<std::string> implNames {
"UniformArmadilloPrecomputedInterpolationTable<4>",
"UniformArmadilloPrecomputedInterpolationTable<5>",
"UniformArmadilloPrecomputedInterpolationTable<6>",
"UniformArmadilloPrecomputedInterpolationTable<7>",
"UniformCubicHermiteTable",
"UniformCubicPrecomputedInterpolationTable",
"UniformCubicTaylorTable",
"UniformLinearInterpolationTable",
"UniformLinearPrecomputedInterpolationTable",
"UniformLinearTaylorTable",
"NonUniformLinearInterpolationTable",
"UniformQuadraticPrecomputedInterpolationTable",
"UniformQuadraticTaylorTable"
};

std::vector<std::string> padeNames {
"UniformPadeTable<1,1>",
"UniformPadeTable<2,1>",
"UniformPadeTable<3,1>",
"UniformPadeTable<4,1>",
"UniformPadeTable<5,1>",
"UniformPadeTable<6,1>",
"UniformPadeTable<2,2>",
"UniformPadeTable<3,2>",
"UniformPadeTable<4,2>",
"UniformPadeTable<5,2>",
"UniformPadeTable<3,3>",
"UniformPadeTable<4,3>",
};

UniformLookupTableGenerator<double> gen(&func_container, tableMin, tableMax);

/* add implementations to vector */
// unique_ptr<EvaluationImplementation> test = make_unique<DirectEvaluation>(&func,tableMin,tableMax);

impls.emplace_back(unique_ptr<EvaluationImplementation>(new DirectEvaluation(&func,tableMin,tableMax)));
impls.emplace_back(unique_ptr<EvaluationImplementation<double>>(new DirectEvaluation<double>(&func_container,tableMin,tableMax)));
for (auto itName : implNames) {
impls.emplace_back(gen.generate_by_tol(itName,tableTol));
}

/* Run comparator */
ImplementationComparator implCompare(impls, nEvals, seed);
//for (auto itName : padeNames) {
// impls.emplace_back(gen.generate_by_tol(itName,tableTol));
//}

//add a composite table. The generator doesn't converge with mid = the root
//and also this is far too specific for this experiment.
//double mid = exp(7.7/13.0287)+1;
//UniformLookupTableGenerator gen1(&func_container, tableMin, mid);
//UniformLookupTableGenerator gen2(&func_container, mid, tableMax);

//impls.emplace_back(unique_ptr<EvaluationImplementation>(
// new CompositeLookupTable({gen1.generate_by_tol(implNames[3],tableTol*(mid-tableMin)/(tableMax-tableMin)),
// gen2.generate_by_tol(implNames[7],tableTol*(tableMax-mid)/(tableMax-tableMin))})));

ImplementationComparator<double> implCompare(impls, nEvals, seed);
implCompare.run_timings(nExperiments);

/* Summarize the results */
Expand Down
20 changes: 7 additions & 13 deletions examples/experiment_best_worst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,8 @@
./experiment_best_worst <tableMin> <tableMax> <tableTol> <nExperiments> <nEvals> <seed>
*/

// #include "sin.hpp"
// #include "func.hpp"
#include "func.hpp"
#include "ZeroFunction.hpp"
// #include "chaste_log_function.hpp"

#include "ImplementationComparator.hpp"
#include "UniformLookupTableGenerator.hpp"
#include "UniformTables.hpp"
#include "DirectEvaluation.hpp"

#include <iostream>
#include <fstream>
Expand Down Expand Up @@ -43,7 +36,8 @@ int main(int argc, char* argv[])
int nEvals = std::stoi(argv[3]);
int seed = std::stoi(argv[4]);

ZeroFunction func;
FunctionContainer<double> func_container {SET_F(ZeroFunction,double)};

double stepSize;

/* Which LUT implementations to use */
Expand All @@ -68,10 +62,10 @@ int main(int argc, char* argv[])
std::cout << "\n# impls using ~ " << percentRam <<"% of RAM\n";
cout << "# Function: " << FUNCNAME << endl << endl;

UniformLookupTableGenerator gen(&func, 0, 1);
UniformLookupTableGenerator<double> gen(&func_container, 0, 1);

/* Fill in the implementations */
std::vector<unique_ptr<EvaluationImplementation>> impls;
std::vector<unique_ptr<EvaluationImplementation<double>>> impls;


/* Run the best case */
Expand All @@ -82,7 +76,7 @@ int main(int argc, char* argv[])
}

/* Run comparator */
ImplementationComparator implCompare_best(impls, nEvals, seed);
ImplementationComparator<double> implCompare_best(impls, nEvals, seed);
implCompare_best.run_timings(nExperiments);

/* Summarize the results */
Expand All @@ -108,7 +102,7 @@ int main(int argc, char* argv[])
}

/* Run comparator */
ImplementationComparator implCompare_worst(impls, nEvals, seed);
ImplementationComparator<double> implCompare_worst(impls, nEvals, seed);
implCompare_worst.run_timings(nExperiments);

/* Summarize the results */
Expand Down
6 changes: 3 additions & 3 deletions examples/generate_tables_at_tol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ int main()
{
using namespace std;

MyFunction func;
FunctionContainer<double> func_container{SET_F(MyFunction,double)};

cout << "# Function: " << FUNCNAME << "\n";
cout << "# Tol: " << TOL << "\n";

vector<unique_ptr<EvaluationImplementation>> impls;
vector<unique_ptr<EvaluationImplementation<double>>> impls;

/* Which LUT implementations to use */
vector<string> implNames {"UniformLinearInterpolationTable",
Expand All @@ -34,7 +34,7 @@ int main()
"UniformCubicTaylorTable"};


UniformLookupTableGenerator gen(&func, MIN_ARG, MAX_ARG);
UniformLookupTableGenerator<double> gen(&func_container, MIN_ARG, MAX_ARG);

for (auto itName : implNames) {
std::cout << "\nGenerating " << itName << ":" << std::endl;
Expand Down
5 changes: 3 additions & 2 deletions examples/plot_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ int main()
{
using namespace std;

MyFunction func;
FunctionContainer func_container;
func_container.double_func = new MyFunction<double>;

cout << "# Function: " << FUNCNAME << endl;
cout << "# h";
Expand All @@ -25,7 +26,7 @@ int main()
// UniformLookupTableGenerator<UniformLinearInterpolationTable>
// gen(&func,MIN_ARG,MAX_ARG,0.0);

UniformLookupTableGenerator gen(&func,MIN_ARG,MAX_ARG);
UniformLookupTableGenerator gen(&func_container,MIN_ARG,MAX_ARG);

gen.plot_implementation_at_step_size("UniformLinearInterpolationTable",STEP);

Expand Down
17 changes: 3 additions & 14 deletions examples/test_function.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,9 @@
#define FUNC(x) (7.7*x*exp(x)-13.0287*x*x*log(x)-x +13.0*x*x*x)
#define FUNCNAME "(7.7*x*exp(x)-13.0287*x*x*log(x)-x +13.0*x*x*x)"

class MyFunction final : public EvaluationFunctor<double,double>
template <typename T>
class MyFunction final : public EvaluationFunctor<T,T>
{
public:
double operator()(double x) override { return FUNC(x); }
double deriv(double x) override
{
return 7.7*exp(x)*(1.0+x) - 13.0287*(2.0*x*log(x)+x) - 1.0 + 39.0*x*x;
}
double deriv2(double x) override
{
return 7.7*exp(x)*(2.0+x) - 13.0287*(2.0*log(x)+3.0) + 78.0*x;
}
double deriv3(double x) override
{
return 7.7*exp(x)*(3.0+x) - 13.0287*(2.0/x) + 78.0;
}
T operator()(T x) override { return FUNC(x); }
};
71 changes: 0 additions & 71 deletions src/ArgumentRecord.cpp

This file was deleted.

Loading