pub struct Hyperplane<'a> { /* 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> Hyperplane<'a>
impl<'a> Hyperplane<'a>
Sourcepub fn new(normal_vector: &'a [f64], offset: f64) -> Self
pub fn new(normal_vector: &'a [f64], offset: f64) -> 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 bias
§Arguments
normal_vector
: the normal vector, $c$, as a sliceoffset
: the offset parameter, $b$
§Returns
New instance of Hyperplane
§Panics
Does not panic. Note: it does not panic if you provide an empty slice as normal_vector
,
but you should avoid doing that.
§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);
Trait Implementations§
Source§impl<'a> Clone for Hyperplane<'a>
impl<'a> Clone for Hyperplane<'a>
Source§fn clone(&self) -> Hyperplane<'a>
fn clone(&self) -> Hyperplane<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<'a> Constraint for Hyperplane<'a>
impl<'a> Constraint for Hyperplane<'a>
Source§fn project(&self, x: &mut [f64])
fn project(&self, x: &mut [f64])
Projects on the hyperplane using the formula:
$$\begin{aligned} \mathrm{proj}_{H}(x) = x - \frac{\langle c, x\rangle - b} {\|c\|}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 second-order cone
§Panics
This method panics if the length of x
is not equal to the dimension
of the hyperplane.