2
2
use num_complex:: * ;
3
3
use num_traits:: Float ;
4
4
5
+ use std:: rc:: Rc ;
5
6
use std:: f32:: consts:: PI ;
6
7
use std:: io:: { Read } ;
7
8
use dft;
@@ -203,13 +204,13 @@ const SLICE_OFFSET: usize = (NUM_POINTS / 2) / SLICES_PER_FRAME;
203
204
const SLICES_PER_FRAGMENT : usize = SLICES_PER_FRAME / FRAGMENTS_PER_FRAME ;
204
205
const FRAGMENT_WINDOW : ( f32 , f32 ) = ( 350. , 500. ) ;
205
206
206
- const SIMILARITY : usize = 80 ;
207
+ const SIMILARITY : usize = 60 ;
207
208
208
209
type KeyVec = Vec < Option < FragmentKey > > ;
209
210
210
211
pub fn build_glossary < ' d > ( filename : & str , detectors : & ' d [ Detector ] ) -> ( Glossary < ' d > , KeyVec ) {
211
212
// (100, 199), (200, 299), ... (1900, 1999)
212
- let regions: Vec < _ > = ( 1 .. 13 ) . into_iter ( ) . map ( |i : u32 | ( i as f32 * 100. , i as f32 * 100. + 99. ) ) . collect ( ) ;
213
+ let regions: Vec < _ > = ( 1 .. 33 ) . into_iter ( ) . map ( |i : u32 | ( i as f32 * 100. , i as f32 * 100. + 99. ) ) . collect ( ) ;
213
214
let mut dictionaries: Vec < _ > = regions. iter ( ) . map ( |r| Dictionary :: new ( detectors, r. 0 , r. 1 ) ) . collect ( ) ;
214
215
215
216
let plan = dft:: Plan :: new ( dft:: Operation :: Forward , NUM_POINTS ) ;
@@ -225,7 +226,8 @@ pub fn build_glossary<'d>(filename: &str, detectors: &'d [Detector]) -> (Glossar
225
226
. samples :: < i16 > ( )
226
227
. map ( |s| Cplx :: new ( s. unwrap ( ) as f32 / i16:: max_value ( ) as f32 , 0.0 ) )
227
228
. collect_chunks :: < Samples > ( NUM_POINTS / 2 )
228
- . tuple_windows ( ) // FIXME eliminate cloning. Rc<Samples> maybe?
229
+ . map ( |chunk| Rc :: new ( chunk) ) // Wrap into Rc for cheap cloning
230
+ . tuple_windows ( )
229
231
{
230
232
if first. len ( ) < NUM_POINTS / 2 || second. len ( ) < NUM_POINTS / 2 {
231
233
break ;
0 commit comments