From 345ee811be0b8ec75e3700dca8d7f7561368cf0e Mon Sep 17 00:00:00 2001 From: Turiiya <34311583+ttytm@users.noreply.github.com> Date: Sun, 22 Oct 2023 18:10:29 +0200 Subject: [PATCH] rebase on main, use &char only in C functions, cleanup --- vlas/conversions.v | 18 ++++-------------- vlas/lapack_common.v | 8 ++------ vlas/lapack_default.c.v | 8 +++++--- vlas/lapack_macos.c.v | 6 +++--- 4 files changed, 14 insertions(+), 26 deletions(-) diff --git a/vlas/conversions.v b/vlas/conversions.v index ba8416806..520017ade 100644 --- a/vlas/conversions.v +++ b/vlas/conversions.v @@ -7,29 +7,19 @@ import vsl.errors import vsl.vlas.internal.vblas pub fn c_trans(trans bool) vblas.Transpose { - if trans { - return .trans - } - return .no_trans + return if trans { .trans } else { .no_trans } } pub fn c_uplo(up bool) vblas.Uplo { - if up { - return .upper - } - return .lower + return if up { .upper } else { .lower } } fn l_uplo(up bool) u8 { return if up { `U` } else { `L` } } -fn job_vlr(do_calc bool) &char { - return &char(if do_calc { - 'V' - } else { - 'N' - }.str) +fn job_vlr(do_calc bool) rune { + return if do_calc { `V` } else { `N` } } // slice_to_col_major converts nested slice into an array representing a col-major matrix diff --git a/vlas/lapack_common.v b/vlas/lapack_common.v index 25fbd6221..64ad4c304 100644 --- a/vlas/lapack_common.v +++ b/vlas/lapack_common.v @@ -189,14 +189,10 @@ pub fn dgeev(calc_vl bool, calc_vr bool, n int, mut a []f64, lda int, wr []f64, ldvr = 1 } unsafe { - info := C.LAPACKE_dgeev(.row_major, job_vlr(calc_vl), job_vlr(calc_vr), n, &a[0], - lda, &wr[0], &wi[0], &vvl, ldvl, &vvr, ldvr) + info := C.LAPACKE_dgeev(.row_major, &char(job_vlr(calc_vl).str().str), &char(job_vlr(calc_vr).str().str), + n, &a[0], lda, &wr[0], &wi[0], &vvl, ldvl, &vvr, ldvr) if info != 0 { errors.vsl_panic('lapack failed', .efailed) } } } - -pub fn dlange(norm &char, m int, n int, a []f64, lda int, work []f64) f64 { - return unsafe { C.LAPACKE_dlange(.row_major, norm, m, n, &a[0], lda, &work[0]) } -} diff --git a/vlas/lapack_default.c.v b/vlas/lapack_default.c.v index bda7a30fa..392faeca0 100644 --- a/vlas/lapack_default.c.v +++ b/vlas/lapack_default.c.v @@ -2,8 +2,10 @@ module vlas import vsl.vlas.internal.vblas -fn C.LAPACKE_dlange(matrix_layout vblas.MemoryLayout, norm byte, m int, n int, a &f64, lda int, work &f64) f64 +fn C.LAPACKE_dlange(matrix_layout vblas.MemoryLayout, norm &char, m int, n int, a &f64, lda int, work &f64) f64 -pub fn dlange(norm byte, m int, n int, a []f64, lda int, work []f64) f64 { - return unsafe { C.LAPACKE_dlange(.row_major, norm, m, n, &a[0], lda, &work[0]) } +pub fn dlange(norm rune, m int, n int, a []f64, lda int, work []f64) f64 { + return unsafe { + C.LAPACKE_dlange(.row_major, &char(norm.str().str), m, n, &a[0], lda, &work[0]) + } } diff --git a/vlas/lapack_macos.c.v b/vlas/lapack_macos.c.v index db481f58c..2c0cbc7c3 100644 --- a/vlas/lapack_macos.c.v +++ b/vlas/lapack_macos.c.v @@ -1,7 +1,7 @@ module vlas -fn C.LAPACKE_dlange(norm byte, m int, n int, a &f64, lda int, work &f64) f64 +fn C.LAPACKE_dlange(norm &char, m int, n int, a &f64, lda int, work &f64) f64 -pub fn dlange(norm byte, m int, n int, a []f64, lda int, work []f64) f64 { - return unsafe { C.LAPACKE_dlange(norm, m, n, &a[0], lda, &work[0]) } +pub fn dlange(norm rune, m int, n int, a []f64, lda int, work []f64) f64 { + return unsafe { C.LAPACKE_dlange(&char(norm.str().str), m, n, &a[0], lda, &work[0]) } }