[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnuastro-commits] master fd93332: Pointer increment correction in Arith

From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master fd93332: Pointer increment correction in Arithmetic
Date: Wed, 31 Aug 2016 13:18:24 +0000 (UTC)

branch: master
commit fd93332045c20eb639a4f73e77cb52dfe667e9e0
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>

    Pointer increment correction in Arithmetic
    In Arithmetic's `where' operator, when the first popped operand was an
    array, it would increment the pointer to it only if the third operand (the
    conditional) had a value of 1. The increment is now taken outside of
    ternary operator.
    Also in the documentation, the example for where still had the old
    greater-than operator (`>'), which was later (in commit 21eef31, "Letters,
    not symbols for Arithmetic's conditional operators") changed to `gt'.
 doc/gnuastro.texi           |    2 +-
 src/arithmetic/arithmetic.c |    6 +++++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index 91fb63b..9dd411e 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -6997,7 +6997,7 @@ values of 0 or 1) directly. You will mostly use them 
internally, for
-$ astarithmetic a.fits 100 > b.fits c.fits where
+$ astarithmetic a.fits 100 gt b.fits c.fits where
 @end example
 will be read as: Make a conditional image where all the pixels of
diff --git a/src/arithmetic/arithmetic.c b/src/arithmetic/arithmetic.c
index 870af04..dcb2166 100644
--- a/src/arithmetic/arithmetic.c
+++ b/src/arithmetic/arithmetic.c
@@ -866,8 +866,12 @@ where(struct imgarithparams *p)
+          printf("\nhere\n");
-          do *s = *t++ ? *f++ : *s; while(++s<ss);
+          /* Note that we need to increment "f" after the check and
+             replace. If the increment is inside the conditional replace,
+             then when t==0, the increment won't work.*/
+          do {*s = *t++ ? *f : *s; ++f;} while(++s<ss);
         do *s = *t++ ? fnum : *s; while(++s<ss);

reply via email to

[Prev in Thread] Current Thread [Next in Thread]