Skip to content

Commit

Permalink
Add namespace to each subdirectory
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesYang007 committed Apr 19, 2020
1 parent f09ada0 commit 7341f48
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 11 deletions.
7 changes: 7 additions & 0 deletions include/autoppl/algorithm/mh.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once

namespace ppl {



} // namespace ppl
2 changes: 2 additions & 0 deletions include/autoppl/distribution/bernoulli.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <autoppl/distribution/dist_expr.hpp>

namespace ppl {
namespace dist {

template <typename p_type>
struct Bernoulli : public DistExpr<Bernoulli<p_type>>
Expand Down Expand Up @@ -43,4 +44,5 @@ struct Bernoulli : public DistExpr<Bernoulli<p_type>>
p_type p_;
};

} // namespace dist
} // namespace ppl
4 changes: 3 additions & 1 deletion include/autoppl/distribution/dist_expr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <type_traits>

namespace ppl {
namespace dist {

template <class Derived>
struct DistExpr
Expand All @@ -15,7 +16,7 @@ struct DistExpr

template <class T>
inline constexpr bool is_dist_expr_v =
std::is_convertible_v<T, DistExpr<T>>;
std::is_convertible_v<T, dist::DistExpr<T>>;

#ifdef AUTOPPL_USE_CONCEPTS
// TODO: definition should be extended with a stronger
Expand All @@ -24,4 +25,5 @@ template <class T>
concept dist_expressable = is_dist_expr_v<T>;
#endif

} // namespace dist
} // namespace ppl
4 changes: 3 additions & 1 deletion include/autoppl/distribution/normal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <autoppl/distribution/dist_expr.hpp>

namespace ppl {
namespace dist {

template <typename mean_type, typename var_type>
struct Normal : public DistExpr<Normal<mean_type, var_type>>
Expand Down Expand Up @@ -43,4 +44,5 @@ struct Normal : public DistExpr<Normal<mean_type, var_type>>
var_type var_;
};

} // namespace ppl
} // namespace dist
} // namespace ppl
2 changes: 2 additions & 0 deletions include/autoppl/distribution/uniform.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <autoppl/distribution/dist_expr.hpp>

namespace ppl {
namespace dist {

template <typename min_type, typename max_type>
struct Uniform : public DistExpr<Uniform<min_type, max_type>>
Expand Down Expand Up @@ -44,4 +45,5 @@ struct Uniform : public DistExpr<Uniform<min_type, max_type>>
max_type max_;
};

} // namespace dist
} // namespace ppl
14 changes: 9 additions & 5 deletions include/autoppl/expr_builder.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#pragma once
#include <autoppl/expression/variable.hpp>
#include <autoppl/expression/model_expr.hpp>
#include <autoppl/expression/var_expr.hpp>
#include <autoppl/expression/model.hpp>
#include <autoppl/expression/variable.hpp>
#include <autoppl/distribution/dist_expr.hpp>
#include <autoppl/distribution/uniform.hpp>
#include <autoppl/distribution/normal.hpp>
#include <autoppl/distribution/bernoulli.hpp>

namespace ppl {

Expand All @@ -20,7 +24,7 @@ namespace details {
using cont_raw_param_t = double;
template <class T>
inline constexpr bool is_cont_param_valid =
is_var_expr_v<T> ||
expr::is_var_expr_v<T> ||
std::is_convertible_v<T, cont_raw_param_t>;

} // namespace details
Expand Down Expand Up @@ -88,7 +92,7 @@ template <class T, class DistType>
inline constexpr auto operator|=(const Variable<T>& var,
const DistType& dist)
{
static_assert(is_dist_expr_v<DistType>);
static_assert(dist::is_dist_expr_v<DistType>);
return EqNode(var, dist);
}
#else
Expand All @@ -104,8 +108,8 @@ template <class LHSNodeType, class RHSNodeType>
inline constexpr auto operator,(const LHSNodeType& lhs,
const RHSNodeType& rhs)
{
static_assert(is_model_expr_v<LHSNodeType>);
static_assert(is_model_expr_v<RHSNodeType>);
static_assert(expr::is_model_expr_v<LHSNodeType>);
static_assert(expr::is_model_expr_v<RHSNodeType>);
return GlueNode(lhs, rhs);
}
#else
Expand Down
2 changes: 2 additions & 0 deletions include/autoppl/expression/model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <autoppl/expression/model_expr.hpp>

namespace ppl {
namespace expr {
namespace details {

template <class Iter>
Expand Down Expand Up @@ -95,4 +96,5 @@ struct GlueNode : public ModelExpr<GlueNode<LHSNodeType, RHSNodeType>>
right_node_t right_node_;
};

} // namespace expr
} // namespace ppl
2 changes: 2 additions & 0 deletions include/autoppl/expression/model_expr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <type_traits>

namespace ppl {
namespace expr {

template <class Derived>
struct ModelExpr
Expand All @@ -24,4 +25,5 @@ template <class T>
concept model_expressable = is_model_expr_v<T>;
#endif

} // namespace expr
} // namespace ppl
2 changes: 2 additions & 0 deletions include/autoppl/expression/var_expr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <type_traits>

namespace ppl {
namespace expr {

template <class Derived>
struct VarExpr
Expand All @@ -24,4 +25,5 @@ template <class T>
concept var_expressable = is_var_expr_v<T>;
#endif

} // namespace expr
} // namespace ppl
2 changes: 1 addition & 1 deletion include/autoppl/expression/variable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ enum class var_state : bool {
* a model expression and the users, who must supply storage of values associated with this var.
*/
template <class ValueType>
struct Variable : public VarExpr<Variable<ValueType>>
struct Variable : public expr::VarExpr<Variable<ValueType>>
{
using value_t = ValueType;
using pointer_t = value_t*;
Expand Down
4 changes: 3 additions & 1 deletion test/distribution/bernoulli_unittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "gtest/gtest.h"

namespace ppl {
namespace dist {

struct bernoulli_dist_fixture : ::testing::Test {
protected:
Expand Down Expand Up @@ -39,4 +40,5 @@ TEST_F(bernoulli_dist_fixture, bernoulli_sampling) {
}
}

} // ppl
} // namespace dist
} // namespace ppl
4 changes: 3 additions & 1 deletion test/distribution/normal_unittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "gtest/gtest.h"

namespace ppl {
namespace dist {

struct normal_dist_fixture : ::testing::Test {
protected:
Expand Down Expand Up @@ -43,4 +44,5 @@ TEST_F(normal_dist_fixture, simple_gaussian) {
EXPECT_DOUBLE_EQ(dist2.log_pdf(4), std::log(dist1.pdf(4)));
}

} // ppl
} // namespace dist
} // namespace ppl
4 changes: 3 additions & 1 deletion test/distribution/uniform_unittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "gtest/gtest.h"

namespace ppl {
namespace dist {

struct uniform_dist_fixture : ::testing::Test {
protected:
Expand Down Expand Up @@ -49,4 +50,5 @@ TEST_F(uniform_dist_fixture, uniform_sampling) {
}
}

} // ppl
} // namespace dist
} // namespace ppl
2 changes: 2 additions & 0 deletions test/expression/model_unittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <autoppl/expression/model.hpp>

namespace ppl {
namespace expr {

//////////////////////////////////////////////////////
// Model with one RV TESTS
Expand Down Expand Up @@ -196,4 +197,5 @@ TEST_F(many_var_dist_fixture, four_vars)
+ std::log(zv) + std::log(wv));
}

} // namespace expr
} // namespace ppl

0 comments on commit 7341f48

Please sign in to comment.