use nalgebra::DMatrix;
use crate::regression::glm::link::core::Link;
#[derive(Default, Clone, Debug)]
pub struct Inverse {}
impl Inverse {
pub fn new() -> Self {
Self::default()
}
}
impl Link for Inverse {
fn link_func(&self, mu: &DMatrix<f64>) -> DMatrix<f64> {
mu.map(|mu| 1.0 / mu)
}
fn link_inverse(&self, eta: &DMatrix<f64>) -> DMatrix<f64> {
eta.map(|eta| 1.0 / eta)
}
fn mu_eta(&self, eta: &DMatrix<f64>) -> DMatrix<f64> {
eta.map(|eta| -1.0 / eta.powi(2))
}
fn valid_eta(&self, eta: &DMatrix<f64>) -> bool {
eta.iter().all(|&eta| eta.is_finite() && eta != 0.0)
}
}