pub fn sum_atoms_densities(bader_charge: &[Vec<f64>],
                           bader_volume: &[f64],
                           atoms_map: &[usize],
                           atoms_len: usize)
                           -> Result<(Vec<Vec<f64>>, Vec<f64>)> {
    let mut atoms_density = vec![vec![0.0; bader_charge[0].len()]; atoms_len];
    let mut atoms_volume = vec![0.0; atoms_len];
    bader_charge.iter()
                .zip(bader_volume)
                .zip(atoms_map)
                .for_each(|((bc, bv), am)| {
                    atoms_density[*am].iter_mut()
                                      .zip(bc)
                                      .for_each(|(ad, d)| *ad += d);
                    atoms_volume[*am] += bv;
                });
    Ok((atoms_density, atoms_volume))
}
/// Sums the densities for each atom.
Sums the densities for each atom.
Sums the densities for each atom .
pub fn sum_atoms_densities(bader_charge: &[Vec<f64>],
                           bader_volume: &[f64],
                           atoms_map: &[usize],
                           atoms_len: usize)
                           -> Result<(Vec<Vec<f64>>, Vec<f64>)> {
    let mut atoms_density = vec![vec![0.0; bader_charge[0].len()]; atoms_len];
    let mut atoms_volume = vec![0.0; atoms_len];
    bader_charge.iter()
                .zip(bader_volume)
                .zip(atoms_map)
                .for_each(|((bc, bv), am)| {
                    atoms_density[*am].iter_mut()
                                      .zip(bc)
                                      .for_each(|(ad, d)| *ad += d);
                    atoms_volume[*am] += bv;
                });
    Ok((atoms_density, atoms_volume))
}
pub fn sum_atoms_densities ( bader_charge : & [ Vec < f64 > ] , bader_volume : & [ f64 ] , atoms_map : & [ usize ] , atoms_len : usize ) -> Result < ( Vec < Vec < f64 > > , Vec < f64 > ) > { let mut atoms_density = vec ! [ vec [ 0.0 bader_charge [ 0 ] len ( ) ] atoms_len ] ; let mut atoms_volume = vec ! [ 0.0 atoms_len ] ; bader_charge . iter ( ) . zip ( bader_volume ) . zip ( atoms_map ) . for_each ( | ( ( bc , bv ) , am ) | { atoms_density [ * am ] . iter_mut ( ) . zip ( bc ) . for_each ( | ( ad , d ) | * ad += d ) ; atoms_volume [ * am ] += bv ; } ) ; Ok ( ( atoms_density , atoms_volume ) ) }
Sums the densities for each atom.
Sums the densities for each atom .
bader_charge
&[Vec<f64>]
bader_volume
&[f64]
atoms_map
&[usize]
atoms_len
usize
bader_charge
&[Vec<f64>]
bader_volume
&[f64]
atoms_map
&[usize]
atoms_len
usize