Skip to content

Commit

Permalink
merge master; fix clippy issues; fix typo in Cargo
Browse files Browse the repository at this point in the history
  • Loading branch information
alphaville committed Mar 20, 2024
1 parent ca663e1 commit 1d19ab3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jemallocator = { version = "0.5.0", optional = true }


# computation of roots of cubic equation needed for the projection on the
# epigraph of the squared Eucliean norm
# epigraph of the squared Euclidean norm
roots = "0.0.8"

# Least squares solver
Expand Down
11 changes: 5 additions & 6 deletions src/constraints/epigraph_squared_norm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::matrix_operations;

use super::Constraint;

#[derive(Copy, Clone)]
#[derive(Copy, Clone, Default)]
/// The epigraph of the squared Eucliden norm is a set of the form
/// $X = \\{x = (z, t) \in \mathbb{R}^{n}\times \mathbb{R} {}:{} \\|z\\|^2 \leq t \\}.$
pub struct EpigraphSquaredNorm {}
Expand Down Expand Up @@ -39,7 +39,7 @@ impl Constraint for EpigraphSquaredNorm {
assert!(nx > 0, "x must have a length of at least 2");
let z: &[f64] = &x[..nx];
let t: f64 = x[nx];
let norm_z_sq = matrix_operations::norm2_squared(&z);
let norm_z_sq = matrix_operations::norm2_squared(z);
if norm_z_sq <= t {
return;
}
Expand All @@ -62,7 +62,6 @@ impl Constraint for EpigraphSquaredNorm {
right_root = *ri;
scaling = denom;
}
return;
}
});

Expand All @@ -77,15 +76,15 @@ impl Constraint for EpigraphSquaredNorm {
let zsol_cb = zsol_sq * zsol;
let p_z = a3 * zsol_cb + a2 * zsol_sq + a1 * zsol + a0;
let dp_z = 3. * a3 * zsol_sq + 2. * a2 * zsol + a1;
zsol = zsol - p_z / dp_z;
zsol -= p_z / dp_z;
refinement_error = p_z.abs();
iter += 1;
}
right_root = zsol;

// Projection
for i in 0..nx {
x[i] /= scaling;
for xi in x.iter_mut().take(nx) {
*xi /= scaling;
}
x[nx] = right_root;
}
Expand Down
3 changes: 2 additions & 1 deletion src/constraints/tests.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::matrix_operations;

use super::*;
use modcholesky::ModCholeskySE99;
use rand;

#[test]
Expand Down Expand Up @@ -922,6 +921,8 @@ fn t_epigraph_squared_norm_correctness() {
"wrong projection on epigraph of squared norm",
);
}

#[test]
fn t_affine_space() {
let a = vec![
0.5, 0.1, 0.2, -0.3, -0.6, 0.3, 0., 0.5, 1.0, 0.1, -1.0, -0.4,
Expand Down

0 comments on commit 1d19ab3

Please sign in to comment.