diff --git a/README.md b/README.md index 84c70fa..95feada 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,10 @@ See [wiki: Link with CBLAS & LAPACK](https://github.com/libmir/mir-lapack/wiki/L ## Wrapped API + - gebak + - gebal + - geev + - gehrd - gelsd - geqrf - geqrs @@ -19,6 +23,9 @@ See [wiki: Link with CBLAS & LAPACK](https://github.com/libmir/mir-lapack/wiki/L - getrf - getri - getrs + - hsein + - hseqr + - orgqr - ormqr - potrf - potri @@ -28,13 +35,18 @@ See [wiki: Link with CBLAS & LAPACK](https://github.com/libmir/mir-lapack/wiki/L - spev - sptrf - sptri + - steqr - syev - syev_2stage - sysv_rook - sytrf - sytrs2 - tptri + - trevc - trtri + - unghr + - ungqr + - unmhr - unmqr --------------- diff --git a/source/mir/lapack.d b/source/mir/lapack.d index 890b197..317f8e5 100644 --- a/source/mir/lapack.d +++ b/source/mir/lapack.d @@ -28,585 +28,585 @@ in } do { - lapackint n = cast(lapackint) a.length; - lapackint lda = cast(lapackint) a._stride.max(1); - T work = void; - lapackint lwork = -1; - lapackint info = void; + lapackint n = cast(lapackint) a.length; + lapackint lda = cast(lapackint) a._stride.max(1); + T work = void; + lapackint lwork = -1; + lapackint info = void; - lapack.getri_(n, null, lda, null, &work, lwork, info); + lapack.getri_(n, null, lda, null, &work, lwork, info); - assert(info == 0); - return cast(size_t) work; + assert(info == 0); + return cast(size_t) work; } unittest { - alias s = getri_wq!float; - alias d = getri_wq!double; - alias c = getri_wq!cfloat; - alias z = getri_wq!cdouble; + alias s = getri_wq!float; + alias d = getri_wq!double; + alias c = getri_wq!cfloat; + alias z = getri_wq!cdouble; } /// size_t getri(T)( - Slice!(T*, 2, Canonical) a, - Slice!(lapackint*) ipiv, - Slice!(T*) work, - ) + Slice!(T*, 2, Canonical) a, + Slice!(lapackint*) ipiv, + Slice!(T*) work, + ) in { - assert(a.length!0 == a.length!1, "getri: The input 'a' must be a square matrix."); - assert(ipiv.length == a.length!0, "getri: The length of 'ipiv' must be equal to the number of rows of 'a'."); - assert(work.length, "getri: work must have a non-zero length."); + assert(a.length!0 == a.length!1, "getri: The input 'a' must be a square matrix."); + assert(ipiv.length == a.length!0, "getri: The length of 'ipiv' must be equal to the number of rows of 'a'."); + assert(work.length, "getri: work must have a non-zero length."); } do { - lapackint n = cast(lapackint) a.length; - lapackint lda = cast(lapackint) a._stride.max(1); - lapackint lwork = cast(lapackint) work.length; - lapackint info = void; + lapackint n = cast(lapackint) a.length; + lapackint lda = cast(lapackint) a._stride.max(1); + lapackint lwork = cast(lapackint) work.length; + lapackint info = void; - lapack.getri_(n, a.iterator, lda, ipiv.iterator, work.iterator, lwork, info); + lapack.getri_(n, a.iterator, lda, ipiv.iterator, work.iterator, lwork, info); - assert(info >= 0); - return info; + assert(info >= 0); + return info; } unittest { - alias s = getri!float; - alias d = getri!double; - alias c = getri!cfloat; - alias z = getri!cdouble; + alias s = getri!float; + alias d = getri!double; + alias c = getri!cfloat; + alias z = getri!cdouble; } /// size_t getrf(T)( - Slice!(T*, 2, Canonical) a, - Slice!(lapackint*) ipiv, - ) + Slice!(T*, 2, Canonical) a, + Slice!(lapackint*) ipiv, + ) in { assert(ipiv.length >= min(a.length!0, a.length!1), "getrf: The length of 'ipiv' must be at least the smaller of 'a''s dimensions"); } do { - lapackint m = cast(lapackint) a.length!1; - lapackint n = cast(lapackint) a.length!0; - lapackint lda = cast(lapackint) a._stride.max(1); - lapackint info = void; + lapackint m = cast(lapackint) a.length!1; + lapackint n = cast(lapackint) a.length!0; + lapackint lda = cast(lapackint) a._stride.max(1); + lapackint info = void; - lapack.getrf_(m, n, a.iterator, lda, ipiv.iterator, info); + lapack.getrf_(m, n, a.iterator, lda, ipiv.iterator, info); - assert(info >= 0); - return info; + assert(info >= 0); + return info; } unittest { - alias s = getrf!float; - alias d = getrf!double; - alias c = getrf!cfloat; - alias z = getrf!cdouble; + alias s = getrf!float; + alias d = getrf!double; + alias c = getrf!cfloat; + alias z = getrf!cdouble; } /// template sptrf(T) { - /// `sptrf` for upper triangular input. - size_t sptrf( - Slice!(StairsIterator!(T*, "+")) ap, - Slice!(lapackint*) ipiv, - ) + /// `sptrf` for upper triangular input. + size_t sptrf( + Slice!(StairsIterator!(T*, "+")) ap, + Slice!(lapackint*) ipiv, + ) in { - assert(ipiv.length == ap.length, "sptrf: The length of 'ipiv' must be equal to the length 'ap'."); + assert(ipiv.length == ap.length, "sptrf: The length of 'ipiv' must be equal to the length 'ap'."); } do - { - char uplo = 'U'; - lapackint n = cast(lapackint) ap.length; - lapackint info = void; - - lapack.sptrf_(uplo, n, &ap[0][0], ipiv.iterator, info); - - assert(info >= 0); - return info; - } - - /// `sptrf` for lower triangular input. - size_t sptrf( - Slice!(StairsIterator!(T*, "-")) ap, - Slice!(lapackint*) ipiv, - ) + { + char uplo = 'U'; + lapackint n = cast(lapackint) ap.length; + lapackint info = void; + + lapack.sptrf_(uplo, n, &ap[0][0], ipiv.iterator, info); + + assert(info >= 0); + return info; + } + + /// `sptrf` for lower triangular input. + size_t sptrf( + Slice!(StairsIterator!(T*, "-")) ap, + Slice!(lapackint*) ipiv, + ) in { - assert(ipiv.length == ap.length, "sptrf: The length of 'ipiv' must be equal to the length 'ap'."); + assert(ipiv.length == ap.length, "sptrf: The length of 'ipiv' must be equal to the length 'ap'."); } do - { - char uplo = 'L'; - lapackint n = cast(lapackint) ap.length; - lapackint info = void; + { + char uplo = 'L'; + lapackint n = cast(lapackint) ap.length; + lapackint info = void; - lapack.sptrf_(uplo, n, &ap[0][0], ipiv.iterator, info); + lapack.sptrf_(uplo, n, &ap[0][0], ipiv.iterator, info); - assert(info >= 0); - return info; - } + assert(info >= 0); + return info; + } } unittest { - alias s = sptrf!float; - alias d = sptrf!double; + alias s = sptrf!float; + alias d = sptrf!double; } /// size_t gesv(T)( - Slice!(T*, 2, Canonical) a, - Slice!(lapackint*) ipiv, - Slice!(T*, 2, Canonical) b, - ) + Slice!(T*, 2, Canonical) a, + Slice!(lapackint*) ipiv, + Slice!(T*, 2, Canonical) b, + ) in { - assert(a.length!0 == a.length!1, "gesv: The input 'a' must be a square matrix."); - assert(ipiv.length == a.length!0, "gesv: The length of 'ipiv' must be equal to the number of rows of 'a'."); - assert(b.length!1 == a.length!0, "gesv: The number of columns of 'b' must equal the number of rows of 'a'"); + assert(a.length!0 == a.length!1, "gesv: The input 'a' must be a square matrix."); + assert(ipiv.length == a.length!0, "gesv: The length of 'ipiv' must be equal to the number of rows of 'a'."); + assert(b.length!1 == a.length!0, "gesv: The number of columns of 'b' must equal the number of rows of 'a'"); } do { - lapackint n = cast(lapackint) a.length; - lapackint nrhs = cast(lapackint) b.length; - lapackint lda = cast(lapackint) a._stride.max(1); - lapackint ldb = cast(lapackint) b._stride.max(1); - lapackint info = void; + lapackint n = cast(lapackint) a.length; + lapackint nrhs = cast(lapackint) b.length; + lapackint lda = cast(lapackint) a._stride.max(1); + lapackint ldb = cast(lapackint) b._stride.max(1); + lapackint info = void; - lapack.gesv_(n, nrhs, a.iterator, lda, ipiv.iterator, b.iterator, ldb, info); + lapack.gesv_(n, nrhs, a.iterator, lda, ipiv.iterator, b.iterator, ldb, info); - assert(info >= 0); - return info; + assert(info >= 0); + return info; } unittest { - alias s = gesv!float; - alias d = gesv!double; + alias s = gesv!float; + alias d = gesv!double; } /// `gelsd` work space query. size_t gelsd_wq(T)( - Slice!(T*, 2, Canonical) a, - Slice!(T*, 2, Canonical) b, - ref size_t liwork, - ) - if(!isComplex!T) + Slice!(T*, 2, Canonical) a, + Slice!(T*, 2, Canonical) b, + ref size_t liwork, + ) + if(!isComplex!T) in { assert(b.length!1 == a.length!1, "gelsd_wq: The number of columns of 'b' must equal the number of columns of 'a'"); } do { - lapackint m = cast(lapackint) a.length!1; - lapackint n = cast(lapackint) a.length!0; - lapackint nrhs = cast(lapackint) b.length; - lapackint lda = cast(lapackint) a._stride.max(1); - lapackint ldb = cast(lapackint) b._stride.max(1); - T rcond = void; - lapackint rank = void; - T work = void; - lapackint lwork = -1; - lapackint iwork = void; - lapackint info = void; + lapackint m = cast(lapackint) a.length!1; + lapackint n = cast(lapackint) a.length!0; + lapackint nrhs = cast(lapackint) b.length; + lapackint lda = cast(lapackint) a._stride.max(1); + lapackint ldb = cast(lapackint) b._stride.max(1); + T rcond = void; + lapackint rank = void; + T work = void; + lapackint lwork = -1; + lapackint iwork = void; + lapackint info = void; - lapack.gelsd_(m, n, nrhs, a.iterator, lda, b.iterator, ldb, null, rcond, rank, &work, lwork, &iwork, info); + lapack.gelsd_(m, n, nrhs, a.iterator, lda, b.iterator, ldb, null, rcond, rank, &work, lwork, &iwork, info); - assert(info == 0); - liwork = iwork; - return cast(size_t) work; + assert(info == 0); + liwork = iwork; + return cast(size_t) work; } /// ditto size_t gelsd_wq(T)( - Slice!(T*, 2, Canonical) a, - Slice!(T*, 2, Canonical) b, - ref size_t lrwork, - ref size_t liwork, - ) - if(isComplex!T) + Slice!(T*, 2, Canonical) a, + Slice!(T*, 2, Canonical) b, + ref size_t lrwork, + ref size_t liwork, + ) + if(isComplex!T) in { assert(b.length!1 == a.length!1, "gelsd_wq: The number of columns of 'b' must equal the number of columns of 'a'"); } do { - lapackint m = cast(lapackint) a.length!1; - lapackint n = cast(lapackint) a.length!0; - lapackint nrhs = cast(lapackint) b.length; - lapackint lda = cast(lapackint) a._stride.max(1); - lapackint ldb = cast(lapackint) b._stride.max(1); - realType!T rcond = void; - lapackint rank = void; - T work = void; - lapackint lwork = -1; - realType!T rwork = void; - lapackint iwork = void; - lapackint info = void; - - lapack.gelsd_(m, n, nrhs, a.iterator, lda, b.iterator, ldb, null, rcond, rank, &work, lwork, &rwork, &iwork, info); - - assert(info == 0); - lrwork = cast(size_t)rwork; - liwork = iwork; - return cast(size_t) work; + lapackint m = cast(lapackint) a.length!1; + lapackint n = cast(lapackint) a.length!0; + lapackint nrhs = cast(lapackint) b.length; + lapackint lda = cast(lapackint) a._stride.max(1); + lapackint ldb = cast(lapackint) b._stride.max(1); + realType!T rcond = void; + lapackint rank = void; + T work = void; + lapackint lwork = -1; + realType!T rwork = void; + lapackint iwork = void; + lapackint info = void; + + lapack.gelsd_(m, n, nrhs, a.iterator, lda, b.iterator, ldb, null, rcond, rank, &work, lwork, &rwork, &iwork, info); + + assert(info == 0); + lrwork = cast(size_t)rwork; + liwork = iwork; + return cast(size_t) work; } unittest { - alias s = gelsd_wq!float; - alias d = gelsd_wq!double; - alias c = gelsd_wq!cfloat; - alias z = gelsd_wq!cdouble; + alias s = gelsd_wq!float; + alias d = gelsd_wq!double; + alias c = gelsd_wq!cfloat; + alias z = gelsd_wq!cdouble; } /// size_t gelsd(T)( - Slice!(T*, 2, Canonical) a, - Slice!(T*, 2, Canonical) b, - Slice!(T*) s, - T rcond, - ref size_t rank, - Slice!(T*) work, - Slice!(lapackint*) iwork, - ) - if(!isComplex!T) + Slice!(T*, 2, Canonical) a, + Slice!(T*, 2, Canonical) b, + Slice!(T*) s, + T rcond, + ref size_t rank, + Slice!(T*) work, + Slice!(lapackint*) iwork, + ) + if(!isComplex!T) in { - assert(b.length!1 == a.length!1, "gelsd: The number of columns of 'b' must equal the number of columns of 'a'"); - assert(s.length == min(a.length!0, a.length!1), "gelsd: The length of 's' must equal the smaller of the dimensions of 'a'"); + assert(b.length!1 == a.length!1, "gelsd: The number of columns of 'b' must equal the number of columns of 'a'"); + assert(s.length == min(a.length!0, a.length!1), "gelsd: The length of 's' must equal the smaller of the dimensions of 'a'"); } do { - lapackint m = cast(lapackint) a.length!1; - lapackint n = cast(lapackint) a.length!0; - lapackint nrhs = cast(lapackint) b.length; - lapackint lda = cast(lapackint) a._stride.max(1); - lapackint ldb = cast(lapackint) b._stride.max(1); - lapackint rank_ = void; - lapackint lwork = cast(lapackint) work.length; - lapackint info = void; + lapackint m = cast(lapackint) a.length!1; + lapackint n = cast(lapackint) a.length!0; + lapackint nrhs = cast(lapackint) b.length; + lapackint lda = cast(lapackint) a._stride.max(1); + lapackint ldb = cast(lapackint) b._stride.max(1); + lapackint rank_ = void; + lapackint lwork = cast(lapackint) work.length; + lapackint info = void; - lapack.gelsd_(m, n, nrhs, a.iterator, lda, b.iterator, ldb, s.iterator, rcond, rank_, work.iterator, lwork, iwork.iterator, info); + lapack.gelsd_(m, n, nrhs, a.iterator, lda, b.iterator, ldb, s.iterator, rcond, rank_, work.iterator, lwork, iwork.iterator, info); - assert(info >= 0); - rank = rank_; - return info; + assert(info >= 0); + rank = rank_; + return info; } /// ditto size_t gelsd(T)( - Slice!(T*, 2, Canonical) a, - Slice!(T*, 2, Canonical) b, - Slice!(realType!T*) s, - realType!T rcond, - ref size_t rank, - Slice!(T*) work, - Slice!(realType!T*) rwork, - Slice!(lapackint*) iwork, - ) - if(isComplex!T) + Slice!(T*, 2, Canonical) a, + Slice!(T*, 2, Canonical) b, + Slice!(realType!T*) s, + realType!T rcond, + ref size_t rank, + Slice!(T*) work, + Slice!(realType!T*) rwork, + Slice!(lapackint*) iwork, + ) + if(isComplex!T) in { - assert(b.length!1 == a.length!1, "gelsd: The number of columns of 'b' must equal the number of columns of 'a'"); - assert(s.length == min(a.length!0, a.length!1), "gelsd: The length of 's' must equal the smaller of the dimensions of 'a'"); + assert(b.length!1 == a.length!1, "gelsd: The number of columns of 'b' must equal the number of columns of 'a'"); + assert(s.length == min(a.length!0, a.length!1), "gelsd: The length of 's' must equal the smaller of the dimensions of 'a'"); } do { - lapackint m = cast(lapackint) a.length!1; - lapackint n = cast(lapackint) a.length!0; - lapackint nrhs = cast(lapackint) b.length; - lapackint lda = cast(lapackint) a._stride.max(1); - lapackint ldb = cast(lapackint) b._stride.max(1); - lapackint rank_ = void; - lapackint lwork = cast(lapackint) work.length; - lapackint info = void; + lapackint m = cast(lapackint) a.length!1; + lapackint n = cast(lapackint) a.length!0; + lapackint nrhs = cast(lapackint) b.length; + lapackint lda = cast(lapackint) a._stride.max(1); + lapackint ldb = cast(lapackint) b._stride.max(1); + lapackint rank_ = void; + lapackint lwork = cast(lapackint) work.length; + lapackint info = void; - lapack.gelsd_(m, n, nrhs, a.iterator, lda, b.iterator, ldb, s.iterator, rcond, rank_, work.iterator, lwork, rwork.iterator, iwork.iterator, info); + lapack.gelsd_(m, n, nrhs, a.iterator, lda, b.iterator, ldb, s.iterator, rcond, rank_, work.iterator, lwork, rwork.iterator, iwork.iterator, info); - assert(info >= 0); - rank = rank_; - return info; + assert(info >= 0); + rank = rank_; + return info; } unittest { - alias s = gelsd!float; - alias d = gelsd!double; - alias c = gelsd!cfloat; - alias z = gelsd!cdouble; + alias s = gelsd!float; + alias d = gelsd!double; + alias c = gelsd!cfloat; + alias z = gelsd!cdouble; } /// `gesdd` work space query size_t gesdd_wq(T)( - char jobz, - Slice!(T*, 2, Canonical) a, - Slice!(T*, 2, Canonical) u, - Slice!(T*, 2, Canonical) vt, - ) -{ - lapackint m = cast(lapackint) a.length!1; - lapackint n = cast(lapackint) a.length!0; - lapackint lda = cast(lapackint) a._stride.max(1); - lapackint ldu = cast(lapackint) u._stride.max(1); - lapackint ldvt = cast(lapackint) vt._stride.max(1); - T work = void; - lapackint lwork = -1; - lapackint info = void; - - static if(!isComplex!T) - { - lapack.gesdd_(jobz, m, n, null, lda, null, null, ldu, null, ldvt, &work, lwork, null, info); - } - else - { - lapack.gesdd_(jobz, m, n, null, lda, null, null, ldu, null, ldvt, &work, lwork, null, null, info); - } - - assert(info == 0); - return cast(size_t) work; + char jobz, + Slice!(T*, 2, Canonical) a, + Slice!(T*, 2, Canonical) u, + Slice!(T*, 2, Canonical) vt, + ) +{ + lapackint m = cast(lapackint) a.length!1; + lapackint n = cast(lapackint) a.length!0; + lapackint lda = cast(lapackint) a._stride.max(1); + lapackint ldu = cast(lapackint) u._stride.max(1); + lapackint ldvt = cast(lapackint) vt._stride.max(1); + T work = void; + lapackint lwork = -1; + lapackint info = void; + + static if(!isComplex!T) + { + lapack.gesdd_(jobz, m, n, null, lda, null, null, ldu, null, ldvt, &work, lwork, null, info); + } + else + { + lapack.gesdd_(jobz, m, n, null, lda, null, null, ldu, null, ldvt, &work, lwork, null, null, info); + } + + assert(info == 0); + return cast(size_t) work; } unittest { - alias s = gesdd_wq!float; - alias d = gesdd_wq!double; - alias c = gesdd_wq!cfloat; - alias z = gesdd_wq!cdouble; + alias s = gesdd_wq!float; + alias d = gesdd_wq!double; + alias c = gesdd_wq!cfloat; + alias z = gesdd_wq!cdouble; } /// size_t gesdd(T)( - char jobz, - Slice!(T*, 2, Canonical) a, - Slice!(T*) s, - Slice!(T*, 2, Canonical) u, - Slice!(T*, 2, Canonical) vt, - Slice!(T*) work, - Slice!(lapackint*) iwork, - ) - if(!isComplex!T) -{ - lapackint m = cast(lapackint) a.length!1; - lapackint n = cast(lapackint) a.length!0; - lapackint lda = cast(lapackint) a._stride.max(1); - lapackint ldu = cast(lapackint) u._stride.max(1); - lapackint ldvt = cast(lapackint) vt._stride.max(1); - lapackint lwork = cast(lapackint) work.length; - lapackint info = void; - - lapack.gesdd_(jobz, m, n, a.iterator, lda, s.iterator, u.iterator, ldu, vt.iterator, ldvt, work.iterator, lwork, iwork.iterator, info); - - assert(info >= 0); - return info; + char jobz, + Slice!(T*, 2, Canonical) a, + Slice!(T*) s, + Slice!(T*, 2, Canonical) u, + Slice!(T*, 2, Canonical) vt, + Slice!(T*) work, + Slice!(lapackint*) iwork, + ) + if(!isComplex!T) +{ + lapackint m = cast(lapackint) a.length!1; + lapackint n = cast(lapackint) a.length!0; + lapackint lda = cast(lapackint) a._stride.max(1); + lapackint ldu = cast(lapackint) u._stride.max(1); + lapackint ldvt = cast(lapackint) vt._stride.max(1); + lapackint lwork = cast(lapackint) work.length; + lapackint info = void; + + lapack.gesdd_(jobz, m, n, a.iterator, lda, s.iterator, u.iterator, ldu, vt.iterator, ldvt, work.iterator, lwork, iwork.iterator, info); + + assert(info >= 0); + return info; } /// ditto size_t gesdd(T)( - char jobz, - Slice!(T*, 2, Canonical) a, - Slice!(realType!T*) s, - Slice!(T*, 2, Canonical) u, - Slice!(T*, 2, Canonical) vt, - Slice!(T*) work, - Slice!(realType!T*) rwork, - Slice!(lapackint*) iwork, - ) - if(isComplex!T) -{ - lapackint m = cast(lapackint) a.length!1; - lapackint n = cast(lapackint) a.length!0; - lapackint lda = cast(lapackint) a._stride.max(1); - lapackint ldu = cast(lapackint) u._stride.max(1); - lapackint ldvt = cast(lapackint) vt._stride.max(1); - lapackint lwork = cast(lapackint) work.length; - lapackint info = void; - - lapack.gesdd_(jobz, m, n, a.iterator, lda, s.iterator, u.iterator, ldu, vt.iterator, ldvt, work.iterator, lwork, rwork.iterator, iwork.iterator, info); - - assert(info >= 0); - return info; + char jobz, + Slice!(T*, 2, Canonical) a, + Slice!(realType!T*) s, + Slice!(T*, 2, Canonical) u, + Slice!(T*, 2, Canonical) vt, + Slice!(T*) work, + Slice!(realType!T*) rwork, + Slice!(lapackint*) iwork, + ) + if(isComplex!T) +{ + lapackint m = cast(lapackint) a.length!1; + lapackint n = cast(lapackint) a.length!0; + lapackint lda = cast(lapackint) a._stride.max(1); + lapackint ldu = cast(lapackint) u._stride.max(1); + lapackint ldvt = cast(lapackint) vt._stride.max(1); + lapackint lwork = cast(lapackint) work.length; + lapackint info = void; + + lapack.gesdd_(jobz, m, n, a.iterator, lda, s.iterator, u.iterator, ldu, vt.iterator, ldvt, work.iterator, lwork, rwork.iterator, iwork.iterator, info); + + assert(info >= 0); + return info; } unittest { - alias s = gesdd!float; - alias d = gesdd!double; - alias c = gesdd!cfloat; - alias z = gesdd!cdouble; + alias s = gesdd!float; + alias d = gesdd!double; + alias c = gesdd!cfloat; + alias z = gesdd!cdouble; } /// `gesvd` work space query size_t gesvd_wq(T)( - char jobu, - char jobvt, - Slice!(T*, 2, Canonical) a, - Slice!(T*, 2, Canonical) u, - Slice!(T*, 2, Canonical) vt, - ) -{ - lapackint m = cast(lapackint) a.length!1; - lapackint n = cast(lapackint) a.length!0; - lapackint lda = cast(lapackint) a._stride.max(1); - lapackint ldu = cast(lapackint) u._stride.max(1); - lapackint ldvt = cast(lapackint) vt._stride.max(1); - T work = void; - lapackint lwork = -1; - lapackint info = void; - - static if(!isComplex!T) - { - lapack.gesvd_(jobu, jobvt, m, n, null, lda, null, null, ldu, null, ldvt, &work, lwork, info); - } - else - { - lapack.gesvd_(jobu, jobvt, m, n, null, lda, null, null, ldu, null, ldvt, &work, lwork, null, info); - } - - assert(info == 0); - return cast(size_t) work; + char jobu, + char jobvt, + Slice!(T*, 2, Canonical) a, + Slice!(T*, 2, Canonical) u, + Slice!(T*, 2, Canonical) vt, + ) +{ + lapackint m = cast(lapackint) a.length!1; + lapackint n = cast(lapackint) a.length!0; + lapackint lda = cast(lapackint) a._stride.max(1); + lapackint ldu = cast(lapackint) u._stride.max(1); + lapackint ldvt = cast(lapackint) vt._stride.max(1); + T work = void; + lapackint lwork = -1; + lapackint info = void; + + static if(!isComplex!T) + { + lapack.gesvd_(jobu, jobvt, m, n, null, lda, null, null, ldu, null, ldvt, &work, lwork, info); + } + else + { + lapack.gesvd_(jobu, jobvt, m, n, null, lda, null, null, ldu, null, ldvt, &work, lwork, null, info); + } + + assert(info == 0); + return cast(size_t) work; } unittest { - alias s = gesvd_wq!float; - alias d = gesvd_wq!double; - alias c = gesvd_wq!cfloat; - alias z = gesvd_wq!cdouble; + alias s = gesvd_wq!float; + alias d = gesvd_wq!double; + alias c = gesvd_wq!cfloat; + alias z = gesvd_wq!cdouble; } /// size_t gesvd(T)( - char jobu, - char jobvt, - Slice!(T*, 2, Canonical) a, - Slice!(T*) s, - Slice!(T*, 2, Canonical) u, - Slice!(T*, 2, Canonical) vt, - Slice!(T*) work, - ) - if(!isComplex!T) -{ - lapackint m = cast(lapackint) a.length!1; - lapackint n = cast(lapackint) a.length!0; - lapackint lda = cast(lapackint) a._stride.max(1); - lapackint ldu = cast(lapackint) u._stride.max(1); - lapackint ldvt = cast(lapackint) vt._stride.max(1); - lapackint lwork = cast(lapackint) work.length; - lapackint info = void; - - lapack.gesvd_(jobu, jobvt, m, n, a.iterator, lda, s.iterator, u.iterator, ldu, vt.iterator, ldvt, work.iterator, lwork, info); - - assert(info >= 0); - return info; + char jobu, + char jobvt, + Slice!(T*, 2, Canonical) a, + Slice!(T*) s, + Slice!(T*, 2, Canonical) u, + Slice!(T*, 2, Canonical) vt, + Slice!(T*) work, + ) + if(!isComplex!T) +{ + lapackint m = cast(lapackint) a.length!1; + lapackint n = cast(lapackint) a.length!0; + lapackint lda = cast(lapackint) a._stride.max(1); + lapackint ldu = cast(lapackint) u._stride.max(1); + lapackint ldvt = cast(lapackint) vt._stride.max(1); + lapackint lwork = cast(lapackint) work.length; + lapackint info = void; + + lapack.gesvd_(jobu, jobvt, m, n, a.iterator, lda, s.iterator, u.iterator, ldu, vt.iterator, ldvt, work.iterator, lwork, info); + + assert(info >= 0); + return info; } /// ditto size_t gesvd(T)( - char jobu, - char jobvt, - Slice!(T*, 2, Canonical) a, - Slice!(realType!T*) s, - Slice!(T*, 2, Canonical) u, - Slice!(T*, 2, Canonical) vt, - Slice!(T*) work, - Slice!(realType!T*) rwork, - ) - if(isComplex!T) -{ - lapackint m = cast(lapackint) a.length!1; - lapackint n = cast(lapackint) a.length!0; - lapackint lda = cast(lapackint) a._stride.max(1); - lapackint ldu = cast(lapackint) u._stride.max(1); - lapackint ldvt = cast(lapackint) vt._stride.max(1); - lapackint lwork = cast(lapackint) work.length; - lapackint info = void; - - lapack.gesvd_(jobu, jobvt, m, n, a.iterator, lda, s.iterator, u.iterator, ldu, vt.iterator, ldvt, work.iterator, lwork, rwork.iterator, info); - - assert(info >= 0); - return info; + char jobu, + char jobvt, + Slice!(T*, 2, Canonical) a, + Slice!(realType!T*) s, + Slice!(T*, 2, Canonical) u, + Slice!(T*, 2, Canonical) vt, + Slice!(T*) work, + Slice!(realType!T*) rwork, + ) + if(isComplex!T) +{ + lapackint m = cast(lapackint) a.length!1; + lapackint n = cast(lapackint) a.length!0; + lapackint lda = cast(lapackint) a._stride.max(1); + lapackint ldu = cast(lapackint) u._stride.max(1); + lapackint ldvt = cast(lapackint) vt._stride.max(1); + lapackint lwork = cast(lapackint) work.length; + lapackint info = void; + + lapack.gesvd_(jobu, jobvt, m, n, a.iterator, lda, s.iterator, u.iterator, ldu, vt.iterator, ldvt, work.iterator, lwork, rwork.iterator, info); + + assert(info >= 0); + return info; } unittest { - alias s = gesvd!float; - alias d = gesvd!double; - alias c = gesvd!cfloat; - alias z = gesvd!cdouble; + alias s = gesvd!float; + alias d = gesvd!double; + alias c = gesvd!cfloat; + alias z = gesvd!cdouble; } /// template spev(T) { - /// - size_t spev( - char jobz, - Slice!(StairsIterator!(T*, "+")) ap, - Slice!(T*) w, - Slice!(T*, 2, Canonical) z, - Slice!(T*) work, - ) + /// + size_t spev( + char jobz, + Slice!(StairsIterator!(T*, "+")) ap, + Slice!(T*) w, + Slice!(T*, 2, Canonical) z, + Slice!(T*) work, + ) in { - assert(work.length == 3 * ap.length, "spev: The length of 'work' must equal three times the length of 'ap'."); - assert(w.length == ap.length, "spev: The length of 'w' must equal the length of 'ap'."); + assert(work.length == 3 * ap.length, "spev: The length of 'work' must equal three times the length of 'ap'."); + assert(w.length == ap.length, "spev: The length of 'w' must equal the length of 'ap'."); } do - { - char uplo = 'U'; - lapackint n = cast(lapackint) ap.length; - lapackint ldz = cast(lapackint) z._stride.max(1); - lapackint info = void; - - lapack.spev_(jobz, uplo, n, &ap[0][0], w.iterator, z.iterator, ldz, work.iterator, info); - - assert(info >= 0); - return info; - } - - /// - size_t spev( - char jobz, - Slice!(StairsIterator!(T*, "-")) ap, - Slice!(T*) w, - Slice!(T*, 2, Canonical) z, - Slice!(T*) work, - ) + { + char uplo = 'U'; + lapackint n = cast(lapackint) ap.length; + lapackint ldz = cast(lapackint) z._stride.max(1); + lapackint info = void; + + lapack.spev_(jobz, uplo, n, &ap[0][0], w.iterator, z.iterator, ldz, work.iterator, info); + + assert(info >= 0); + return info; + } + + /// + size_t spev( + char jobz, + Slice!(StairsIterator!(T*, "-")) ap, + Slice!(T*) w, + Slice!(T*, 2, Canonical) z, + Slice!(T*) work, + ) in { - assert(work.length == 3 * ap.length, "spev: The length of 'work' must equal three times the length of 'ap'."); - assert(w.length == ap.length, "spev: The length of 'w' must equal the length of 'ap'."); + assert(work.length == 3 * ap.length, "spev: The length of 'work' must equal three times the length of 'ap'."); + assert(w.length == ap.length, "spev: The length of 'w' must equal the length of 'ap'."); } do - { - char uplo = 'L'; - lapackint n = cast(lapackint) ap.length; - lapackint ldz = cast(lapackint) z._stride.max(1); - lapackint info = void; + { + char uplo = 'L'; + lapackint n = cast(lapackint) ap.length; + lapackint ldz = cast(lapackint) z._stride.max(1); + lapackint info = void; - lapack.spev_(jobz, uplo, n, &ap[0][0], w.iterator, z.iterator, ldz, work.iterator, info); + lapack.spev_(jobz, uplo, n, &ap[0][0], w.iterator, z.iterator, ldz, work.iterator, info); - assert(info >= 0); - return info; - } + assert(info >= 0); + return info; + } } unittest { - alias s = spev!float; - alias d = spev!double; + alias s = spev!float; + alias d = spev!double; } /// @@ -639,10 +639,10 @@ do unittest { - alias s = sytrf!float; - alias d = sytrf!double; - alias c = sytrf!cfloat; - alias z = sytrf!cdouble; + alias s = sytrf!float; + alias d = sytrf!double; + alias c = sytrf!cfloat; + alias z = sytrf!cdouble; } /// @@ -682,10 +682,10 @@ do unittest { - alias s = geqrf!float; - alias d = geqrf!double; - alias c = geqrf!cfloat; - alias z = geqrf!cdouble; + alias s = geqrf!float; + alias d = geqrf!double; + alias c = geqrf!cfloat; + alias z = geqrf!cdouble; } /// @@ -718,10 +718,10 @@ do unittest { - alias s = getrs!float; - alias d = getrs!double; - alias c = getrs!cfloat; - alias z = getrs!cdouble; + alias s = getrs!float; + alias d = getrs!double; + alias c = getrs!cfloat; + alias z = getrs!cdouble; } /// @@ -752,10 +752,10 @@ do unittest { - alias s = potrs!float; - alias d = potrs!double; - alias c = potrs!cfloat; - alias z = potrs!cdouble; + alias s = potrs!float; + alias d = potrs!double; + alias c = potrs!cfloat; + alias z = potrs!cdouble; } /// @@ -788,10 +788,10 @@ do unittest { - alias s = sytrs2!float; - alias d = sytrs2!double; - alias c = sytrs2!cfloat; - alias z = sytrs2!cdouble; + alias s = sytrs2!float; + alias d = sytrs2!double; + alias c = sytrs2!cfloat; + alias z = sytrs2!cdouble; } /// @@ -814,7 +814,7 @@ in assert(work.length >= a.length!0, "geqrs: The length of 'work' must be " ~ "greater than or equal to the number of rows of 'a'."); //lwork>=n } -body +do { lapackint m = cast(lapackint) a.length!1; lapackint n = cast(lapackint) a.length!0; @@ -834,209 +834,209 @@ body version(none) unittest { - alias s = geqrs!float; - alias d = geqrs!double; - alias c = geqrs!cfloat; - alias z = geqrs!cdouble; + alias s = geqrs!float; + alias d = geqrs!double; + alias c = geqrs!cfloat; + alias z = geqrs!cdouble; } /// size_t sysv_rook_wk(T)( - char uplo, - Slice!(T*, 2, Canonical) a, - Slice!(T*, 2, Canonical) b, - ) + char uplo, + Slice!(T*, 2, Canonical) a, + Slice!(T*, 2, Canonical) b, + ) in { - assert(a.length!0 == a.length!1, "sysv_rook_wk: The input 'a' must be a square matrix."); - assert(b.length!1 == a.length!0, "sysv_rook_wk: The number of columns of 'b' must equal the number of rows of 'a'."); + assert(a.length!0 == a.length!1, "sysv_rook_wk: The input 'a' must be a square matrix."); + assert(b.length!1 == a.length!0, "sysv_rook_wk: The number of columns of 'b' must equal the number of rows of 'a'."); } do { - lapackint n = cast(lapackint) a.length; - lapackint nrhs = cast(lapackint) b.length; - lapackint lda = cast(lapackint) a._stride.max(1); - lapackint ldb = cast(lapackint) b._stride.max(1); - T work = void; - lapackint lwork = -1; - lapackint info = void; + lapackint n = cast(lapackint) a.length; + lapackint nrhs = cast(lapackint) b.length; + lapackint lda = cast(lapackint) a._stride.max(1); + lapackint ldb = cast(lapackint) b._stride.max(1); + T work = void; + lapackint lwork = -1; + lapackint info = void; - lapack.sysv_rook_(uplo, n, nrhs, a._iterator, lda, null, b._iterator, ldb, &work, lwork, info); + lapack.sysv_rook_(uplo, n, nrhs, a._iterator, lda, null, b._iterator, ldb, &work, lwork, info); - return cast(size_t) work; + return cast(size_t) work; } unittest { - alias s = sysv_rook_wk!float; - alias d = sysv_rook_wk!double; - alias c = sysv_rook_wk!cfloat; - alias z = sysv_rook_wk!cdouble; + alias s = sysv_rook_wk!float; + alias d = sysv_rook_wk!double; + alias c = sysv_rook_wk!cfloat; + alias z = sysv_rook_wk!cdouble; } /// size_t sysv_rook(T)( - char uplo, - Slice!(T*, 2, Canonical) a, - Slice!(lapackint*) ipiv, - Slice!(T*, 2, Canonical) b, - Slice!(T*) work, - ) + char uplo, + Slice!(T*, 2, Canonical) a, + Slice!(lapackint*) ipiv, + Slice!(T*, 2, Canonical) b, + Slice!(T*) work, + ) in { - assert(a.length!0 == a.length!1, "sysv_rook: The input 'a' must be a square matrix."); - assert(ipiv.length == a.length!0, "sysv_rook: The length of 'ipiv' must be equal to the number of rows of 'a'"); - assert(b.length!1 == a.length!0, "sysv_rook: The number of columns of 'b' must equal the number of rows of 'a'."); + assert(a.length!0 == a.length!1, "sysv_rook: The input 'a' must be a square matrix."); + assert(ipiv.length == a.length!0, "sysv_rook: The length of 'ipiv' must be equal to the number of rows of 'a'"); + assert(b.length!1 == a.length!0, "sysv_rook: The number of columns of 'b' must equal the number of rows of 'a'."); } do { - lapackint n = cast(lapackint) a.length; - lapackint nrhs = cast(lapackint) b.length; - lapackint lda = cast(lapackint) a._stride.max(1); - lapackint ldb = cast(lapackint) b._stride.max(1); - lapackint lwork = cast(lapackint) work.length; - lapackint info = void; + lapackint n = cast(lapackint) a.length; + lapackint nrhs = cast(lapackint) b.length; + lapackint lda = cast(lapackint) a._stride.max(1); + lapackint ldb = cast(lapackint) b._stride.max(1); + lapackint lwork = cast(lapackint) work.length; + lapackint info = void; - lapack.sysv_rook_(uplo, n, nrhs, a._iterator, lda, ipiv._iterator, b._iterator, ldb, work._iterator, lwork, info); + lapack.sysv_rook_(uplo, n, nrhs, a._iterator, lda, ipiv._iterator, b._iterator, ldb, work._iterator, lwork, info); - assert(info >= 0); - return info; + assert(info >= 0); + return info; } unittest { - alias s = sysv_rook!float; - alias d = sysv_rook!double; - alias c = sysv_rook!cfloat; - alias z = sysv_rook!cdouble; + alias s = sysv_rook!float; + alias d = sysv_rook!double; + alias c = sysv_rook!cfloat; + alias z = sysv_rook!cdouble; } /// size_t syev_wk(T)( - char jobz, - char uplo, - Slice!(T*, 2, Canonical) a, - Slice!(T*) w, - ) + char jobz, + char uplo, + Slice!(T*, 2, Canonical) a, + Slice!(T*) w, + ) in { - assert(a.length!0 == a.length!1, "syev_wk: The input 'a' must be a square matrix."); - assert(w.length == a.length!0, "syev_wk: The length of 'w' must equal the number of rows of 'a'."); + assert(a.length!0 == a.length!1, "syev_wk: The input 'a' must be a square matrix."); + assert(w.length == a.length!0, "syev_wk: The length of 'w' must equal the number of rows of 'a'."); } do { - lapackint n = cast(lapackint) a.length; - lapackint lda = cast(lapackint) a._stride.max(1); - T work = void; - lapackint lwork = -1; - lapackint info = void; + lapackint n = cast(lapackint) a.length; + lapackint lda = cast(lapackint) a._stride.max(1); + T work = void; + lapackint lwork = -1; + lapackint info = void; - lapack.syev_(jobz, uplo, n, a._iterator, lda, w._iterator, &work, lwork, info); + lapack.syev_(jobz, uplo, n, a._iterator, lda, w._iterator, &work, lwork, info); - return cast(size_t) work; + return cast(size_t) work; } unittest { - alias s = syev_wk!float; - alias d = syev_wk!double; + alias s = syev_wk!float; + alias d = syev_wk!double; } /// size_t syev(T)( - char jobz, - char uplo, - Slice!(T*, 2, Canonical) a, - Slice!(T*) w, - Slice!(T*) work, - ) + char jobz, + char uplo, + Slice!(T*, 2, Canonical) a, + Slice!(T*) w, + Slice!(T*) work, + ) in { - assert(a.length!0 == a.length!1, "syev: The input 'a' must be a square matrix."); - assert(w.length == a.length!0, "syev: The length of 'w' must equal the number of rows of 'a'."); + assert(a.length!0 == a.length!1, "syev: The input 'a' must be a square matrix."); + assert(w.length == a.length!0, "syev: The length of 'w' must equal the number of rows of 'a'."); } do { - lapackint n = cast(lapackint) a.length; - lapackint lda = cast(lapackint) a._stride.max(1); - lapackint lwork = cast(lapackint) work.length; - lapackint info = void; + lapackint n = cast(lapackint) a.length; + lapackint lda = cast(lapackint) a._stride.max(1); + lapackint lwork = cast(lapackint) work.length; + lapackint info = void; - lapack.syev_(jobz, uplo, n, a._iterator, lda, w._iterator, work._iterator, lwork, info); + lapack.syev_(jobz, uplo, n, a._iterator, lda, w._iterator, work._iterator, lwork, info); - assert(info >= 0); - return info; + assert(info >= 0); + return info; } unittest { - alias s = syev!float; - alias d = syev!double; + alias s = syev!float; + alias d = syev!double; } /// size_t syev_2stage_wk(T)( - char jobz, - char uplo, - Slice!(T*, 2, Canonical) a, - Slice!(T*) w, - ) + char jobz, + char uplo, + Slice!(T*, 2, Canonical) a, + Slice!(T*) w, + ) in { - assert(a.length!0 == a.length!1, "syev_2stage_wk: The input 'a' must be a square matrix."); - assert(w.length == a.length, "syev_2stage_wk: The length of 'w' must equal the number of rows of 'a'."); + assert(a.length!0 == a.length!1, "syev_2stage_wk: The input 'a' must be a square matrix."); + assert(w.length == a.length, "syev_2stage_wk: The length of 'w' must equal the number of rows of 'a'."); } do { - lapackint n = cast(lapackint) a.length; - lapackint lda = cast(lapackint) a._stride.max(1); - T work = void; - lapackint lwork = -1; - lapackint info = void; + lapackint n = cast(lapackint) a.length; + lapackint lda = cast(lapackint) a._stride.max(1); + T work = void; + lapackint lwork = -1; + lapackint info = void; - lapack.syev_2stage_(jobz, uplo, n, a._iterator, lda, w._iterator, &work, lwork, info); + lapack.syev_2stage_(jobz, uplo, n, a._iterator, lda, w._iterator, &work, lwork, info); - return cast(size_t) work; + return cast(size_t) work; } version(none) unittest { - alias s = syev_2stage_wk!float; - alias d = syev_2stage_wk!double; + alias s = syev_2stage_wk!float; + alias d = syev_2stage_wk!double; } /// size_t syev_2stage(T)( - char jobz, - char uplo, - Slice!(T*, 2, Canonical) a, - Slice!(T*) w, - Slice!(T*) work, - ) + char jobz, + char uplo, + Slice!(T*, 2, Canonical) a, + Slice!(T*) w, + Slice!(T*) work, + ) in { - assert(a.length!0 == a.length!1, "syev_2stage: The input 'a' must be a square matrix."); - assert(w.length == a.length, "syev_2stage: The length of 'w' must equal the number of rows of 'a'."); + assert(a.length!0 == a.length!1, "syev_2stage: The input 'a' must be a square matrix."); + assert(w.length == a.length, "syev_2stage: The length of 'w' must equal the number of rows of 'a'."); } do { - lapackint n = cast(lapackint) a.length; - lapackint lda = cast(lapackint) a._stride.max(1); - lapackint lwork = cast(lapackint) work.length; - lapackint info = void; + lapackint n = cast(lapackint) a.length; + lapackint lda = cast(lapackint) a._stride.max(1); + lapackint lwork = cast(lapackint) work.length; + lapackint info = void; - lapack.syev_2stage_(jobz, uplo, n, a._iterator, lda, w._iterator, work._iterator, lwork, info); + lapack.syev_2stage_(jobz, uplo, n, a._iterator, lda, w._iterator, work._iterator, lwork, info); - assert(info >= 0); - return info; + assert(info >= 0); + return info; } version(none) unittest { - alias s = syev_2stage!float; - alias d = syev_2stage!double; + alias s = syev_2stage!float; + alias d = syev_2stage!double; } /// @@ -1063,238 +1063,238 @@ do unittest { - alias s = potrf!float; - alias d = potrf!double; - alias c = potrf!cfloat; - alias z = potrf!cdouble; + alias s = potrf!float; + alias d = potrf!double; + alias c = potrf!cfloat; + alias z = potrf!cdouble; } /// size_t pptrf(T)( - char uplo, - Slice!(T*, 2, Canonical) ap, - ) + char uplo, + Slice!(T*, 2, Canonical) ap, + ) { - lapackint n = cast(lapackint) ap.length; - lapackint info = void; - - lapack.pptrf_(uplo, n, ap.iterator, info); - - assert(info >= 0); - - return info; + lapackint n = cast(lapackint) ap.length; + lapackint info = void; + + lapack.pptrf_(uplo, n, ap.iterator, info); + + assert(info >= 0); + + return info; } unittest { - alias s = pptrf!float; - alias d = pptrf!double; - alias c = pptrf!cfloat; - alias z = pptrf!cdouble; + alias s = pptrf!float; + alias d = pptrf!double; + alias c = pptrf!cfloat; + alias z = pptrf!cdouble; } /// template sptri(T) { - /// `sptri` for upper triangular input. - size_t sptri( - Slice!(StairsIterator!(T*, "+")) ap, - Slice!(lapackint*) ipiv, - Slice!(T*) work - ) + /// `sptri` for upper triangular input. + size_t sptri( + Slice!(StairsIterator!(T*, "+")) ap, + Slice!(lapackint*) ipiv, + Slice!(T*) work + ) in { - assert(ipiv.length == ap.length, "sptri: The length of 'ipiv' must be equal to the length of 'ap'."); - assert(work.length == ap.length, "sptri: The length of 'work' must be equal to the length of 'ap'."); + assert(ipiv.length == ap.length, "sptri: The length of 'ipiv' must be equal to the length of 'ap'."); + assert(work.length == ap.length, "sptri: The length of 'work' must be equal to the length of 'ap'."); } do - { - lapackint n = cast(lapackint) ap.length; - lapackint info = void; - - char uplo = 'U'; - lapack.sptri_(uplo, n, &ap[0][0], ipiv.iterator, work.iterator, info); - - assert(info >= 0); - return info; - } - - /// `sptri` for lower triangular input. - size_t sptri( - Slice!(StairsIterator!(T*, "-")) ap, - Slice!(lapackint*) ipiv, - Slice!(T*) work - ) + { + lapackint n = cast(lapackint) ap.length; + lapackint info = void; + + char uplo = 'U'; + lapack.sptri_(uplo, n, &ap[0][0], ipiv.iterator, work.iterator, info); + + assert(info >= 0); + return info; + } + + /// `sptri` for lower triangular input. + size_t sptri( + Slice!(StairsIterator!(T*, "-")) ap, + Slice!(lapackint*) ipiv, + Slice!(T*) work + ) in { - assert(ipiv.length == ap.length, "sptri: The length of 'ipiv' must be equal to the length of 'ap'."); - assert(work.length == ap.length, "sptri: The length of 'work' must be equal to the length of 'ap'."); + assert(ipiv.length == ap.length, "sptri: The length of 'ipiv' must be equal to the length of 'ap'."); + assert(work.length == ap.length, "sptri: The length of 'work' must be equal to the length of 'ap'."); } do - { - lapackint n = cast(lapackint) ap.length; - lapackint info = void; + { + lapackint n = cast(lapackint) ap.length; + lapackint info = void; - char uplo = 'L'; - lapack.sptri_(uplo, n, &ap[0][0], ipiv.iterator, work.iterator, info); + char uplo = 'L'; + lapack.sptri_(uplo, n, &ap[0][0], ipiv.iterator, work.iterator, info); - assert(info >= 0); - return info; - } + assert(info >= 0); + return info; + } } unittest { - alias s = sptri!float; - alias d = sptri!double; - alias c = sptri!cfloat; - alias z = sptri!cdouble; + alias s = sptri!float; + alias d = sptri!double; + alias c = sptri!cfloat; + alias z = sptri!cdouble; } /// size_t potri(T)( char uplo, - Slice!(T*, 2, Canonical) a, - ) + Slice!(T*, 2, Canonical) a, + ) in { assert(a.length!0 == a.length!1, "potri: The input 'a' must be a square matrix."); } do { - lapackint n = cast(lapackint) a.length; - lapackint lda = cast(lapackint) a._stride.max(1); - lapackint info = void; + lapackint n = cast(lapackint) a.length; + lapackint lda = cast(lapackint) a._stride.max(1); + lapackint info = void; - lapack.potri_(uplo, n, a.iterator, lda, info); + lapack.potri_(uplo, n, a.iterator, lda, info); - assert(info >= 0); - return info; + assert(info >= 0); + return info; } unittest { - alias s = potri!float; - alias d = potri!double; - alias c = potri!cfloat; - alias z = potri!cdouble; + alias s = potri!float; + alias d = potri!double; + alias c = potri!cfloat; + alias z = potri!cdouble; } /// template pptri(T) { - /// `pptri` for upper triangular input. - size_t pptri( - Slice!(StairsIterator!(T*, "+")) ap - ) - { - lapackint n = cast(lapackint) ap.length; - lapackint info = void; + /// `pptri` for upper triangular input. + size_t pptri( + Slice!(StairsIterator!(T*, "+")) ap + ) + { + lapackint n = cast(lapackint) ap.length; + lapackint info = void; - char uplo = 'U'; - lapack.pptri_(uplo, n, &ap[0][0], info); + char uplo = 'U'; + lapack.pptri_(uplo, n, &ap[0][0], info); - assert(info >= 0); - return info; - } + assert(info >= 0); + return info; + } - /// `pptri` for lower triangular input. - size_t pptri( - Slice!(StairsIterator!(T*, "-")) ap - ) - { - lapackint n = cast(lapackint) ap.length; - lapackint info = void; + /// `pptri` for lower triangular input. + size_t pptri( + Slice!(StairsIterator!(T*, "-")) ap + ) + { + lapackint n = cast(lapackint) ap.length; + lapackint info = void; - char uplo = 'L'; - lapack.pptri_(uplo, n, &ap[0][0], info); + char uplo = 'L'; + lapack.pptri_(uplo, n, &ap[0][0], info); - assert(info >= 0); - return info; - } + assert(info >= 0); + return info; + } } unittest { - alias s = pptri!float; - alias d = pptri!double; - alias c = pptri!cfloat; - alias z = pptri!cdouble; + alias s = pptri!float; + alias d = pptri!double; + alias c = pptri!cfloat; + alias z = pptri!cdouble; } /// size_t trtri(T)( char uplo, char diag, - Slice!(T*, 2, Canonical) a, - ) + Slice!(T*, 2, Canonical) a, + ) in { assert(a.length!0 == a.length!1, "trtri: The input 'a' must be a square matrix."); } do { - lapackint n = cast(lapackint) a.length; - lapackint lda = cast(lapackint) a._stride.max(1); - lapackint info = void; + lapackint n = cast(lapackint) a.length; + lapackint lda = cast(lapackint) a._stride.max(1); + lapackint info = void; - lapack.trtri_(uplo, diag, n, a.iterator, lda, info); + lapack.trtri_(uplo, diag, n, a.iterator, lda, info); - assert(info >= 0); - return info; + assert(info >= 0); + return info; } unittest { - alias s = trtri!float; - alias d = trtri!double; - alias c = trtri!cfloat; - alias z = trtri!cdouble; + alias s = trtri!float; + alias d = trtri!double; + alias c = trtri!cfloat; + alias z = trtri!cdouble; } /// template tptri(T) { - /// `tptri` for upper triangular input. - size_t tptri( - char diag, - Slice!(StairsIterator!(T*, "+")) ap, - ) - { - lapackint n = cast(lapackint) ap.length; - lapackint info = void; + /// `tptri` for upper triangular input. + size_t tptri( + char diag, + Slice!(StairsIterator!(T*, "+")) ap, + ) + { + lapackint n = cast(lapackint) ap.length; + lapackint info = void; - char uplo = 'U'; - lapack.tptri_(uplo, diag, n, &ap[0][0], info); + char uplo = 'U'; + lapack.tptri_(uplo, diag, n, &ap[0][0], info); - assert(info >= 0); - return info; - } + assert(info >= 0); + return info; + } - /// `tptri` for lower triangular input. - size_t tptri( - char diag, - Slice!(StairsIterator!(T*, "-")) ap, - ) - { - lapackint n = cast(lapackint) ap.length; - lapackint info = void; + /// `tptri` for lower triangular input. + size_t tptri( + char diag, + Slice!(StairsIterator!(T*, "-")) ap, + ) + { + lapackint n = cast(lapackint) ap.length; + lapackint info = void; - char uplo = 'L'; - lapack.tptri_(uplo, diag, n, &ap[0][0], info); + char uplo = 'L'; + lapack.tptri_(uplo, diag, n, &ap[0][0], info); - assert(info >= 0); - return info; + assert(info >= 0); + return info; - } + } } unittest { - alias s = tptri!float; - alias d = tptri!double; - alias c = tptri!cfloat; - alias z = tptri!cdouble; + alias s = tptri!float; + alias d = tptri!double; + alias c = tptri!cfloat; + alias z = tptri!cdouble; } /// @@ -1325,8 +1325,8 @@ size_t ormqr(T)( unittest { - alias s = ormqr!float; - alias d = ormqr!double; + alias s = ormqr!float; + alias d = ormqr!double; } /// @@ -1714,6 +1714,7 @@ unittest alias b = ormhr!float; } +/// size_t hseqr(T)( char job, char compz, @@ -1748,6 +1749,7 @@ do return cast(size_t)info; } +/// size_t hseqr(T)( char job, char compz, @@ -1791,6 +1793,7 @@ unittest alias c = hseqr!cdouble; } +/// size_t trevc(T)(char side, char howmany, lapackint select, @@ -1832,6 +1835,7 @@ alias complexType(T : float) = cfloat; alias complexType(T : real) = creal; alias complexType(T : isComplex!T) = T; +/// size_t gebal(T, realT)(char job, Slice!(T*, 2, Canonical) a, lapackint ilo, @@ -1856,6 +1860,7 @@ unittest alias d = gebal!(cfloat,float); } +/// size_t gebak(T, realT)( char job, char side, @@ -1883,6 +1888,7 @@ unittest alias d = gebak!(cfloat,float); } +/// size_t geev(T, realT)( char jobvl, char jobvr, @@ -1905,6 +1911,8 @@ size_t geev(T, realT)( assert(info >= 0); return info; } + +/// size_t geev(T)( char jobvl, char jobvr, @@ -1927,3 +1935,36 @@ size_t geev(T)( assert(info >= 0); return info; } + +/// +size_t steqr(T, realT = realType!T)( + char compz, + Slice!(realT*) d, + Slice!(realT*) e, + Slice!(T*, 2, Canonical) z, + Slice!(realT*) work) + if (is(realType!T == realT)) +in { + assert(d.length == e.length + 1); + assert(work.length >= (e.length * 2).max(1u)); + assert(z.length!0 == d.length); + assert(z.length!1 == d.length); + assert(z._stride >= d.length); +} +do { + lapackint n = cast(lapackint) d.length; + lapackint ldz = cast(lapackint) z._stride.max(1); + lapackint info = void; + + lapack.steqr_(compz, n, d.iterator, e.iterator, z.iterator, ldz, work.iterator, info); + assert(info >= 0); + return info; +} + +unittest +{ + alias a = steqr!float; + alias b = steqr!double; + alias c = steqr!cfloat; + alias d = steqr!cdouble; +}