[Top][All Lists]

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

[gnuastro-commits] master 3ab540d: Size of reference corrected after col

From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master 3ab540d: Size of reference corrected after collapse in Arithmetic
Date: Thu, 5 Jul 2018 20:31:36 -0400 (EDT)

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

    Size of reference corrected after collapse in Arithmetic
    When reading each operand into memory, Arithmetic uses a reference dataset
    to make sure the next given operand has the same size. But the new
    collapsing operators change the necessary size for the next steps. So the
    reference needs to be corrected after the collapse.
    We were already correcting the reference's WCS, but hadn't corrected its
    `ndim' and `dsize'. These two are now also corrected with this commit.
 bin/arithmetic/arithmetic.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/bin/arithmetic/arithmetic.c b/bin/arithmetic/arithmetic.c
index f89dbed..f83e461 100644
--- a/bin/arithmetic/arithmetic.c
+++ b/bin/arithmetic/arithmetic.c
@@ -751,6 +751,15 @@ arithmetic_collapse(struct arithmeticparams *p, char 
*token, int operator)
   collapsed->wcs = NULL;
+  /* We'll also need to correct the size of the reference dataset. We'll
+     use `memcpy' to write the new `dsize' values into the old ones. The
+     dimensions have decreased, so we won't be writing outside of allocated
+     space that `p->refdata.dsize' points to. */
+  p->refdata.ndim -= 1;
+  memcpy( p->refdata.dsize, collapsed->dsize,
+           p->refdata.ndim * (sizeof *p->refdata.dsize) );
   /* Clean up and add the collapsed dataset to the top of the operands. */

reply via email to

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