STIR 6.4.0
convert_array.inl
Go to the documentation of this file.
1//
2//
3/*
4 Copyright (C) 2006 - 2007, Hammersmith Imanet Ltd
5 This file is part of STIR.
6
7 SPDX-License-Identifier: Apache-2.0
8
9 See STIR/LICENSE.txt for details
10*/
21#include "stir/NumericInfo.h"
22#include "stir/Array.h"
23#include "stir/convert_range.h"
24START_NAMESPACE_STIR
25
26template <int num_dimensions, class T1, class T2, class scaleT>
27void
28find_scale_factor(scaleT& scale_factor, const Array<num_dimensions, T1>& data_in, const NumericInfo<T2> info_for_out_type)
29{
30 find_scale_factor(scale_factor, data_in.begin_all(), data_in.end_all(), info_for_out_type);
31}
32
33template <int num_dimensions, class T1, class T2, class scaleT>
34Array<num_dimensions, T2>
35convert_array(scaleT& scale_factor, const Array<num_dimensions, T1>& data_in, const NumericInfo<T2> info_for_out_type)
36{
37 Array<num_dimensions, T2> data_out(data_in.get_index_range());
38
39 convert_array(data_out, scale_factor, data_in);
40 return data_out;
41}
42
43template <int num_dimensions, class T1, class T2, class scaleT>
44void
45convert_array(Array<num_dimensions, T2>& data_out, scaleT& scale_factor, const Array<num_dimensions, T1>& data_in)
46{
47 convert_range(data_out.begin_all(), scale_factor, data_in.begin_all(), data_in.end_all());
48}
49
50END_NAMESPACE_STIR
defines the stir::Array class for multi-dimensional (numeric) arrays
This file declares the class stir::NumericInfo.
This class defines multi-dimensional (numeric) arrays.
Definition Array.h:78
full_iterator begin_all()
start value for iterating through all elements in the array, see full_iterator
Definition Array.inl:213
full_iterator end_all()
end value for iterating through all elements in the array, see full_iterator
Definition Array.inl:185
class NumericInfo<NUMBER> defines properties for the type NUMBER.
Definition NumericInfo.h:68
This file declares the stir::convert_range and stir::find_scale_factor functions.
void convert_range(const OutputIteratorT &out_begin, scaleT &scale_factor, const InputIteratorT &in_begin, const InputIteratorT &in_end)
Converts the data in the input range to the output range (with elements of different types) such that...
Definition convert_range.inl:129
void find_scale_factor(scaleT &scale_factor, const Array< num_dimensions, T1 > &data_in, const NumericInfo< T2 > info_for_out_type)
A function that finds a scale factor to use when converting data to a new type.
Definition convert_array.inl:28
Array< num_dimensions, T2 > convert_array(scaleT &scale_factor, const Array< num_dimensions, T1 > &data_in, const NumericInfo< T2 > info2)
A function that returns a new Array (of the same dimension) with elements of type T2.
Definition convert_array.inl:35