Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Casted pointers to work on different platforms #366

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lax/src/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ macro_rules! impl_as_ptr {
impl AsPtr for $target {
type Elem = $elem;
fn as_ptr(vec: &[Self]) -> *const Self::Elem {
vec.as_ptr() as *const _
vec.as_ptr().cast() as *const _
}
fn as_mut_ptr(vec: &mut [Self]) -> *mut Self::Elem {
vec.as_mut_ptr() as *mut _
Expand Down Expand Up @@ -55,7 +55,7 @@ impl<T> VecAssumeInit for Vec<MaybeUninit<T>> {
}

unsafe fn slice_assume_init_ref(&self) -> &[T] {
std::slice::from_raw_parts(self.as_ptr() as *const T, self.len())
std::slice::from_raw_parts(self.as_ptr().cast() as *const T, self.len())
}

unsafe fn slice_assume_init_mut(&mut self) -> &mut [T] {
Expand Down
6 changes: 3 additions & 3 deletions lax/src/cholesky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ macro_rules! impl_cholesky_ {
}
let mut info = 0;
unsafe {
$trf(uplo.as_ptr(), &n, AsPtr::as_mut_ptr(a), &n, &mut info);
$trf(uplo.as_ptr().cast(), &n, AsPtr::as_mut_ptr(a), &n, &mut info);
}
info.as_lapack_result()?;
if matches!(l, MatrixLayout::C { .. }) {
Expand Down Expand Up @@ -66,7 +66,7 @@ macro_rules! impl_inv_cholesky {
}
let mut info = 0;
unsafe {
$tri(uplo.as_ptr(), &n, AsPtr::as_mut_ptr(a), &l.lda(), &mut info);
$tri(uplo.as_ptr().cast(), &n, AsPtr::as_mut_ptr(a), &l.lda(), &mut info);
}
info.as_lapack_result()?;
if matches!(l, MatrixLayout::C { .. }) {
Expand Down Expand Up @@ -115,7 +115,7 @@ macro_rules! impl_solve_cholesky {
}
unsafe {
$trs(
uplo.as_ptr(),
uplo.as_ptr().cast(),
&n,
&nrhs,
AsPtr::as_ptr(a),
Expand Down
16 changes: 8 additions & 8 deletions lax/src/eig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ macro_rules! impl_eig_work_c {
let mut work_size = [<$c>::zero()];
unsafe {
$ev(
jobvl.as_ptr(),
jobvr.as_ptr(),
jobvl.as_ptr().cast(),
jobvr.as_ptr().cast(),
&n,
std::ptr::null_mut(),
&n,
Expand Down Expand Up @@ -200,8 +200,8 @@ macro_rules! impl_eig_work_c {
let mut info = 0;
unsafe {
$ev(
self.jobvl.as_ptr(),
self.jobvr.as_ptr(),
self.jobvl.as_ptr().cast(),
self.jobvr.as_ptr().cast(),
&self.n,
AsPtr::as_mut_ptr(a),
&self.n,
Expand Down Expand Up @@ -279,8 +279,8 @@ macro_rules! impl_eig_work_r {
let mut work_size: [$f; 1] = [0.0];
unsafe {
$ev(
jobvl.as_ptr(),
jobvr.as_ptr(),
jobvl.as_ptr().cast(),
jobvr.as_ptr().cast(),
&n,
std::ptr::null_mut(),
&n,
Expand Down Expand Up @@ -325,8 +325,8 @@ macro_rules! impl_eig_work_r {
let mut info = 0;
unsafe {
$ev(
self.jobvl.as_ptr(),
self.jobvr.as_ptr(),
self.jobvl.as_ptr().cast(),
self.jobvr.as_ptr().cast(),
&self.n,
AsPtr::as_mut_ptr(a),
&self.n,
Expand Down
16 changes: 8 additions & 8 deletions lax/src/eigh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ macro_rules! impl_eigh_work_c {
let mut work_size = [Self::Elem::zero()];
unsafe {
$ev(
jobz.as_ptr(),
UPLO::Upper.as_ptr(), // dummy, working memory is not affected by UPLO
jobz.as_ptr().cast(),
UPLO::Upper.as_ptr().cast(), // dummy, working memory is not affected by UPLO
&n,
std::ptr::null_mut(),
&n,
Expand Down Expand Up @@ -80,8 +80,8 @@ macro_rules! impl_eigh_work_c {
let mut info = 0;
unsafe {
$ev(
self.jobz.as_ptr(),
uplo.as_ptr(),
self.jobz.as_ptr().cast(),
uplo.as_ptr().cast(),
&self.n,
AsPtr::as_mut_ptr(a),
&self.n,
Expand Down Expand Up @@ -128,8 +128,8 @@ macro_rules! impl_eigh_work_r {
let mut work_size = [Self::Elem::zero()];
unsafe {
$ev(
jobz.as_ptr(),
UPLO::Upper.as_ptr(), // dummy, working memory is not affected by UPLO
jobz.as_ptr().cast(),
UPLO::Upper.as_ptr().cast(), // dummy, working memory is not affected by UPLO
&n,
std::ptr::null_mut(),
&n,
Expand Down Expand Up @@ -160,8 +160,8 @@ macro_rules! impl_eigh_work_r {
let mut info = 0;
unsafe {
$ev(
self.jobz.as_ptr(),
uplo.as_ptr(),
self.jobz.as_ptr().cast(),
uplo.as_ptr().cast(),
&self.n,
AsPtr::as_mut_ptr(a),
&self.n,
Expand Down
16 changes: 8 additions & 8 deletions lax/src/eigh_generalized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ macro_rules! impl_eigh_generalized_work_c {
unsafe {
$gv(
&1, // ITYPE A*x = (lambda)*B*x
jobz.as_ptr(),
UPLO::Upper.as_ptr(), // dummy, working memory is not affected by UPLO
jobz.as_ptr().cast(),
UPLO::Upper.as_ptr().cast(), // dummy, working memory is not affected by UPLO
&n,
std::ptr::null_mut(),
&n,
Expand Down Expand Up @@ -95,8 +95,8 @@ macro_rules! impl_eigh_generalized_work_c {
unsafe {
$gv(
&1, // ITYPE A*x = (lambda)*B*x
self.jobz.as_ptr(),
uplo.as_ptr(),
self.jobz.as_ptr().cast(),
uplo.as_ptr().cast(),
&self.n,
AsPtr::as_mut_ptr(a),
&self.n,
Expand Down Expand Up @@ -147,8 +147,8 @@ macro_rules! impl_eigh_generalized_work_r {
unsafe {
$gv(
&1, // ITYPE A*x = (lambda)*B*x
jobz.as_ptr(),
UPLO::Upper.as_ptr(), // dummy, working memory is not affected by UPLO
jobz.as_ptr().cast(),
UPLO::Upper.as_ptr().cast(), // dummy, working memory is not affected by UPLO
&n,
std::ptr::null_mut(),
&n,
Expand Down Expand Up @@ -183,8 +183,8 @@ macro_rules! impl_eigh_generalized_work_r {
unsafe {
$gv(
&1, // ITYPE A*x = (lambda)*B*x
self.jobz.as_ptr(),
uplo.as_ptr(),
self.jobz.as_ptr().cast(),
uplo.as_ptr().cast(),
&self.n,
AsPtr::as_mut_ptr(a),
&self.n,
Expand Down
2 changes: 1 addition & 1 deletion lax/src/opnorm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ macro_rules! impl_operator_norm {
};
unsafe {
$lange(
t.as_ptr(),
t.as_ptr().cast(),
&m,
&n,
AsPtr::as_ptr(a),
Expand Down
4 changes: 2 additions & 2 deletions lax/src/rcond.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ macro_rules! impl_rcond_work_c {
};
unsafe {
$con(
norm_type.as_ptr(),
norm_type.as_ptr().cast(),
&n,
AsPtr::as_ptr(a),
&self.layout.lda(),
Expand Down Expand Up @@ -103,7 +103,7 @@ macro_rules! impl_rcond_work_r {
};
unsafe {
$con(
norm_type.as_ptr(),
norm_type.as_ptr().cast(),
&n,
AsPtr::as_ptr(a),
&self.layout.lda(),
Expand Down
6 changes: 3 additions & 3 deletions lax/src/solve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ macro_rules! impl_solve {
}
unsafe {
$getrs(
t.as_ptr(),
t.as_ptr().cast(),
&n,
&nrhs,
AsPtr::as_ptr(a),
&l.lda(),
ipiv.as_ptr(),
ipiv.as_ptr().cast(),
AsPtr::as_mut_ptr(b),
&ldb,
&mut info,
Expand Down Expand Up @@ -205,7 +205,7 @@ macro_rules! impl_inv_work {
&self.layout.len(),
AsPtr::as_mut_ptr(a),
&self.layout.lda(),
ipiv.as_ptr(),
ipiv.as_ptr().cast(),
AsPtr::as_mut_ptr(&mut self.work),
&lwork,
&mut info,
Expand Down
12 changes: 6 additions & 6 deletions lax/src/solveh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ macro_rules! impl_bk_work {
let mut work_size = [Self::Elem::zero()];
unsafe {
$trf(
UPLO::Upper.as_ptr(),
UPLO::Upper.as_ptr().cast(),
&n,
std::ptr::null_mut(),
&layout.lda(),
Expand All @@ -66,7 +66,7 @@ macro_rules! impl_bk_work {
let mut info = 0;
unsafe {
$trf(
uplo.as_ptr(),
uplo.as_ptr().cast(),
&n,
AsPtr::as_mut_ptr(a),
&self.layout.lda(),
Expand Down Expand Up @@ -128,11 +128,11 @@ macro_rules! impl_invh_work {
let mut info = 0;
unsafe {
$tri(
uplo.as_ptr(),
uplo.as_ptr().cast(),
&n,
AsPtr::as_mut_ptr(a),
&self.layout.lda(),
ipiv.as_ptr(),
ipiv.as_ptr().cast(),
AsPtr::as_mut_ptr(&mut self.work),
&mut info,
)
Expand Down Expand Up @@ -175,12 +175,12 @@ macro_rules! impl_solveh_ {
let mut info = 0;
unsafe {
$trs(
uplo.as_ptr(),
uplo.as_ptr().cast(),
&n,
&1,
AsPtr::as_ptr(a),
&l.lda(),
ipiv.as_ptr(),
ipiv.as_ptr().cast(),
AsPtr::as_mut_ptr(b),
&n,
&mut info,
Expand Down
16 changes: 8 additions & 8 deletions lax/src/svd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ macro_rules! impl_svd_work_c {
let mut work_size = [Self::Elem::zero()];
unsafe {
$svd(
ju.as_ptr(),
jvt.as_ptr(),
ju.as_ptr().cast(),
jvt.as_ptr().cast(),
&m,
&n,
std::ptr::null_mut(),
Expand Down Expand Up @@ -122,8 +122,8 @@ macro_rules! impl_svd_work_c {
let mut info = 0;
unsafe {
$svd(
self.ju.as_ptr(),
self.jvt.as_ptr(),
self.ju.as_ptr().cast(),
self.jvt.as_ptr().cast(),
&m,
&n,
AsPtr::as_mut_ptr(a),
Expand Down Expand Up @@ -217,8 +217,8 @@ macro_rules! impl_svd_work_r {
let mut work_size = [Self::Elem::zero()];
unsafe {
$svd(
ju.as_ptr(),
jvt.as_ptr(),
ju.as_ptr().cast(),
jvt.as_ptr().cast(),
&m,
&n,
std::ptr::null_mut(),
Expand Down Expand Up @@ -256,8 +256,8 @@ macro_rules! impl_svd_work_r {
let mut info = 0;
unsafe {
$svd(
self.ju.as_ptr(),
self.jvt.as_ptr(),
self.ju.as_ptr().cast(),
self.jvt.as_ptr().cast(),
&m,
&n,
AsPtr::as_mut_ptr(a),
Expand Down
8 changes: 4 additions & 4 deletions lax/src/svddc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ macro_rules! impl_svd_dc_work_c {
let mut work_size = [Self::Elem::zero()];
unsafe {
$sdd(
jobz.as_ptr(),
jobz.as_ptr().cast(),
&m,
&n,
std::ptr::null_mut(),
Expand Down Expand Up @@ -115,7 +115,7 @@ macro_rules! impl_svd_dc_work_c {
let mut info = 0;
unsafe {
$sdd(
self.jobz.as_ptr(),
self.jobz.as_ptr().cast(),
&m,
&n,
AsPtr::as_mut_ptr(a),
Expand Down Expand Up @@ -205,7 +205,7 @@ macro_rules! impl_svd_dc_work_r {
let mut work_size = [Self::Elem::zero()];
unsafe {
$sdd(
jobz.as_ptr(),
jobz.as_ptr().cast(),
&m,
&n,
std::ptr::null_mut(),
Expand Down Expand Up @@ -249,7 +249,7 @@ macro_rules! impl_svd_dc_work_r {
let mut info = 0;
unsafe {
$sdd(
self.jobz.as_ptr(),
self.jobz.as_ptr().cast(),
&m,
&n,
AsPtr::as_mut_ptr(a),
Expand Down
6 changes: 3 additions & 3 deletions lax/src/triangular.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ macro_rules! impl_triangular {
let mut info = 0;
unsafe {
$trtrs(
uplo.as_ptr(),
Transpose::No.as_ptr(),
diag.as_ptr(),
uplo.as_ptr().cast(),
Transpose::No.as_ptr().cast(),
diag.as_ptr().cast(),
&m,
&nrhs,
AsPtr::as_ptr(a_t.as_ref().map(|v| v.as_slice()).unwrap_or(a)),
Expand Down
6 changes: 3 additions & 3 deletions lax/src/tridiagonal/rcond.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ macro_rules! impl_rcond_tridiagonal_work_c {
let mut info = 0;
unsafe {
$gtcon(
NormType::One.as_ptr(),
NormType::One.as_ptr().cast(),
&n,
AsPtr::as_ptr(&lu.a.dl),
AsPtr::as_ptr(&lu.a.d),
AsPtr::as_ptr(&lu.a.du),
AsPtr::as_ptr(&lu.du2),
ipiv.as_ptr(),
ipiv.as_ptr().cast(),
&lu.a_opnorm_one,
&mut rcond,
AsPtr::as_mut_ptr(&mut self.work),
Expand Down Expand Up @@ -84,7 +84,7 @@ macro_rules! impl_rcond_tridiagonal_work_r {
let mut info = 0;
unsafe {
$gtcon(
NormType::One.as_ptr(),
NormType::One.as_ptr().cast(),
&n,
AsPtr::as_ptr(&lu.a.dl),
AsPtr::as_ptr(&lu.a.d),
Expand Down
Loading