Thanks to visit codestin.com
Credit goes to docs.rs

Struct Hyperplane

Source
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>

Source

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 slice
  • offset: 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>

Source§

fn clone(&self) -> Hyperplane<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Constraint for Hyperplane<'a>

Source§

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.

Source§

fn is_convex(&self) -> bool

Hyperplanes are convex sets

§Returns

Returns true

Auto Trait Implementations§

§

impl<'a> Freeze for Hyperplane<'a>

§

impl<'a> RefUnwindSafe for Hyperplane<'a>

§

impl<'a> Send for Hyperplane<'a>

§

impl<'a> Sync for Hyperplane<'a>

§

impl<'a> Unpin for Hyperplane<'a>

§

impl<'a> UnwindSafe for Hyperplane<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V