Skip to content

Commit

Permalink
bump nalgebra to latest version and fix compile
Browse files Browse the repository at this point in the history
  • Loading branch information
geo-ant committed Jul 22, 2024
1 parent 7e9feb9 commit b6330ff
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 27 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ default = []
minpack-compat = []

[dependencies]
nalgebra = { version = "0.32.1", default-features = false }
num-traits = { version = "0.2.14", default-features = false, features = [
nalgebra = { version = "0.33", default-features = false }
num-traits = { version = "0.2", default-features = false, features = [
"libm",
] }
cfg-if = "1.0.0"

[dev-dependencies]
arrsac = "0.10.0"
rand = { version = "0.8.4", default-features = false }
nalgebra = "0.32.1"
nalgebra = "0.33"
pcg_rand = "0.13.0"
sample-consensus = "1.0.2"
approx = "0.5.1"
Expand Down
11 changes: 5 additions & 6 deletions src/lm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,7 @@ impl<F: RealField + Float> LevenbergMarquardt<F> {
N: Dim,
M: DimMin<N> + DimMax<N>,
O: LeastSquaresProblem<F, M, N>,
DefaultAllocator:
Allocator<F, N> + Reallocator<F, M, N, DimMaximum<M, N>, N> + Allocator<usize, N>,
DefaultAllocator: Allocator<N> + Reallocator<F, M, N, DimMaximum<M, N>, N>,
{
let (mut lm, mut residuals) = match LM::new(self, target) {
Err(report) => return report,
Expand Down Expand Up @@ -309,7 +308,7 @@ where
N: Dim,
M: DimMin<N> + DimMax<N>,
O: LeastSquaresProblem<F, M, N>,
DefaultAllocator: Allocator<F, N> + Allocator<F, DimMaximum<M, N>, N>,
DefaultAllocator: Allocator<N> + Allocator<DimMaximum<M, N>, N>,
{
config: &'a LevenbergMarquardt<F>,
/// Current parameters `$\vec{x}$`
Expand Down Expand Up @@ -342,7 +341,7 @@ where
N: Dim,
M: DimMin<N> + DimMax<N>,
O: LeastSquaresProblem<F, M, N>,
DefaultAllocator: Allocator<F, N> + Allocator<F, DimMaximum<M, N>, N>,
DefaultAllocator: Allocator<N> + Allocator<DimMaximum<M, N>, N>,
{
#[allow(clippy::type_complexity)]
fn new(
Expand Down Expand Up @@ -455,7 +454,7 @@ where
lls: &mut LinearLeastSquaresDiagonalProblem<F, M, N>,
) -> Result<(), TerminationReason>
where
DefaultAllocator: Allocator<usize, N>,
DefaultAllocator: Allocator<N>,
{
// Compute norm of scaled gradient and detect degeneracy
self.gnorm = match lls.max_a_t_b_scaled(self.residuals_norm) {
Expand Down Expand Up @@ -510,7 +509,7 @@ where
param: LMParameter<F, N>,
) -> Result<Option<Vector<F, M, O::ResidualStorage>>, TerminationReason>
where
DefaultAllocator: Allocator<usize, N>,
DefaultAllocator: Allocator<N>,
{
const P1: f64 = 0.1;
const P0001: f64 = 1.0e-4;
Expand Down
6 changes: 3 additions & 3 deletions src/lm/test_examples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -512,14 +512,14 @@ impl LeastSquaresProblem<f64, U16, U3> for Meyer {
#[derive(Clone)]
struct Watson<P: DimName>
where
DefaultAllocator: Allocator<f64, P>,
DefaultAllocator: Allocator<P>,
{
params: OVector<f64, P>,
}

impl<P: DimName> Watson<P>
where
DefaultAllocator: Allocator<f64, P>,
DefaultAllocator: Allocator<P>,
{
fn new(params: OVector<f64, P>, _n: usize) -> Self {
Self { params }
Expand All @@ -528,7 +528,7 @@ where

impl<P: DimName> LeastSquaresProblem<f64, U31, P> for Watson<P>
where
DefaultAllocator: Allocator<f64, P> + Allocator<f64, U31, P>,
DefaultAllocator: Allocator<P> + Allocator<U31, P>,
{
type ParameterStorage = Owned<f64, P>;
type ResidualStorage = Owned<f64, U31>;
Expand Down
6 changes: 3 additions & 3 deletions src/lm/test_helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub enum MockCall {
#[derive(Clone)]
pub struct MockProblem<N: Dim, M: Dim>
where
DefaultAllocator: Allocator<f64, N> + Allocator<f64, M> + Allocator<f64, M, N>,
DefaultAllocator: Allocator<N> + Allocator<M> + Allocator<M, N>,
{
call_history: RefCell<Vec<MockCall>>,
params: Vec<OVector<f64, N>>,
Expand All @@ -27,7 +27,7 @@ where

impl<N: Dim, M: Dim> MockProblem<N, M>
where
DefaultAllocator: Allocator<f64, N> + Allocator<f64, M> + Allocator<f64, M, N>,
DefaultAllocator: Allocator<N> + Allocator<M> + Allocator<M, N>,
{
pub fn new(initial: OVector<f64, N>, residuals: Vec<Option<OVector<f64, M>>>) -> Self {
Self {
Expand All @@ -47,7 +47,7 @@ where

impl<N: Dim, M: Dim> LeastSquaresProblem<f64, M, N> for MockProblem<N, M>
where
DefaultAllocator: Allocator<f64, N> + Allocator<f64, M> + Allocator<f64, M, N>,
DefaultAllocator: Allocator<N> + Allocator<M> + Allocator<M, N>,
{
type ResidualStorage = Owned<f64, M>;
type ParameterStorage = Owned<f64, N>;
Expand Down
12 changes: 6 additions & 6 deletions src/qr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ where
M: Dim + DimMin<N>,
N: Dim,
S: RawStorageMut<F, M, N> + IsContiguous,
DefaultAllocator: Allocator<F, N> + Allocator<usize, N>,
DefaultAllocator: Allocator<N>,
{
/// The column norms of the input matrix `$\mathbf{A}$`
column_norms: OVector<F, N>,
Expand All @@ -54,7 +54,7 @@ where
M: Dim + DimMin<N> + DimMax<N>,
N: Dim,
S: RawStorageMut<F, M, N> + Storage<F, M, N> + IsContiguous,
DefaultAllocator: Allocator<F, N> + Allocator<F, DimMaximum<M, N>, N> + Allocator<usize, N>,
DefaultAllocator: Allocator<N> + Allocator<DimMaximum<M, N>, N>,
{
/// Create a pivoted QR decomposition of a matrix `$\mathbf{A}\in\R^{m\times n}$`.
pub fn new(mut a: Matrix<F, M, N, S>) -> Self {
Expand Down Expand Up @@ -203,7 +203,7 @@ where
F: nalgebra::RealField + Float + Copy,
M: Dim + DimMax<N>,
N: Dim,
DefaultAllocator: Allocator<F, N> + Allocator<F, DimMaximum<M, N>, N> + Allocator<usize, N>,
DefaultAllocator: Allocator<N> + Allocator<DimMaximum<M, N>, N>,
{
/// The first `$n$` entries of `$\mathbf{Q}^\top \vec{b}$`.
qt_b: OVector<F, N>,
Expand All @@ -224,7 +224,7 @@ where
F: nalgebra::RealField + Copy,
M: Dim + DimMax<N>,
N: Dim,
DefaultAllocator: Allocator<F, N> + Allocator<F, DimMaximum<M, N>, N> + Allocator<usize, N>,
DefaultAllocator: Allocator<N> + Allocator<DimMaximum<M, N>, N>,
{
pub permutation: &'a OVector<usize, N>,
l: &'a OMatrix<F, DimMaximum<M, N>, N>,
Expand All @@ -239,7 +239,7 @@ where
F: nalgebra::RealField + Copy,
M: Dim + DimMin<N> + DimMax<N>,
N: Dim,
DefaultAllocator: Allocator<F, N> + Allocator<F, DimMaximum<M, N>, N> + Allocator<usize, N>,
DefaultAllocator: Allocator<N> + Allocator<DimMaximum<M, N>, N> + Allocator<N>,
{
/// Solve the equation `$\mathbf{L}\vec{x} = \mathbf{P}^\top \vec{b}$`.
pub fn solve(&mut self, mut rhs: OVector<F, N>) -> OVector<F, N> {
Expand Down Expand Up @@ -295,7 +295,7 @@ where
F: nalgebra::RealField + Float + Copy,
M: Dim + DimMin<N> + DimMax<N>,
N: Dim,
DefaultAllocator: Allocator<F, N> + Allocator<F, DimMaximum<M, N>, N> + Allocator<usize, N>,
DefaultAllocator: Allocator<N> + Allocator<DimMaximum<M, N>, N>,
{
/// Compute scaled maximum of dot products between `$\vec{b}$` and the columns of `$\mathbf{A}$`.
///
Expand Down
4 changes: 2 additions & 2 deletions src/trust_region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use num_traits::Float;

pub struct LMParameter<F: RealField, N: Dim>
where
DefaultAllocator: Allocator<F, N>,
DefaultAllocator: Allocator<N>,
{
pub step: OVector<F, N>,
pub lambda: F,
Expand Down Expand Up @@ -59,7 +59,7 @@ where
F: RealField + Float,
N: Dim,
M: Dim + DimMin<N> + DimMax<N>,
DefaultAllocator: Allocator<F, N> + Allocator<F, DimMaximum<M, N>, N> + Allocator<usize, N>,
DefaultAllocator: Allocator<N> + Allocator<DimMaximum<M, N>, N>,
{
const P1: f64 = 0.1;
debug_assert!(delta.is_positive());
Expand Down
7 changes: 3 additions & 4 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ where
M: Dim,
O: LeastSquaresProblem<F, M, N>,
O::JacobianStorage: Clone,
DefaultAllocator: Allocator<F, M, N, Buffer = O::JacobianStorage>,
DefaultAllocator: Allocator<M, N, Buffer<F> = O::JacobianStorage>,
{
let params = problem.params();
let n = params.data.shape().0;
Expand Down Expand Up @@ -217,9 +217,8 @@ where
N: Dim,
M: Dim,
O: LeastSquaresProblem<Complex<F>, M, N>,
DefaultAllocator: Allocator<Complex<F>, N, Buffer = O::ParameterStorage>
+ Allocator<F, N>
+ Allocator<F, M, N>,
DefaultAllocator:
Allocator<N, Buffer<Complex<F>> = O::ParameterStorage> + Allocator<N> + Allocator<M, N>,
{
let mut params = problem.params();
assert!(params.iter().all(|x| x.im.is_zero()), "params must be real");
Expand Down

0 comments on commit b6330ff

Please sign in to comment.