[arrayfire] 20/408: Make dim4 a POD object
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Mon Sep 21 19:11:07 UTC 2015
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch debian/sid
in repository arrayfire.
commit 967ffb0d0453712a50556ea2dc050424eb5484c3
Author: Umar Arshad <umar at arrayfire.com>
Date: Sat Jun 20 16:32:08 2015 -0400
Make dim4 a POD object
---
include/af/dim4.hpp | 13 ++++---------
src/api/c/det.cpp | 4 ++--
src/api/c/fast.cpp | 6 +++---
src/api/c/hamming.cpp | 4 ++--
src/api/c/lu.cpp | 6 +++---
src/api/c/norm.cpp | 2 +-
src/api/c/orb.cpp | 12 ++++++------
src/api/c/qr.cpp | 6 +++---
src/api/c/rank.cpp | 6 +++---
src/api/c/sort.cpp | 8 ++++----
src/backend/cpu/assign.cpp | 2 +-
src/backend/cpu/exampleFunction.cpp | 2 +-
src/backend/cpu/fast.cpp | 8 ++++----
src/backend/cpu/index.cpp | 2 +-
src/backend/cpu/orb.cpp | 22 +++++++++++-----------
src/backend/cpu/set.cpp | 2 +-
src/backend/cuda/assign.cu | 2 +-
src/backend/cuda/exampleFunction.cu | 2 +-
src/backend/cuda/index.cu | 2 +-
src/backend/cuda/join.cu | 8 ++++----
src/backend/cuda/solve.cu | 2 +-
src/backend/dim4.cpp | 14 --------------
test/iota.cpp | 4 ++--
23 files changed, 60 insertions(+), 79 deletions(-)
diff --git a/include/af/dim4.hpp b/include/af/dim4.hpp
index 7511d84..b6e467e 100644
--- a/include/af/dim4.hpp
+++ b/include/af/dim4.hpp
@@ -14,9 +14,6 @@
#include <ostream>
#include <istream>
#include <vector>
-#if __cplusplus > 199711L // Necessary for NVCC
-//#include <initializer_list>
-#endif
#include <af/defines.h>
#include <af/seq.h>
@@ -25,18 +22,16 @@ namespace af
{
class AFAPI dim4
{
- public:
dim_t dims[4]; //FIXME: Make this C compatiable
- dim4(); //deleted
public:
-#if __cplusplus > 199711L
- //dim4(std::initializer_list<dim_t> dim_vals);
-#endif
dim4( dim_t first,
dim_t second = 1,
dim_t third = 1,
dim_t fourth = 1);
- dim4(const dim4& other);
+#if __cplusplus > 199711L
+ dim4() = default;
+ dim4(const dim4& other) = default;
+#endif
dim4(const unsigned ndims, const dim_t * const dims);
dim_t elements();
dim_t elements() const;
diff --git a/src/api/c/det.cpp b/src/api/c/det.cpp
index bdad4b6..a8b15a4 100644
--- a/src/api/c/det.cpp
+++ b/src/api/c/det.cpp
@@ -32,8 +32,8 @@ T det(const af_array a)
std::vector<T> hD(num);
std::vector<int> hP(num);
- Array<T> D = createEmptyArray<T>(dim4());
- Array<int> pivot = createEmptyArray<int>(dim4());
+ Array<T> D = createEmptyArray<T>(dim4(0));
+ Array<int> pivot = createEmptyArray<int>(dim4(0));
// Free memory as soon as possible
{
diff --git a/src/api/c/fast.cpp b/src/api/c/fast.cpp
index e28f590..c9befe4 100644
--- a/src/api/c/fast.cpp
+++ b/src/api/c/fast.cpp
@@ -25,9 +25,9 @@ static af_features fast(af_array const &in, const float thr,
const unsigned arc_length, const bool non_max,
const float feature_ratio, const unsigned edge)
{
- Array<float> x = createEmptyArray<float>(dim4());
- Array<float> y = createEmptyArray<float>(dim4());
- Array<float> score = createEmptyArray<float>(dim4());
+ Array<float> x = createEmptyArray<float>(dim4(0));
+ Array<float> y = createEmptyArray<float>(dim4(0));
+ Array<float> score = createEmptyArray<float>(dim4(0));
af_features_t feat;
feat.n = fast<T>(x, y, score,
diff --git a/src/api/c/hamming.cpp b/src/api/c/hamming.cpp
index 8a1dd91..7ac98b8 100644
--- a/src/api/c/hamming.cpp
+++ b/src/api/c/hamming.cpp
@@ -21,8 +21,8 @@ using namespace detail;
template<typename T>
static void hamming_matcher(af_array* idx, af_array* dist, const af_array query, const af_array train, const dim_t dist_dim, const uint n_dist)
{
- Array<uint> oIdxArray = createEmptyArray<uint>(af::dim4());
- Array<uint> oDistArray = createEmptyArray<uint>(af::dim4());
+ Array<uint> oIdxArray = createEmptyArray<uint>(af::dim4(0));
+ Array<uint> oDistArray = createEmptyArray<uint>(af::dim4(0));
hamming_matcher<T>(oIdxArray, oDistArray, getArray<T>(query), getArray<T>(train), dist_dim, n_dist);
diff --git a/src/api/c/lu.cpp b/src/api/c/lu.cpp
index c6004bc..5a859a4 100644
--- a/src/api/c/lu.cpp
+++ b/src/api/c/lu.cpp
@@ -23,9 +23,9 @@ template<typename T>
static inline void lu(af_array *lower, af_array *upper, af_array *pivot,
const af_array in)
{
- Array<T> lowerArray = createEmptyArray<T>(af::dim4());
- Array<T> upperArray = createEmptyArray<T>(af::dim4());
- Array<int> pivotArray = createEmptyArray<int>(af::dim4());
+ Array<T> lowerArray = createEmptyArray<T>(af::dim4(0));
+ Array<T> upperArray = createEmptyArray<T>(af::dim4(0));
+ Array<int> pivotArray = createEmptyArray<int>(af::dim4(0));
lu<T>(lowerArray, upperArray, pivotArray, getArray<T>(in));
diff --git a/src/api/c/norm.cpp b/src/api/c/norm.cpp
index bf83353..7842135 100644
--- a/src/api/c/norm.cpp
+++ b/src/api/c/norm.cpp
@@ -59,7 +59,7 @@ double vectorNorm(const Array<T> &A, double p)
template<typename T>
double LPQNorm(const Array<T> &A, double p, double q)
{
- Array<T> A_p_norm = createEmptyArray<T>(dim4());
+ Array<T> A_p_norm = createEmptyArray<T>(dim4(0));
if (p == 1) {
A_p_norm = reduce<af_add_t, T, T>(A, 0);
diff --git a/src/api/c/orb.cpp b/src/api/c/orb.cpp
index 98f5170..5a486fc 100644
--- a/src/api/c/orb.cpp
+++ b/src/api/c/orb.cpp
@@ -26,12 +26,12 @@ static void orb(af_features& feat_, af_array& descriptor,
const unsigned max_feat, const float scl_fctr,
const unsigned levels, const bool blur_img)
{
- Array<float> x = createEmptyArray<float>(dim4());
- Array<float> y = createEmptyArray<float>(dim4());
- Array<float> score = createEmptyArray<float>(dim4());
- Array<float> ori = createEmptyArray<float>(dim4());
- Array<float> size = createEmptyArray<float>(dim4());
- Array<uint > desc = createEmptyArray<uint >(dim4());
+ Array<float> x = createEmptyArray<float>(dim4(0));
+ Array<float> y = createEmptyArray<float>(dim4(0));
+ Array<float> score = createEmptyArray<float>(dim4(0));
+ Array<float> ori = createEmptyArray<float>(dim4(0));
+ Array<float> size = createEmptyArray<float>(dim4(0));
+ Array<uint > desc = createEmptyArray<uint >(dim4(0));
af_features_t feat;
diff --git a/src/api/c/qr.cpp b/src/api/c/qr.cpp
index 95eb53a..8d54aea 100644
--- a/src/api/c/qr.cpp
+++ b/src/api/c/qr.cpp
@@ -22,9 +22,9 @@ using namespace detail;
template<typename T>
static inline void qr(af_array *q, af_array *r, af_array *tau, const af_array in)
{
- Array<T> qArray = createEmptyArray<T>(af::dim4());
- Array<T> rArray = createEmptyArray<T>(af::dim4());
- Array<T> tArray = createEmptyArray<T>(af::dim4());
+ Array<T> qArray = createEmptyArray<T>(af::dim4(0));
+ Array<T> rArray = createEmptyArray<T>(af::dim4(0));
+ Array<T> tArray = createEmptyArray<T>(af::dim4(0));
qr<T>(qArray, rArray, tArray, getArray<T>(in));
diff --git a/src/api/c/rank.cpp b/src/api/c/rank.cpp
index c1eeb73..bb6cba0 100644
--- a/src/api/c/rank.cpp
+++ b/src/api/c/rank.cpp
@@ -26,12 +26,12 @@ static inline uint rank(const af_array in, double tol)
{
Array<T> In = getArray<T>(in);
- Array<T> r = createEmptyArray<T>(dim4());
+ Array<T> r = createEmptyArray<T>(dim4(0));
// Scoping to get rid of q and t as they are not necessary
{
- Array<T> q = createEmptyArray<T>(dim4());
- Array<T> t = createEmptyArray<T>(dim4());
+ Array<T> q = createEmptyArray<T>(dim4(0));
+ Array<T> t = createEmptyArray<T>(dim4(0));
qr(q, r, t, In);
}
diff --git a/src/api/c/sort.cpp b/src/api/c/sort.cpp
index 39a7f22..25b67de 100644
--- a/src/api/c/sort.cpp
+++ b/src/api/c/sort.cpp
@@ -70,8 +70,8 @@ static inline void sort_index(af_array *val, af_array *idx, const af_array in,
const Array<T> &inArray = getArray<T>(in);
// Initialize Dummy Arrays
- Array<T> valArray = createEmptyArray<T>(af::dim4());
- Array<uint> idxArray = createEmptyArray<uint>(af::dim4());
+ Array<T> valArray = createEmptyArray<T>(af::dim4(0));
+ Array<uint> idxArray = createEmptyArray<uint>(af::dim4(0));
if(isAscending) {
sort_index<T, 1>(valArray, idxArray, inArray, dim);
@@ -120,8 +120,8 @@ static inline void sort_by_key(af_array *okey, af_array *oval, const af_array ik
const Array<Tv> &ivalArray = getArray<Tv>(ival);
// Initialize Dummy Arrays
- Array<Tk> okeyArray = createEmptyArray<Tk>(af::dim4());
- Array<Tv> ovalArray = createEmptyArray<Tv>(af::dim4());
+ Array<Tk> okeyArray = createEmptyArray<Tk>(af::dim4(0));
+ Array<Tv> ovalArray = createEmptyArray<Tv>(af::dim4(0));
if(isAscending) {
sort_by_key<Tk, Tv, 1>(okeyArray, ovalArray, ikeyArray, ivalArray, dim);
diff --git a/src/backend/cpu/assign.cpp b/src/backend/cpu/assign.cpp
index a8ac33e..47b8720 100644
--- a/src/backend/cpu/assign.cpp
+++ b/src/backend/cpu/assign.cpp
@@ -57,7 +57,7 @@ void assign(Array<T>& out, const af_index_t idxrs[], const Array<T>& rhs)
dim4 src_dims = rhs.dims();
dim4 src_strides = rhs.strides();
- std::vector< Array<uint> > idxArrs(4, createEmptyArray<uint>(dim4()));
+ std::vector< Array<uint> > idxArrs(4, createEmptyArray<uint>(dim4(0)));
// look through indexs to read af_array indexs
for (dim_t x=0; x<4; ++x) {
if (!isSeq[x]) {
diff --git a/src/backend/cpu/exampleFunction.cpp b/src/backend/cpu/exampleFunction.cpp
index a9e7bca..4396cce 100644
--- a/src/backend/cpu/exampleFunction.cpp
+++ b/src/backend/cpu/exampleFunction.cpp
@@ -24,7 +24,7 @@ namespace cpu
template<typename T>
Array<T> exampleFunction(const Array<T> &in, const af_someenum_t method)
{
- dim4 outputDims; // this should be '= in.dims();' in most cases
+ dim4 outputDims(0); // this should be '= in.dims();' in most cases
// but would definitely depend on the type of
// algorithm you are implementing.
diff --git a/src/backend/cpu/fast.cpp b/src/backend/cpu/fast.cpp
index 929d48f..7a8bbfa 100644
--- a/src/backend/cpu/fast.cpp
+++ b/src/backend/cpu/fast.cpp
@@ -253,7 +253,7 @@ unsigned fast(Array<float> &x_out, Array<float> &y_out, Array<float> &score_out,
// Matrix containing scores for detected features, scores are stored in the
// same coordinates as features, dimensions should be equal to in.
- Array<float> V = createEmptyArray<float>(dim4());
+ Array<float> V = createEmptyArray<float>(dim4(0));
if (nonmax == 1) {
dim4 V_dims(in_dims[0], in_dims[1]);
V = createValueArray<float>(V_dims, (float)0);
@@ -277,9 +277,9 @@ unsigned fast(Array<float> &x_out, Array<float> &y_out, Array<float> &score_out,
unsigned feat_found = std::min(max_feat, count);
dim4 feat_found_dims(feat_found);
- Array<float> x_total = createEmptyArray<float>(af::dim4());
- Array<float> y_total = createEmptyArray<float>(af::dim4());
- Array<float> score_total = createEmptyArray<float>(af::dim4());
+ Array<float> x_total = createEmptyArray<float>(af::dim4(0));
+ Array<float> y_total = createEmptyArray<float>(af::dim4(0));
+ Array<float> score_total = createEmptyArray<float>(af::dim4(0));
if (nonmax == 1) {
diff --git a/src/backend/cpu/index.cpp b/src/backend/cpu/index.cpp
index 162e67f..e9bc598 100644
--- a/src/backend/cpu/index.cpp
+++ b/src/backend/cpu/index.cpp
@@ -55,7 +55,7 @@ Array<T> index(const Array<T>& in, const af_index_t idxrs[])
dim4 iOffs = toOffset(seqs, dDims);
dim4 iStrds= toStride(seqs, dDims);
- std::vector< Array<uint> > idxArrs(4, createEmptyArray<uint>(dim4()));
+ std::vector< Array<uint> > idxArrs(4, createEmptyArray<uint>(dim4(0)));
// look through indexs to read af_array indexs
for (dim_t x=0; x<4; ++x) {
if (!isSeq[x]) {
diff --git a/src/backend/cpu/orb.cpp b/src/backend/cpu/orb.cpp
index 342487f..8ad6db0 100644
--- a/src/backend/cpu/orb.cpp
+++ b/src/backend/cpu/orb.cpp
@@ -581,17 +581,17 @@ unsigned orb(Array<float> &x, Array<float> &y,
lvl_best[max_levels-1] = max_feat - feat_sum;
// Maintain a reference to previous level image
- Array<T> prev_img = createEmptyArray<T>(af::dim4());
- af::dim4 prev_ldims;
+ Array<T> prev_img = createEmptyArray<T>(af::dim4(0));
+ af::dim4 prev_ldims(0);
af::dim4 gauss_dims(9);
T* h_gauss = nullptr;
- Array<T> gauss_filter = createEmptyArray<T>(af::dim4());
+ Array<T> gauss_filter = createEmptyArray<T>(af::dim4(0));
for (unsigned i = 0; i < max_levels; i++) {
- af::dim4 ldims;
+ af::dim4 ldims(0);
const float lvl_scl = (float)std::pow(scl_fctr,(float)i);
- Array<T> lvl_img = createEmptyArray<T>(af::dim4());
+ Array<T> lvl_img = createEmptyArray<T>(af::dim4(0));
if (i == 0) {
// First level is used in its original size
@@ -613,9 +613,9 @@ unsigned orb(Array<float> &x, Array<float> &y,
}
- Array<float> x_feat = createEmptyArray<float>(dim4());
- Array<float> y_feat = createEmptyArray<float>(dim4());
- Array<float> score_feat = createEmptyArray<float>(dim4());
+ Array<float> x_feat = createEmptyArray<float>(dim4(0));
+ Array<float> y_feat = createEmptyArray<float>(dim4(0));
+ Array<float> score_feat = createEmptyArray<float>(dim4(0));
// Round feature size to nearest odd integer
float size = 2.f * floor(patch_size / 2.f) + 1.f;
@@ -660,8 +660,8 @@ unsigned orb(Array<float> &x, Array<float> &y,
// Sort features according to Harris responses
af::dim4 usable_feat_dims(usable_feat);
Array<float> score_harris = createHostDataArray(usable_feat_dims, h_score_harris);
- Array<float> harris_sorted = createEmptyArray<float>(af::dim4());
- Array<unsigned> harris_idx = createEmptyArray<unsigned>(af::dim4());
+ Array<float> harris_sorted = createEmptyArray<float>(af::dim4(0));
+ Array<unsigned> harris_idx = createEmptyArray<unsigned>(af::dim4(0));
sort_index<float, false>(harris_sorted, harris_idx, score_harris, 0);
@@ -695,7 +695,7 @@ unsigned orb(Array<float> &x, Array<float> &y,
centroid_angle<T>(h_x_lvl, h_y_lvl, h_ori_lvl, usable_feat,
lvl_img, patch_size);
- Array<T> lvl_filt = createEmptyArray<T>(dim4());
+ Array<T> lvl_filt = createEmptyArray<T>(dim4(0));
if (blur_img) {
// Calculate a separable Gaussian kernel, if one is not already stored
diff --git a/src/backend/cpu/set.cpp b/src/backend/cpu/set.cpp
index 3a8239e..be8dd2a 100644
--- a/src/backend/cpu/set.cpp
+++ b/src/backend/cpu/set.cpp
@@ -28,7 +28,7 @@ namespace cpu
Array<T> setUnique(const Array<T> &in,
const bool is_sorted)
{
- Array<T> out = createEmptyArray<T>(af::dim4());
+ Array<T> out = createEmptyArray<T>(af::dim4(0));
if (is_sorted) out = copyArray<T>(in);
else out = sort<T, 1>(in, 0);
diff --git a/src/backend/cuda/assign.cu b/src/backend/cuda/assign.cu
index 7bea851..3e67a00 100644
--- a/src/backend/cuda/assign.cu
+++ b/src/backend/cuda/assign.cu
@@ -47,7 +47,7 @@ void assign(Array<T>& out, const af_index_t idxrs[], const Array<T>& rhs)
p.strds[i] = dstStrds[i];
}
- std::vector< Array<uint> > idxArrs(4, createEmptyArray<uint>(dim4()));
+ std::vector< Array<uint> > idxArrs(4, createEmptyArray<uint>(dim4(0)));
// look through indexs to read af_array indexs
for (dim_t x=0; x<4; ++x) {
// set idxPtrs to null
diff --git a/src/backend/cuda/exampleFunction.cu b/src/backend/cuda/exampleFunction.cu
index 4a7db44..2c17f38 100644
--- a/src/backend/cuda/exampleFunction.cu
+++ b/src/backend/cuda/exampleFunction.cu
@@ -29,7 +29,7 @@ namespace cuda
template<typename T>
Array<T> exampleFunction(const Array<T> &in, const af_someenum_t method)
{
- dim4 outputDims; // this should be '= in.dims();' in most cases
+ dim4 outputDims(0); // this should be '= in.dims();' in most cases
// but would definitely depend on the type of
// algorithm you are implementing.
diff --git a/src/backend/cuda/index.cu b/src/backend/cuda/index.cu
index 988f589..fa0c71e 100644
--- a/src/backend/cuda/index.cu
+++ b/src/backend/cuda/index.cu
@@ -47,7 +47,7 @@ Array<T> index(const Array<T>& in, const af_index_t idxrs[])
p.strds[i] = iStrds[i];
}
- std::vector< Array<uint> > idxArrs(4, createEmptyArray<uint>(dim4()));
+ std::vector< Array<uint> > idxArrs(4, createEmptyArray<uint>(dim4(0)));
// look through indexs to read af_array indexs
for (dim_t x=0; x<4; ++x) {
// set idxPtrs to null
diff --git a/src/backend/cuda/join.cu b/src/backend/cuda/join.cu
index 074326e..b09887e 100644
--- a/src/backend/cuda/join.cu
+++ b/src/backend/cuda/join.cu
@@ -18,7 +18,7 @@ namespace cuda
template<int dim>
af::dim4 calcOffset(const af::dim4 dims)
{
- af::dim4 offset;
+ af::dim4 offset(0);
offset[0] = (dim == 0) ? dims[0] : 0;
offset[1] = (dim == 1) ? dims[1] : 0;
offset[2] = (dim == 2) ? dims[2] : 0;
@@ -31,7 +31,7 @@ namespace cuda
{
// All dimensions except join dimension must be equal
// Compute output dims
- af::dim4 odims;
+ af::dim4 odims(0);
af::dim4 fdims = first.dims();
af::dim4 sdims = second.dims();
@@ -112,9 +112,9 @@ namespace cuda
{
// All dimensions except join dimension must be equal
// Compute output dims
- af::dim4 odims;
+ af::dim4 odims(0);
const dim_t n_arrays = inputs.size();
- std::vector<af::dim4> idims(n_arrays);
+ std::vector<af::dim4> idims(n_arrays, dim4(0));
dim_t dim_size = 0;
for(int i = 0; i < (int)idims.size(); i++) {
diff --git a/src/backend/cuda/solve.cu b/src/backend/cuda/solve.cu
index 7077c1f..166a494 100644
--- a/src/backend/cuda/solve.cu
+++ b/src/backend/cuda/solve.cu
@@ -228,7 +228,7 @@ Array<T> leastSquares(const Array<T> &a, const Array<T> &b)
int N = a.dims()[1];
int K = b.dims()[1];
- Array<T> B = createEmptyArray<T>(dim4());
+ Array<T> B = createEmptyArray<T>(dim4(0));
if (M < N) {
diff --git a/src/backend/dim4.cpp b/src/backend/dim4.cpp
index 7958e96..aa36db3 100644
--- a/src/backend/dim4.cpp
+++ b/src/backend/dim4.cpp
@@ -22,13 +22,6 @@ using std::vector;
using std::numeric_limits;
using std::abs;
-dim4::dim4()
-{
- dims[0] = 0;
- dims[1] = 0;
- dims[2] = 0;
- dims[3] = 0;
-}
dim4::dim4( dim_t first,
dim_t second,
@@ -41,13 +34,6 @@ dim4::dim4( dim_t first,
dims[3] = fourth;
}
-dim4::dim4(const dim4& other)
-{
- dims[0] = other.dims[0];
- dims[1] = other.dims[1];
- dims[2] = other.dims[2];
- dims[3] = other.dims[3];
-}
dim4::dim4(const unsigned ndims_, const dim_t * const dims_)
{
diff --git a/test/iota.cpp b/test/iota.cpp
index fae4f72..0b35752 100644
--- a/test/iota.cpp
+++ b/test/iota.cpp
@@ -55,7 +55,7 @@ void iotaTest(const af::dim4 idims, const af::dim4 tdims)
af_array temp0 = 0, temp1 = 0, temp2 = 0;
af::dim4 tempdims(idims.elements());
- af::dim4 fulldims;
+ af::dim4 fulldims(0);
for(unsigned i = 0; i < 4; i++) {
fulldims[i] = idims[i] * tdims[i];
}
@@ -112,7 +112,7 @@ TEST(Iota, CPP)
af::dim4 idims(23, 15, 1, 1);
af::dim4 tdims(2, 2, 1, 1);
- af::dim4 fulldims;
+ af::dim4 fulldims(0);
for(unsigned i = 0; i < 4; i++) {
fulldims[i] = idims[i] * tdims[i];
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/arrayfire.git
More information about the debian-science-commits
mailing list