20 #ifndef __stir_numerics_stir_NumericalRecipes_h__ 21 #define __stir_numerics_stir_NumericalRecipes_h__ 36 stir_to_nr(
const VectorWithOffset<std::complex<float>>& c, VectorWithOffset<float>& nr_data)
38 for (
int i = 0; i < c.get_length(); ++i)
40 nr_data[2 * i + 1] = c[i].real();
41 nr_data[2 * i + 2] = c[i].imag();
46 stir_to_nr(
const Array<2, std::complex<float>>& c2d, VectorWithOffset<float>& nr_data)
49 VectorWithOffset<float>::iterator nr_iter = nr_data.begin();
51 Array<2, std::complex<float>>::const_full_iterator iter = c2d.begin_all();
53 while (iter != c2d.end_all())
55 *nr_iter++ = iter->real();
56 *nr_iter++ = iter->imag();
62 stir_to_nr(
const VectorWithOffset<Array<1, std::complex<float>>>& c2d, VectorWithOffset<float>& nr_data)
65 VectorWithOffset<float>::iterator nr_iter = nr_data.begin();
67 VectorWithOffset<Array<1, std::complex<float>>>::const_iterator iter = c2d.begin();
68 while (iter != c2d.end())
70 Array<1, std::complex<float>>::const_iterator row_iter = iter->begin();
71 while (row_iter != iter->end())
73 *nr_iter++ = row_iter->real();
74 *nr_iter++ = row_iter->imag();
82 nr_to_stir(
const VectorWithOffset<float>& nr_data, VectorWithOffset<std::complex<float>>& c)
84 for (
int i = 0; i < c.get_length(); ++i)
86 c[i] = std::complex<float>(nr_data[2 * i + 1], nr_data[2 * i + 2]);
91 nr_to_stir(
const VectorWithOffset<float>& nr_data, Array<2, std::complex<float>>& c2d)
93 VectorWithOffset<float>::const_iterator nr_iter = nr_data.begin();
94 Array<2, std::complex<float>>::full_iterator iter = c2d.begin_all();
95 while (iter != c2d.end_all())
97 *iter = std::complex<float>(*nr_iter, *(nr_iter + 1));
104 nr_to_stir(
const VectorWithOffset<float>& nr_data, VectorWithOffset<Array<1, std::complex<float>>>& c2d)
106 VectorWithOffset<float>::const_iterator nr_iter = nr_data.begin();
107 VectorWithOffset<Array<1, std::complex<float>>>::iterator iter = c2d.begin();
108 while (iter != c2d.end())
110 Array<1, std::complex<float>>::iterator row_iter = iter->begin();
111 while (row_iter != iter->end())
113 *row_iter = std::complex<float>(*nr_iter, *(nr_iter + 1));
122 void real_to_complex(
const VectorWithOffset< std::complex<float> >& c,
123 VectorWithOffset<float>& nr_data)
125 Array<2,std::complex<float> >::const_full_iterator iter=
128 while(iter != c2d.end_all())
130 *nr_iter++ = iter->real();
131 *nr_iter++ = iter->imag();
134 for (
int i=0; i<c.get_length(); ++i)
136 nr_data[2*i+1] = c[i].real();
137 nr_data[2*i+2] = c[i].imag();
defines the Array class for multi-dimensional (numeric) arrays
defines the stir::VectorWithOffset class