@@ -75,11 +75,12 @@ namespace WireCell {
7575 // / Return a new sequence resampled and interpolated from the
7676 // / original wave defined over the domain to a new domain of
7777 // / nsamples.
78- template <typename Val>
78+ // / if Val is complex then Scalar must match the scala rtype of Val
79+ template <typename Val, typename Scalar>
7980 Sequence<Val> resample (const Sequence<Val>& wave, const Domain& domain, int nsamples, const Domain& newdomain)
8081 {
8182 const int oldnsamples = wave.size ();
82- const double oldstep = sample_width (domain, oldnsamples);
83+ const Scalar oldstep = sample_width (domain, oldnsamples);
8384 const double step = sample_width (newdomain, nsamples);
8485 Sequence<Val> ret;
8586 for (int ind = 0 ; ind < nsamples; ++ind) {
@@ -94,14 +95,24 @@ namespace WireCell {
9495 ret.push_back (wave[oldnsamples - 1 ]);
9596 continue ;
9697 }
97- double d1 = oldfracsteps - oldstep * oldind;
98- double d2 = oldstep - d1;
98+ Scalar d1 = oldfracsteps - oldstep * oldind;
99+ Scalar d2 = oldstep - d1;
99100 Val newval = (wave[oldind] * d1 + wave[oldind + 1 ] * d2) / oldstep;
100101 ret.push_back (newval);
101102 }
102103 return ret;
103104 }
104105
106+ // / two supported overloads
107+ inline realseq_t resample (const realseq_t & wave, const Domain& domain, int nsamples, const Domain& newdomain)
108+ {
109+ return resample<real_t , real_t >(wave, domain, nsamples, newdomain);
110+ }
111+ inline compseq_t resample (const compseq_t & wave, const Domain& domain, int nsamples, const Domain& newdomain)
112+ {
113+ return resample<complex_t , real_t >(wave, domain, nsamples, newdomain);
114+ }
115+
105116 // / Return the real part of the sequence
106117 realseq_t real (const compseq_t & seq);
107118 // / Return the imaginary part of the sequence
0 commit comments