pub struct LinearOperation<T>{
_marker: PhantomData<fn() -> T>,
}Expand description
$(a, b) \circ (c, d) = \lambda x. c \times (a \times x + b) + d$
Fields§
§_marker: PhantomData<fn() -> T>Implementations§
Source§impl<T> LinearOperation<T>
impl<T> LinearOperation<T>
Sourcepub fn apply(f: &(T, T), x: &T) -> T
pub fn apply(f: &(T, T), x: &T) -> T
Examples found in repository?
crates/library_checker/src/tree/dynamic_tree_vertex_set_path_composite.rs (line 103)
90pub fn dynamic_tree_vertex_set_path_composite(reader: impl Read, writer: impl Write) {
91 prepare_io!(reader, writer);
92 sc!(n, q, ab: [Affine; n], edges: [(usize, usize); n - 1]);
93 let mut tree = PathLinkCutTree::<PathComposite>::from_edges(ab, &edges);
94 for _ in 0..q {
95 sc!(query: Query);
96 match query {
97 Query::Relink { u, v, w, x } => {
98 tree.cut(u, v);
99 tree.link(w, x);
100 }
101 Query::Set { p, cd } => tree.set(p, cd),
102 Query::Apply { u, v, x } => {
103 pp!(LinearOperation::apply(&tree.fold_path(u, v).0, &x));
104 }
105 }
106 }
107}
108
109#[verify::library_checker("dynamic_tree_vertex_set_path_composite")]
110pub fn dynamic_tree_vertex_set_path_composite_top_tree(reader: impl Read, writer: impl Write) {
111 prepare_io!(reader, writer);
112 sc!(n, q, ab: [Affine; n], edges: [(usize, usize); n - 1]);
113 let mut tree = TopTree::<PathComposite>::from_edges(ab, &edges);
114 for _ in 0..q {
115 sc!(query: Query);
116 match query {
117 Query::Relink { u, v, w, x } => {
118 tree.cut(u, v);
119 tree.link(w, x);
120 }
121 Query::Set { p, cd } => tree.set(p, cd),
122 Query::Apply { u, v, x } => {
123 pp!(LinearOperation::apply(&tree.fold_path(u, v).0, &x));
124 }
125 }
126 }
127}Trait Implementations§
impl<T> Associative for LinearOperation<T>
Source§impl<T> Invertible for LinearOperation<T>
impl<T> Invertible for LinearOperation<T>
Source§impl<T> Magma for LinearOperation<T>
impl<T> Magma for LinearOperation<T>
Auto Trait Implementations§
impl<T> Freeze for LinearOperation<T>
impl<T> RefUnwindSafe for LinearOperation<T>
impl<T> Send for LinearOperation<T>
impl<T> Sync for LinearOperation<T>
impl<T> Unpin for LinearOperation<T>
impl<T> UnsafeUnpin for LinearOperation<T>
impl<T> UnwindSafe for LinearOperation<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more