Fix warnings.

This commit is contained in:
2020-04-17 20:39:01 +02:00
parent 81ed582e59
commit 5aaada0c05
11 changed files with 76 additions and 112 deletions

View File

@@ -463,58 +463,6 @@ impl Normest1 {
}
}
/// Estimates the 1-norm of matrix `a`.
///
/// The parameter `t` is the number of vectors that have to fulfill some bound. See [Higham,
/// Tisseur] for more information. `itmax` is the maximum number of sweeps permitted.
///
/// **NOTE:** This function allocates on every call. If you want to repeatedly estimate the
/// 1-norm on matrices of the same size, construct a [`Normest1`] first, and call its methods.
///
/// [Higham, Tisseur]: http://eprints.ma.man.ac.uk/321/1/covered/MIMS_ep2006_145.pdf
/// [`Normest1`]: struct.Normest1.html
pub fn normest1(a_matrix: &Array2<f64>, t: usize, itmax: usize) -> f64 {
// Assume the matrix is square and take the columns as n. If it's not square, the assertion in
// normest.calculate will fail.
let n = a_matrix.dim().1;
let mut normest1 = Normest1::new(n, t);
normest1.normest1(a_matrix, itmax)
}
/// Estimates the 1-norm of a matrix `a` to the power `m`, `a^m`.
///
/// The parameter `t` is the number of vectors that have to fulfill some bound. See [Higham,
/// Tisseur] for more information. `itmax` is the maximum number of sweeps permitted.
///
/// **NOTE:** This function allocates on every call. If you want to repeatedly estimate the
/// 1-norm on matrices of the same size, construct a [`Normest1`] first, and call its methods.
///
/// [Higham, Tisseur]: http://eprints.ma.man.ac.uk/321/1/covered/MIMS_ep2006_145.pdf
pub fn normest1_pow(a_matrix: &Array2<f64>, m: usize, t: usize, itmax: usize) -> f64 {
// Assume the matrix is square and take the columns as n. If it's not square, the assertion in
// normest.calculate will fail.
let n = a_matrix.dim().1;
let mut normest1 = Normest1::new(n, t);
normest1.normest1_pow(a_matrix, m, itmax)
}
/// Estimates the 1-norm of a product of matrices `a1`, `a2`, ..., `an` passed in as a slice of
/// references.
///
/// The parameter `t` is the number of vectors that have to fulfill some bound. See [Higham,
/// Tisseur] for more information. `itmax` is the maximum number of sweeps permitted.
///
/// **NOTE:** This function allocates on every call. If you want to repeatedly estimate the
/// 1-norm on matrices of the same size, construct a [`Normest1`] first, and call its methods.
///
/// [Higham, Tisseur]: http://eprints.ma.man.ac.uk/321/1/covered/MIMS_ep2006_145.pdf
pub fn normest1_prod(a_matrices: &[&Array2<f64>], t: usize, itmax: usize) -> f64 {
assert!(a_matrices.len() > 0);
let n = a_matrices[0].dim().1;
let mut normest1 = Normest1::new(n, t);
normest1.normest1_prod(a_matrices, itmax)
}
/// Assigns the sign of matrix `a` to matrix `b`.
///
/// Panics if matrices `a` and `b` have different shape and strides, or if either underlying array is

View File

@@ -29,7 +29,7 @@ pub trait Kernel {
b
}
fn noise_cov(&self, t0: f64, t1: f64) -> Array2<f64> {
fn noise_cov(&self, _t0: f64, _t1: f64) -> Array2<f64> {
/*
mat = self.noise_effect.dot(self.noise_density).dot(self.noise_effect.T)
#print(g)

View File

@@ -21,11 +21,11 @@ impl Kernel for Constant {
1
}
fn state_mean(&self, t: f64) -> Array1<f64> {
fn state_mean(&self, _t: f64) -> Array1<f64> {
Array1::zeros(1)
}
fn state_cov(&self, t: f64) -> Array2<f64> {
fn state_cov(&self, _t: f64) -> Array2<f64> {
array![[1.0]] * self.var
}
@@ -37,11 +37,11 @@ impl Kernel for Constant {
array![[0.0]]
}
fn transition(&self, t0: f64, t1: f64) -> Array2<f64> {
fn transition(&self, _t0: f64, _t1: f64) -> Array2<f64> {
array![[1.0]]
}
fn noise_cov(&self, t0: f64, t1: f64) -> Array2<f64> {
fn noise_cov(&self, _t0: f64, _t1: f64) -> Array2<f64> {
array![[0.0]]
}
}

View File

@@ -22,11 +22,11 @@ impl Kernel for Exponential {
1
}
fn state_mean(&self, t: f64) -> Array1<f64> {
fn state_mean(&self, _t: f64) -> Array1<f64> {
Array1::zeros(1)
}
fn state_cov(&self, t: f64) -> Array2<f64> {
fn state_cov(&self, _t: f64) -> Array2<f64> {
array![[1.0]] * self.var
}

View File

@@ -28,11 +28,11 @@ impl Kernel for Matern32 {
2
}
fn state_mean(&self, t: f64) -> Array1<f64> {
fn state_mean(&self, _t: f64) -> Array1<f64> {
Array1::zeros(2)
}
fn state_cov(&self, t: f64) -> Array2<f64> {
fn state_cov(&self, _t: f64) -> Array2<f64> {
let a = self.lambda;
array![[1.0, 0.0], [0.0, a * a]] * self.var

View File

@@ -4,7 +4,7 @@ use super::Kernel;
pub struct Matern52 {
var: f64,
l_scale: f64,
_l_scale: f64,
lambda: f64,
}
@@ -12,7 +12,7 @@ impl Matern52 {
pub fn new(var: f64, l_scale: f64) -> Self {
Matern52 {
var,
l_scale,
_l_scale: l_scale,
lambda: 5.0f64.sqrt() / l_scale,
}
}
@@ -27,11 +27,11 @@ impl Kernel for Matern52 {
3
}
fn state_mean(&self, t: f64) -> Array1<f64> {
fn state_mean(&self, _t: f64) -> Array1<f64> {
Array1::zeros(3)
}
fn state_cov(&self, t: f64) -> Array2<f64> {
fn state_cov(&self, _t: f64) -> Array2<f64> {
let a = self.lambda;
array![

View File

@@ -16,7 +16,7 @@ pub struct DifferenceModel {
storage: Storage,
last_t: f64,
observations: Vec<GaussianObservation>,
last_method: Option<DifferenceModelFitMethod>,
_last_method: Option<DifferenceModelFitMethod>,
var: f64,
}
@@ -26,7 +26,7 @@ impl DifferenceModel {
storage: Storage::new(),
last_t: f64::NEG_INFINITY,
observations: Vec::new(),
last_method: None,
_last_method: None,
var, // default = 1.0
}
}
@@ -83,10 +83,10 @@ impl DifferenceModel {
pub fn probabilities(
&mut self,
team_1: &[&str],
team_2: &[&str],
t: f64,
margin: Option<f64>,
_team_1: &[&str],
_team_2: &[&str],
_t: f64,
_margin: Option<f64>,
) -> (f64, f64, f64) {
unimplemented!();
}

View File

@@ -3,34 +3,41 @@ use crate::storage::Storage;
use super::Observation;
pub struct GaussianObservation {
m: usize,
items: Vec<usize>,
coeffs: Vec<f64>,
indices: Vec<usize>,
ns_cav: Vec<f64>,
xs_cav: Vec<f64>,
t: f64,
logpart: f64,
exp_ll: usize,
margin: f64,
}
/*
m: usize,
items: Vec<usize>,
coeffs: Vec<f64>,
indices: Vec<usize>,
ns_cav: Vec<f64>,
xs_cav: Vec<f64>,
t: f64,
logpart: f64,
exp_ll: usize,
margin: f64,
*/}
impl GaussianObservation {
pub fn new(storage: &mut Storage, elems: &[(usize, f64)], diff: f64, t: f64, var: f64) -> Self {
pub fn new(
_storage: &mut Storage,
_elems: &[(usize, f64)],
_diff: f64,
_t: f64,
_var: f64,
) -> Self {
unimplemented!();
}
}
impl Observation for GaussianObservation {
fn match_moments(&self, mean_cav: f64, cov_cav: f64) -> (f64, f64, f64) {
fn match_moments(&self, _mean_cav: f64, _cov_cav: f64) -> (f64, f64, f64) {
unimplemented!();
}
fn ep_update(&mut self, lr: f64, storage: &mut Storage) -> f64 {
fn ep_update(&mut self, _lr: f64, _storage: &mut Storage) -> f64 {
unimplemented!();
}
fn kl_update(&mut self, lr: f64, storage: &mut Storage) -> f64 {
fn kl_update(&mut self, _lr: f64, _storage: &mut Storage) -> f64 {
unimplemented!();
}
}

View File

@@ -32,9 +32,9 @@ pub struct ProbitWinObservation {
indices: Vec<usize>,
ns_cav: Vec<f64>,
xs_cav: Vec<f64>,
t: f64,
_t: f64,
logpart: f64,
exp_ll: usize,
_exp_ll: usize,
margin: f64,
}
@@ -54,9 +54,9 @@ impl ProbitWinObservation {
.collect(),
ns_cav: (0..elems.len()).map(|_| 0.0).collect(),
xs_cav: (0..elems.len()).map(|_| 0.0).collect(),
t,
_t: t,
logpart: 0.0,
exp_ll: 0,
_exp_ll: 0,
margin,
}
}
@@ -119,7 +119,7 @@ impl Observation for ProbitWinObservation {
diff
}
fn kl_update(&mut self, lr: f64, storage: &mut Storage) -> f64 {
fn kl_update(&mut self, _lr: f64, _storage: &mut Storage) -> f64 {
todo!();
}
}
@@ -129,30 +129,30 @@ pub struct LogitWinObservation {
}
impl LogitWinObservation {
pub fn new(storage: &mut Storage, elems: &[(usize, f64)], t: f64, margin: f64) -> Self {
pub fn new(_storage: &mut Storage, _elems: &[(usize, f64)], _t: f64, _margin: f64) -> Self {
todo!();
}
}
impl Observation for LogitWinObservation {
fn match_moments(&self, mean_cav: f64, cov_cav: f64) -> (f64, f64, f64) {
fn match_moments(&self, _mean_cav: f64, _cov_cav: f64) -> (f64, f64, f64) {
todo!();
}
fn ep_update(&mut self, lr: f64, storage: &mut Storage) -> f64 {
fn ep_update(&mut self, _lr: f64, _storage: &mut Storage) -> f64 {
todo!();
}
fn kl_update(&mut self, lr: f64, storage: &mut Storage) -> f64 {
fn kl_update(&mut self, _lr: f64, _storage: &mut Storage) -> f64 {
todo!();
}
}
pub fn probit_tie_observation(
elems: &[(usize, f64)],
t: f64,
margin: f64,
storage: &Storage,
_elems: &[(usize, f64)],
_t: f64,
_margin: f64,
_storage: &Storage,
) -> f64 {
unimplemented!();
}
@@ -162,21 +162,21 @@ pub struct ProbitTieObservation {
}
impl ProbitTieObservation {
pub fn new(storage: &mut Storage, elems: &[(usize, f64)], t: f64, margin: f64) -> Self {
pub fn new(_storage: &mut Storage, _elems: &[(usize, f64)], _t: f64, _margin: f64) -> Self {
todo!();
}
}
impl Observation for ProbitTieObservation {
fn match_moments(&self, mean_cav: f64, cov_cav: f64) -> (f64, f64, f64) {
fn match_moments(&self, _mean_cav: f64, _cov_cav: f64) -> (f64, f64, f64) {
todo!();
}
fn ep_update(&mut self, lr: f64, storage: &mut Storage) -> f64 {
fn ep_update(&mut self, _lr: f64, _storage: &mut Storage) -> f64 {
todo!();
}
fn kl_update(&mut self, lr: f64, storage: &mut Storage) -> f64 {
fn kl_update(&mut self, _lr: f64, _storage: &mut Storage) -> f64 {
todo!();
}
}
@@ -186,21 +186,21 @@ pub struct LogitTieObservation {
}
impl LogitTieObservation {
pub fn new(storage: &mut Storage, elems: &[(usize, f64)], t: f64, margin: f64) -> Self {
pub fn new(_storage: &mut Storage, _elems: &[(usize, f64)], _t: f64, _margin: f64) -> Self {
todo!();
}
}
impl Observation for LogitTieObservation {
fn match_moments(&self, mean_cav: f64, cov_cav: f64) -> (f64, f64, f64) {
fn match_moments(&self, _mean_cav: f64, _cov_cav: f64) -> (f64, f64, f64) {
todo!();
}
fn ep_update(&mut self, lr: f64, storage: &mut Storage) -> f64 {
fn ep_update(&mut self, _lr: f64, _storage: &mut Storage) -> f64 {
todo!();
}
fn kl_update(&mut self, lr: f64, storage: &mut Storage) -> f64 {
fn kl_update(&mut self, _lr: f64, _storage: &mut Storage) -> f64 {
todo!();
}
}