binius_field/arch/portable/
reuse_multiply_arithmetic.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright 2024 Irreducible Inc.

use std::ops::Mul;

use crate::{
	arch::ReuseMultiplyStrategy,
	arithmetic_traits::{TaggedMulAlpha, TaggedSquare},
};

impl<T> TaggedSquare<ReuseMultiplyStrategy> for T
where
	T: Mul<Self, Output = Self> + Copy,
{
	fn square(self) -> Self {
		self * self
	}
}

pub trait Alpha {
	fn alpha() -> Self;
}

impl<T> TaggedMulAlpha<ReuseMultiplyStrategy> for T
where
	T: Mul<Self, Output = Self> + Alpha,
{
	#[inline]
	fn mul_alpha(self) -> Self {
		self * Self::alpha()
	}
}