Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
radj307 committed Jan 25, 2024
1 parent 51c97d4 commit e46bf6a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 23 deletions.
16 changes: 1 addition & 15 deletions calc/calc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ inline const std::vector<std::pair<std::vector<std::string>, std::function<void(
<< " Functions must be called with the correct number of parameters, or an exception is thrown." << '\n'
;
} }),
std::make_pair(std::vector<std::string>{ "debug", "dbg" }, [](std::ostream& os, print_help const& h) { {
std::make_pair(std::vector<std::string>{ "debug", "dbg" }, [](std::ostream& os, print_help const& h) { {
os
<< "USAGE:\n"
<< " " << h.executableName << " -d -- \"<EXPRESSION>\"" << '\n'
Expand Down Expand Up @@ -155,24 +155,10 @@ inline std::string num_to_oct(calc::Number const&);
inline std::string num_to_dec(calc::Number const&);
inline std::string num_to_hex(calc::Number const&);

#include <calc_exception.hpp>

int main(const int argc, char** argv)
{
using namespace calc;

namespace mp = boost::multiprecision;
using cpp_float = mp::cpp_dec_float_100;
using cpp_int = mp::cpp_int;

cpp_int i{ 2 };
cpp_float f{ 0.5 };

//mp::hypot(f, f);
//mp::cbrt(i);
mp::cbrt(f);


try {
opt3::ArgManager args{ argc, argv,
// capturing argument defs:
Expand Down
14 changes: 6 additions & 8 deletions libcalc/include/FunctionMap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
#include <var.hpp> //< for concepts
#include <print_table.hpp> //< for term::print_table

// boost
#include <boost/math_fwd.hpp>

// stl
#include <cmath> //< for math functions
#include <cstdint> //< for std::uint8_t (for clarity)
Expand Down Expand Up @@ -40,11 +37,11 @@ namespace calc {

/// Exponential and Logarithmic Functions
std::make_pair("exp", std::make_tuple(new func(exp), "Compute exponential function")),
//std::make_pair("frexp", std::make_tuple(new func( frexpl ), "Get significand and exponent")), //< uses pointers, must be adapted
//std::make_pair("frexp", std::make_tuple(new func( frexpl ), "Get significand and exponent")), //< uses pointers
std::make_pair("ldexp", std::make_tuple(new func(ldexp), "Generate value from significand and exponent")),
std::make_pair("log", std::make_tuple(new func(log), "Compute natural logarithm")),
std::make_pair("log10", std::make_tuple(new func(log10), "Compute common logarithm")),
//std::make_pair("modf", std::make_tuple(new func( modfl ), "Break into fractional and integral parts")), //< uses pointers, must be adapted
//std::make_pair("modf", std::make_tuple(new func( modfl ), "Break into fractional and integral parts")), //< uses pointers
std::make_pair("exp2", std::make_tuple(new func(exp2), "Compute binary exponential function")),
std::make_pair("expm1", std::make_tuple(new func(expm1), "Compute exponential minus one")),
std::make_pair("ilogb", std::make_tuple(new func(ilogb), "Integer binary logarithm")),
Expand Down Expand Up @@ -92,6 +89,7 @@ namespace calc {
public:
~FunctionMap()
{
// delete all of the raw function pointers
for (auto& pr : map) {
if (auto* ptr = std::get<0>(pr.second)) {
delete ptr;
Expand Down Expand Up @@ -136,9 +134,9 @@ namespace calc {
{
return os << term::print_table(m.map.begin(), m.map.end(), {
{ "Function", [](auto&& pr) { return pr.first; } },
{ "Param#", [](auto&& pr) { return std::to_string(std::get<0>(pr.second)->getParamsCount()); }, term::HorizontalAlignment::Center },
{ "Description", [](auto&& pr) { return std::get<1>(pr.second); } },
});
{ "Param#", [](auto&& pr) { return std::to_string(std::get<0>(pr.second)->getParamsCount()); }, term::HorizontalAlignment::Center },
{ "Description", [](auto&& pr) { return std::get<1>(pr.second); } },
});
}
};
}

0 comments on commit e46bf6a

Please sign in to comment.