use super::Q;
use flint3_sys::fmpq;
impl Default for Q {
fn default() -> Self {
Q {
value: fmpq { num: 0, den: 1 },
}
}
}
impl Q {
pub const ONE: Q = Q {
value: fmpq { num: 1, den: 1 },
};
pub const ZERO: Q = Q {
value: fmpq { num: 0, den: 1 },
};
pub const MINUS_ONE: Q = Q {
value: fmpq { num: -1, den: 1 },
};
pub const E: Q = Q {
value: fmpq {
num: 2922842896378005707,
den: 1075253811351460636,
},
};
pub const PI: Q = Q {
value: fmpq {
num: 2646693125139304345,
den: 842468587426513207,
},
};
pub const MAX62: Q = Q {
value: fmpq {
num: i64::pow(2, 62) - 1,
den: 1,
},
};
pub const INV_MAX62: Q = Q {
value: fmpq {
num: 1,
den: i64::pow(2, 62) - 1,
},
};
pub const MAX32: Q = Q {
value: fmpq {
num: i64::pow(2, 32) - 1,
den: 1,
},
};
pub const INV_MAX32: Q = Q {
value: fmpq {
num: 1,
den: i64::pow(2, 32) - 1,
},
};
pub const MAX16: Q = Q {
value: fmpq {
num: i64::pow(2, 16) - 1,
den: 1,
},
};
pub const INV_MAX16: Q = Q {
value: fmpq {
num: 1,
den: i64::pow(2, 16) - 1,
},
};
pub const MAX8: Q = Q {
value: fmpq {
num: i64::pow(2, 8) - 1,
den: 1,
},
};
pub const INV_MAX8: Q = Q {
value: fmpq {
num: 1,
den: i64::pow(2, 8) - 1,
},
};
}
#[cfg(test)]
mod tests_init {
use super::Q;
#[test]
fn init_default() {
assert_eq!(Q::ZERO, Q::default());
}
#[test]
fn init_zero() {
assert_eq!(Q::from(0), Q::ZERO);
}
#[test]
fn init_one() {
assert_eq!(Q::from(1), Q::ONE);
}
#[test]
fn init_minus_one() {
assert_eq!(Q::from(-1), Q::MINUS_ONE);
}
#[test]
fn init_max62() {
assert_eq!(Q::from(i64::pow(2, 62) - 1), Q::MAX62);
}
#[test]
fn init_inv_max62() {
assert_eq!(Q::from((1, i64::pow(2, 62) - 1)), Q::INV_MAX62);
}
#[test]
fn init_max32() {
assert_eq!(Q::from(i64::pow(2, 32) - 1), Q::MAX32);
}
#[test]
fn init_inv_max32() {
assert_eq!(Q::from((1, i64::pow(2, 32) - 1)), Q::INV_MAX32);
}
#[test]
fn init_max16() {
assert_eq!(Q::from(i64::pow(2, 16) - 1), Q::MAX16);
}
#[test]
fn init_inv_max16() {
assert_eq!(Q::from((1, i64::pow(2, 16) - 1)), Q::INV_MAX16);
}
#[test]
fn init_max8() {
assert_eq!(Q::from(i64::pow(2, 8) - 1), Q::MAX8);
}
#[test]
fn init_inv_max8() {
assert_eq!(Q::from((1, i64::pow(2, 8) - 1)), Q::INV_MAX8);
}
}