/// Given an iterator over an SVMLight line (or even a subsequence
/// of it), write out dense features in it into an output array of
/// size ndense, writes the i+nsparse()-th dense feature
/// observed in the iterator into the i-th position in the array.
///
/// Any dense features not present in the iteration are set to 0.
///
/// For tsv input, this assumes we're reading the tsv starting at the
/// first feature column and records dense outputs accordingly.
Given an iterator over an SVMLight line (or even a subsequence
of it), write out dense features in it into an output array of
size ndense, writes the i+nsparse()-th dense feature
observed in the iterator into the i-th position in the array.

Any dense features not present in the iteration are set to 0.

For tsv input, this assumes we're reading the tsv starting at the
first feature column and records dense outputs accordingly.
Given an iterator over an SVMLight line ( or even a subsequence of it ) write out dense features in it into an output array of size ndense writes the i + nsparse () - th dense feature observed in the iterator into the i - th position in the array . Any dense features not present in the iteration are set to 0 . For tsv input this assumes we ' re reading the tsv starting at the first feature column and records dense outputs accordingly .
pub(crate) fn write_dense<'a>(&self, line: impl Iterator<Item = &'a [u8]>, out: &mut [f64]) {
        for f in out.iter_mut() {
            *f = 0.0;
        }
        if let Some(is_dense) = &self.is_dense {
            let mut ctr = 0;
            line.zip(is_dense.iter().copied())
                .for_each(|(word, dense)| {
                    if dense {
                        let value: f64 = if word.len() > 0 {
                            let value_str = std::str::from_utf8(word).expect("utf-8 value (tsv)");
                            str::parse(value_str).expect("f64 parse (tsv)")
                        } else {
                            0.
                        };
                        out[ctr] = value;
                        ctr += 1;
                    }
                });
            return;
        }
        line.filter(|word| not_space(*word))
            .map(pair_value)
            .flat_map(|(feature, value)| {
                let hash = Identity64::from(hash(feature));
                let idx = self.dense.get(&hash)?;
                let value_str = std::str::from_utf8(value).expect("utf-8 value (svm)");
                let value: f64 = str::parse(value_str).expect("f64 parse (svm)");
                Some(((*idx as usize) - self.nsparse(), value))
            })
            .for_each(|(idx, value)| out[idx] = value);
    }
pub ( crate ) fn write_dense < ' a > ( & self , line : impl Iterator < Item = & ' a [ u8 ] > , out : & mut [ f64 ] ) { for f in out . iter_mut ( ) { * f = 0.0 ; } if let Some ( is_dense ) = & self . is_dense { let mut ctr = 0 ; line . zip ( is_dense . iter ( ) . copied ( ) ) . for_each ( | ( word , dense ) | { if dense { let value : f64 = if word . len ( ) > 0 { let value_str = std :: str :: from_utf8 ( word ) . expect ( " " ) ; str :: parse ( value_str ) . expect ( " " ) } else { 0. } ; out [ ctr ] = value ; ctr += 1 ; } } ) ; return ; } line . filter ( | word | not_space ( * word ) ) . map ( pair_value ) . flat_map ( | ( feature , value ) | { let hash = Identity64 :: from ( hash ( feature ) ) ; let idx = self . dense . get ( & hash ) ? ; let value_str = std :: str :: from_utf8 ( value ) . expect ( " " ) ; let value : f64 = str :: parse ( value_str ) . expect ( " " ) ; Some ( ( ( * idx as usize ) - self . nsparse ( ) , value ) ) } ) . for_each ( | ( idx , value ) | out [ idx ] = value ) ; }
Given an iterator over an SVMLight line (or even a subsequence
of it), write out dense features in it into an output array of
size ndense, writes the i+nsparse()-th dense feature
observed in the iterator into the i-th position in the array.
Given an iterator over an SVMLight line ( or even a subsequence of it ) write out dense features in it into an output array of size ndense writes the i + nsparse () - th dense feature observed in the iterator into the i - th position in the array .
&self
line
impl Iterator<Item = &'a [u8]>
out
&mut [f64]