#![allow(unused_variables)]
use crate::prelude::*;
#[macro_export]
#[doc(hidden)]
macro_rules! _implement_numeric_unsigned_public {
($name:ident) => {
impl PartialOrd for $name {
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl Ord for $name {
#[cfg_attr(feature = "use_attributes", unsafe_hacspec)]
fn cmp(&self, other: &Self) -> Ordering {
self.0.cmp(&other.0)
}
}
impl Eq for $name {}
impl $name {
fn compatible(&self, other: &Self) -> bool {
assert!(
self.len() == other.len(),
"Can't combine two sequences that don't have the same length."
);
if self.len() != other.len() {
return false;
}
return true;
}
}
impl Add for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn add(self, rhs: $name) -> $name {
self.compatible(&rhs);
let mut out = Self::new();
for i in 0..self.len() {
out[i] = self[i].wrapping_add(rhs[i])
}
out
}
}
impl Sub for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn sub(self, rhs: $name) -> $name {
self.compatible(&rhs);
let mut out = Self::new();
for i in 0..self.len() {
out[i] = self[i].wrapping_sub(rhs[i])
}
out
}
}
impl Mul for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn mul(self, rhs: $name) -> $name {
self.compatible(&rhs);
vec_poly_mul(self, rhs, 0)
}
}
impl Div for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn div(self, rhs: $name) -> $name {
self.compatible(&rhs);
let mut out = Self::new();
for i in 0..self.len() {
out[i] = self[i].wrapping_div(rhs[i])
}
out
}
}
impl Not for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn not(self) -> Self::Output {
let mut out = Self::new();
for i in 0..self.len() {
out[i] = !self[i]
}
out
}
}
impl BitOr for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn bitor(self, rhs: Self) -> Self::Output {
self.compatible(&rhs);
let mut out = Self::new();
for i in 0..self.len() {
out[i] = self[i] | rhs[i]
}
out
}
}
impl BitXor for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn bitxor(self, rhs: Self) -> Self::Output {
self.compatible(&rhs);
let mut out = Self::new();
for i in 0..self.len() {
out[i] = self[i] ^ rhs[i]
}
out
}
}
impl BitAnd for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn bitand(self, rhs: Self) -> Self::Output {
self.compatible(&rhs);
let mut out = Self::new();
for i in 0..self.len() {
out[i] = self[i] & rhs[i]
}
out
}
}
impl Shr<usize> for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn shr(self, _rhs: usize) -> Self::Output {
unimplemented!();
}
}
impl Shl<usize> for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn shl(self, _rhs: usize) -> Self::Output {
unimplemented!();
}
}
impl NumericCopy for $name {}
impl ModNumeric for $name {
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn sub_mod(self, rhs: Self, n: Self) -> Self {
(self - rhs).modulo(n)
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn add_mod(self, rhs: Self, n: Self) -> Self {
(self + rhs).modulo(n)
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn mul_mod(self, rhs: Self, n: Self) -> Self {
(self * rhs).modulo(n)
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn pow_mod(self, exp: Self, n: Self) -> Self {
self.pow_self(exp).modulo(n)
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn modulo(self, n: Self) -> Self {
self.compatible(&n);
let mut out = Self::new();
for i in 0..self.len() {
out[i] = self[i].modulo(n[i])
}
out
}
fn signed_modulo(self, n: Self) -> Self {
self.modulo(n)
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn absolute(self) -> Self {
self
}
}
impl Numeric for $name {
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn max_val() -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn wrap_add(self, rhs: Self) -> Self {
self + rhs
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn wrap_sub(self, rhs: Self) -> Self {
self - rhs
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn wrap_mul(self, rhs: Self) -> Self {
self * rhs
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn wrap_div(self, rhs: Self) -> Self {
self / rhs
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn exp(self, exp: u32) -> Self {
let mut out = Self::new();
for i in 0..self.len() {
out[i] = self[i].exp(exp)
}
out
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn pow_self(self, _exp: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn divide(self, rhs: Self) -> Self {
self.compatible(&rhs);
let mut out = Self::new();
for i in 0..self.len() {
out[i] = self[i].div(rhs[i])
}
out
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn inv(self, _n: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn equal(self, _other: Self) -> bool {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn greater_than(self, _other: Self) -> bool {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn greater_than_or_equal(self, _other: Self) -> bool {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn less_than(self, _other: Self) -> bool {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn less_than_or_equal(self, _other: Self) -> bool {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn not_equal_bm(self, _other: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn equal_bm(self, _other: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn greater_than_bm(self, _other: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn greater_than_or_equal_bm(self, _other: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn less_than_bm(self, _other: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn less_than_or_equal_bm(self, _other: Self) -> Self {
unimplemented!();
}
}
};
}
#[macro_export]
#[doc(hidden)]
macro_rules! _implement_numeric_signed_public {
($name:ident) => {
impl PartialOrd for $name {
#[cfg_attr(feature = "use_attributes", unsafe_hacspec)]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl Ord for $name {
#[cfg_attr(feature = "use_attributes", unsafe_hacspec)]
fn cmp(&self, other: &Self) -> Ordering {
self.0.cmp(&other.0)
}
}
impl Eq for $name {}
impl Add for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn add(self, rhs: $name) -> $name {
unimplemented!();
}
}
impl Sub for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn sub(self, rhs: $name) -> $name {
unimplemented!();
}
}
impl Mul for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn mul(self, rhs: $name) -> $name {
unimplemented!();
}
}
impl Div for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn div(self, rhs: $name) -> $name {
unimplemented!();
}
}
impl Rem for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn rem(self, rhs: $name) -> $name {
unimplemented!();
}
}
impl Not for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn not(self) -> Self::Output {
unimplemented!();
}
}
impl BitOr for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn bitor(self, rhs: Self) -> Self::Output {
unimplemented!();
}
}
impl BitXor for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn bitxor(self, rhs: Self) -> Self::Output {
unimplemented!();
}
}
impl BitAnd for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn bitand(self, rhs: Self) -> Self::Output {
unimplemented!();
}
}
impl Shr<usize> for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn shr(self, rhs: usize) -> Self::Output {
unimplemented!();
}
}
impl Shl<usize> for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn shl(self, rhs: usize) -> Self::Output {
unimplemented!();
}
}
impl NumericCopy for $name {}
impl ModNumeric for $name {
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn sub_mod(self, rhs: Self, n: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn add_mod(self, rhs: Self, n: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn mul_mod(self, rhs: Self, n: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn pow_mod(self, exp: Self, n: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn modulo(self, n: Self) -> Self {
unimplemented!();
}
fn signed_modulo(self, _n: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn absolute(self) -> Self {
let mut out = Self::new();
for i in 0..self.len() {
out[i] = self[i].absolute();
}
out
}
}
impl Numeric for $name {
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn max_val() -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn wrap_add(self, rhs: Self) -> Self {
self + rhs
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn wrap_sub(self, rhs: Self) -> Self {
self - rhs
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn wrap_mul(self, rhs: Self) -> Self {
self * rhs
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn wrap_div(self, rhs: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn exp(self, exp: u32) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn pow_self(self, exp: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn divide(self, rhs: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn inv(self, n: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn equal(self, other: Self) -> bool {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn greater_than(self, other: Self) -> bool {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn greater_than_or_equal(self, other: Self) -> bool {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn less_than(self, other: Self) -> bool {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn less_than_or_equal(self, other: Self) -> bool {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn not_equal_bm(self, other: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn equal_bm(self, other: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn greater_than_bm(self, other: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn greater_than_or_equal_bm(self, other: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn less_than_bm(self, other: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn less_than_or_equal_bm(self, other: Self) -> Self {
unimplemented!();
}
}
};
}
#[macro_export]
#[doc(hidden)]
macro_rules! _implement_numeric_unsigned_secret {
($name:ident, $t:ty) => {
impl Add for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn add(self, rhs: $name) -> $name {
debug_assert!(
self.len() == rhs.len(),
"Can't add two sequences that don't have the same length."
);
let mut out = Self::new();
for i in 0..self.len() {
out[i] = self[i] + rhs[i]
}
out
}
}
impl Sub for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn sub(self, rhs: $name) -> $name {
debug_assert!(
self.len() == rhs.len(),
"Can't add two sequences that don't have the same length."
);
let mut out = Self::new();
for i in 0..self.len() {
out[i] = self[i] - rhs[i]
}
out
}
}
impl Mul for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn mul(self, rhs: $name) -> $name {
debug_assert!(
self.len() == rhs.len(),
"Can't add two sequences that don't have the same length."
);
let mut out = Self::new();
for i in 0..self.len() {
out[i] = self[i] * rhs[i]
}
out
}
}
impl Rem for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn rem(self, _rhs: $name) -> $name {
unimplemented!();
}
}
impl Not for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn not(self) -> Self::Output {
unimplemented!();
}
}
impl BitOr for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn bitor(self, _rhs: Self) -> Self::Output {
unimplemented!();
}
}
impl BitXor for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn bitxor(self, rhs: Self) -> Self::Output {
let mut out = Self::new();
for i in 0..self.len() {
out[i] = self[i] ^ rhs[i]
}
out
}
}
impl BitAnd for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn bitand(self, _rhs: Self) -> Self::Output {
unimplemented!();
}
}
impl Shr<usize> for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn shr(self, _rhs: usize) -> Self::Output {
unimplemented!();
}
}
impl Shl<usize> for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn shl(self, _rhs: usize) -> Self::Output {
unimplemented!();
}
}
impl NumericCopy for $name {}
impl ModNumeric for $name {
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn sub_mod(self, _rhs: Self, _n: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn add_mod(self, _rhs: Self, _n: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn mul_mod(self, _rhs: Self, _n: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn pow_mod(self, _exp: Self, _n: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn modulo(self, _n: Self) -> Self {
unimplemented!();
}
fn signed_modulo(self, _n: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn absolute(self) -> Self {
self
}
}
impl Numeric for $name {
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn max_val() -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn wrap_add(self, rhs: Self) -> Self {
self + rhs
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn wrap_sub(self, rhs: Self) -> Self {
self - rhs
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn wrap_mul(self, rhs: Self) -> Self {
self * rhs
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn wrap_div(self, _rhs: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn exp(self, _exp: u32) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn pow_self(self, _exp: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn divide(self, _rhs: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn inv(self, _n: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn equal(self, other: Self) -> bool {
let mut result = <$t>::max_value();
for (&a, &b) in self.iter().zip(other.iter()) {
result = result & a.equal_bm(b);
}
result.declassify() == <$t>::max_value().declassify()
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn greater_than(self, _other: Self) -> bool {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn greater_than_or_equal(self, _other: Self) -> bool {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn less_than(self, _other: Self) -> bool {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn less_than_or_equal(self, _other: Self) -> bool {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn not_equal_bm(self, _other: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn equal_bm(self, _other: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn greater_than_bm(self, _other: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn greater_than_or_equal_bm(self, _other: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn less_than_bm(self, _other: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn less_than_or_equal_bm(self, _other: Self) -> Self {
unimplemented!();
}
}
};
}
#[macro_export]
#[doc(hidden)]
macro_rules! _implement_numeric_signed_secret {
($name:ident) => {
impl PartialOrd for $name {
#[cfg_attr(feature = "use_attributes", unsafe_hacspec)]
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
}
}
impl Ord for $name {
#[cfg_attr(feature = "use_attributes", unsafe_hacspec)]
fn cmp(&self, other: &Self) -> Ordering {
unimplemented!();
}
}
impl Eq for $name {}
impl Add for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn add(self, rhs: $name) -> $name {
unimplemented!();
}
}
impl Sub for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn sub(self, rhs: $name) -> $name {
unimplemented!();
}
}
impl Mul for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn mul(self, rhs: $name) -> $name {
unimplemented!();
}
}
impl Div for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn div(self, rhs: $name) -> $name {
unimplemented!();
}
}
impl Rem for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn rem(self, rhs: $name) -> $name {
unimplemented!();
}
}
impl Not for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn not(self) -> Self::Output {
unimplemented!();
}
}
impl BitOr for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn bitor(self, rhs: Self) -> Self::Output {
unimplemented!();
}
}
impl BitXor for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn bitxor(self, rhs: Self) -> Self::Output {
unimplemented!();
}
}
impl BitAnd for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn bitand(self, rhs: Self) -> Self::Output {
unimplemented!();
}
}
impl Shr<usize> for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn shr(self, rhs: usize) -> Self::Output {
unimplemented!();
}
}
impl Shl<usize> for $name {
type Output = $name;
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn shl(self, rhs: usize) -> Self::Output {
unimplemented!();
}
}
impl NumericCopy for $name {}
impl ModNumeric for $name {
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn sub_mod(self, rhs: Self, n: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn add_mod(self, rhs: Self, n: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn mul_mod(self, rhs: Self, n: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn pow_mod(self, exp: Self, n: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn modulo(self, n: Self) -> Self {
unimplemented!();
}
fn signed_modulo(self, _n: Self) -> Self {
unimplemented!();
}
}
impl Numeric for $name {
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn max_val() -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn wrap_add(self, rhs: Self) -> Self {
self + rhs
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn wrap_sub(self, rhs: Self) -> Self {
self - rhs
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn wrap_mul(self, rhs: Self) -> Self {
self * rhs
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn wrap_div(self, rhs: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn exp(self, exp: u32) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn pow_self(self, exp: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn divide(self, rhs: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn inv(self, n: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn absolute(self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn equal(self, other: Self) -> bool {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn greater_than(self, other: Self) -> bool {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn greater_than_or_equal(self, other: Self) -> bool {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn less_than(self, other: Self) -> bool {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn less_than_or_equal(self, other: Self) -> bool {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn not_equal_bm(self, other: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn equal_bm(self, other: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn greater_than_bm(self, other: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn greater_than_or_equal_bm(self, other: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn less_than_bm(self, other: Self) -> Self {
unimplemented!();
}
#[cfg_attr(feature = "use_attributes", in_hacspec)]
fn less_than_or_equal_bm(self, other: Self) -> Self {
unimplemented!();
}
}
};
}
#[inline]
#[cfg_attr(feature = "use_attributes", in_hacspec)]
pub fn vec_poly_mul<T: Numeric + Copy, U: SeqTrait<T>>(x: U, y: U, n: T) -> U {
debug_assert!(x.len() == y.len());
let mut out = U::create(x.len());
for i in 0..x.len() {
if !n.equal(T::default()) {
out[i] = x[i].mul_mod(y[i], n);
} else {
out[i] = x[i].wrap_mul(y[i]);
}
}
out
}
#[inline]
#[cfg_attr(feature = "use_attributes", in_hacspec)]
pub fn vec_poly_add<T: Numeric + Copy, U: SeqTrait<T>>(x: U, y: U, n: T) -> U {
debug_assert!(x.len() == y.len());
let mut out = U::create(x.len());
for i in 0..x.len() {
if !n.equal(T::default()) {
out[i] = x[i].add_mod(y[i], n);
} else {
out[i] = x[i].wrap_add(y[i]);
}
}
out
}
#[inline]
#[cfg_attr(feature = "use_attributes", in_hacspec)]
pub fn vec_poly_sub<T: Numeric + Copy, U: SeqTrait<T>>(x: U, y: U, n: T) -> U {
debug_assert!(x.len() == y.len());
let mut out = U::create(x.len());
for i in 0..x.len() {
if !n.equal(T::default()) {
out[i] = x[i].sub_mod(y[i], n);
} else {
out[i] = x[i].wrap_sub(y[i]);
}
}
out
}