use anyhow::Ok;
use catenary::table::Table;
use clap::Parser;
use clap_derive::ValueEnum;
use std::fs;
#[derive(Parser)]
#[command(version, about, long_about = None)]
struct Args {
#[arg(short, long, default_value = "1000")]
theta_n: usize,
#[arg(short, long, default_value = "1000")]
length_n: usize,
#[arg(short, long, default_value = "output")]
output_folder: String,
#[arg(value_enum, default_value = "f64")]
float_type: FloatType,
}
#[derive(Parser, Clone, Copy, Debug, ValueEnum)]
enum FloatType {
F32,
F64,
}
fn main() -> anyhow::Result<()> {
let args = Args::parse();
match args.float_type {
FloatType::F32 => println!("Using f32"),
FloatType::F64 => println!("Using f64"),
}
fs::create_dir_all(&args.output_folder).unwrap();
let table_file = format!(
"{}/{:?}_catenary_table_t{}_d{}.bin",
args.output_folder, args.float_type, args.theta_n, args.length_n
)
.to_lowercase();
match args.float_type {
FloatType::F32 => {
println!("Using f32");
Table::<f32>::generate(args.theta_n, args.length_n)?
.save(&table_file)
.unwrap()
}
FloatType::F64 => {
println!("Using f64");
Table::<f64>::generate(args.theta_n, args.length_n)?
.save(&table_file)
.unwrap()
}
};
println!("Catenary table saved to: {table_file}",);
println!(
"File size: {} bytes",
fs::metadata(&table_file).unwrap().len()
);
Ok(())
}