pub mod backend;
#[cfg(feature = "config")]
pub mod config;
pub mod data;
pub mod dtype;
pub mod error;
pub mod geometry;
pub mod params;
pub mod cpu;
pub mod cuda;
pub mod wgpu;
pub mod io;
pub mod prep;
pub mod recon;
pub mod sim;
#[cfg(feature = "xanes")]
pub mod xanes;
pub mod align;
pub mod engine;
pub mod pipeline;
pub use engine::Engine;
pub use pipeline::{
prep_band, reconstruct, reconstruct_lamino_streaming, CancelToken, PrepOptions, ReconSteps,
};
pub use backend::{
Backend, DeviceBuffer, DeviceKind, Elementwise, FbpFilter, Fft, FilteredBackproject,
ForwardProject, IterativeReconstruct, RankFilter,
};
pub use cpu::CpuBackend;
pub use cuda::CudaBackend;
pub use data::{Dataset, Frames, Layout, Slice2D, Tomo, Volume};
pub use dtype::{Complex32, Dtype, Element};
pub use error::{Error, Result};
pub use geometry::{Angles, Beam, Center, Detector, Geometry, ValidFov};
pub use params::{Algorithm, BackendKind, FilterName, PhaseMethod, ReconParams, StripeMethod};
#[cfg(test)]
mod tests {
use super::*;
#[cfg(not(any(feature = "cuda", feature = "gpu-wgpu")))]
#[test]
fn auto_engine_falls_back_to_cpu() {
let e = Engine::new(BackendKind::Auto).unwrap();
assert_eq!(e.name(), "cpu");
}
#[test]
fn explicit_cpu_engine() {
let e = Engine::new(BackendKind::Cpu).unwrap();
assert_eq!(e.name(), "cpu");
assert!(e.backend().elementwise().is_some());
}
#[cfg(not(feature = "cuda"))]
#[test]
fn cuda_engine_unavailable_without_feature() {
assert!(Engine::new(BackendKind::Cuda).is_err());
}
#[test]
fn angles_uniform_spans_half_turn() {
let a = Angles::uniform(4, 0.0, std::f32::consts::PI);
assert_eq!(a.len(), 4);
assert!((a.0[2] - std::f32::consts::FRAC_PI_2).abs() < 1e-6);
}
#[test]
fn tomo_layout_roundtrip_swaps_axes() {
let arr = ndarray::Array3::<f32>::zeros((3, 5, 7));
let t = Tomo::new(arr, Layout::Projection);
let s = t.to_layout(Layout::Sinogram);
assert_eq!(s.array.shape(), &[5, 3, 7]);
assert_eq!(s.n_angles(), 3);
}
#[test]
fn algorithm_parses_and_classifies() {
assert_eq!("fbp".parse::<Algorithm>().unwrap(), Algorithm::Fbp);
assert!(Algorithm::Fbp.is_analytic());
assert!(!Algorithm::Sirt.is_analytic());
}
}