use crate::core::{ArgminFloat, ArgminOp, Error};
use serde::de::DeserializeOwned;
use serde::{Deserialize, Serialize};
use std::fmt::{Debug, Display};
#[derive(
Clone, Default, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Hash, Copy,
)]
pub struct NoOperator<T, U, H, J, F> {
param: std::marker::PhantomData<T>,
output: std::marker::PhantomData<U>,
hessian: std::marker::PhantomData<H>,
jacobian: std::marker::PhantomData<J>,
float: std::marker::PhantomData<F>,
}
impl<T, U, H, J, F> NoOperator<T, U, H, J, F> {
#[allow(dead_code)]
pub fn new() -> Self {
NoOperator {
param: std::marker::PhantomData,
output: std::marker::PhantomData,
hessian: std::marker::PhantomData,
jacobian: std::marker::PhantomData,
float: std::marker::PhantomData,
}
}
}
impl<T, U, H, J, F> Display for NoOperator<T, U, H, J, F> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "NoOperator")
}
}
impl<T, U, H, J, F> ArgminOp for NoOperator<T, U, H, J, F>
where
T: Clone + Default + Debug + Send + Sync + Serialize + DeserializeOwned,
U: Clone + Default + Debug + Send + Sync + Serialize + DeserializeOwned,
H: Clone + Default + Debug + Send + Sync + Serialize + DeserializeOwned,
J: Clone + Default + Debug + Send + Sync + Serialize + DeserializeOwned,
F: ArgminFloat,
{
type Param = T;
type Output = U;
type Hessian = H;
type Jacobian = J;
type Float = F;
fn apply(&self, _p: &Self::Param) -> Result<Self::Output, Error> {
Ok(Self::Output::default())
}
fn gradient(&self, _p: &Self::Param) -> Result<Self::Param, Error> {
Ok(Self::Param::default())
}
fn hessian(&self, _p: &Self::Param) -> Result<Self::Hessian, Error> {
Ok(Self::Hessian::default())
}
fn modify(&self, _p: &Self::Param, _t: Self::Float) -> Result<Self::Param, Error> {
Ok(Self::Param::default())
}
}
#[derive(
Clone, Default, Debug, Serialize, Deserialize, Eq, PartialEq, Ord, PartialOrd, Hash, Copy,
)]
pub struct MinimalNoOperator {}
impl MinimalNoOperator {
#[allow(dead_code)]
pub fn new() -> Self {
MinimalNoOperator {}
}
}
impl Display for MinimalNoOperator {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "MinimalNoOperator")
}
}
impl ArgminOp for MinimalNoOperator {
type Param = Vec<f64>;
type Output = f64;
type Hessian = Vec<Vec<f64>>;
type Jacobian = Vec<f64>;
type Float = f64;
fn apply(&self, _p: &Self::Param) -> Result<Self::Output, Error> {
unimplemented!()
}
fn gradient(&self, _p: &Self::Param) -> Result<Self::Param, Error> {
unimplemented!()
}
fn hessian(&self, _p: &Self::Param) -> Result<Self::Hessian, Error> {
unimplemented!()
}
fn modify(&self, _p: &Self::Param, _t: f64) -> Result<Self::Param, Error> {
unimplemented!()
}
}