Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Untangles all of our includes! #254

Merged
merged 30 commits into from
Mar 16, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
29c62a4
Updating makefile help
syclik Mar 3, 2016
17ea996
Updating comment in fwd/mat/functor/gradient.hpp
syclik Mar 3, 2016
a2f475d
Removing prim/arr header from prim/scal
syclik Mar 3, 2016
a3fb372
Fixing prim/scal/meta/scalar_type.hpp includes and adding mat test
syclik Mar 3, 2016
2563d58
Updating tests
syclik Mar 4, 2016
a846164
Updating includes
syclik Mar 4, 2016
cb731ec
Adding more to VectorBuilder and VectorBuilderHelper; added tests
syclik Mar 4, 2016
e86e3c8
Untangling more includes
syclik Mar 4, 2016
688acac
Cleaning up includes for neg_binomial_2_cdf functions
syclik Mar 4, 2016
d04dab1
Fixing includes on coupled_ode_system
syclik Mar 5, 2016
bb5b685
Splitting apart prim/mat/err/check_ordered_test.cpp
syclik Mar 5, 2016
ddccb14
Updating integrate_ode
syclik Mar 5, 2016
7dfd17e
Splitting apart OperandsAndPartials_test
syclik Mar 5, 2016
7a3af35
Moving VectorViewMvt to prim/mat/meta
syclik Mar 7, 2016
5ab6556
Reimplementing VectorView
syclik Mar 8, 2016
270c08a
Fixing more test includes
syclik Mar 9, 2016
02d7a88
Splitting apart OperandsAndPartials
syclik Mar 10, 2016
55e70b0
Including header for is_constant_struct
syclik Mar 10, 2016
25240a1
Fixing check_nonzero_size
syclik Mar 11, 2016
5653b99
Fixing doxygen
syclik Mar 11, 2016
7a7e69d
Fixing more includes
syclik Mar 11, 2016
a0b4cea
Cpplint
syclik Mar 11, 2016
1131b6c
Included stdexcept
syclik Mar 11, 2016
52b1b6d
Squashing a compiler warning in a test
syclik Mar 11, 2016
57ab0ed
Fixed one last OperandsAndPartials thing
syclik Mar 11, 2016
55690fc
Fixing use of VectorBuilder
syclik Mar 12, 2016
9ca5021
Fixing neg_binonial_2
syclik Mar 12, 2016
d3f05ae
cpplint
syclik Mar 13, 2016
ddc580d
Moving check_nonzero_size to arr and fixing behavior to act like it d…
syclik Mar 14, 2016
7e49dc2
added to VectorView doc
Mar 16, 2016
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
Prev Previous commit
Next Next commit
Updating tests
  • Loading branch information
syclik committed Mar 10, 2016
commit 2563d584e15640227e6cb9ae51a95b00be13cc6a
3 changes: 3 additions & 0 deletions stan/math/prim/arr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
#include <stan/math/prim/arr/meta/container_view.hpp>
#include <stan/math/prim/arr/meta/get.hpp>
#include <stan/math/prim/arr/meta/index_type.hpp>
#include <stan/math/prim/arr/meta/is_constant_struct.hpp>
#include <stan/math/prim/arr/meta/is_vector.hpp>
#include <stan/math/prim/arr/meta/length.hpp>

#include <stan/math/prim/arr/fun/dist.hpp>
#include <stan/math/prim/arr/fun/dot.hpp>
#include <stan/math/prim/arr/fun/dot_self.hpp>
#include <stan/math/prim/arr/fun/log_sum_exp.hpp>
#include <stan/math/prim/arr/fun/promote_scalar.hpp>
#include <stan/math/prim/arr/fun/promote_scalar_type.hpp>
#include <stan/math/prim/arr/fun/rep_array.hpp>
#include <stan/math/prim/arr/fun/scaled_add.hpp>
#include <stan/math/prim/arr/fun/sub.hpp>
Expand Down
44 changes: 44 additions & 0 deletions stan/math/prim/arr/fun/promote_scalar.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#ifndef STAN_MATH_PRIM_ARR_FUN_PROMOTE_SCALAR_HPP
#define STAN_MATH_PRIM_ARR_FUN_PROMOTE_SCALAR_HPP

#include <stan/math/prim/scal/fun/promote_scalar.hpp>
#include <stan/math/prim/scal/fun/promote_scalar_type.hpp>
#include <stan/math/prim/arr/meta/index_type.hpp>
#include <vector>

namespace stan {
namespace math {

/**
* Struct to hold static function for promoting underlying scalar
* types. This specialization is for standard vector inputs.
*
* @tparam T return scalar type
* @tparam S input type for standard vector elements in static
* nested function, which must have an underlying scalar type
* assignable to T.
*/
template <typename T, typename S>
struct promote_scalar_struct<T, std::vector<S> > {
/**
* Return the standard vector consisting of the recursive
* promotion of the elements of the input standard vector to the
* scalar type specified by the return template parameter.
*
* @param x input standard vector.
* @return standard vector with values promoted from input vector.
*/
static std::vector<typename promote_scalar_type<T, S>::type>
apply(const std::vector<S>& x) {
typedef std::vector<typename promote_scalar_type<T, S>::type> return_t;
typedef typename index_type<return_t>::type idx_t;
return_t y(x.size());
for (idx_t i = 0; i < x.size(); ++i)
y[i] = promote_scalar_struct<T, S>::apply(x[i]);
return y;
}
};

}
}
#endif
28 changes: 28 additions & 0 deletions stan/math/prim/arr/fun/promote_scalar_type.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef STAN_MATH_PRIM_ARR_FUN_PROMOTE_SCALAR_TYPE_HPP
#define STAN_MATH_PRIM_ARR_FUN_PROMOTE_SCALAR_TYPE_HPP

#include <stan/math/prim/scal/fun/promote_scalar_type.hpp>
#include <vector>

namespace stan {
namespace math {

/**
* Template metaprogram to calculate a type for a container whose
* underlying scalar is converted from the second template
* parameter type to the first.
*
* @tparam T result scalar type.
* @tparam S input type
*/
template <typename T, typename S>
struct promote_scalar_type<T, std::vector<S> > {
/**
* The promoted type.
*/
typedef std::vector<typename promote_scalar_type<T, S>::type> type;
};

}
}
#endif
17 changes: 17 additions & 0 deletions stan/math/prim/arr/meta/is_constant_struct.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#ifndef STAN_MATH_PRIM_ARR_META_IS_CONSTANT_STRUCT_HPP
#define STAN_MATH_PRIM_ARR_META_IS_CONSTANT_STRUCT_HPP

#include <stan/math/prim/scal/meta/is_constant.hpp>
#include <stan/math/prim/scal/meta/is_constant_struct.hpp>
#include <vector>

namespace stan {

template <typename T>
struct is_constant_struct<std::vector<T> > {
enum { value = is_constant_struct<T>::value };
};

}
#endif

1 change: 1 addition & 0 deletions stan/math/prim/mat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <stan/math/prim/mat/meta/container_view.hpp>
#include <stan/math/prim/mat/meta/get.hpp>
#include <stan/math/prim/mat/meta/index_type.hpp>
#include <stan/math/prim/mat/meta/is_constant_struct.hpp>
#include <stan/math/prim/mat/meta/is_vector.hpp>
#include <stan/math/prim/mat/meta/is_vector_like.hpp>
#include <stan/math/prim/mat/meta/length.hpp>
Expand Down
23 changes: 23 additions & 0 deletions stan/math/prim/mat/meta/is_constant_struct.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef STAN_MATH_PRIM_MAT_META_IS_CONSTANT_STRUCT_HPP
#define STAN_MATH_PRIM_MAT_META_IS_CONSTANT_STRUCT_HPP

#include <stan/math/prim/arr/meta/is_constant_struct.hpp>
#include <stan/math/prim/mat/fun/Eigen.hpp>
#include <stan/math/prim/scal/meta/is_constant.hpp>


namespace stan {

template <typename T, int R, int C>
struct is_constant_struct<Eigen::Matrix<T, R, C> > {
enum { value = is_constant_struct<T>::value };
};

template <typename T>
struct is_constant_struct<Eigen::Block<T> > {
enum { value = is_constant_struct<T>::value };
};

}
#endif

34 changes: 0 additions & 34 deletions stan/math/prim/scal/fun/promote_scalar.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@

#include <stan/math/prim/scal/fun/promote_scalar_type.hpp>
#include <stan/math/prim/scal/meta/index_type.hpp>
#include <vector>

namespace stan {

namespace math {

/**
Expand Down Expand Up @@ -55,36 +53,6 @@ namespace stan {
}
};

/**
* Struct to hold static function for promoting underlying scalar
* types. This specialization is for standard vector inputs.
*
* @tparam T return scalar type
* @tparam S input type for standard vector elements in static
* nested function, which must have an underlying scalar type
* assignable to T.
*/
template <typename T, typename S>
struct promote_scalar_struct<T, std::vector<S> > {
/**
* Return the standard vector consisting of the recursive
* promotion of the elements of the input standard vector to the
* scalar type specified by the return template parameter.
*
* @param x input standard vector.
* @return standard vector with values promoted from input vector.
*/
static std::vector<typename promote_scalar_type<T, S>::type>
apply(const std::vector<S>& x) {
typedef std::vector<typename promote_scalar_type<T, S>::type> return_t;
typedef typename index_type<return_t>::type idx_t;
return_t y(x.size());
for (idx_t i = 0; i < x.size(); ++i)
y[i] = promote_scalar_struct<T, S>::apply(x[i]);
return y;
}
};

/**
* This is the top-level function to call to promote the scalar
* types of an input of type S to type T.
Expand All @@ -100,8 +68,6 @@ namespace stan {
return promote_scalar_struct<T, S>::apply(x);
}


}
}

#endif
24 changes: 0 additions & 24 deletions stan/math/prim/scal/fun/promote_scalar_type.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
#ifndef STAN_MATH_PRIM_SCAL_FUN_PROMOTE_SCALAR_TYPE_HPP
#define STAN_MATH_PRIM_SCAL_FUN_PROMOTE_SCALAR_TYPE_HPP

#include <vector>

namespace stan {

namespace math {


/**
* Template metaprogram to calculate a type for converting a
* convertible type. This is the base case.
Expand All @@ -23,26 +19,6 @@ namespace stan {
typedef T type;
};


/**
* Template metaprogram to calculate a type for a container whose
* underlying scalar is converted from the second template
* parameter type to the first.
*
* @tparam T result scalar type.
* @tparam S input type
*/
template <typename T, typename S>
struct promote_scalar_type<T, std::vector<S> > {
/**
* The promoted type.
*/
typedef std::vector<typename promote_scalar_type<T, S>::type> type;
};


}

}

#endif
19 changes: 0 additions & 19 deletions stan/math/prim/scal/meta/is_constant_struct.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
#define STAN_MATH_PRIM_SCAL_META_IS_CONSTANT_STRUCT_HPP

#include <stan/math/prim/scal/meta/is_constant.hpp>
#include <stan/math/prim/mat/fun/Eigen.hpp>
#include <vector>


namespace stan {

Expand All @@ -17,21 +14,5 @@ namespace stan {
enum { value = is_constant<T>::value };
};

template <typename T>
struct is_constant_struct<std::vector<T> > {
enum { value = is_constant_struct<T>::value };
};

template <typename T, int R, int C>
struct is_constant_struct<Eigen::Matrix<T, R, C> > {
enum { value = is_constant_struct<T>::value };
};

template <typename T>
struct is_constant_struct<Eigen::Block<T> > {
enum { value = is_constant_struct<T>::value };
};

}
#endif

3 changes: 0 additions & 3 deletions stan/math/prim/scal/meta/scalar_type_pre.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
#define STAN_MATH_PRIM_SCAL_META_SCALAR_TYPE_PRE_HPP

#include <stan/math/prim/scal/meta/is_vector.hpp>
#include <stan/math/prim/mat/meta/is_vector.hpp>
#include <stan/math/prim/arr/meta/is_vector.hpp>
#include <stan/math/prim/mat/meta/value_type.hpp>
#include <stan/math/prim/scal/meta/value_type.hpp>

namespace stan {
Expand Down
4 changes: 0 additions & 4 deletions stan/math/prim/scal/meta/size_of.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@
#define STAN_MATH_PRIM_SCAL_META_SIZE_OF_HPP

#include <stan/math/prim/scal/meta/is_vector.hpp>
#include <stan/math/prim/mat/meta/is_vector.hpp>
#include <stan/math/prim/arr/meta/is_vector.hpp>

namespace stan {



template<typename T, bool is_vec>
struct size_of_helper {
static size_t size_of(const T& /*x*/) {
Expand Down
12 changes: 12 additions & 0 deletions test/unit/math/prim/arr/fun/promote_scalar_type_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <stan/math/prim/arr.hpp>
#include <gtest/gtest.h>
#include <test/unit/math/prim/scal/fun/promote_type_test_util.hpp>

TEST(MathFunctionsPromoteScalarType,StdVector) {
using std::vector;
expect_promote_type<vector<vector<double> >,
double, vector<vector<int> > >();
expect_promote_type<vector<vector<double> >,
double, vector<vector<double> > >();
}

9 changes: 0 additions & 9 deletions test/unit/math/prim/scal/fun/promote_scalar_type_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,3 @@ TEST(MathFunctionsPromoteScalarType,primitive) {
expect_promote_type<vector<double>,
double, vector<int> >();
}

TEST(MathFunctionsPromoteScalarType,StdVector) {
using std::vector;
expect_promote_type<vector<vector<double> >,
double, vector<vector<int> > >();
expect_promote_type<vector<vector<double> >,
double, vector<vector<double> > >();
}