-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathops.rs
97 lines (78 loc) · 2.24 KB
/
ops.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//! # Number operations
//!
//! During the interaction with each of a `MatrixProvider`'s associated types it should be possible
//! to do certain operations.
use std::fmt::{Debug, Display};
use std::iter::Sum;
use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign};
use num_traits::{One, Zero};
use relp_num::NonZero;
use relp_num::Signed;
use crate::data::linear_algebra::traits::SparseElement;
/// Operations done by the number type within the inverse maintenance algorithm.
pub trait Field =
Zero +
NonZero +
One +
Signed +
Neg<Output=Self> +
Add<Self, Output=Self> +
for<'r> Add<&'r Self, Output=Self> +
AddAssign +
for<'r> AddAssign<&'r Self> +
Sub<Self, Output=Self> +
for<'r> Sub<&'r Self, Output=Self> +
SubAssign +
for<'r> SubAssign<&'r Self> +
Mul<Self, Output=Self> +
for<'r> Mul<&'r Self, Output=Self> +
MulAssign +
for<'r> MulAssign<&'r Self> +
Div<Self, Output=Self> +
for<'r> Div<&'r Self, Output=Self> +
DivAssign<Self> +
for<'r> DivAssign<&'r Self> +
Sum +
Column<relp_num::One> +
Eq +
PartialEq +
Ord +
PartialOrd +
SparseElement<Self> +
for<'r> From<&'r Self> +
Clone +
Debug +
Display +
;
// TODO(ARCHITECTURE): Once HRTB are propagated like normal associated type trait bounds, remove
// this trait by integrating the requirements into `InverseMaintenance::F`'s trait bounds.
#[allow(clippy::type_repetition_in_bounds)]
pub trait FieldHR =
where
for<'r> &'r Self: Neg<Output=Self>,
for<'r> &'r Self: Mul<&'r Self, Output=Self>,
for<'r> &'r Self: Div<&'r Self, Output=Self>,
;
/// Operations with the values in the columns.
pub trait Column<Rhs> =
for<'r> AddAssign<&'r Rhs> +
for<'r> Add<&'r Rhs, Output=Self> +
for<'r> Mul<&'r Rhs, Output=Self> +
From<Rhs> +
for<'r> From<&'r Rhs> +
where
for<'r> &'r Self: Mul<&'r Rhs, Output=Self>,
;
/// Operations with the cost type.
pub trait Cost<Rhs> =
Add<Rhs, Output=Self> +
Mul<Rhs, Output=Self> +
where
for<'r> &'r Self: Mul<Rhs, Output=Self>,
;
/// Operations with the right-hand side.
pub trait Rhs<Rhs> =
for<'r> AddAssign<&'r Rhs> +
for<'r> Add<&'r Rhs, Output=Self> +
From<Rhs> +
;