Adds LBFGS optimization method

This commit is contained in:
Volodymyr Orlov
2019-11-15 08:56:09 -08:00
parent 4488cc110e
commit b5e677e615
6 changed files with 525 additions and 33 deletions
+72
View File
@@ -67,12 +67,44 @@ pub trait Vector: Into<Vec<f64>> + Clone + Debug {
fn norm2(&self) -> f64;
fn norm(&self, p:f64) -> f64;
fn negative_mut(&mut self) -> &Self;
fn negative(&self) -> Self;
fn add_mut(&mut self, other: &Self) -> &Self;
fn sub_mut(&mut self, other: &Self) -> &Self;
fn mul_mut(&mut self, other: &Self) -> &Self;
fn div_mut(&mut self, other: &Self) -> &Self;
fn add(&self, other: &Self) -> Self {
let mut r = self.clone();
r.add_mut(other);
r
}
fn sub(&self, other: &Self) -> Self {
let mut r = self.clone();
r.sub_mut(other);
r
}
fn mul(&self, other: &Self) -> Self {
let mut r = self.clone();
r.mul_mut(other);
r
}
fn div(&self, other: &Self) -> Self {
let mut r = self.clone();
r.div_mut(other);
r
}
fn add_scalar_mut(&mut self, scalar: f64) -> &Self;
fn sub_scalar_mut(&mut self, scalar: f64) -> &Self;
@@ -81,6 +113,46 @@ pub trait Vector: Into<Vec<f64>> + Clone + Debug {
fn div_scalar_mut(&mut self, scalar: f64) -> &Self;
fn add_scalar(&self, scalar: f64) -> Self{
let mut r = self.clone();
r.add_scalar_mut(scalar);
r
}
fn sub_scalar(&self, scalar: f64) -> Self{
let mut r = self.clone();
r.sub_scalar_mut(scalar);
r
}
fn mul_scalar(&self, scalar: f64) -> Self{
let mut r = self.clone();
r.mul_scalar_mut(scalar);
r
}
fn div_scalar(&self, scalar: f64) -> Self{
let mut r = self.clone();
r.div_scalar_mut(scalar);
r
}
fn dot(&self, other: &Self) -> f64;
fn copy_from(&mut self, other: &Self);
fn abs_mut(&mut self) -> &Self;
fn pow_mut(&mut self, p: f64) -> &Self;
fn sum(&self) -> f64;
fn abs(&self) -> Self{
let mut r = self.clone();
r.abs_mut();
r
}
fn max_diff(&self, other: &Self) -> f64;
}