Skip to content

Commit

Permalink
sphere2: API documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
alphaville committed Oct 27, 2023
1 parent d083416 commit 493c5eb
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/constraints/sphere2.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use super::Constraint;

#[derive(Copy, Clone)]
/// A Euclidean sphere, that is, a set given by $B_2^r = \\{x \in \mathbb{R}^n {}:{} \Vert{}x{}\Vert = r\\}$
/// or a Euclidean sphere centered at a point $x_c$, that is, $B_2^{x_c, r} = \\{x \in \mathbb{R}^n {}:{} \Vert{}x-x_c{}\Vert = r\\}$
/// A Euclidean sphere, that is, a set given by $S_2^r = \\{x \in \mathbb{R}^n {}:{} \Vert{}x{}\Vert = r\\}$
/// or a Euclidean sphere centered at a point $x_c$, that is, $S_2^{x_c, r} = \\{x \in \mathbb{R}^n {}:{} \Vert{}x-x_c{}\Vert = r\\}$
pub struct Sphere2<'a> {
center: Option<&'a [f64]>,
radius: f64,
Expand All @@ -18,13 +18,16 @@ impl<'a> Sphere2<'a> {
}

impl<'a> Constraint for Sphere2<'a> {
/// Projection onto the set, that is,
/// Projection onto the sphere, $S_{r, c}$ with radius $r$ and center $c$.
/// If $x\neq c$, the projection is uniquely defined by
///
/// $$
/// \Pi_C(v) = \mathrm{argmin}_{z\in C}\Vert{}z-v{}\Vert
/// P_{S_{r, c}}(x) = c + r\frac{x-c}{\Vert{}x-c\Vert_2},
/// $$
///
///
/// but for $x=c$, the projection is multi-valued. In particular, let
/// $y = P_{S_{r, c}}(c)$. Then $y_1 = c_1 + r$ and $y_i = c_i$ for
/// $i=2,\ldots, n$.
///
/// ## Arguments
///
Expand Down Expand Up @@ -53,6 +56,8 @@ impl<'a> Constraint for Sphere2<'a> {
}
}

/// Returns false (the sphere is not a convex set)
///
fn is_convex(&self) -> bool {
false
}
Expand Down

0 comments on commit 493c5eb

Please sign in to comment.