Skip to content

Commit 4afd51c

Browse files
committed
WIP: LeastSquaresWork
1 parent ac2f7bc commit 4afd51c

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

lax/src/least_squares.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ pub struct LeastSquaresOwned<A: Scalar> {
1212
pub rank: i32,
1313
}
1414

15+
/// Result of LeastSquares
16+
pub struct LeastSquaresRef<'work, A: Scalar> {
17+
/// singular values
18+
pub singular_values: &'work [A::Real],
19+
/// The rank of the input matrix A
20+
pub rank: i32,
21+
}
22+
1523
#[cfg_attr(doc, katexit::katexit)]
1624
/// Solve least square problem
1725
pub trait LeastSquaresSvdDivideConquer_: Scalar {
@@ -29,7 +37,18 @@ pub trait LeastSquaresSvdDivideConquer_: Scalar {
2937
a: &mut [Self],
3038
b_layout: MatrixLayout,
3139
b: &mut [Self],
32-
) -> Result<LeastSquaresOutput<Self>>;
40+
) -> Result<LeastSquaresOwned<Self>>;
41+
}
42+
43+
pub struct LeastSquaresWork<T: Scalar> {
44+
pub work: Vec<MaybeUninit<T>>,
45+
}
46+
47+
pub trait LeastSquaresWorkImpl: Sized {
48+
type Elem: Scalar;
49+
fn new(a_layout: MatrixLayout, b_layout: MatrixLayout) -> Result<Self>;
50+
fn calc(&mut self, a: &mut [Self], b: &mut [Self]) -> Result<LeastSquaresRef<Self::Elem>>;
51+
fn eval(self, a: &mut [Self], b: &mut [Self]) -> Result<LeastSquaresOwned<Self::Elem>>;
3352
}
3453

3554
macro_rules! impl_least_squares {

0 commit comments

Comments
 (0)