From 6871e46fad6896a0b3995c634b52ef9207f79c39 Mon Sep 17 00:00:00 2001 From: Kris Thielemans Date: Thu, 24 Aug 2023 14:24:47 +0100 Subject: [PATCH] Array: remove wrong/not implemented constructors The NumericVectorWithOffset constructor would only work when T=NUMBER. The 1D Array constructor taking an `elemT*` wasn't implemented yet. --- src/include/stir/Array.h | 3 +++ src/include/stir/NumericVectorWithOffset.h | 5 +---- src/include/stir/NumericVectorWithOffset.inl | 6 ------ src/swig/stir.i | 2 ++ src/test/test_Array.cxx | 4 ++++ 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/include/stir/Array.h b/src/include/stir/Array.h index 221c7bff3d..cb8c24f175 100644 --- a/src/include/stir/Array.h +++ b/src/include/stir/Array.h @@ -380,6 +380,8 @@ class Array<1, elemT> : public NumericVectorWithOffset //! constructor given first and last indices, initialising elements to 0 inline Array(const int min_index, const int max_index); +#if 0 + // TODO. these are not implemented yet. //! constructor given an IndexRange<1>, pointing to \c data_ptr inline Array(const IndexRange<1>& range, elemT * const data_ptr ); @@ -388,6 +390,7 @@ class Array<1, elemT> : public NumericVectorWithOffset \arg data_ptr should start to a contiguous block of correct size */ inline Array(const int min_index, const int max_index, elemT * const data_ptr); +#endif //! constructor from basetype inline Array(const NumericVectorWithOffset &il); diff --git a/src/include/stir/NumericVectorWithOffset.h b/src/include/stir/NumericVectorWithOffset.h index 373da43dc6..4411e5a9ec 100644 --- a/src/include/stir/NumericVectorWithOffset.h +++ b/src/include/stir/NumericVectorWithOffset.h @@ -4,7 +4,7 @@ Copyright (C) 2000 PARAPET partners Copyright (C) 2000 - 2005-06-03, Hammersmith Imanet Ltd Copyright (C) 2011-07-01 - 2012, Kris Thielemans - Copyright (C) 2020, 2023 UCL + Copyright (C) 2020, 2023 University College London This file is part of STIR. SPDX-License-Identifier: Apache-2.0 AND License-ref-PARAPET-license @@ -60,9 +60,6 @@ class NumericVectorWithOffset : public VectorWithOffset //! Construct a NumericVectorWithOffset of elements with offset \c min_index inline NumericVectorWithOffset(const int min_index, const int max_index); - //! Construct a NumericVectorWithOffset of elements with offset \c min_index pointing to \c data_ptr - inline NumericVectorWithOffset(const int min_index, const int max_index, elemT * const data_ptr); - //! Constructor from an object of this class' base_type inline NumericVectorWithOffset(const VectorWithOffset& t); diff --git a/src/include/stir/NumericVectorWithOffset.inl b/src/include/stir/NumericVectorWithOffset.inl index a23585d7ff..d79bd47c16 100644 --- a/src/include/stir/NumericVectorWithOffset.inl +++ b/src/include/stir/NumericVectorWithOffset.inl @@ -44,12 +44,6 @@ NumericVectorWithOffset::NumericVectorWithOffset(const int min_index, : base_type(min_index, max_index) {} -template -inline -NumericVectorWithOffset::NumericVectorWithOffset(const int min_index, const int max_index, NUMBER * const data_ptr) - : base_type(min_index, max_index, data_ptr) -{} - template NumericVectorWithOffset:: NumericVectorWithOffset(const VectorWithOffset& t) diff --git a/src/swig/stir.i b/src/swig/stir.i index 41a9fbe401..1ea3a6b976 100644 --- a/src/swig/stir.i +++ b/src/swig/stir.i @@ -942,6 +942,7 @@ namespace std { %template(FloatLORInAxialAndNoArcCorrSinogramCoordinates) stir::LORInAxialAndNoArcCorrSinogramCoordinates; %include "stir_array.i" +#if 0 // KT %include "stir_exam.i" %shared_ptr(stir::DataSymmetriesForViewSegmentNumbers); @@ -1020,3 +1021,4 @@ namespace std { %shared_ptr(stir::InvertAxis); %include "stir/spatial_transformation/InvertAxis.h" +#endif // KT diff --git a/src/test/test_Array.cxx b/src/test/test_Array.cxx index 22ccc007d1..1da0813bb9 100644 --- a/src/test/test_Array.cxx +++ b/src/test/test_Array.cxx @@ -350,6 +350,7 @@ ArrayTests::run_tests() std::copy(test.begin_all_const(), test.end_all_const(), mem.begin()); Array<1,float> preallocated; preallocated.init(test.get_index_range(), &mem[0], false); + check(!preallocated.owns_memory_for_data(), "test preallocated without copy: should not own memory"); check_if_equal(test, preallocated, "test preallocated: equality"); std::copy(test.begin_all_const(), test.end_all_const(), preallocated.begin_all()); check_if_equal(test, preallocated, "test preallocated: copy with full_iterator"); @@ -384,6 +385,7 @@ ArrayTests::run_tests() std::copy(test.begin_all_const(), test.end_all_const(), mem.begin()); Array<1,float> test_from_mem; test_from_mem.init(test.get_index_range(), &mem[0], true); + check(test_from_mem.owns_memory_for_data(), "test preallocated with copy: should own memory"); check_if_equal(test, test_from_mem, "test construct from mem: equality"); std::copy(test.begin_all_const(), test.end_all_const(), test_from_mem.begin_all()); check_if_equal(test, test_from_mem, "test construct from mem: copy with full_iterator"); @@ -520,6 +522,7 @@ ArrayTests::run_tests() } Array<2,float> preallocated; preallocated.init(t2.get_index_range(), &mem[0], false); + //check(!preallocated.owns_memory_for_data(), "test preallocated without copy: should not own memory"); check_if_equal(t2, preallocated, "test preallocated: equality"); std::copy(t2.begin_all_const(), t2.end_all_const(), preallocated.begin_all()); check_if_equal(t2, preallocated, "test preallocated: copy with full_iterator"); @@ -1017,6 +1020,7 @@ ArrayTests::run_tests() Array<4,int> a1; a1.init(range, v.data(), false); t.stop(); + //check(!a1.owns_memory_for_data(), "test preallocated without copy: should not own memory"); create_duration = t.value(); std::cerr << "contiguous array creation (total) " << t.value()*1000 << "ms\n"; t.start();