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

Consistently use 'long int' for return of size functions #3086

Merged
merged 7 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Use int64_t
  • Loading branch information
WardBrian committed Jun 17, 2024
commit bd85f663ff1a0e256e1ca359f557622ac8c906b9
3 changes: 2 additions & 1 deletion stan/math/prim/fun/cols.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <stan/math/prim/fun/Eigen.hpp>
#include <stan/math/prim/meta.hpp>
#include <cstdint>

namespace stan {
namespace math {
Expand All @@ -16,7 +17,7 @@ namespace math {
* @return Number of columns.
*/
template <typename T, require_matrix_t<T>* = nullptr>
inline long int cols(const T& m) {
inline int64_t cols(const T& m) {
return m.cols();
}

Expand Down
7 changes: 4 additions & 3 deletions stan/math/prim/fun/num_elements.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <stan/math/prim/fun/Eigen.hpp>
#include <stan/math/prim/meta.hpp>
#include <cstdint>
#include <vector>

namespace stan {
Expand All @@ -16,7 +17,7 @@ namespace math {
* @return 1
*/
template <typename T, require_stan_scalar_t<T>* = nullptr>
inline long int num_elements(const T& x) {
inline int64_t num_elements(const T& x) {
return 1;
}

Expand All @@ -29,7 +30,7 @@ inline long int num_elements(const T& x) {
* @return size of matrix
*/
template <typename T, require_matrix_t<T>* = nullptr>
inline long int num_elements(const T& m) {
inline int64_t num_elements(const T& m) {
return m.size();
}

Expand All @@ -43,7 +44,7 @@ inline long int num_elements(const T& m) {
* @return number of contained arguments
*/
template <typename T>
inline long int num_elements(const std::vector<T>& v) {
inline int64_t num_elements(const std::vector<T>& v) {
if (v.size() == 0) {
return 0;
}
Expand Down
3 changes: 2 additions & 1 deletion stan/math/prim/fun/rows.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <stan/math/prim/fun/Eigen.hpp>
#include <stan/math/prim/meta.hpp>
#include <cstdint>

namespace stan {
namespace math {
Expand All @@ -16,7 +17,7 @@ namespace math {
* @return Number of rows.
*/
template <typename T, require_matrix_t<T>* = nullptr>
inline long int rows(const T& m) {
inline int64_t rows(const T& m) {
return m.rows();
}

Expand Down
7 changes: 4 additions & 3 deletions stan/math/prim/fun/size.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <stan/math/prim/meta.hpp>
#include <stan/math/prim/fun/Eigen.hpp>
#include <cstdint>
#include <vector>

namespace stan {
Expand All @@ -13,7 +14,7 @@ namespace math {
* that are always of length 1.
*/
template <typename T, require_stan_scalar_t<T>* = nullptr>
inline long int size(const T& /*x*/) {
inline int64_t size(const T& /*x*/) {
return 1;
}

Expand All @@ -24,12 +25,12 @@ inline long int size(const T& /*x*/) {
* @tparam T type of m
*/
template <typename T, require_container_t<T>* = nullptr>
inline long int size(const T& m) {
inline int64_t size(const T& m) {
return m.size();
}

template <typename T, require_var_matrix_t<T>* = nullptr>
inline long int size(const T& m) {
inline int64_t size(const T& m) {
return m.size();
}

Expand Down