src/mapping.rs

branch
dev
changeset 68
c5f70e767511
parent 61
05089fbc0310
child 69
e5fab0125a8e
child 80
f802ddbabcfc
--- a/src/mapping.rs	Mon Dec 30 09:49:08 2024 -0500
+++ b/src/mapping.rs	Tue Dec 31 08:48:50 2024 -0500
@@ -4,8 +4,7 @@
 
 use std::marker::PhantomData;
 use std::borrow::Cow;
-use crate::types::{Num, Float};
-use serde::Serialize;
+use crate::types::{Num, Float, ClosedMul};
 use crate::loc::Loc;
 pub use crate::instance::{Instance, Decomposition, BasicDecomposition, Space};
 use crate::norms::{Norm, NormExponent};
@@ -45,6 +44,17 @@
     {
         Composition{ outer : self, inner : other, intermediate_norm_exponent : norm }
     }
+
+    /// Multiply `self` by the scalar `a`.
+    #[inline]
+    fn weigh<C>(self, a : C) -> Weighted<Self, C>
+    where
+        Self : Sized,
+        C : Constant,
+        Self::Codomain : ClosedMul<C::Type>,
+    {
+        Weighted { weight : a, base_fn : self }
+    }
 }
 
 /// Automatically implemented shorthand for referring to [`Mapping`]s from [`Loc<F, N>`] to `F`.

mercurial