src/discrete_gradient.rs

branch
dev
changeset 80
f802ddbabcfc
parent 67
d7c0f431cbd6
equal deleted inserted replaced
68:c5f70e767511 80:f802ddbabcfc
5 use nalgebra::{ 5 use nalgebra::{
6 DVector, Matrix, U1, Storage, StorageMut, Dyn 6 DVector, Matrix, U1, Storage, StorageMut, Dyn
7 }; 7 };
8 use crate::types::Float; 8 use crate::types::Float;
9 use crate::instance::Instance; 9 use crate::instance::Instance;
10 use crate::mapping::ArithmeticTrue;
10 use crate::linops::{Mapping, Linear, BoundedLinear, Adjointable, GEMV}; 11 use crate::linops::{Mapping, Linear, BoundedLinear, Adjointable, GEMV};
11 use crate::norms::{Norm, L2}; 12 use crate::norms::{Norm, L2};
12 13
13 #[derive(Copy, Clone, Debug)] 14 #[derive(Copy, Clone, Debug)]
14 /// Forward differences with Neumann boundary conditions 15 /// Forward differences with Neumann boundary conditions
256 where 257 where
257 B : Discretisation<F>, 258 B : Discretisation<F>,
258 F : Float + nalgebra::RealField, 259 F : Float + nalgebra::RealField,
259 { 260 {
260 type Codomain = DVector<F>; 261 type Codomain = DVector<F>;
262 type ArithmeticOptIn = ArithmeticTrue;
263
261 fn apply<I : Instance<DVector<F>>>(&self, i : I) -> DVector<F> { 264 fn apply<I : Instance<DVector<F>>>(&self, i : I) -> DVector<F> {
262 let mut y = DVector::zeros(N * self.len()); 265 let mut y = DVector::zeros(N * self.len());
263 self.apply_add(&mut y, i); 266 self.apply_add(&mut y, i);
264 y 267 y
265 } 268 }
300 where 303 where
301 B : Discretisation<F>, 304 B : Discretisation<F>,
302 F : Float + nalgebra::RealField, 305 F : Float + nalgebra::RealField,
303 { 306 {
304 type Codomain = DVector<F>; 307 type Codomain = DVector<F>;
308 type ArithmeticOptIn = ArithmeticTrue;
309
305 fn apply<I : Instance<DVector<F>>>(&self, i : I) -> DVector<F> { 310 fn apply<I : Instance<DVector<F>>>(&self, i : I) -> DVector<F> {
306 let mut y = DVector::zeros(self.len()); 311 let mut y = DVector::zeros(self.len());
307 self.apply_add(&mut y, i); 312 self.apply_add(&mut y, i);
308 y 313 y
309 } 314 }

mercurial