Port of (subset of) GLM to Rust