Skip to content

lapack64 #

The dqds routines in this file (dlasq1 .. dlasq6) compute the singular values of a real bidiagonal matrix to high relative accuracy using the differential quotient-difference algorithm with shifts. The code follows the reference LAPACK routines of the same names (via their Go port in gonum, BSD-3-Clause), including the 0-based index translation, so that results are reproducible against the reference.

Constants #

const smlsiz = 25

smlsiz is the maximum size of the subproblems at the bottom of the divide and conquer tree of dbdsdc (ILAENV(9) in the reference implementation).

const bad_apply_ortho = 'lapack: bad ApplyOrtho'

Panic strings for bad enumeration values.

const bad_balance_job = 'lapack: bad BalanceJob'

bad_balance_job is a public constant used by this module.

const bad_diag = 'lapack: bad Diag'

bad_diag is a public constant used by this module.

const bad_direct = 'lapack: bad Direct'

bad_direct is a public constant used by this module.

const bad_ev_comp = 'lapack: bad EigenVectorsComp'

bad_ev_comp is a public constant used by this module.

const bad_ev_how_many = 'lapack: bad EigenVectorsHowMany'

bad_ev_how_many is a public constant used by this module.

const bad_ev_job = 'lapack: bad EigenVectorsJob'

bad_ev_job is a public constant used by this module.

const bad_ev_side = 'lapack: bad EigenVectorsSide'

bad_ev_side is a public constant used by this module.

const bad_gsvd_job = 'lapack: bad GSVDJob'

bad_gsvd_job is a public constant used by this module.

const bad_gen_ortho = 'lapack: bad GenOrtho'

bad_gen_ortho is a public constant used by this module.

const bad_left_ev_job = 'lapack: bad LeftEigenVectorsJob'

bad_left_ev_job is a public constant used by this module.

const bad_matrix_type = 'lapack: bad MatrixType'

bad_matrix_type is a public constant used by this module.

const bad_maximize_norm_x_job = 'lapack: bad MaximizeNormXJob'

bad_maximize_norm_x_job is a public constant used by this module.

const bad_norm = 'lapack: bad Norm'

bad_norm is a public constant used by this module.

const bad_ortho_comp = 'lapack: bad OrthoComp'

bad_ortho_comp is a public constant used by this module.

const bad_pivot = 'lapack: bad Pivot'

bad_pivot is a public constant used by this module.

const bad_right_ev_job = 'lapack: bad RightEigenVectorsJob'

bad_right_ev_job is a public constant used by this module.

const bad_svd_job = 'lapack: bad SVDJob'

bad_svd_job is a public constant used by this module.

const bad_schur_comp = 'lapack: bad SchurComp'

bad_schur_comp is a public constant used by this module.

const bad_schur_job = 'lapack: bad SchurJob'

bad_schur_job is a public constant used by this module.

const bad_side = 'lapack: bad Side'

bad_side is a public constant used by this module.

const bad_sort = 'lapack: bad Sort'

bad_sort is a public constant used by this module.

const bad_store_v = 'lapack: bad StoreV'

bad_store_v is a public constant used by this module.

const bad_trans = 'lapack: bad Trans'

bad_trans is a public constant used by this module.

const bad_update_schur_comp = 'lapack: bad UpdateSchurComp'

bad_update_schur_comp is a public constant used by this module.

const bad_uplo = 'lapack: bad Uplo'

bad_uplo is a public constant used by this module.

const both_svd_over = 'lapack: both jobU and jobVT are lapack.SingularValueDecompositionOverwrite'

both_svd_over is a public constant used by this module.

const bad_ifst = 'lapack: ifst out of range'

Panic strings for bad numerical and string values.

const bad_ihi = 'lapack: ihi out of range'

bad_ihi is a public constant used by this module.

const bad_ihiz = 'lapack: ihiz out of range'

bad_ihiz is a public constant used by this module.

const bad_ilo = 'lapack: ilo out of range'

bad_ilo is a public constant used by this module.

const bad_iloz = 'lapack: iloz out of range'

bad_iloz is a public constant used by this module.

const bad_ilst = 'lapack: ilst out of range'

bad_ilst is a public constant used by this module.

const bad_isave = 'lapack: bad isave value'

bad_isave is a public constant used by this module.

const bad_ispec = 'lapack: bad ispec value'

bad_ispec is a public constant used by this module.

const bad_j1 = 'lapack: j1 out of range'

bad_j1 is a public constant used by this module.

const bad_jpvt = 'lapack: bad element of jpvt'

bad_jpvt is a public constant used by this module.

const bad_k1 = 'lapack: k1 out of range'

bad_k1 is a public constant used by this module.

const bad_k2 = 'lapack: k2 out of range'

bad_k2 is a public constant used by this module.

const bad_kacc22 = 'lapack: invalid value of kacc22'

bad_kacc22 is a public constant used by this module.

const bad_kbot = 'lapack: kbot out of range'

bad_kbot is a public constant used by this module.

const bad_ktop = 'lapack: ktop out of range'

bad_ktop is a public constant used by this module.

const bad_l_work = 'lapack: insufficient declared workspace length'

bad_l_work is a public constant used by this module.

const bad_mm = 'lapack: mm out of range'

bad_mm is a public constant used by this module.

const bad_n1 = 'lapack: bad value of n1'

bad_n1 is a public constant used by this module.

const bad_n2 = 'lapack: bad value of n2'

bad_n2 is a public constant used by this module.

const bad_na = 'lapack: bad value of na'

bad_na is a public constant used by this module.

const bad_name = 'lapack: bad name'

bad_name is a public constant used by this module.

const bad_nh = 'lapack: bad value of nh'

bad_nh is a public constant used by this module.

const bad_nw = 'lapack: bad value of nw'

bad_nw is a public constant used by this module.

const bad_pp = 'lapack: bad value of pp'

bad_pp is a public constant used by this module.

const bad_shifts = 'lapack: bad shifts'

bad_shifts is a public constant used by this module.

const i0lt0 = 'lapack: i0 < 0'

i0lt0 is a public constant used by this module.

const k_gtm = 'lapack: k > m'

k_gtm is a public constant used by this module.

const k_gtn = 'lapack: k > n'

k_gtn is a public constant used by this module.

const k_lt0 = 'lapack: k < 0'

k_lt0 is a public constant used by this module.

const k_lt1 = 'lapack: k < 1'

k_lt1 is a public constant used by this module.

const kd_lt0 = 'lapack: kd < 0'

kd_lt0 is a public constant used by this module.

const kl_lt0 = 'lapack: kl < 0'

kl_lt0 is a public constant used by this module.

const ku_lt0 = 'lapack: ku < 0'

ku_lt0 is a public constant used by this module.

const m_gtn = 'lapack: m > n'

m_gtn is a public constant used by this module.

const m_lt0 = 'lapack: m < 0'

m_lt0 is a public constant used by this module.

const mm_lt0 = 'lapack: mm < 0'

mm_lt0 is a public constant used by this module.

const n0lt0 = 'lapack: n0 < 0'

n0lt0 is a public constant used by this module.

const n_gtm = 'lapack: n > m'

n_gtm is a public constant used by this module.

const n_lt0 = 'lapack: n < 0'

n_lt0 is a public constant used by this module.

const n_lt1 = 'lapack: n < 1'

n_lt1 is a public constant used by this module.

const n_ltm = 'lapack: n < m'

n_ltm is a public constant used by this module.

const nan_c_from = 'lapack: cfrom is NaN'

nan_c_from is a public constant used by this module.

const nan_c_to = 'lapack: cto is NaN'

nan_c_to is a public constant used by this module.

const nb_gtm = 'lapack: nb > m'

nb_gtm is a public constant used by this module.

const nb_gtn = 'lapack: nb > n'

nb_gtn is a public constant used by this module.

const nb_lt0 = 'lapack: nb < 0'

nb_lt0 is a public constant used by this module.

const ncc_lt0 = 'lapack: ncc < 0'

ncc_lt0 is a public constant used by this module.

const ncvt_lt0 = 'lapack: ncvt < 0'

ncvt_lt0 is a public constant used by this module.

const neg_a_norm = 'lapack: anorm < 0'

neg_a_norm is a public constant used by this module.

const neg_z = 'lapack: negative z value'

neg_z is a public constant used by this module.

const nh_lt0 = 'lapack: nh < 0'

nh_lt0 is a public constant used by this module.

const not_isolated = 'lapack: block is not isolated'

not_isolated is a public constant used by this module.

const nrhs_lt0 = 'lapack: nrhs < 0'

nrhs_lt0 is a public constant used by this module.

const nru_lt0 = 'lapack: nru < 0'

nru_lt0 is a public constant used by this module.

const nshfts_lt0 = 'lapack: nshfts < 0'

nshfts_lt0 is a public constant used by this module.

const nshfts_odd = 'lapack: nshfts must be even'

nshfts_odd is a public constant used by this module.

const nv_lt0 = 'lapack: nv < 0'

nv_lt0 is a public constant used by this module.

const offset_gtm = 'lapack: offset > m'

offset_gtm is a public constant used by this module.

const offset_lt0 = 'lapack: offset < 0'

offset_lt0 is a public constant used by this module.

const p_lt0 = 'lapack: p < 0'

p_lt0 is a public constant used by this module.

const recur_lt0 = 'lapack: recur < 0'

recur_lt0 is a public constant used by this module.

const zero_c_from = 'lapack: zero cfrom'

zero_c_from is a public constant used by this module.

const bad_len_alpha = 'lapack: bad length of alpha'

Panic strings for bad slice lengths.

const bad_len_beta = 'lapack: bad length of beta'

bad_len_beta is a public constant used by this module.

const bad_len_ipiv = 'lapack: bad length of ipiv'

bad_len_ipiv is a public constant used by this module.

const bad_len_jpiv = 'lapack: bad length of jpiv'

bad_len_jpiv is a public constant used by this module.

const bad_len_jpvt = 'lapack: bad length of jpvt'

bad_len_jpvt is a public constant used by this module.

const bad_len_k = 'lapack: bad length of k'

bad_len_k is a public constant used by this module.

const bad_len_piv = 'lapack: bad length of piv'

bad_len_piv is a public constant used by this module.

const bad_len_selected = 'lapack: bad length of selected'

bad_len_selected is a public constant used by this module.

const bad_len_si = 'lapack: bad length of si'

bad_len_si is a public constant used by this module.

const bad_len_sr = 'lapack: bad length of sr'

bad_len_sr is a public constant used by this module.

const bad_len_tau = 'lapack: bad length of tau'

bad_len_tau is a public constant used by this module.

const bad_len_wi = 'lapack: bad length of wi'

bad_len_wi is a public constant used by this module.

const bad_len_wr = 'lapack: bad length of wr'

bad_len_wr is a public constant used by this module.

const short_a = 'lapack: insufficient length of a'

Panic strings for insufficient slice lengths.

const short_ab = 'lapack: insufficient length of ab'

short_ab is a public constant used by this module.

const short_auxv = 'lapack: insufficient length of auxv'

short_auxv is a public constant used by this module.

const short_b = 'lapack: insufficient length of b'

short_b is a public constant used by this module.

const short_c = 'lapack: insufficient length of c'

short_c is a public constant used by this module.

const short_c_norm = 'lapack: insufficient length of cnorm'

short_c_norm is a public constant used by this module.

const short_d = 'lapack: insufficient length of d'

short_d is a public constant used by this module.

const short_dl = 'lapack: insufficient length of dl'

short_dl is a public constant used by this module.

const short_du = 'lapack: insufficient length of du'

short_du is a public constant used by this module.

const short_e = 'lapack: insufficient length of e'

short_e is a public constant used by this module.

const short_f = 'lapack: insufficient length of f'

short_f is a public constant used by this module.

const short_h = 'lapack: insufficient length of h'

short_h is a public constant used by this module.

const short_i_work = 'lapack: insufficient length of iwork'

short_i_work is a public constant used by this module.

const short_isgn = 'lapack: insufficient length of isgn'

short_isgn is a public constant used by this module.

const short_q = 'lapack: insufficient length of q'

short_q is a public constant used by this module.

const short_rhs = 'lapack: insufficient length of rhs'

short_rhs is a public constant used by this module.

const short_s = 'lapack: insufficient length of s'

short_s is a public constant used by this module.

const short_scale = 'lapack: insufficient length of scale'

short_scale is a public constant used by this module.

const short_t = 'lapack: insufficient length of t'

short_t is a public constant used by this module.

const short_tau = 'lapack: insufficient length of tau'

short_tau is a public constant used by this module.

const short_tau_p = 'lapack: insufficient length of tauP'

short_tau_p is a public constant used by this module.

const short_tau_q = 'lapack: insufficient length of tauQ'

short_tau_q is a public constant used by this module.

const short_u = 'lapack: insufficient length of u'

short_u is a public constant used by this module.

const short_v = 'lapack: insufficient length of v'

short_v is a public constant used by this module.

const short_vl = 'lapack: insufficient length of vl'

short_vl is a public constant used by this module.

const short_vr = 'lapack: insufficient length of vr'

short_vr is a public constant used by this module.

const short_vt = 'lapack: insufficient length of vt'

short_vt is a public constant used by this module.

const short_vn1 = 'lapack: insufficient length of vn1'

short_vn1 is a public constant used by this module.

const short_vn2 = 'lapack: insufficient length of vn2'

short_vn2 is a public constant used by this module.

const short_w = 'lapack: insufficient length of w'

short_w is a public constant used by this module.

const short_wh = 'lapack: insufficient length of wh'

short_wh is a public constant used by this module.

const short_wv = 'lapack: insufficient length of wv'

short_wv is a public constant used by this module.

const short_wi = 'lapack: insufficient length of wi'

short_wi is a public constant used by this module.

const short_work = 'lapack: insufficient length of work'

short_work is a public constant used by this module.

const short_wr = 'lapack: insufficient length of wr'

short_wr is a public constant used by this module.

const short_x = 'lapack: insufficient length of x'

short_x is a public constant used by this module.

const short_y = 'lapack: insufficient length of y'

short_y is a public constant used by this module.

const short_z = 'lapack: insufficient length of z'

short_z is a public constant used by this module.

const bad_ld_a = 'lapack: bad leading dimension of A'

Panic strings for bad leading dimensions of matrices.

const bad_ld_b = 'lapack: bad leading dimension of B'

bad_ld_b is a public constant used by this module.

const bad_ld_c = 'lapack: bad leading dimension of C'

bad_ld_c is a public constant used by this module.

const bad_ld_f = 'lapack: bad leading dimension of F'

bad_ld_f is a public constant used by this module.

const bad_ld_h = 'lapack: bad leading dimension of H'

bad_ld_h is a public constant used by this module.

const bad_ld_q = 'lapack: bad leading dimension of Q'

bad_ld_q is a public constant used by this module.

const bad_ld_t = 'lapack: bad leading dimension of T'

bad_ld_t is a public constant used by this module.

const bad_ld_u = 'lapack: bad leading dimension of U'

bad_ld_u is a public constant used by this module.

const bad_ld_v = 'lapack: bad leading dimension of V'

bad_ld_v is a public constant used by this module.

const bad_ld_vl = 'lapack: bad leading dimension of VL'

bad_ld_vl is a public constant used by this module.

const bad_ld_vr = 'lapack: bad leading dimension of VR'

bad_ld_vr is a public constant used by this module.

const bad_ld_vt = 'lapack: bad leading dimension of VT'

bad_ld_vt is a public constant used by this module.

const bad_ld_w = 'lapack: bad leading dimension of W'

bad_ld_w is a public constant used by this module.

const bad_ld_wh = 'lapack: bad leading dimension of WH'

bad_ld_wh is a public constant used by this module.

const bad_ld_wv = 'lapack: bad leading dimension of WV'

bad_ld_wv is a public constant used by this module.

const bad_ld_work = 'lapack: bad leading dimension of Work'

bad_ld_work is a public constant used by this module.

const bad_ld_x = 'lapack: bad leading dimension of X'

bad_ld_x is a public constant used by this module.

const bad_ld_y = 'lapack: bad leading dimension of Y'

bad_ld_y is a public constant used by this module.

const bad_ld_z = 'lapack: bad leading dimension of Z'

bad_ld_z is a public constant used by this module.

const abs_inc_not_one = 'lapack: increment not one or negative one'

Panic strings for bad vector increments.

const bad_inc_x = 'lapack: incx <= 0'

bad_inc_x is a public constant used by this module.

const bad_inc_y = 'lapack: incy <= 0'

bad_inc_y is a public constant used by this module.

const zero_inc_v = 'lapack: incv == 0'

zero_inc_v is a public constant used by this module.

const info_not_implemented = 1 << 30

info_not_implemented is the info value returned by pure-V routines that validate their arguments but have no pure-V implementation yet. It is non-zero so every caller that checks info != 0 fails instead of reading uncomputed output. Build with -d vsl_lapack_lapacke for the LAPACKE implementation of these routines.

fn dbdsdc #

fn dbdsdc(uplo MatrixType, mode BdsdcMode, n int, mut d []f64, mut e []f64, mut u []f64, ldu int, mut vt []f64, ldvt int) int

dbdsdc computes the singular value decomposition (SVD) of a real n×n (upper or lower) bidiagonal matrix B = USVᵀ using the divide and conquer method, where S is a diagonal matrix with non-negative diagonal elements (the singular values of B), and U and V are orthogonal matrices of left and right singular vectors. All matrices are column-major.

uplo selects upper or lower bidiagonal B; d (length n) holds the diagonal and e (length n-1) the off-diagonal elements. For mode = vectors the matrices U (n×n, ldu >= n) and Vᵀ (n×n, ldvt >= n) are computed and overwrite u and vt. On exit d contains the singular values in decreasing order and e is destroyed.

The singular values are computed to high relative accuracy by the divide and conquer iteration in the sense that errors are bounded by eps times the largest singular value; use dbdsqr or dlasq1 for high relative accuracy of the small values.

Subproblems of at most smlsiz = 25 rows are solved with dbdsqr (the QR iteration). If the divide and conquer iteration fails to converge (which only happens for pathological secular equations), the whole problem is recomputed with dbdsqr, so info > 0 is only returned if that fails too and then has the semantics of dbdsqr (the number of off-diagonal elements that did not converge to zero).

info is 0 on success and -i if the i-th argument had an illegal value (1 uplo, 2 mode, 3 n, 5 d, 6 e... counting as in the argument list of LAPACK DBDSDC without compq 'P').

This is a port of the reference LAPACK routine DBDSDC (COMPQ = 'N' and 'I').

fn dbdsdc_sml #

fn dbdsdc_sml(uplo MatrixType, mode BdsdcMode, n int, mut d []f64, mut e []f64, mut u []f64, ldu int, mut vt []f64, ldvt int, sml int) int

dbdsdc_sml is dbdsdc with an explicit size sml (>= 3) below which the subproblems are solved with the QR iteration. It is an internal routine exported for testing purposes (small values exercise the divide and conquer recursion on small matrices).

fn dbdsqr #

fn dbdsqr(uplo MatrixType, n int, ncvt int, nru int, ncc int, mut d []f64, mut e []f64, mut vt []f64, ldvt int, mut u []f64, ldu int, mut c []f64, ldc int) int

dbdsqr computes the singular values and, optionally, the right and/or left singular vectors of a real n×n bidiagonal matrix B using the implicit zero-shift QR algorithm. All matrices are column-major.

uplo selects upper_tri or lower_tri bidiagonal. d (length n) holds the diagonal and e (length n-1) the off-diagonal elements of B. On exit d holds the singular values in decreasing order.

If ncvt > 0, vt (n×ncvt) is overwritten by PᵀVT where B = QSPᵀ; if nru > 0, u (nru×n) is overwritten by UQ; if ncc > 0, c (n×ncc) is overwritten by Qᵀ*C.

The return value is info: 0 on success, otherwise the number of off-diagonal elements that did not converge to zero. A negative value -i indicates that the i-th argument had an illegal value.

fn dgebak_cm #

fn dgebak_cm(job BalanceJob, right bool, n int, ilo int, ihi int, scale []f64, m int, mut v []f64, ldv int)

dgebak_cm forms the right or the left eigenvectors of the original matrix by back-transforming those of the matrix balanced by dgebal_cm (LAPACK DGEBAK). v is the n×m column-major matrix of eigenvectors; ilo, ihi and scale are the outputs of dgebal_cm. right selects right eigenvectors, otherwise left eigenvectors are transformed.

fn dgebal #

fn dgebal(job BalanceJob, n int, mut a []f64, lda int, mut scale []f64) int

dgebal balances an n×n matrix A. Balancing consists of two stages, permuting and scaling. Both steps are optional and depend on the value of job.

Permuting consists of applying a permutation matrix P such that the matrix that results from PᵀAP takes the upper block triangular form

[ T1 X Y ] Pᵀ A P = [ 0 B Z ], [ 0 0 T2 ]

where T1 and T2 are upper triangular matrices and B contains at least one nonzero off-diagonal element in each row and column. The indices ilo and ihi mark the starting and ending columns of the submatrix B. The eigenvalues of A isolated in the first 0 to ilo-1 and last ihi+1 to n-1 elements on the diagonal can be read off without any roundoff error.

Scaling consists of applying a diagonal similarity transformation D such that D^{-1}BD has the 1-norm of each row and its corresponding column nearly equal. The output matrix is

[ T1 X*D Y ] [ 0 inv(D)BD inv(D)*Z ]. [ 0 0 T2 ]

Scaling may reduce the 1-norm of the matrix, and improve the accuracy of the computed eigenvalues and/or eigenvectors.

job specifies the operations that will be performed on A. If job is BalanceJob.balance_none, dgebal sets scale[i] = 1 for all i and returns 0. If job is BalanceJob.permute, only permuting will be done. If job is BalanceJob.scale, only scaling will be done. If job is BalanceJob.permute_scale, both permuting and scaling will be done.

On return, scale will contain information about the permutations and scaling factors applied to A. If π(j) denotes the index of the column interchanged with column j, and D[j,j] denotes the scaling factor applied to column j, then

scale[j] == π(j), for j ∈ {0, ..., ilo-1, ihi+1, ..., n-1}, == D[j,j], for j ∈ {ilo, ..., ihi}.

scale must have length equal to n, otherwise dgebal will panic.

dgebal returns 0 on success, or a negative error code.

fn dgebal_cm #

fn dgebal_cm(job BalanceJob, n int, mut a []f64, lda int, mut scale []f64) (int, int)

dgebal_cm balances a general real n×n column-major matrix A (LAPACK DGEBAL, BSD-3-Clause, University of Tennessee et al.). job is one of balance_none, permute, scale and permute_scale, as in dgebal.

It returns the 1-based indices (ilo, ihi) such that A[i,j] = 0 if i > j and 1 <= j < ilo or ihi < i <= n. scale (length n) holds the permutation indices (1-based, as float64) for the rows and columns outside ilo:ihi and the scaling factors for those inside.

Unlike dgebal, which follows the row-major gonum convention, this routine uses the column-major layout of the rest of the pure-V eigenvalue driver.

fn dgebd2 #

fn dgebd2(m int, n int, mut a []f64, lda int, mut d []f64, mut e []f64, mut tauq []f64, mut taup []f64)

dgebd2 reduces a general m×n column-major matrix A to upper or lower bidiagonal form B by an orthogonal transformation QᵀAP = B using unblocked Householder reflections. See dgebrd for the storage conventions.

dgebd2 is an internal routine. It is exported for testing purposes.

fn dgebrd #

fn dgebrd(m int, n int, mut a []f64, lda int, mut d []f64, mut e []f64, mut tauq []f64, mut taup []f64)

dgebrd reduces a general m×n column-major matrix A to bidiagonal form B = QᵀAP by an orthogonal transformation.

If m >= n, B is upper bidiagonal; if m < n, B is lower bidiagonal. On exit the diagonal and the first super-diagonal (m >= n) or sub-diagonal (m < n) of a contain B, the elements below (m >= n) or above (m < n) that bidiagonal hold the reflectors representing Q and the remaining elements hold the reflectors representing P. d has length min(m,n), e has length min(m,n)-1, and tauq and taup have length min(m,n).

For min(m,n) above the crossover point (512) the reduction is blocked (nb = 32): dlabrd reduces a panel of nb rows and columns and the trailing matrix is updated with two matrix-matrix products; the remaining part is reduced with dgebd2.

fn dgebrd_blocked #

fn dgebrd_blocked(m int, n int, mut a []f64, lda int, mut d []f64, mut e []f64, mut tauq []f64, mut taup []f64, nb_ int, nx_ int)

dgebrd_blocked is dgebrd with an explicit block size nb and crossover nx. The blocked algorithm is used while more than nx rows/columns remain; use nb = 1 or nx >= min(m,n) to force the unblocked code. It is an internal routine exported for testing purposes.

fn dgeev #

fn dgeev(jobvl LeftEigenVectorsJob, jobvr RightEigenVectorsJob, n int, mut a []f64, lda int, mut wr []f64, mut wi []f64, mut vl []f64, ldvl int, mut vr []f64, ldvr int) int

dgeev computes, for an n×n real nonsymmetric column-major matrix A, the eigenvalues and, optionally, the left and/or right eigenvectors.

The right eigenvector v(j) of A satisfies A*v(j) = λ(j)v(j); the left eigenvector u(j) satisfies u(j)ᴴA = λ(j)*u(j)ᴴ.

The computed eigenvectors are normalized to have Euclidean norm equal to 1 and largest component real.

Complex conjugate pairs of eigenvalues appear consecutively with the positive imaginary part first (wr[j] ± iwi[j]). If the j-th eigenvalue is real, its eigenvector is the j-th column of vr (resp. vl). If the j-th and (j+1)-th eigenvalues form a complex pair, columns j and j+1 of vr hold the real and imaginary parts of the eigenvector of the eigenvalue with positive imaginary part: v(j) = vr[:,j] + ivr[:,j+1] and v(j+1) = vr[:,j] - i*vr[:,j+1].

jobvl and jobvr select which eigenvectors are computed. On exit a is overwritten. wr and wi must have length at least n; vl (ldvl >= n when requested, otherwise ldvl >= 1) and vr analogously.

The algorithm is the one of LAPACK DGEEV (BSD-3-Clause, University of Tennessee et al.): scale A if its largest entry is outside [sqrt(safmin)/eps, eps/sqrt(safmin)], balance (dgebal_cm), reduce to Hessenberg form (dgehrd), generate the orthogonal factor (dorghr), compute the Schur form with the double-shift QR algorithm (dhseqr), obtain the eigenvectors of the quasi-triangular factor (dtrevc3), undo the balancing (dgebak_cm), normalize, and undo the scaling.

It returns 0 on success, -i if the i-th argument had an illegal value, and i > 0 if the QR algorithm failed to compute all the eigenvalues; in that case no eigenvectors have been computed and the elements wr[i:n] and wi[i:n] contain the eigenvalues that have converged.

fn dgehd2 #

fn dgehd2(n int, ilo int, ihi int, mut a []f64, lda int, mut tau []f64)

dgehd2 reduces a real general n×n column-major matrix A to upper Hessenberg form H by an orthogonal similarity transformation, QᵀAQ = H, using the unblocked algorithm.

ilo and ihi are 1-based and must be the values returned by dgebal (or 1 and n if A was not balanced); A is assumed to be already upper triangular in rows and columns 1:ilo-1 and ihi+1:n. On exit the upper triangle and the first subdiagonal of a contain H; the elements below the first subdiagonal, with the array tau, represent Q as a product of elementary reflectors

Q = H(ilo) * H(ilo+1) * ... * H(ihi-1), H(i) = I - tau[i-1]vvᵀ,

where v[0:i] = 0, v[i] = 1 and v[i+1:ihi] is stored on exit in a[i+1:ihi, i-1] (1-based row and column indices). tau must have length at least n-1.

The algorithm is the unblocked reduction of LAPACK DGEHD2 (BSD-3-Clause, University of Tennessee et al.), as ported in gonum/lapack.

fn dgehrd #

fn dgehrd(n int, ilo int, ihi int, mut a []f64, lda int, mut tau []f64) int

dgehrd reduces a real general n×n column-major matrix A to upper Hessenberg form H = QᵀAQ (see dgehd2 for the meaning of ilo, ihi, a and tau).

The reduction uses the unblocked Householder algorithm.

It returns 0 on success and -i if the i-th argument had an illegal value.

fn dgeqr2 #

fn dgeqr2(m int, n int, mut a []f64, lda int, mut tau []f64, mut work []f64)

dgeqr2 computes a QR factorization of the m×n matrix A.

In a QR factorization, Q is an m×m orthonormal matrix, and R is an upper triangular m×n matrix.

A is modified to contain the information to construct Q and R. The upper triangle of a contains the matrix R. The lower triangular elements (not including the diagonal) contain the elementary reflectors. tau is modified to contain the reflector scales. tau must have length min(m,n), and this function will panic otherwise.

The ith elementary reflector can be explicitly constructed by first extracting the

v[j] = 0 j < i v[j] = 1 j == i v[j] = a[j*lda+i] j > i

and computing H_i = I - tau[i] * v * vᵀ.

The orthonormal matrix Q can be constructed from a product of these elementary reflectors, Q = H_0 * H_1 * ... * H_{k-1}, where k = min(m,n).

work is temporary storage of length at least n and this function will panic otherwise.

dgeqr2 is an internal routine. It is exported for testing purposes.

fn dgeqrf #

fn dgeqrf(m int, n int, mut a []f64, lda int, mut tau []f64, mut work []f64, lwork int)

dgeqrf computes the QR factorization of the m×n matrix A using a blocked algorithm. See the documentation for dgeqr2 for a description of the parameters at entry and exit.

work is temporary storage, and lwork specifies the usable memory length. The length of work must be at least max(1, lwork) and lwork must be -1 or at least n, otherwise this function will panic. dgeqrf is a blocked QR factorization, but the block size is limited by the temporary space available. If lwork == -1, instead of performing dgeqrf, the optimal work length will be stored into work[0].

tau must have length min(m,n), and this function will panic otherwise.

fn dgesdd #

fn dgesdd(jobz SVDJob, m int, n int, mut a []f64, lda int, s []f64, mut u []f64, ldu int, mut vt []f64, ldvt int) int

dgesdd computes the singular value decomposition (SVD) of a real m×n column-major matrix A, optionally computing the left and/or right singular vectors, using a divide and conquer method for the bidiagonal SVD:

A = U * Σ * Vᵀ

where Σ is an m×n matrix that is zero except for its min(m,n) diagonal elements (the singular values, returned in s in descending order), U is an m×m orthogonal matrix and V is an n×n orthogonal matrix. Note that the routine returns Vᵀ, not V.

jobz specifies the columns of U and rows of Vᵀ that are computed:

  • svd_all: all m columns of U and all n rows of Vᵀ are returned in u (ldu >= m) and vt (ldvt >= n);
  • svd_store: the first min(m,n) columns of U and rows of Vᵀ are returned in u (ldu >= m) and vt (ldvt >= min(m,n));
  • svd_overwrite: if m >= n the first n columns of U overwrite a and all n rows of Vᵀ are returned in vt (ldvt >= n); otherwise all m columns of U are returned in u (ldu >= m) and the first m rows of Vᵀ overwrite a;
  • svd_none: no singular vectors are computed.

On exit a is left unchanged unless it receives an overwritten factor.

A is scaled when its largest entry is very small or very large. Wide matrices are handled through the transpose. For m much larger than n (m >= 11n/6) the matrix is first reduced by a QR factorization; the resulting square matrix (or A itself) is bidiagonalized with dgebrd, the bidiagonal SVD is computed with dbdsdc, and the singular vectors are obtained by applying the dgebrd reflectors with dormbr.

The return value is info: 0 on success; -i if the i-th argument had an illegal value; -4 is also returned if A contains NaN or Inf; and i > 0 if the bidiagonal SVD did not converge (see dbdsdc).

Compared with the LAPACK routine the work and iwork arguments are omitted (workspace is allocated internally).

fn dgesdd_blocked #

fn dgesdd_blocked(jobz SVDJob, m int, n int, mut a []f64, lda int, s []f64, mut u []f64, ldu int, mut vt []f64, ldvt int, nb int, nx int) int

dgesdd_blocked is dgesdd with an explicit block size nb and crossover nx for the blocked bidiagonalization (nb <= 0 or nx <= 0 select the defaults). It is an internal routine exported for testing purposes.

fn dgesv #

fn dgesv(n int, nrhs int, mut a []f64, lda int, mut ipiv []int, mut b []f64, ldb int) int

dgesv computes the solution to a real system of linear equations

A * X = B

where A is an n×n matrix and X and B are n×nrhs matrices.

The LU decomposition with partial pivoting and row interchanges is used to factor A as

A = P * L * U

where P is a permutation matrix, L is unit lower triangular, and U is upper triangular. On return, the factors L and U are stored in a; the unit diagonal elements of L are not stored. The row pivot indices that define the permutation matrix P are stored in ipiv.

The factored form of A is then used to solve the system of equations A * X = B. On entry, b contains the right hand side matrix B. On return, if ok is true, b contains the solution matrix X.

fn dgesvd #

fn dgesvd(jobu SVDJob, jobvt SVDJob, m int, n int, mut a []f64, lda int, s []f64, mut u []f64, ldu int, mut vt []f64, ldvt int, superb []f64) int

dgesvd computes the singular value decomposition (SVD) of a real m×n column-major matrix A, optionally computing the left and/or right singular vectors:

A = U * Σ * Vᵀ

where Σ is an m×n matrix that is zero except for its min(m,n) diagonal elements (the singular values, returned in s in descending order), U is an m×m orthogonal matrix and V is an n×n orthogonal matrix. Note that the routine returns Vᵀ, not V.

jobu specifies the columns of U that are computed:

  • svd_all: all m columns of U are returned in u (ldu >= m);
  • svd_store: the first min(m,n) columns of U are returned in u (ldu >= m);
  • svd_overwrite: the first min(m,n) columns of U overwrite a;
  • svd_none: no columns of U are computed.

jobvt is analogous for Vᵀ: svd_all returns all n rows in vt (ldvt >= n), svd_store returns the first min(m,n) rows in vt (ldvt >= min(m,n)), svd_overwrite overwrites a with the first min(m,n) rows of Vᵀ and svd_none computes none. jobu and jobvt must not both be svd_overwrite.

On exit a is left unchanged unless it receives an overwritten factor. superb is accepted for LAPACKE compatibility and is not referenced.

A is first scaled when its largest entry is very small or very large. For m much larger than n the matrix is first reduced by a QR factorization (and for n much larger than m the transpose is used, which is the LQ preconditioning of the reference implementation), then bidiagonalized with dgebrd and diagonalized with dbdsqr.

The return value is info: 0 on success; -i if the i-th argument had an illegal value; -4 is also returned if A contains NaN or Inf; and i > 0 if dbdsqr did not converge, in which case i is the number of off-diagonal elements of the intermediate bidiagonal form that did not converge to zero.

fn dgesvd_blocked #

fn dgesvd_blocked(jobu SVDJob, jobvt SVDJob, m int, n int, mut a []f64, lda int, s []f64, mut u []f64, ldu int, mut vt []f64, ldvt int, superb []f64, nb int, nx int) int

dgesvd_blocked is dgesvd with an explicit block size nb and crossover nx for the blocked bidiagonalization and orthogonal factor generation (nb <= 0 or nx <= 0 select the defaults of each routine). It is an internal routine exported for testing purposes.

fn dgetf2 #

fn dgetf2(m int, n int, mut a []f64, lda int, mut ipiv []int) bool

dgetf2 exposes this operation as part of the public API.

fn dgetrf #

fn dgetrf(m int, n int, mut a []f64, lda int, mut ipiv []int) bool

dgetrf computes the LU decomposition of an m×n matrix A using partial pivoting with row interchanges.

The LU decomposition is a factorization of A into

A = P * L * U

where P is a permutation matrix, L is a lower triangular with unit diagonal elements (lower trapezoidal if m > n), and U is upper triangular (upper trapezoidal if m < n).

On entry, a contains the matrix A. On return, L and U are stored in place into a, and P is represented by ipiv.

ipiv contains a sequence of row interchanges. It indicates that row i of the matrix was interchanged with ipiv[i]. ipiv must have length min(m,n), and Dgetrf will panic otherwise. ipiv is zero-indexed.

Dgetrf returns whether the matrix A is nonsingular. The LU decomposition will be computed regardless of the singularity of A, but the result should not be used to solve a system of equation.

fn dgetri #

fn dgetri(n int, mut a []f64, lda int, ipiv []int, mut work []f64, lwork int) bool

dgetri computes the inverse of the matrix A using the LU factorization computed by dgetrf. On entry, a contains the PLU decomposition of A as computed by dgetrf and on exit contains the reciprocal of the original matrix.

dgetri will not perform the inversion if the matrix is singular, and returns a boolean indicating whether the inversion was successful.

work is temporary storage, and lwork specifies the usable memory length. At minimum, lwork >= n and this function will panic otherwise. dgetri is a blocked inversion, but the block size is limited by the temporary space available. If lwork == -1, instead of performing dgetri, the optimal work length will be stored into work[0].

fn dgetrs #

fn dgetrs(trans blas.Transpose, n int, nrhs int, mut a []f64, lda int, mut ipiv []int, mut b []f64, ldb int)

dgetrs solves a system of equations using an LU factorization. The system of equations solved is

A * X = B if trans == blas.Trans Aᵀ * X = B if trans == blas.NoTrans

A is a general n×n matrix with stride lda. B is a general matrix of size n×nrhs.

On entry b contains the elements of the matrix B. On exit, b contains the elements of X, the solution to the system of equations.

a and ipiv contain the LU factorization of A and the permutation indices as computed by Dgetrf. ipiv is zero-indexed.

fn dhseqr #

fn dhseqr(job SchurJob, compz SchurComp, n int, ilo int, ihi int, mut h []f64, ldh int, mut wr []f64, mut wi []f64, mut z []f64, ldz int) int

dhseqr computes the eigenvalues of a real upper Hessenberg n×n column-major matrix H and, optionally, the matrices T and Z from the Schur decomposition H = ZTZᵀ, where T is an upper quasi-triangular matrix (the Schur form) and Z is the orthogonal matrix of Schur vectors.

job selects whether only the eigenvalues (eigenvalues_only) or also the Schur form T (eigenvalues_and_schur) are computed. compz selects the Schur vectors: schur_none computes none, schur_orig (Z must contain the orthogonal matrix Q from the reduction to Hessenberg form on entry) returns Q*Z, and schur_hess initializes Z to the identity and returns the Schur vectors of H.

ilo and ihi are 1-based. It is assumed that H is already upper triangular in rows and columns 1:ilo-1 and ihi+1:n (as set up by dgebal); ilo = 1 and ihi = n are always valid. wr and wi (length >= n) receive the real and imaginary parts of the eigenvalues; complex conjugate pairs appear consecutively with the positive imaginary part first. When T is requested its 2×2 diagonal blocks are in standardized form (equal diagonal entries and off-diagonal entries of opposite sign).

It returns 0 on success, -i if the i-th argument had an illegal value, and i > 0 if the QR algorithm failed to compute all the eigenvalues; in that case the elements wr[i:n] hold the eigenvalues that converged and H is not in Schur form.

Only the double-shift QR algorithm (dlahqr) is used, which is robust and efficient for the matrix orders where a pure-V implementation is practical; the multishift aggressive early deflation of LAPACK DLAQR0 is not implemented.

fn dlabrd #

fn dlabrd(m int, n int, nb int, mut a []f64, lda int, mut d []f64, mut e []f64, mut tauq []f64, mut taup []f64, mut x []f64, ldx int, mut y []f64, ldy int)

dlabrd reduces the first nb rows and columns of the m×n column-major matrix A to (upper if m >= n, lower otherwise) bidiagonal form by an orthogonal transformation QᵀAP and returns the matrices X (m×nb, leading dimension ldx) and Y (n×nb, leading dimension ldy) needed to apply the transformation to the unreduced part of A:

A := A - VYᵀ - XUᵀ

where V and U are the reflector vectors stored in a. d, e, tauq and taup receive the bidiagonal entries and the reflector scalars of the first nb steps. On exit A(i,i) (m >= n) or A(i,i+1)... hold unit entries of the reflectors, the caller (dgebrd) restores the bidiagonal entries after the trailing update.

dlabrd is an internal routine. It is exported for testing purposes.

fn dlacpy #

fn dlacpy(uplo blas.Uplo, m int, n int, a []f64, lda int, mut b []f64, ldb int)

dlacpy copies the elements of A specified by uplo into B. Uplo can specify a triangular portion with blas.Uplo.upper or blas.Uplo.lower, or can specify all of the elements with blas.Uplo.all.

dlacpy is an internal routine. It is exported for testing purposes.

fn dlae2 #

fn dlae2(a f64, b f64, c f64) (f64, f64)

dlae2 computes the eigenvalues of a 2×2 symmetric matrix

[a b] [b c]

and returns the eigenvalue with the larger absolute value as rt1 and the smaller as rt2.

dlae2 is an internal routine. It is exported for testing purposes.

fn dlaev2 #

fn dlaev2(a f64, b f64, c f64) (f64, f64, f64, f64)

dlaev2 exposes this operation as part of the public API.

fn dlahqr #

fn dlahqr(wantt bool, wantz bool, n int, ilo int, ihi int, mut h []f64, ldh int, mut wr []f64, mut wi []f64, iloz int, ihiz int, mut z []f64, ldz int) int

dlahqr computes the eigenvalues and, optionally, the Schur factorization of the active block H[ilo:ihi+1, ilo:ihi+1] of an upper Hessenberg n×n column-major matrix using the double-shift Francis QR algorithm.

ilo, ihi, iloz and ihiz are 0-based and inclusive. It is assumed that H is already upper quasi-triangular in rows and columns ihi+1:n, and that H[ilo, ilo-1] = 0 (unless ilo == 0).

If wantt is true the full Schur form T is computed (otherwise only the diagonal blocks are valid); if wantz is true the orthogonal transformation is accumulated into rows iloz:ihiz+1 of z. wr and wi (length >= n) receive the real and imaginary parts of the computed eigenvalues of the block; complex conjugate pairs are stored consecutively with positive imaginary part first. For each 2×2 block that stays on the diagonal the block is returned in standardized form (see dlanv2).

It returns 0 on success. If it returns i > 0 the QR algorithm failed to compute all the eigenvalues of rows ilo:i (0-based, i being 1-based count of the last unconverged eigenvalue); the elements wr[i:ihi+1] hold the eigenvalues that were found.

The algorithm is LAPACK DLAHQR (BSD-3-Clause, University of Tennessee et al.) with the Ahues-Tisseur deflation criterion and the iteration counter reset of LAPACK 3.10, following the gonum/lapack port. The inner loops use raw pointers to avoid bounds-check overhead.

fn dlaln2 #

fn dlaln2(ltrans bool, na int, nw int, smin f64, ca f64, a []f64, ao int, lda int, d1 f64, d2 f64, b []f64, bo int, ldb int, wr f64, wi f64) ([2][2]f64, f64, f64, int)

dlaln2 solves a system of the form (caA - wD)X = sB or (caAᵀ - wD)X = sB with possible scaling s and perturbation of A, where A is a na×na real matrix (na = 1 or 2), D = diag(d1, d2), w = wr + i*wi is a real (nw = 1) or complex (nw = 2) scalar, and B and X are na×nw matrices. The scale factor s <= 1 is chosen so that X can be computed without overflow; A is perturbed to avoid singularity when its pivots are smaller than smin.

a is an na×na column-major block at offset ao with leading dimension lda; b is the na×nw block at offset bo with leading dimension ldb. It returns the solution as x[2][2] (x[i][j] = X(i,j)), the scale s, the infinity norm of X, and info (1 if a perturbation was needed, 0 otherwise).

This is LAPACK DLALN2 (BSD-3-Clause, University of Tennessee et al.) with a Smith complex division in place of DLADIV.

fn dlamrg #

fn dlamrg(n1 int, n2 int, a []f64, dtrd1 int, dtrd2 int, mut index []int)

dlamrg creates a permutation list that merges the entries of two independently sorted sets a[0..n1) and a[n1..n1+n2) into a single set sorted in ascending order.

dtrd1 and dtrd2 are the strides (1 or -1) with which the first and second subsets are to be traversed to obtain them in ascending order: 1 means the subset is sorted ascending, -1 means it is sorted descending. On exit index holds the 1-based positions in a that put a into ascending order, so the i-th smallest entry is a[index[i]-1].

This is a Go/V port of the reference LAPACK routine DLAMRG.

dlamrg is an internal routine. It is exported for testing purposes.

fn dlange #

fn dlange(norm MatrixNorm, m int, n int, a []f64, lda int, mut work []f64) f64

dlange returns the value of the specified norm of a general m×n matrix A:

MatrixNorm.max_abs: the maximum absolute value of any element. MatrixNorm.max_column_sum: the maximum column sum of the absolute values of the elements (1-norm). MatrixNorm.max_row_sum: the maximum row sum of the absolute values of the elements (infinity-norm). MatrixNorm.frobenius: the square root of the sum of the squares of the elements (Frobenius norm).

If norm == MatrixNorm.max_column_sum, work must be of length n, and this function will panic otherwise. There are no restrictions on work for the other matrix norms.

fn dlanst #

fn dlanst(norm MatrixNorm, n int, d []f64, e []f64) f64

dlanst computes the specified norm of a symmetric tridiagonal matrix A. The diagonal elements of A are stored in d and the off-diagonal elements are stored in e.

fn dlansy #

fn dlansy(norm MatrixNorm, uplo blas.Uplo, n int, a []f64, lda int, mut work []f64) f64

dlansy returns the value of the specified norm of an n×n symmetric matrix. If norm == MatrixNorm.max_column_sum or norm == MatrixNorm.max_row_sum, work must have length at least n, otherwise work is unused.

fn dlanv2 #

fn dlanv2(a_ f64, b_ f64, c_ f64, d_ f64) (f64, f64, f64, f64, f64, f64, f64, f64, f64, f64)

dlanv2 computes the Schur factorization of a real 2×2 nonsymmetric matrix in standardized form:

[ a b ] = [ cs -sn ] [ aa bb ] [ cs sn ] [ c d ] [ sn cs ] [ cc dd ] [ -sn cs ]

where either cc = 0 so that (aa, dd) are real eigenvalues, or aa = dd and bbcc < 0 so that aa ± sqrt(bbcc)·i are complex conjugate eigenvalues. It returns (aa, bb, cc, dd, rt1r, rt1i, rt2r, rt2i, cs, sn).

The algorithm is LAPACK DLANV2 (BSD-3-Clause, University of Tennessee et al., as updated in LAPACK 3.7 with the scaling safeguard of Baudin and Kahan), following the gonum/lapack port.

fn dlapy2 #

fn dlapy2(x f64, y f64) f64

dlapy2 is the LAPACK version of math.hypot.

dlapy2 is an internal routine. It is exported for testing purposes.

fn dlarf #

fn dlarf(side blas.Side, m int, n int, v []f64, incv int, tau f64, mut c []f64, ldc int, mut work []f64)

dlarf applies an elementary reflector H to an m×n matrix C:

C = H * C if side == .left C = C * H if side == .right

H is represented in the form

H = I - tau * v * vᵀ

where tau is a scalar and v is a vector.

work must have length at least m if side == .left and at least n if side == .right.

dlarf is an internal routine. It is exported for testing purposes.

fn dlarfb #

fn dlarfb(side blas.Side, trans blas.Transpose, direct Direct, store StoreV, m int, n int, k int, v []f64, ldv int, t []f64, ldt int, mut c []f64, ldc int, mut work []f64, ldwork int)

dlarfb exposes this operation as part of the public API.

fn dlarfg #

fn dlarfg(n int, alpha f64, mut x []f64, incx int) (f64, f64)

dlarfg exposes this operation as part of the public API.

fn dlarft #

fn dlarft(direct Direct, store StoreV, n int, k int, v []f64, ldv int, tau []f64, mut t []f64, ldt int)

dlarft forms the triangular factor T of a block reflector H, storing the answer in t.

H = I - V * T * Vᵀ if store == .column_wise H = I - Vᵀ * T * V if store == .row_wise

H is defined by a product of the elementary reflectors where

H = H_0 * H_1 * ... * H_{k-1} if direct == .forward H = H_{k-1} * ... * H_1 * H_0 if direct == .backward

t is a k×k triangular matrix. t is upper triangular if direct = .forward and lower triangular otherwise. This function will panic if t is not of sufficient size.

store describes the storage of the elementary reflectors in v. See dlarfb for a description of layout.

tau contains the scalar factors of the elementary reflectors H_i.

dlarft is an internal routine. It is exported for testing purposes.

fn dlartg #

fn dlartg(f f64, g f64) (f64, f64, f64)

dlartg generates a plane rotation so that

[ cs sn] * [f] = [r] [-sn cs] [g] = [0]

where cscs + snsn = 1.

This is a more accurate version of BLAS Drotg that uses scaling to avoid overflow or underflow, with the other differences that

  • cs >= 0
  • if g = 0, then cs = 1 and sn = 0
  • if f = 0 and g != 0, then cs = 0 and sn = sign(1,g)

dlartg is an internal routine. It is exported for testing purposes.

fn dlas2 #

fn dlas2(f f64, g f64, h f64) (f64, f64)

dlas2 computes the singular values of the 2×2 matrix

[ f g ] [ 0 h ]

ssmin is the smaller singular value and ssmax is the larger one.

dlas2 is an internal routine. It is exported for testing purposes.

fn dlascl #

fn dlascl(kind MatrixType, kl int, ku int, cfrom f64, cto f64, m int, n int, mut a []f64, lda int)

dlascl multiplies an m×n matrix by the scalar cto/cfrom.

cfrom must not be zero, and cto and cfrom must not be NaN, otherwise dlascl will panic.

dlascl is an internal routine. It is exported for testing purposes.

fn dlasd0 #

fn dlasd0(n int, sqre int, mut d []f64, mut e []f64, mut u []f64, ldu int, mut vt []f64, ldvt int, smlsiz int) int

dlasd0 computes the singular values of a real upper bidiagonal n×m matrix B (m = n+sqre) with diagonal d and off-diagonal e, and the singular vectors, using the divide and conquer method.

On entry u (n×n, leading dimension ldu) and vt (m×m, leading dimension ldvt) must be initialised to identity matrices; on exit they hold the left and right singular vectors of B, i.e. B = U*diag(d)*VT with d in ascending order within each merged subproblem (the entries of d are the singular values but not necessarily sorted; callers sort them). Subproblems of at most smlsiz rows are solved directly with dlasdq. e has length n-1+sqre.

The returned info is 0 on success, -i if the i-th argument had an illegal value and i > 0 if the singular value iteration did not converge (the error then lies in the subproblem or merge, see dlasdq and dlasd1).

This is a port of the reference LAPACK routine DLASD0.

dlasd0 is an internal routine. It is exported for testing purposes.

fn dlasd1 #

fn dlasd1(nl int, nr int, sqre int, mut d []f64, alpha_in f64, beta_in f64, mut u []f64, ldu int, mut vt []f64, ldvt int, mut idxq []int) int

dlasd1 computes the SVD of an upper bidiagonal n×m matrix B (n = nl+nr+1, m = n+sqre) with diagonal d and off-diagonal e, where the first nl rows and the last nr rows are the already diagonalised subproblems,

B = [ D1(in) 0 0 0 ] [ Z1ᵀ a Z2ᵀ b ] [ 0 0 D2(in) 0 ]

with a = alpha and b = beta the entries of the node row. On entry u and vt hold the singular vectors of the two subproblems (u is n×n with the upper nl×nl and lower nr×nr blocks populated, vt is m×m, both with leading dimensions ldu and ldvt), d[0..nl) and d[nl+1..n) hold their singular values in ascending order and idxq (0-based, 1-based values) the permutation sorting each half ascending. On exit d holds the singular values of B (not sorted), u and vt the updated singular vectors and idxq the permutation that sorts d in ascending order.

The returned info is 0 on success and 1 if the secular equation solver failed to converge.

This is a port of the reference LAPACK routine DLASD1.

dlasd1 is an internal routine. It is exported for testing purposes.

fn dlasd2 #

fn dlasd2(nl int, nr int, sqre int, mut d []f64, mut z []f64, alpha f64, beta f64, mut u []f64, ldu int, mut vt []f64, ldvt int, mut dsigma []f64, mut u2 []f64, ldu2 int, mut vt2 []f64, ldvt2 int, mut idxp []int, mut idx []int, mut idxc []int, idxq []int, mut coltyp []int) int

dlasd2 merges the two sets of singular values together into a single sorted set. Then it tries to deflate the size of the problem. There are two ways in which deflation can occur: when two or more singular values are close together or if there is a tiny entry in the z vector. For each such occurrence the order of the related secular equation problem is reduced by one.

nl and nr are the dimensions of the upper and lower subproblems, n = nl+nr+1 and m = n+sqre. d (length n) holds the singular values of the two subproblems (d[0..nl) and d[nl+1..n), each ascending) and on exit the deflated values are stored in d[k..n). The routine returns k, the order of the secular equation that remains to be solved; on exit dsigma[1..=k], z[1..=k] and the first k columns of u2 / rows of vt2 define it for dlasd3.

The arrays z, dsigma, idxp, idx, idxc and coltyp are 1-based work arrays (element 0 is unused) of length at least m+1 (n+1 for the integer arrays; coltyp needs max(n+1, 5)); u2 is n×n (leading dimension ldu2 >= n), vt2 is m×m (ldvt2 >= m). idxq (0-based, holding 1-based indices) is the permutation that sorts the two subproblems of d separately into ascending order.

On exit coltyp[1..=4] hold the number of columns of each type: 1 nonzero in the upper half only, 2 nonzero in the lower half only, 3 dense, 4 deflated.

This is a port of the reference LAPACK routine DLASD2.

dlasd2 is an internal routine. It is exported for testing purposes.

fn dlasd3 #

fn dlasd3(nl int, nr int, sqre int, k int, mut d []f64, mut q []f64, ldq int, mut dsigma []f64, mut u []f64, ldu int, u2 []f64, ldu2 int, mut vt []f64, ldvt int, mut vt2 []f64, ldvt2 int, idxc []int, ctot []int, mut z []f64) int

dlasd3 finds all the square roots of the roots of the secular equation, as defined by the values in dsigma and z, and then updates the singular vectors by matrix multiplication.

nl and nr are the dimensions of the subproblems, n = nl+nr+1, m = n+sqre and k is the order of the secular equation left after deflation by dlasd2. On exit d[0..k) holds the updated singular values (in ascending order), the first k columns of u hold the left singular vectors and the first k rows of vt the right singular vectors; the deflated vectors (columns k+1..n of u2 and rows k+1..n of vt2 as copied by dlasd2) are untouched.

q is a k×k work matrix (leading dimension ldq >= k). dsigma, z, idxc and ctot (the column counts returned in coltyp[1..=4] by dlasd2) are 1-based arrays as in dlasd2.

It returns info: 0 on success and 1 if the secular equation solver failed to converge.

This is a port of the reference LAPACK routine DLASD3.

dlasd3 is an internal routine. It is exported for testing purposes.

fn dlasd4 #

fn dlasd4(n int, i int, d []f64, z []f64, mut delta []f64, rho f64, mut work []f64) (f64, int)

dlasd4 computes the square root of the i-th updated eigenvalue of a positive symmetric rank-one modification of a positive definite diagonal matrix,

diag(d[0]², ..., d[n-1]²) + rho * z * zᵀ,

where 0 <= d[0] < d[1] < ... < d[n-1], rho > 0 and ||z||₂ = 1. The updated eigenvalues interlace the old ones, so the i-th root sigma (i is 1-based) lies in (d[i-1], d[i]) for i < n and in (d[n-1], sqrt(d[n-1]² + rho)] for i = n. It is the i-th root of the secular equation

f(σ) = 1/rho + Σ_j z[j]² / ((d[j]-σ)(d[j]+σ)) = 0.

On exit delta[j] = d[j] - sigma and work[j] = d[j] + sigma, both evaluated without cancellation (relative to the pole nearest to sigma), which is what the Gu-Eisenstat vector computation of dlasd3 requires. delta and work must have length at least n.

The roots are found with safeguarded rational interpolation: the secular function is split into the parts belonging to the two poles adjacent to the root, each fitted by a single pole term matching the value and slope, and the resulting quadratic is solved for the step. Every iterate stays inside a bracket that is tightened on each evaluation, with bisection as the fallback, so the iteration cannot diverge. The returned info is 0 on success and 1 if the iteration did not converge in 400 steps.

This follows the algorithm of the reference LAPACK routine DLASD4 (origin shift to the closest pole, Li's "middle way" interpolation, errors bounded by rounding in the evaluation of f) and shares its interface; it is not a line-by-line port.

dlasd4 is an internal routine. It is exported for testing purposes.

fn dlasd5 #

fn dlasd5(i int, d []f64, z []f64, mut delta []f64, rho f64, mut work []f64) f64

dlasd5 computes the square root of the i-th eigenvalue of a positive symmetric rank-one modification of a 2×2 diagonal matrix

diag(d[0]², d[1]²) + rho * z * zᵀ, z = (z[0], z[1])ᵀ

where 0 <= d[0] < d[1] and rho > 0. i must be 1 or 2. The result sigma is returned together with delta (d[j] - sigma, computed accurately) and work (d[j] + sigma) for j = 0, 1; delta and work must have length at least 2.

This is a port of the reference LAPACK routine DLASD5.

dlasd5 is an internal routine. It is exported for testing purposes.

fn dlasdq #

fn dlasdq(uplo MatrixType, sqre int, n int, ncvt int, nru int, ncc int, mut d []f64, mut e []f64, mut vt []f64, ldvt int, mut u []f64, ldu int, mut c []f64, ldc int) int

dlasdq computes the singular value decomposition (SVD) of a real (upper or lower) bidiagonal matrix with diagonal d and off-diagonal e, accumulating the transformations if desired. Let the SVD of B be

B = Q * S * Pᵀ

Letting B have n rows (n+sqre columns when sqre = 1), dlasdq computes vt := Pᵀvt (ncvt columns), u := uQ (nru rows) and c := Qᵀ*c (ncc columns). All matrices are column-major.

uplo selects an upper or lower bidiagonal matrix B. If sqre = 0, B is square (n×n); if sqre = 1, B is (n+1)×n if lower bidiagonal and n×(n+1) if upper bidiagonal, in which case vt is (n+1)×ncvt and, for a lower B, u is nru×(n+1) and c is (n+1)×ncc. The matrix is first rotated to square upper bidiagonal form and then dbdsqr is called.

On exit d contains the singular values in ascending order (this is the order expected by dlasd1; dbdsqr itself returns them in decreasing order). info is 0 on success, -i if the i-th argument had an illegal value and i > 0 if dbdsqr did not converge.

This is a port of the reference LAPACK routine DLASDQ.

dlasdq is an internal routine. It is exported for testing purposes.

fn dlasdt #

fn dlasdt(n int, mut inode []int, mut ndiml []int, mut ndimr []int, msub int) (int, int)

dlasdt creates a tree of subproblems for bidiagonal divide and conquer.

n is the number of diagonal elements of the bidiagonal matrix and msub the maximum size of a leaf subproblem. On exit lvl is the number of levels of the tree, nd the number of nodes, and inode, ndiml and ndimr (each of length at least nd) hold, for every node, the 1-based index of its centre row and the dimensions of its left and right subproblems. Nodes are numbered level by level, the root being node 0.

This is a port of the reference LAPACK routine DLASDT.

dlasdt is an internal routine. It is exported for testing purposes.

fn dlaset #

fn dlaset(uplo blas.Uplo, m int, n int, alpha f64, beta f64, mut a []f64, lda int)

dlaset sets the off-diagonal elements of A to alpha, and the diagonal elements to beta. If uplo == blas.upper, only the elements in the upper triangular part are set. If uplo == blas.lower, only the elements in the lower triangular part are set. If uplo is otherwise, all of the elements of A are set.

dlaset is an internal routine. It is exported for testing purposes.

fn dlasq1 #

fn dlasq1(n int, mut d []f64, mut e []f64, mut work []f64) int

dlasq1 computes the singular values of the n×n real upper bidiagonal matrix with diagonal d and off-diagonal e. The singular values are returned in d in decreasing order. work must have length at least 4*n.

The return value is 0 on success, 1 or 3 on an internal failure (d holds the absolute values of the input diagonal) and 2 when the iteration limit was exceeded (d and e then hold the partially converged bidiagonal matrix so that the caller can finish with another method).

dlasq1 is an internal routine. It is exported for testing purposes.

fn dlasq2 #

fn dlasq2(n int, mut z []f64) int

dlasq2 computes all the eigenvalues of the symmetric positive definite tridiagonal matrix associated with the qd array z to high relative accuracy. z has length at least 4n and holds q_1, e_1, q_2, ... in its first 2n-1 entries. On exit the eigenvalues are in z[0..n] in decreasing order. The return value is 0 on success, 1 for a negative shift, 2 when the maximum number of iterations is exceeded and 3 for a failure to converge.

dlasq2 is an internal routine. It is exported for testing purposes.

fn dlasr #

fn dlasr(side blas.Side, pivot Pivot, direct Direct, m int, n int, c []f64, s []f64, mut a []f64, lda int)

Dlasr applies a sequence of plane rotations to the m×n matrix A. This series of plane rotations is implicitly represented by a matrix P. P is multiplied by a depending on the value of side -- A = P * A if side == Side.left, A = A * Pᵀ if side == Side.right.

The exact value of P depends on the value of pivot, but in all cases P is implicitly represented by a series of 2×2 rotation matrices. The entries of rotation matrix k are defined by s[k] and c[k]

R(k) = [ c[k] s[k]] [-s[k] s[k]]

If direct == Direct.forward, the rotation matrices are applied as P = P(z-1) * ... * P(2) * P(1), while if direct == Direct.backward they are applied as P = P(1) * P(2) * ... * P(n).

pivot defines the mapping of the elements in R(k) to P(k). If pivot == Pivot.variable, the rotation is performed for the (k, k+1) plane.

P(k) = [1 ] [ ... ] [ 1 ] [ c[k] s[k] ] [ -s[k] c[k] ] [ 1 ] [ ... ] [ 1]

if pivot == Pivot.top, the rotation is performed for the (1, k+1) plane,

P(k) = [c[k] s[k] ] [ 1 ] [ ... ] [ 1 ] [-s[k] c[k] ] [ 1 ] [ ... ] [ 1]

and if pivot == Pivot.bottom, the rotation is performed for the (k, z) plane.

P(k) = [1 ] [ ... ] [ 1 ] [ c[k] s[k]] [ 1 ] [ ... ] [ 1 ] [ -s[k] c[k]]

s and c have length m - 1 if side == Side.left, and n - 1 if side == Side.right.

fn dlasrt #

fn dlasrt(s Sort, n int, mut d []f64)

dlasrt sorts the numbers in the input slice d. If s == .increasing, the elements are sorted in increasing order. If s == .decreasing, the elements are sorted in decreasing order. For other values of s dlasrt will panic.

dlasrt is an internal routine. It is exported for testing purposes.

fn dlassq #

fn dlassq(n int, x []f64, incx int, scale f64, sumsq f64) (f64, f64)

dlassq updates a sum of squares represented in scaled form. It returns the values scl and smsq such that

scl^2smsq = X[0]^2 + ... + X[n-1]^2 + scale^2sumsq

The value of sumsq is assumed to be non-negative.

fn dlasv2 #

fn dlasv2(f f64, g f64, h f64) (f64, f64, f64, f64, f64, f64)

dlasv2 computes the singular value decomposition of a 2×2 triangular matrix

[ f g ] [ 0 h ]

On return, abs(ssmax) is the larger singular value, abs(ssmin) is the smaller singular value, and (csl, snl) and (csr, snr) are the left and right singular vectors for abs(ssmax), giving the decomposition

[ csl snl ] [ f g ] [ csr -snr ] [ ssmax 0 ] [-snl csl ] [ 0 h ] [ snr csr ] = [ 0 ssmin ]

The returned tuple is (ssmin, ssmax, snr, csr, snl, csl).

dlasv2 is an internal routine. It is exported for testing purposes.

fn dlaswp #

fn dlaswp(n int, mut a []f64, lda int, k1 int, k2 int, mut ipiv []int, incx int)

dlaswp exposes this operation as part of the public API.

fn dlatrd #

fn dlatrd(uplo blas.Uplo, n int, nb int, mut a []f64, lda int, mut e []f64, mut tau []f64, mut w []f64, ldw int)

dlatrd exposes this operation as part of the public API.

fn dorg2l #

fn dorg2l(m int, n int, k int, mut a []f64, lda int, tau []f64, mut work []f64)

dorg2l generates an m×n matrix Q with orthonormal columns which is defined as the last n columns of a product of k elementary reflectors of order m.

Q = H_{k-1} * ... * H_1 * H_0

See dgelqf for more information. It must be that m >= n >= k.

tau contains the scalar reflectors computed by dgeqlf. tau must have length at least k, and dorg2l will panic otherwise.

work contains temporary memory, and must have length at least n. dorg2l will panic otherwise.

dorg2l is an internal routine. It is exported for testing purposes.

fn dorg2r #

fn dorg2r(m int, n int, k int, mut a []f64, lda int, tau []f64, mut work []f64)

dorg2r exposes this operation as part of the public API.

fn dorgbr #

fn dorgbr(vect GenOrtho, m int, n int, k int, mut a []f64, lda int, tau []f64)

dorgbr generates the orthogonal matrix Q or Pᵀ determined by dgebrd when reducing a real matrix A to bidiagonal form A = QBPᵀ. The matrix a is column-major with leading dimension lda.

If vect is generate_q, a holds the reflectors returned by dgebrd for an m×k matrix and dorgbr returns the first n columns of Q (m×n). If m >= k, Q is the product H_0...H_{k-1} and n >= k is not required to be m; if m < k, Q is of order m and n must equal m.

If vect is generate_pt, a holds the reflectors returned by dgebrd for a k×n matrix and dorgbr returns the first m rows of Pᵀ (m×n). If k < n, Pᵀ is the product of k reflectors and m <= n; if k >= n, Pᵀ is of order n and m must equal n.

tau holds the reflector scalars (tauq or taup from dgebrd).

fn dorgbr_blocked #

fn dorgbr_blocked(vect GenOrtho, m int, n int, k int, mut a []f64, lda int, tau []f64, nb int, nx int)

dorgbr_blocked is dorgbr with an explicit block size nb and crossover nx for the blocked generation of the orthogonal factor. It is an internal routine exported for testing purposes.

fn dorghr #

fn dorghr(n int, ilo int, ihi int, mut a []f64, lda int, tau []f64)

dorghr generates the real orthogonal n×n column-major matrix Q determined by dgehrd, Q = H(ilo) * H(ilo+1) * ... * H(ihi-1). a and tau must be the output of dgehrd with the same n, ilo and ihi; on exit a contains Q.

fn dorgql #

fn dorgql(m int, n int, k int, mut a []f64, lda int, tau []f64, mut work []f64, lwork int)

dorgql generates the m×n matrix Q with orthonormal columns defined as the last n columns of a product of k elementary reflectors of order m

Q = H_{k-1} * ... * H_1 * H_0.

It must hold that

0 <= k <= n <= m,

and dorgql will panic otherwise.

On entry, the (n-k+i)-th column of A must contain the vector which defines the elementary reflector H_i, for i=0,...,k-1, and tau[i] must contain its scalar factor. On return, a contains the m×n matrix Q.

tau must have length at least k, and dorgql will panic otherwise.

work must have length at least max(1,lwork), and lwork must be at least max(1,n), otherwise dorgql will panic. For optimum performance lwork must be a sufficiently large multiple of n.

If lwork == -1, instead of computing dorgql the optimal work length is stored into work[0].

dorgql is an internal routine. It is exported for testing purposes.

fn dorgqr #

fn dorgqr(m int, n int, k int, mut a []f64, lda int, tau []f64, mut work []f64, lwork int)

dorgqr exposes this operation as part of the public API.

fn dorgtr #

fn dorgtr(uplo blas.Uplo, n int, mut a []f64, lda int, tau []f64, mut work []f64, lwork int)

dorgtr generates a real orthogonal matrix Q which is defined as the product of n-1 elementary reflectors of order n as returned by dsytrd.

The construction of Q depends on the value of uplo:

Q = H_{n-1} * ... * H_1 * H_0 if uplo == blas.Upper Q = H_0 * H_1 * ... * H_{n-1} if uplo == blas.Lower

where H_i is constructed from the elementary reflectors as computed by dsytrd. See the documentation for dsytrd for more information.

tau must have length at least n-1, and dorgtr will panic otherwise.

work is temporary storage, and lwork specifies the usable memory length. At minimum, lwork >= max(1,n-1), and dorgtr will panic otherwise. The amount of blocking is limited by the usable length. If lwork == -1, instead of computing dorgtr the optimal work length is stored into work[0].

dorgtr is an internal routine. It is exported for testing purposes.

fn dormbr #

fn dormbr(vect ApplyOrtho, left bool, trans bool, m int, n int, k int, a []f64, lda int, tau []f64, mut c []f64, ldc int)

dormbr applies one of the orthogonal matrices Q or P produced by dgebrd to a general m×n column-major matrix C, from the left or from the right:

C := QC C := QᵀC C := CQ C := CQᵀ (vect = apply_q) C := PC C := PᵀC C := CP C := CPᵀ (vect = apply_p)

left selects the side (QC or CQ when true) and trans the transposed operator. nq is the order of the applied matrix: m if left, n otherwise. For apply_q, a is the nq×k (nq >= k) or nq×(nq-1) array of reflectors returned by dgebrd for a matrix with k columns; Q is the product of k reflectors if nq >= k and of nq-1 reflectors (stored one row lower) if nq < k. For apply_p, a is the k×nq array returned by dgebrd for a matrix with k rows; P is the product of k reflectors if nq > k and of nq-1 reflectors (stored one column to the right) if nq <= k. tau holds the scalar factors (tauq or taup of dgebrd).

The reflectors are applied in blocks of 32 with matrix-matrix products when there are more than 64 of them, otherwise one at a time.

fn dormbr_blocked #

fn dormbr_blocked(vect ApplyOrtho, left bool, trans bool, m int, n int, k int, a []f64, lda int, tau []f64, mut c []f64, ldc int, nb int, nx int)

dormbr_blocked is dormbr with an explicit block size nb and crossover nx: the blocked code is used when there are more than nx reflectors and nb >= 2. It is an internal routine exported for testing purposes.

fn dpotf2 #

fn dpotf2(ul blas.Uplo, n int, mut a []f64, lda int) bool

dpotf2 computes the Cholesky decomposition of the symmetric positive definite matrix a. If ul == .upper, then a is stored as an upper-triangular matrix, and a = Uᵀ U is stored in place into a. If ul == .lower, then a = L Lᵀ is computed and stored in-place into a. If a is not positive definite, false is returned. This is the unblocked version of the algorithm.

dpotf2 is an internal routine. It is exported for testing purposes.

fn dpotrf #

fn dpotrf(ul blas.Uplo, n int, mut a []f64, lda int) bool

dpotrf exposes this operation as part of the public API.

fn dsteqr #

fn dsteqr(compz EigenVectorsComp, n int, mut d []f64, mut e []f64, mut z []f64, ldz int, mut work []f64) bool

dsteqr computes the eigenvalues and optionally the eigenvectors of a symmetric tridiagonal matrix using the implicit QL or QR method. The eigenvectors of a full or band symmetric matrix can also be found if dsytrd, dsptrd, or dsbtrd have been used to reduce this matrix to tridiagonal form.

d, on entry, contains the diagonal elements of the tridiagonal matrix. On exit, d contains the eigenvalues in ascending order. d must have length n and dsteqr will panic otherwise.

e, on entry, contains the off-diagonal elements of the tridiagonal matrix on entry, and is overwritten during the call to dsteqr. e must have length n-1 and dsteqr will panic otherwise.

z, on entry, contains the n×n orthogonal matrix used in the reduction to tridiagonal form if compz == lapack.EigenVectorsOrig. On exit, if compz == lapack.EigenVectorsOrig, z contains the orthonormal eigenvectors of the original symmetric matrix, and if compz == lapack.EigenVectorsTridiag, z contains the orthonormal eigenvectors of the symmetric tridiagonal matrix. z is not used if compz == lapack.EigenVectorsCompNone.

work must have length at least max(1, 2*n-2) if the eigenvectors are computed, and dsteqr will panic otherwise.

dsteqr is an internal routine. It is exported for testing purposes.

fn dsterf #

fn dsterf(n int, mut d []f64, mut e []f64) bool

dsterf computes all eigenvalues of a symmetric tridiagonal matrix using the Pal-Walker-Kahan variant of the QL or QR algorithm.

d contains the diagonal elements of the tridiagonal matrix on entry, and contains the eigenvalues in ascending order on exit. d must have length at least n, or dsterf will panic.

e contains the off-diagonal elements of the tridiagonal matrix on entry, and is overwritten during the call to dsterf. e must have length of at least n-1 or dsterf will panic.

dsterf is an internal routine. It is exported for testing purposes.

fn dsyev #

fn dsyev(jobz EigenVectorsJob, uplo blas.Uplo, n int, mut a []f64, lda int, mut w []f64, mut work []f64, lwork int)

dsyev exposes this operation as part of the public API.

fn dsytd2 #

fn dsytd2(uplo blas.Uplo, n int, mut a []f64, lda int, mut d []f64, mut e []f64, mut tau []f64)

Dsytd2 reduces a symmetric n×n matrix A to symmetric tridiagonal form T by an orthogonal similarity transformation

Qᵀ * A * Q = T

On entry, the matrix is contained in the specified triangle of a. On exit, if uplo == Uplo.upper, the diagonal and first super-diagonal of a are overwritten with the elements of T. The elements above the first super-diagonal are overwritten with the elementary reflectors that are used with the elements written to tau in order to construct Q. If uplo == Uplo.lower, the elements are written in the lower triangular region.

d must have length at least n. e and tau must have length at least n-1. Dsytd2 will panic if these sizes are not met.

Q is represented as a product of elementary reflectors. If uplo == Uplo.upper

Q = H_{n-2} * ... * H_1 * H_0

and if uplo == Uplo.lower

Q = H_0 * H_1 * ... * H_{n-2}

where

H_i = I - tau * v * vᵀ

where tau is stored in tau[i], and v is stored in a.

If uplo == Uplo.upper, v[0:i-1] is stored in A[0:i-1,i+1], v[i] = 1, and v[i+1:] = 0. The elements of a are

[ d e v2 v3 v4] [ d e v3 v4] [ d e v4] [ d e] [ d]

If uplo == Uplo.lower, v[0:i+1] = 0, v[i+1] = 1, and v[i+2:] is stored in A[i+2:n,i]. The elements of a are

[ d ] [ e d ] [v1 e d ] [v1 v2 e d ] [v1 v2 v3 e d]

fn dsytrd #

fn dsytrd(uplo blas.Uplo, n int, mut a []f64, lda int, mut d []f64, mut e []f64, mut tau []f64, mut work []f64, lwork int)

dsytrd reduces a symmetric n×n matrix A to symmetric tridiagonal form by an orthogonal similarity transformation

Qᵀ * A * Q = T

where Q is an orthonormal matrix and T is symmetric and tridiagonal.

On entry, a contains the elements of the input matrix in the triangle specified by uplo. On exit, the diagonal and sub/super-diagonal are overwritten by the corresponding elements of the tridiagonal matrix T. The remaining elements in the triangle, along with the array tau, contain the data to construct Q as the product of elementary reflectors.

If uplo == blas.upper, Q is constructed with

Q = H_{n-2} * ... * H_1 * H_0

where

H_i = I - tau_i * v * vᵀ

v is constructed as v[i+1:n] = 0, v[i] = 1, v[0:i-1] is stored in A[0:i-1, i+1]. The elements of A are

[ d e v1 v2 v3] [ d e v2 v3] [ d e v3] [ d e] [ e]

If uplo == blas.lower, Q is constructed with

Q = H_0 * H_1 * ... * H_{n-2}

where

H_i = I - tau_i * v * vᵀ

v is constructed as v[0:i+1] = 0, v[i+1] = 1, v[i+2:n] is stored in A[i+2:n, i]. The elements of A are

[ d ] [ e d ] [v0 e d ] [v0 v1 e d ] [v0 v1 v2 e d]

d must have length n, and e and tau must have length n-1. dsytrd will panic if these conditions are not met.

work is temporary storage, and lwork specifies the usable memory length. At minimum, lwork >= 1, and dsytrd will panic otherwise. The amount of blocking is limited by the usable length. If lwork == -1, instead of computing dsytrd the optimal work length is stored into work[0].

dsytrd is an internal routine. It is exported for testing purposes.

fn dtrevc3 #

fn dtrevc3(side EigenVectorsSide, howmny EigenVectorsHowMany, mut select []bool, n int, t []f64, ldt int, mut vl []f64, ldvl int, mut vr []f64, ldvr int, mm int) (int, int)

dtrevc3 computes some or all of the right and/or left eigenvectors of a real upper quasi-triangular n×n column-major matrix T (the Schur form returned by dhseqr). Matrices of this type are produced by the Schur factorization of a real general matrix, A = QTQᵀ.

The right eigenvector x and the left eigenvector y of T corresponding to an eigenvalue w are defined by Tx = wx and yᴴT = wyᴴ. The routine computes the eigenvectors by back substitution; the 2×2 diagonal blocks of T give complex conjugate eigenvalue pairs, whose eigenvectors are stored as two consecutive real columns holding the real and imaginary parts of the vector for the eigenvalue with positive imaginary part (the vector for the conjugate eigenvalue is its complex conjugate).

side selects right (ev_right), left (ev_left) or both sets of eigenvectors. howmny selects all eigenvectors (ev_all), all eigenvectors back-transformed by the matrices in vr/vl (ev_all_mul_q, for which vr and/or vl must contain the Schur vectors Q on entry so that A's eigenvectors Q*x are returned), or the eigenvectors selected by select (ev_selected: a real eigenvector is selected with select[j]; a complex pair with select[j] or select[j+1]; on exit select is modified so that select[j] is true and select[j+1] false for a selected pair). mm is the number of columns available in vl and vr.

Each eigenvector is scaled so that the element of largest magnitude has magnitude 1 (|re| + |im| for complex vectors). dtrevc3 returns the number of columns used (m) and info: 0 on success, -i if the i-th argument was illegal.

This is the non-blocked back-substitution of LAPACK DTREVC (BSD-3-Clause, University of Tennessee et al.) with DLALN2 to solve the small shifted systems with overflow control.

fn dtrti2 #

fn dtrti2(uplo blas.Uplo, diag blas.Diagonal, n int, mut a []f64, lda int)

dtrti2 computes the inverse of a triangular matrix, storing the result in place into a. This is the BLAS level 2 version of the algorithm.

dtrti2 is an internal routine. It is exported for testing purposes.

fn dtrtri #

fn dtrtri(uplo blas.Uplo, diag blas.Diagonal, n int, mut a []f64, lda int) bool

dtrtri computes the inverse of a triangular matrix, storing the result in place into a. This is the BLAS level 3 version of the algorithm which builds upon dtrti2 to operate on matrix blocks instead of only individual columns.

dtrtri will not perform the inversion if the matrix is singular, and returns a boolean indicating whether the inversion was successful.

fn iladlc #

fn iladlc(m int, n int, a []f64, lda int) int

iladlc scans a matrix for its last non-zero column. Returns -1 if the matrix is all zeros.

fn iladlr #

fn iladlr(m int, n int, a []f64, lda int) int

iladlr scans a matrix for its last non-zero row. Returns -1 if the matrix is all zeros.

fn not_implemented_message #

fn not_implemented_message(routine string) string

not_implemented_message returns the error text for a routine that is not implemented in the pure-V backend.

fn ApplyOrtho.from #

fn ApplyOrtho.from[W](input W) !ApplyOrtho

from returns the ApplyOrtho value of an integer or of a field name, or an error if there is none.

fn BalanceJob.from #

fn BalanceJob.from[W](input W) !BalanceJob

from returns the BalanceJob value of an integer or of a field name, or an error if there is none.

fn BdsdcMode.from #

fn BdsdcMode.from[W](input W) !BdsdcMode

from returns the BdsdcMode value of an integer or of a field name, or an error if there is none.

fn Direct.from #

fn Direct.from[W](input W) !Direct

from returns the Direct value of an integer or of a field name, or an error if there is none.

fn EigenVectorsComp.from #

fn EigenVectorsComp.from[W](input W) !EigenVectorsComp

from returns the EigenVectorsComp value of an integer or of a field name, or an error if there is none.

fn EigenVectorsHowMany.from #

fn EigenVectorsHowMany.from[W](input W) !EigenVectorsHowMany

from returns the EigenVectorsHowMany value of an integer or of a field name, or an error if there is none.

fn EigenVectorsJob.from #

fn EigenVectorsJob.from[W](input W) !EigenVectorsJob

from returns the EigenVectorsJob value of an integer or of a field name, or an error if there is none.

fn EigenVectorsSide.from #

fn EigenVectorsSide.from[W](input W) !EigenVectorsSide

from returns the EigenVectorsSide value of an integer or of a field name, or an error if there is none.

fn GSVDJob.from #

fn GSVDJob.from[W](input W) !GSVDJob

from returns the GSVDJob value of an integer or of a field name, or an error if there is none.

fn GenOrtho.from #

fn GenOrtho.from[W](input W) !GenOrtho

from returns the GenOrtho value of an integer or of a field name, or an error if there is none.

fn LeftEigenVectorsJob.from #

fn LeftEigenVectorsJob.from[W](input W) !LeftEigenVectorsJob

from returns the LeftEigenVectorsJob value of an integer or of a field name, or an error if there is none.

fn MatrixNorm.from #

fn MatrixNorm.from[W](input W) !MatrixNorm

from returns the MatrixNorm value of an integer or of a field name, or an error if there is none.

fn MatrixType.from #

fn MatrixType.from[W](input W) !MatrixType

from returns the MatrixType value of an integer or of a field name, or an error if there is none.

fn MaximizeNormXJob.from #

fn MaximizeNormXJob.from[W](input W) !MaximizeNormXJob

from returns the MaximizeNormXJob value of an integer or of a field name, or an error if there is none.

fn OrthoComp.from #

fn OrthoComp.from[W](input W) !OrthoComp

from returns the OrthoComp value of an integer or of a field name, or an error if there is none.

fn Pivot.from #

fn Pivot.from[W](input W) !Pivot

from returns the Pivot value of an integer or of a field name, or an error if there is none.

fn RightEigenVectorsJob.from #

fn RightEigenVectorsJob.from[W](input W) !RightEigenVectorsJob

from returns the RightEigenVectorsJob value of an integer or of a field name, or an error if there is none.

fn SVDJob.from #

fn SVDJob.from[W](input W) !SVDJob

from returns the SVDJob value of an integer or of a field name, or an error if there is none.

fn SchurComp.from #

fn SchurComp.from[W](input W) !SchurComp

from returns the SchurComp value of an integer or of a field name, or an error if there is none.

fn SchurJob.from #

fn SchurJob.from[W](input W) !SchurJob

from returns the SchurJob value of an integer or of a field name, or an error if there is none.

fn Sort.from #

fn Sort.from[W](input W) !Sort

from returns the Sort value of an integer or of a field name, or an error if there is none.

fn StoreV.from #

fn StoreV.from[W](input W) !StoreV

from returns the StoreV value of an integer or of a field name, or an error if there is none.

fn UpdateSchurComp.from #

fn UpdateSchurComp.from[W](input W) !UpdateSchurComp

from returns the UpdateSchurComp value of an integer or of a field name, or an error if there is none.

enum ApplyOrtho #

enum ApplyOrtho as u8 {
	// Apply P or Pᵀ.
	apply_p = u8(`P`)
	// Apply Q or Qᵀ.
	apply_q = u8(`Q`)
}

ApplyOrtho specifies which orthogonal matrix is applied in Dormbr.

enum BalanceJob #

enum BalanceJob as u8 {
	permute       = u8(`P`)
	scale         = u8(`S`)
	permute_scale = u8(`B`)
	balance_none  = u8(`N`)
}

BalanceJob specifies matrix balancing operation.

enum BdsdcMode #

enum BdsdcMode as u8 {
	// Compute the singular values only.
	values_only = u8(`N`)
	// Compute the singular values and the left and right singular vectors.
	vectors = u8(`I`)
}

BdsdcMode selects what dbdsdc computes.

enum Direct #

enum Direct as u8 {
	// Reflectors are right-multiplied, H_0 * H_1 * ... * H_{k-1}.
	forward = u8(`F`)
	// Reflectors are left-multiplied, H_{k-1} * ... * H_1 * H_0.
	backward = u8(`B`)
}

Direct specifies the direction of the multiplication for the Householder matrix.

enum EigenVectorsComp #

enum EigenVectorsComp as u8 {
	// Compute eigenvectors of the original symmetric matrix.
	ev_orig = u8(`V`)
	// Compute eigenvectors of the tridiagonal matrix.
	ev_tridiag = u8(`I`)
	// Do not compute eigenvectors.
	ev_comp_none = u8(`N`)
}

EigenVectorsComp specifies how eigenvectors are computed in Dsteqr.

enum EigenVectorsHowMany #

enum EigenVectorsHowMany as u8 {
	// Compute all right and/or left eigenvectors.
	ev_all = u8(`A`)
	// Compute all right and/or left eigenvectors multiplied by an input matrix.
	ev_all_mul_q = u8(`B`)
	// Compute selected right and/or left eigenvectors.
	ev_selected = u8(`S`)
}

EigenVectorsHowMany specifies which eigenvectors are computed in Dtrevc3 and how.

enum EigenVectorsJob #

enum EigenVectorsJob as u8 {
	// Compute eigenvectors.
	ev_compute = u8(`V`)
	// Do not compute eigenvectors.
	ev_none = u8(`N`)
}

EigenVectorsJob specifies whether eigenvectors are computed in Dsyev.

enum EigenVectorsSide #

enum EigenVectorsSide as u8 {
	// Compute only right eigenvectors.
	ev_right = u8(`R`)
	// Compute only left eigenvectors.
	ev_left = u8(`L`)
	// Compute both right and left eigenvectors.
	ev_both = u8(`B`)
}

EigenVectorsSide specifies what eigenvectors are computed in Dtrevc3.

enum GSVDJob #

enum GSVDJob as u8 {
	// Compute orthogonal matrix U.
	gsvd_u = u8(`U`)
	// Compute orthogonal matrix V.
	gsvd_v = u8(`V`)
	// Compute orthogonal matrix Q.
	gsvd_q = u8(`Q`)
	// Use unit-initialized matrix.
	gsvd_unit = u8(`I`)
	// Do not compute orthogonal matrix.
	gsvd_none = u8(`N`)
}

GSVDJob specifies the singular vector computation type for Generalized SingularValueDecomposition.

enum GenOrtho #

enum GenOrtho as u8 {
	// Generate Pᵀ.
	generate_pt = u8(`P`)
	// Generate Q.
	generate_q = u8(`Q`)
}

GenOrtho specifies which orthogonal matrix is generated in Dorgbr.

enum LeftEigenVectorsJob #

enum LeftEigenVectorsJob as u8 {
	// Compute left eigenvectors.
	left_ev_compute = u8(`V`)
	// Do not compute left eigenvectors.
	left_ev_none = u8(`N`)
}

LeftEigenVectorsJob specifies whether left eigenvectors are computed in Dgeev.

enum MatrixNorm #

enum MatrixNorm as u8 {
	// max(abs(A(i,j)))
	max_abs = u8(`M`)
	// Maximum absolute column sum (one norm)
	max_column_sum = u8(`O`)
	// Maximum absolute row sum (infinity norm)
	max_row_sum = u8(`I`)
	// Frobenius norm (sqrt of sum of squares)
	frobenius = u8(`F`)
}

MatrixNorm represents the kind of matrix norm to compute.

enum MatrixType #

enum MatrixType as u8 {
	// A general dense matrix.
	general = u8(`G`)
	// An upper triangular matrix.
	upper_tri = u8(`U`)
	// A lower triangular matrix.
	lower_tri = u8(`L`)
}

MatrixType represents the kind of matrix represented in the data.

enum MaximizeNormXJob #

enum MaximizeNormXJob as u8 {
	// Solve Z*x=h-f where h is a vector of ±1.
	local_look_ahead = 0
	// Compute an approximate null-vector e of Z, normalize e and solve Z*x=±e-f.
	normalized_null_vector = 2
}

MaximizeNormXJob specifies the heuristic method for computing a contribution to the reciprocal Dif-estimate in Dlatdf.

enum OrthoComp #

enum OrthoComp as u8 {
	// Do not compute the orthogonal matrix.
	ortho_none = u8(`N`)
	// The orthogonal matrix is formed explicitly and returned in the argument.
	ortho_explicit = u8(`I`)
	// The orthogonal matrix is post-multiplied into the matrix stored in the argument on entry.
	ortho_postmul = u8(`V`)
}

OrthoComp specifies whether and how the orthogonal matrix is computed in Dgghrd.

enum Pivot #

enum Pivot as u8 {
	variable = u8(`V`)
	top      = u8(`T`)
	bottom   = u8(`B`)
}

Pivot specifies the pivot type for plane rotations.

enum RightEigenVectorsJob #

enum RightEigenVectorsJob as u8 {
	// Compute right eigenvectors.
	right_ev_compute = u8(`V`)
	// Do not compute right eigenvectors.
	right_ev_none = u8(`N`)
}

RightEigenVectorsJob specifies whether right eigenvectors are computed in Dgeev.

enum SVDJob #

enum SVDJob as u8 {
	// Compute all columns of the orthogonal matrix U or V.
	svd_all = u8(`A`)
	// Compute the singular vectors and store them in the orthogonal matrix U or V.
	svd_store = u8(`S`)
	// Compute the singular vectors and overwrite them on the input matrix A.
	svd_overwrite = u8(`O`)
	// Do not compute singular vectors.
	svd_none = u8(`N`)
}

SVDJob specifies the singular vector computation type for SingularValueDecomposition.

enum SchurComp #

enum SchurComp as u8 {
	// Compute Schur vectors of the original matrix.
	schur_orig = u8(`V`)
	// Compute Schur vectors of the upper Hessenberg matrix.
	schur_hess = u8(`I`)
	// Do not compute Schur vectors.
	schur_none = u8(`N`)
}

SchurComp specifies whether and how the Schur vectors are computed in Dhseqr.

enum SchurJob #

enum SchurJob as u8 {
	eigenvalues_only      = u8(`E`)
	eigenvalues_and_schur = u8(`S`)
}

SchurJob specifies whether the Schur form is computed in Dhseqr.

enum Sort #

enum Sort as u8 {
	sort_increasing = u8(`I`)
	sort_decreasing = u8(`D`)
}

Sort is the sorting order.

enum StoreV #

enum StoreV as u8 {
	// Reflector stored in a column of the matrix.
	column_wise = u8(`C`)
	// Reflector stored in a row of the matrix.
	row_wise = u8(`R`)
}

StoreV indicates the storage direction of elementary reflectors.

enum UpdateSchurComp #

enum UpdateSchurComp as u8 {
	// Update the matrix of Schur vectors.
	update_schur = u8(`V`)
	// Do not update the matrix of Schur vectors.
	update_schur_none = u8(`N`)
}

UpdateSchurComp specifies whether the matrix of Schur vectors is updated in Dtrexc.