Skip to content

Commit a8cc0ce

Browse files
committed
WIP: InvWork
1 parent 07ab31d commit a8cc0ce

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

Diff for: lax/src/solve.rs

+44
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,50 @@ pub trait Solve_: Scalar + Sized {
6464
fn solve(l: MatrixLayout, t: Transpose, a: &[Self], p: &Pivot, b: &mut [Self]) -> Result<()>;
6565
}
6666

67+
pub struct InvWork<T: Scalar> {
68+
pub work: Vec<MaybeUninit<T>>,
69+
}
70+
71+
pub trait InvWorkImpl: Sized {
72+
type Elem: Scalar;
73+
fn new(layout: MatrixLayout) -> Result<Self>;
74+
fn calc(&mut self, a: &mut [Self::Elem], p: &Pivot) -> Result<()>;
75+
}
76+
77+
macro_rules! impl_inv_work {
78+
($s:ty, $tri:path) => {
79+
impl InvWorkImpl for InvWork<c64> {
80+
type Elem = c64;
81+
fn new(layout: MatrixLayout) -> Result<Self> {
82+
let (n, _) = layout.size();
83+
let mut info = 0;
84+
let mut work_size = [Self::Elem::zero()];
85+
unsafe {
86+
$tri(
87+
&n,
88+
std::ptr::null_mut(),
89+
&layout.lda(),
90+
std::ptr::null(),
91+
AsPtr::as_mut_ptr(&mut work_size),
92+
&(-1),
93+
&mut info,
94+
)
95+
};
96+
info.as_lapack_result()?;
97+
let lwork = work_size[0].to_usize().unwrap();
98+
let work = vec_uninit(lwork);
99+
Ok(InvWork { work })
100+
}
101+
102+
fn calc(&mut self, a: &mut [Self::Elem], p: &Pivot) -> Result<()> {
103+
todo!()
104+
}
105+
}
106+
};
107+
}
108+
109+
impl_inv_work!(c64, lapack_sys::zgetri_);
110+
67111
macro_rules! impl_solve {
68112
($scalar:ty, $getrf:path, $getri:path, $getrs:path) => {
69113
impl Solve_ for $scalar {

0 commit comments

Comments
 (0)