use super::*;
impl<E: Environment> Neg for Group<E> {
type Output = Group<E>;
#[inline]
fn neg(self) -> Self::Output {
Group::from_projective(-self.group)
}
}
impl<E: Environment> Add<Group<E>> for Group<E> {
type Output = Group<E>;
#[inline]
fn add(self, other: Group<E>) -> Self::Output {
Group::from_projective(self.group + other.group)
}
}
impl<E: Environment> Add<&Group<E>> for Group<E> {
type Output = Group<E>;
#[inline]
fn add(self, other: &Group<E>) -> Self::Output {
Group::from_projective(self.group + other.group)
}
}
impl<E: Environment> AddAssign<Group<E>> for Group<E> {
#[inline]
fn add_assign(&mut self, other: Group<E>) {
self.group += other.group;
}
}
impl<E: Environment> AddAssign<&Group<E>> for Group<E> {
#[inline]
fn add_assign(&mut self, other: &Group<E>) {
self.group += other.group;
}
}
impl<E: Environment> Sub<Group<E>> for Group<E> {
type Output = Group<E>;
#[inline]
fn sub(self, other: Group<E>) -> Self::Output {
Group::from_projective(self.group - other.group)
}
}
impl<E: Environment> Sub<&Group<E>> for Group<E> {
type Output = Group<E>;
#[inline]
fn sub(self, other: &Group<E>) -> Self::Output {
Group::from_projective(self.group - other.group)
}
}
impl<E: Environment> SubAssign<Group<E>> for Group<E> {
#[inline]
fn sub_assign(&mut self, other: Group<E>) {
self.group -= other.group;
}
}
impl<E: Environment> SubAssign<&Group<E>> for Group<E> {
#[inline]
fn sub_assign(&mut self, other: &Group<E>) {
self.group -= other.group;
}
}
impl<E: Environment> Mul<Scalar<E>> for Group<E> {
type Output = Group<E>;
#[inline]
fn mul(self, other: Scalar<E>) -> Self::Output {
Group::from_projective(self.group * *other)
}
}
impl<E: Environment> Mul<&Scalar<E>> for Group<E> {
type Output = Group<E>;
#[inline]
fn mul(self, other: &Scalar<E>) -> Self::Output {
Group::from_projective(self.group * **other)
}
}
impl<E: Environment> Mul<Group<E>> for Scalar<E> {
type Output = Group<E>;
#[inline]
fn mul(self, other: Group<E>) -> Self::Output {
Group::from_projective(other.group * *self)
}
}
impl<E: Environment> Mul<&Group<E>> for Scalar<E> {
type Output = Group<E>;
#[inline]
fn mul(self, other: &Group<E>) -> Self::Output {
Group::from_projective(other.group * *self)
}
}
impl<E: Environment> MulAssign<Scalar<E>> for Group<E> {
#[inline]
fn mul_assign(&mut self, other: Scalar<E>) {
self.group *= *other;
}
}
impl<E: Environment> MulAssign<&Scalar<E>> for Group<E> {
#[inline]
fn mul_assign(&mut self, other: &Scalar<E>) {
self.group *= **other;
}
}
impl<E: Environment> Double for Group<E> {
type Output = Group<E>;
#[inline]
fn double(&self) -> Self::Output {
Group::from_projective(self.group.double())
}
}
impl<E: Environment> Sum<Group<E>> for Group<E> {
#[inline]
fn sum<I: Iterator<Item = Group<E>>>(iter: I) -> Self {
iter.fold(Group::zero(), |a, b| a + b)
}
}
impl<'a, E: Environment> Sum<&'a Group<E>> for Group<E> {
#[inline]
fn sum<I: Iterator<Item = &'a Group<E>>>(iter: I) -> Self {
iter.fold(Group::zero(), |a, b| a + b)
}
}