Skip to content

Commit

Permalink
Array: remove wrong/not implemented constructors
Browse files Browse the repository at this point in the history
The NumericVectorWithOffset constructor would only work when T=NUMBER.

The 1D Array constructor taking an `elemT*` wasn't implemented yet.
  • Loading branch information
KrisThielemans committed Aug 24, 2023
1 parent 9d61813 commit f09b35d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
3 changes: 3 additions & 0 deletions src/include/stir/Array.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ class Array<1, elemT> : public NumericVectorWithOffset<elemT, elemT>
//! 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 );

Expand All @@ -388,6 +390,7 @@ class Array<1, elemT> : public NumericVectorWithOffset<elemT, elemT>
\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<elemT,elemT> &il);
Expand Down
5 changes: 1 addition & 4 deletions src/include/stir/NumericVectorWithOffset.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -60,9 +60,6 @@ class NumericVectorWithOffset : public VectorWithOffset<T>
//! 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>& t);

Expand Down
6 changes: 0 additions & 6 deletions src/include/stir/NumericVectorWithOffset.inl
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@ NumericVectorWithOffset<T, NUMBER>::NumericVectorWithOffset(const int min_index,
: base_type(min_index, max_index)
{}

template <class T, class NUMBER>
inline
NumericVectorWithOffset<T, NUMBER>::NumericVectorWithOffset(const int min_index, const int max_index, NUMBER * const data_ptr)
: base_type(min_index, max_index, data_ptr)
{}

template <class T, class NUMBER>
NumericVectorWithOffset<T, NUMBER>::
NumericVectorWithOffset(const VectorWithOffset<T>& t)
Expand Down
4 changes: 4 additions & 0 deletions src/test/test_Array.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit f09b35d

Please sign in to comment.