use nalgebra::DVector;
#[derive(Debug, Clone)]
pub struct FunctionGradient {
grad: DVector<f64>,
g2: DVector<f64>,
gstep: DVector<f64>,
valid: bool,
analytical: bool,
}
impl FunctionGradient {
pub fn new(grad: DVector<f64>, g2: DVector<f64>, gstep: DVector<f64>) -> Self {
Self {
grad,
g2,
gstep,
valid: true,
analytical: false,
}
}
pub fn analytical(grad: DVector<f64>) -> Self {
let n = grad.len();
Self {
grad,
g2: DVector::zeros(n),
gstep: DVector::zeros(n),
valid: true,
analytical: true,
}
}
pub fn grad(&self) -> &DVector<f64> {
&self.grad
}
pub fn g2(&self) -> &DVector<f64> {
&self.g2
}
pub fn gstep(&self) -> &DVector<f64> {
&self.gstep
}
pub fn is_valid(&self) -> bool {
self.valid
}
pub fn is_analytical(&self) -> bool {
self.analytical
}
pub fn set_valid(&mut self, valid: bool) {
self.valid = valid;
}
pub fn set_analytical(&mut self, analytical: bool) {
self.analytical = analytical;
}
}