// Copyright (c) 2011 Jan Kokemüller // Copyright (c) 2020 Sebastian Dröge // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. use std::fs; use std::io::prelude::*; use std::path::PathBuf; fn main() { let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR")); path.push("src"); path.push("histogram_bins.rs"); let mut contents = Vec::new(); let mut energies = [0.0f64; 1000]; for (i, o) in energies.iter_mut().enumerate() { *o = f64::powf(10.0, (i as f64 / 10.0 - 69.95 + 0.691) / 10.0); } let mut boundaries = [0.0f64; 1001]; for (i, o) in boundaries.iter_mut().enumerate() { *o = f64::powf(10.0, (i as f64 / 10.0 - 70.0 + 0.691) / 10.0); } write!( &mut contents, "\ // Copyright (c) 2011 Jan Kokemüller // Copyright (c) 2020 Sebastian Dröge // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the \"Software\"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. // DO NOT EDIT: This file is autogenerated by `examples/generate_histogram_bins.rs` /// Histogram energies, i.e. energy at the center of each histogram bin. pub static ENERGIES: [f64; 1000] = {energies:#.prec$?}; /// Histogram boundaries, i.e. the energies between each histogram bin. pub static BOUNDARIES: [f64; 1001] = {boundaries:#.prec$?}; ", energies = &energies[..], boundaries = &boundaries[..], prec = 36, ) .expect("Failed to format file contents"); fs::write(path, contents).expect("Failed to write file"); }