mirror of
https://github.com/saymrwulf/pasta_curves-source.git
synced 2026-09-06 20:20:34 +00:00
impl<F: FieldExt> {Neg, Sub} for Expression<F>
This commit is contained in:
parent
f566bf7fe0
commit
db0477a606
1 changed files with 19 additions and 2 deletions
|
|
@ -1,10 +1,13 @@
|
||||||
use core::cmp::max;
|
use core::cmp::max;
|
||||||
use core::ops::{Add, Mul};
|
use core::ops::{Add, Mul};
|
||||||
use ff::Field;
|
use ff::Field;
|
||||||
use std::convert::TryFrom;
|
use std::{
|
||||||
|
convert::TryFrom,
|
||||||
|
ops::{Neg, Sub},
|
||||||
|
};
|
||||||
|
|
||||||
use super::{lookup, permutation, Error};
|
use super::{lookup, permutation, Error};
|
||||||
use crate::poly::Rotation;
|
use crate::{arithmetic::FieldExt, poly::Rotation};
|
||||||
|
|
||||||
/// A column type
|
/// A column type
|
||||||
pub trait ColumnType: 'static + Sized {}
|
pub trait ColumnType: 'static + Sized {}
|
||||||
|
|
@ -316,6 +319,13 @@ impl<F: Field> Expression<F> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<F: FieldExt> Neg for Expression<F> {
|
||||||
|
type Output = Expression<F>;
|
||||||
|
fn neg(self) -> Self::Output {
|
||||||
|
Expression::Scaled(Box::new(self), -F::one())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<F> Add for Expression<F> {
|
impl<F> Add for Expression<F> {
|
||||||
type Output = Expression<F>;
|
type Output = Expression<F>;
|
||||||
fn add(self, rhs: Expression<F>) -> Expression<F> {
|
fn add(self, rhs: Expression<F>) -> Expression<F> {
|
||||||
|
|
@ -323,6 +333,13 @@ impl<F> Add for Expression<F> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<F: FieldExt> Sub for Expression<F> {
|
||||||
|
type Output = Expression<F>;
|
||||||
|
fn sub(self, rhs: Expression<F>) -> Expression<F> {
|
||||||
|
Expression::Sum(Box::new(self), Box::new(-rhs))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<F> Mul for Expression<F> {
|
impl<F> Mul for Expression<F> {
|
||||||
type Output = Expression<F>;
|
type Output = Expression<F>;
|
||||||
fn mul(self, rhs: Expression<F>) -> Expression<F> {
|
fn mul(self, rhs: Expression<F>) -> Expression<F> {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue