pub struct Hyperplane<'a, T = f64> { /* private fields */ }Expand description
A hyperplane is a set given by $H = \{x \in \mathbb{R}^n {}:{} \langle c, x\rangle = b\}$.
Implementations§
Source§impl<'a, T> Hyperplane<'a, T>
impl<'a, T> Hyperplane<'a, T>
Sourcepub fn new(normal_vector: &'a [T], offset: T) -> Self
pub fn new(normal_vector: &'a [T], offset: T) -> Self
A hyperplane is a set given by $H = \{x \in \mathbb{R}^n {}:{} \langle c, x\rangle = b\}$, where $c$ is the normal vector of the hyperplane and $b$ is an offset.
This method constructs a new instance of Hyperplane with a given normal
vector and offset.
§Arguments
normal_vector: the normal vector, $c$, as a sliceoffset: the offset parameter, $b$
§Returns
New instance of Hyperplane
§Panics
This method panics if the normal vector has zero Euclidean norm.
§Example
use optimization_engine::constraints::{Constraint, Hyperplane};
let normal_vector = [1., 2.];
let offset = 1.0;
let hyperplane = Hyperplane::new(&normal_vector, offset);
let mut x = [-1., 3.];
hyperplane.project(&mut x).unwrap();Trait Implementations§
Source§impl<'a, T: Clone> Clone for Hyperplane<'a, T>
impl<'a, T: Clone> Clone for Hyperplane<'a, T>
Source§fn clone(&self) -> Hyperplane<'a, T>
fn clone(&self) -> Hyperplane<'a, T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'a, T> Constraint<T> for Hyperplane<'a, T>
impl<'a, T> Constraint<T> for Hyperplane<'a, T>
Source§fn project(&self, x: &mut [T]) -> FunctionCallResult
fn project(&self, x: &mut [T]) -> FunctionCallResult
Projects on the hyperplane using the formula:
$$\begin{aligned} \mathrm{proj}_{H}(x) = x - \frac{\langle c, x\rangle - b} {\|c\|^2}c. \end{aligned}$$
where $H = \{x \in \mathbb{R}^n {}:{} \langle c, x\rangle = b\}$
§Arguments
x: (in) vector to be projected on the current instance of a hyperplane, (out) projection on the hyperplane
§Panics
This method panics if the length of x is not equal to the dimension
of the hyperplane.
Auto Trait Implementations§
impl<'a, T> Freeze for Hyperplane<'a, T>where
T: Freeze,
impl<'a, T> RefUnwindSafe for Hyperplane<'a, T>where
T: RefUnwindSafe,
impl<'a, T> Send for Hyperplane<'a, T>
impl<'a, T> Sync for Hyperplane<'a, T>where
T: Sync,
impl<'a, T> Unpin for Hyperplane<'a, T>where
T: Unpin,
impl<'a, T> UnsafeUnpin for Hyperplane<'a, T>where
T: UnsafeUnpin,
impl<'a, T> UnwindSafe for Hyperplane<'a, T>where
T: UnwindSafe + RefUnwindSafe,
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