From 4afd51c2a04bd503d18ce87358be2623de1e515c Mon Sep 17 00:00:00 2001 From: Toshiki Teramura Date: Wed, 28 Sep 2022 00:19:39 +0900 Subject: [PATCH] WIP: LeastSquaresWork --- lax/src/least_squares.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/lax/src/least_squares.rs b/lax/src/least_squares.rs index 532d1e6b..0af2f0b7 100644 --- a/lax/src/least_squares.rs +++ b/lax/src/least_squares.rs @@ -12,6 +12,14 @@ pub struct LeastSquaresOwned { 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 { @@ -29,7 +37,18 @@ pub trait LeastSquaresSvdDivideConquer_: Scalar { a: &mut [Self], b_layout: MatrixLayout, b: &mut [Self], - ) -> Result>; + ) -> Result>; +} + +pub struct LeastSquaresWork { + pub work: Vec>, +} + +pub trait LeastSquaresWorkImpl: Sized { + type Elem: Scalar; + fn new(a_layout: MatrixLayout, b_layout: MatrixLayout) -> Result; + fn calc(&mut self, a: &mut [Self], b: &mut [Self]) -> Result>; + fn eval(self, a: &mut [Self], b: &mut [Self]) -> Result>; } macro_rules! impl_least_squares {