Skip to content

Commit

Permalink
WIP: LeastSquaresWork
Browse files Browse the repository at this point in the history
  • Loading branch information
termoshtt committed Sep 27, 2022
1 parent ac2f7bc commit 4afd51c
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion lax/src/least_squares.rs
Expand Up @@ -12,6 +12,14 @@ pub struct LeastSquaresOwned<A: Scalar> {
pub rank: i32,
}

/// Result of LeastSquares
pub struct LeastSquaresRef<'work, A: Scalar> {
/// singular values
pub singular_values: &'work [A::Real],
/// The rank of the input matrix A
pub rank: i32,
}

#[cfg_attr(doc, katexit::katexit)]
/// Solve least square problem
pub trait LeastSquaresSvdDivideConquer_: Scalar {
Expand All @@ -29,7 +37,18 @@ pub trait LeastSquaresSvdDivideConquer_: Scalar {
a: &mut [Self],
b_layout: MatrixLayout,
b: &mut [Self],
) -> Result<LeastSquaresOutput<Self>>;
) -> Result<LeastSquaresOwned<Self>>;
}

pub struct LeastSquaresWork<T: Scalar> {
pub work: Vec<MaybeUninit<T>>,
}

pub trait LeastSquaresWorkImpl: Sized {
type Elem: Scalar;
fn new(a_layout: MatrixLayout, b_layout: MatrixLayout) -> Result<Self>;
fn calc(&mut self, a: &mut [Self], b: &mut [Self]) -> Result<LeastSquaresRef<Self::Elem>>;
fn eval(self, a: &mut [Self], b: &mut [Self]) -> Result<LeastSquaresOwned<Self::Elem>>;
}

macro_rules! impl_least_squares {
Expand Down

0 comments on commit 4afd51c

Please sign in to comment.