src/fourier.rs

Sun, 11 Dec 2022 23:25:53 +0200

author
Tuomo Valkonen <tuomov@iki.fi>
date
Sun, 11 Dec 2022 23:25:53 +0200
changeset 24
d29d1fcf5423
parent 0
eb3c7813b67a
permissions
-rw-r--r--

Support arbitrary regularisation terms; implement non-positivity-constrained regularisation.

* Fixes the conditional gradient methods that were incorrectly solving
positivity constrained subproblems although the infinite-dimensional
versions do not include such constraints.

* Introduces the `ExperimentV2` struct that has `regularisation` in place
of `α`. The `Experiment` struct is now deprecated.

* The L^2-squared experiments were switch to be unconstrained, as the
Franke-Wolfe implementations do not support constraints. (This would
be easy to add for the “fully corrective” variant, but is not
immediate for the “relaxed” variant.)

/*!
Fourier transform traits
*/

use alg_tools::types::{Num, Float};
use alg_tools::mapping::{RealMapping, Mapping};
use alg_tools::bisection_tree::Weighted;
use alg_tools::loc::Loc;

/// Trait for Fourier transforms. When F is a non-complex number, the transform
/// also has to be non-complex, i.e., the function itself symmetric.
pub trait Fourier<F : Num> : Mapping<Self::Domain, Codomain=F> {
    type Domain;
    type Transformed : Mapping<Self::Domain, Codomain=F>;

    fn fourier(&self) -> Self::Transformed;
}

impl<F : Float, T, const N : usize> Fourier<F>
for Weighted<T, F>
where T : Fourier<F, Domain = Loc<F, N>> + RealMapping<F, N> {
    type Domain = T::Domain;
    type Transformed = Weighted<T::Transformed, F>;

    #[inline]
    fn fourier(&self) -> Self::Transformed {
        Weighted {
            base_fn : self.base_fn.fourier(),
            weight : self.weight
        }
    }
}

mercurial