pub fn cross_at_points<T>(pair: &mut [Ind<T>], bits_per_sym: usize, cross_points: &[usize]) 
    where T: PrimInt + FromPrimitive + ToPrimitive {
    let ind_len = pair[0].0.len();

    let mut bounded_cross_points = Vec::new();

    // add boundary indices to cross points
    bounded_cross_points.push(0);
    bounded_cross_points.extend_from_slice(cross_points);
    bounded_cross_points.push(ind_len * bits_per_sym - 1);

    // this is used to flip between where we want to do bitwise
    // crossover- the start or end index of the cross points
    let mut flip_flop = true;

    // for each pair of indices
    for point_pair in bounded_cross_points.chunks(2) {
        if point_pair.len() != 2 {
            break;
        }
        // get the word indices to start and end the crossover
        let cross_start = point_pair[0] / bits_per_sym;
        let mut cross_end   = point_pair[1] / bits_per_sym;

        // set up our alternating positions
        let mut first_side = 0;
        let mut other_side = 1;
        let mut cross_index = cross_start;
        if flip_flop {
            first_side = 1;
            other_side = 0;
            cross_index = cross_end;
        }

        // if crossing the end of a word, we may need to go
        // off by 1 to get the right crossed indices
        if point_pair[1] % bits_per_sym != 0 {
            cross_end += other_side;
        }

        // for each index, swap words
        for index in cross_start..cross_end {
            let tmp = pair[0].0[index];
            pair[0].0[index] = pair[1].0[index];
            pair[1].0[index] = tmp;
        }

        // cross the word that the cross point is within
        let cross_bit_index = point_pair[first_side] % bits_per_sym;
        if cross_bit_index != (bits_per_sym - 1) {
            let (first, second) = cross_word(pair[first_side].0[cross_index],
                                             pair[other_side].0[cross_index],
                                             cross_bit_index as u8);

            pair[0].0[cross_index] = second;
            pair[1].0[cross_index] = first;
        }

        flip_flop = !flip_flop;
    }
}
// Generic multipoint crossover. This version skips indices that will not be effected,
// making it somewhat more complex then necessary.

Generic multipoint crossover. This version skips indices that will not be effected,
making it somewhat more complex then necessary.
Generic multipoint crossover . This version skips indices that will not be effected making it somewhat more complex then necessary .
pub fn cross_at_points<T>(pair: &mut [Ind<T>], bits_per_sym: usize, cross_points: &[usize]) 
    where T: PrimInt + FromPrimitive + ToPrimitive {
    let ind_len = pair[0].0.len();
    let mut bounded_cross_points = Vec::new();
    // add boundary indices to cross points
    bounded_cross_points.push(0);
    bounded_cross_points.extend_from_slice(cross_points);
    bounded_cross_points.push(ind_len * bits_per_sym - 1);
    // this is used to flip between where we want to do bitwise
    // crossover- the start or end index of the cross points
    let mut flip_flop = true;
    // for each pair of indices
    for point_pair in bounded_cross_points.chunks(2) {
        if point_pair.len() != 2 {
            break;
        }
        // get the word indices to start and end the crossover
        let cross_start = point_pair[0] / bits_per_sym;
        let mut cross_end   = point_pair[1] / bits_per_sym;
        // set up our alternating positions
        let mut first_side = 0;
        let mut other_side = 1;
        let mut cross_index = cross_start;
        if flip_flop {
            first_side = 1;
            other_side = 0;
            cross_index = cross_end;
        }
        // if crossing the end of a word, we may need to go
        // off by 1 to get the right crossed indices
        if point_pair[1] % bits_per_sym != 0 {
            cross_end += other_side;
        }
        // for each index, swap words
        for index in cross_start..cross_end {
            let tmp = pair[0].0[index];
            pair[0].0[index] = pair[1].0[index];
            pair[1].0[index] = tmp;
        }
        // cross the word that the cross point is within
        let cross_bit_index = point_pair[first_side] % bits_per_sym;
        if cross_bit_index != (bits_per_sym - 1) {
            let (first, second) = cross_word(pair[first_side].0[cross_index],
                                             pair[other_side].0[cross_index],
                                             cross_bit_index as u8);
            pair[0].0[cross_index] = second;
            pair[1].0[cross_index] = first;
        }
        flip_flop = !flip_flop;
    }
}
pub fn cross_at_points < T > ( pair : & mut [ Ind < T > ] , bits_per_sym : usize , cross_points : & [ usize ] ) where T : PrimInt + FromPrimitive + ToPrimitive { let ind_len = pair [ 0 ] . 0 . len ( ) ; let mut bounded_cross_points = Vec :: new ( ) ; // add boundary indices to cross points
 bounded_cross_points . push ( 0 ) ; bounded_cross_points . extend_from_slice ( cross_points ) ; bounded_cross_points . push ( ind_len * bits_per_sym - 1 ) ; // this is used to flip between where we want to do bitwise
 // crossover- the start or end index of the cross points
 let mut flip_flop = true ; // for each pair of indices
 for point_pair in bounded_cross_points . chunks ( 2 ) { if point_pair . len ( ) != 2 { break ; } // get the word indices to start and end the crossover
 let cross_start = point_pair [ 0 ] / bits_per_sym ; let mut cross_end = point_pair [ 1 ] / bits_per_sym ; // set up our alternating positions
 let mut first_side = 0 ; let mut other_side = 1 ; let mut cross_index = cross_start ; if flip_flop { first_side = 1 ; other_side = 0 ; cross_index = cross_end ; } // if crossing the end of a word, we may need to go
 // off by 1 to get the right crossed indices
 if point_pair [ 1 ] % bits_per_sym != 0 { cross_end += other_side ; } // for each index, swap words
 for index in cross_start .. cross_end { let tmp = pair [ 0 ] . 0 [ index ] ; pair [ 0 ] . 0 [ index ] = pair [ 1 ] . 0 [ index ] ; pair [ 1 ] . 0 [ index ] = tmp ; } // cross the word that the cross point is within
 let cross_bit_index = point_pair [ first_side ] % bits_per_sym ; if cross_bit_index != ( bits_per_sym - 1 ) { let ( first , second ) = cross_word ( pair [ first_side ] . 0 [ cross_index ] , pair [ other_side ] . 0 [ cross_index ] , cross_bit_index as u8 ) ; pair [ 0 ] . 0 [ cross_index ] = second ; pair [ 1 ] . 0 [ cross_index ] = first ; } flip_flop = ! flip_flop ; } }
Generic multipoint crossover.
Generic multipoint crossover .
pair
&mut [Ind<T>]
bits_per_sym
usize
cross_points
&[usize]
pair
&mut [Ind<T>]
bits_per_sym
usize
cross_points
&[usize]