[arrayfire] 386/408: BUGFIX: seq.begin can now use negative offsets just like seq.end
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Mon Sep 21 19:12:36 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 714cdc0f5becef4f3e91006f78dec4a96c8cc9e1
Author: Pavan Yalamanchili <pavan at arrayfire.com>
Date: Fri Sep 11 14:32:02 2015 -0400
BUGFIX: seq.begin can now use negative offsets just like seq.end
---
src/api/cpp/array.cpp | 9 +++------
src/api/cpp/index.cpp | 2 +-
src/api/cpp/seq.cpp | 2 +-
src/backend/dim4.cpp | 22 ++++++++--------------
4 files changed, 13 insertions(+), 22 deletions(-)
diff --git a/src/api/cpp/array.cpp b/src/api/cpp/array.cpp
index 7615c39..3280457 100644
--- a/src/api/cpp/array.cpp
+++ b/src/api/cpp/array.cpp
@@ -374,8 +374,7 @@ namespace af
const array::array_proxy array::row(int index) const
{
- seq idx(index, index, 1);
- return this->operator()(idx, span, span, span);
+ return this->operator()(index, span, span, span);
}
array::array_proxy array::row(int index)
@@ -385,8 +384,7 @@ namespace af
const array::array_proxy array::col(int index) const
{
- seq idx(index, index, 1);
- return this->operator()(span, idx, span, span);
+ return this->operator()(span, index, span, span);
}
array::array_proxy array::col(int index)
@@ -396,8 +394,7 @@ namespace af
const array::array_proxy array::slice(int index) const
{
- seq idx(index, index, 1);
- return this->operator()(span, span, idx, span);
+ return this->operator()(span, span, index, span);
}
array::array_proxy array::slice(int index)
diff --git a/src/api/cpp/index.cpp b/src/api/cpp/index.cpp
index ccc698b..d7a0cd1 100644
--- a/src/api/cpp/index.cpp
+++ b/src/api/cpp/index.cpp
@@ -75,7 +75,7 @@ index::index(const af::array& idx0) {
impl.isBatch = false;
}
-index::index(const af::index& idx0) {
+index::index(const af::index& idx0) {
*this = idx0;
}
diff --git a/src/api/cpp/seq.cpp b/src/api/cpp/seq.cpp
index d143356..388fa41 100644
--- a/src/api/cpp/seq.cpp
+++ b/src/api/cpp/seq.cpp
@@ -46,7 +46,7 @@ seq::~seq()
seq::seq(double n): m_gfor(false)
{
if (n < 0) {
- init(n + 1, 0, 1); // seq(-4) = -3, -2, -1, 0
+ init(0, n, 1);
} else {
init(0, n - 1, 1);
}
diff --git a/src/backend/dim4.cpp b/src/backend/dim4.cpp
index 41ea56a..d1f69d2 100644
--- a/src/backend/dim4.cpp
+++ b/src/backend/dim4.cpp
@@ -176,7 +176,7 @@ dim4 operator*(const dim4& first, const dim4& second)
bool
-isEnd(const af_seq &seq) { return (seq.end <= -1); }
+hasEnd(const af_seq &seq) { return (seq.begin <= -1 || seq.end <= -1); }
bool
isSpan(const af_seq &seq) { return (seq.step == 0 && seq.begin == 1 && seq.end == 1); }
@@ -196,18 +196,11 @@ dim_t calcDim(const af_seq &seq, const dim_t &parentDim)
dim_t outDim = 1;
if (isSpan(seq)) {
outDim = parentDim;
- } else if (isEnd(seq)) {
- if(seq.begin == -1) { // only end is passed as seq
- outDim = 1;
- } else if (seq.begin < 0) {
- af_seq temp = {parentDim + seq.begin,
- parentDim + seq.end,
- seq.step};
- outDim = seqElements(temp);
- } else { // end is passed as a part of seq
- af_seq temp = {seq.begin, parentDim + seq.end, seq.step};
- outDim = seqElements(temp);
- }
+ } else if (hasEnd(seq)) {
+ af_seq temp = {seq.begin, seq.end, seq.step};
+ if (seq.begin < 0) temp.begin += parentDim;
+ if (seq.end < 0) temp.end += parentDim;
+ outDim = seqElements(temp);
} else {
DIM_ASSERT(1, seq.begin >= -DBL_MIN && seq.begin < parentDim);
DIM_ASSERT(1, seq.end < parentDim);
@@ -216,7 +209,8 @@ dim_t calcDim(const af_seq &seq, const dim_t &parentDim)
return outDim;
}
-}
+
+} // end namespace af
using af::dim4;
using std::vector;
--
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