⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 slasd7.c

📁 著名的LAPACK矩阵计算软件包, 是比较新的版本, 一般用到矩阵分解的朋友也许会用到
💻 C
📖 第 1 页 / 共 2 页
字号:
#include "blaswrap.h"
/*  -- translated by f2c (version 19990503).
   You must link the resulting object file with the libraries:
	-lf2c -lm   (in that order)
*/

#include "f2c.h"

/* Common Block Declarations */

struct {
    real ops, itcnt;
} latime_;

#define latime_1 latime_

/* Table of constant values */

static integer c__1 = 1;

/* Subroutine */ int slasd7_(integer *icompq, integer *nl, integer *nr, 
	integer *sqre, integer *k, real *d__, real *z__, real *zw, real *vf, 
	real *vfw, real *vl, real *vlw, real *alpha, real *beta, real *dsigma,
	 integer *idx, integer *idxp, integer *idxq, integer *perm, integer *
	givptr, integer *givcol, integer *ldgcol, real *givnum, integer *
	ldgnum, real *c__, real *s, integer *info)
{
    /* System generated locals */
    integer givcol_dim1, givcol_offset, givnum_dim1, givnum_offset, i__1;
    real r__1, r__2;

    /* Local variables */
    static integer idxi, idxj;
    extern /* Subroutine */ int srot_(integer *, real *, integer *, real *, 
	    integer *, real *, real *);
    static integer i__, j, m, n, idxjp, jprev, k2;
    extern /* Subroutine */ int scopy_(integer *, real *, integer *, real *, 
	    integer *);
    static real z1;
    extern doublereal slapy2_(real *, real *);
    static integer jp;
    extern doublereal slamch_(char *);
    extern /* Subroutine */ int xerbla_(char *, integer *), slamrg_(
	    integer *, integer *, real *, integer *, integer *, integer *);
    static real hlftol, eps, tau, tol;
    static integer nlp1, nlp2;


#define givcol_ref(a_1,a_2) givcol[(a_2)*givcol_dim1 + a_1]
#define givnum_ref(a_1,a_2) givnum[(a_2)*givnum_dim1 + a_1]


/*  -- LAPACK auxiliary routine (instrumented to count ops, version 3.0) --   
       Univ. of Tennessee, Oak Ridge National Lab, Argonne National Lab,   
       Courant Institute, NAG Ltd., and Rice University   
       June 30, 1999   


    Purpose   
    =======   

    SLASD7 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.   

    SLASD7 is called from SLASD6.   

    Arguments   
    =========   

    ICOMPQ  (input) INTEGER   
            Specifies whether singular vectors are to be computed   
            in compact form, as follows:   
            = 0: Compute singular values only.   
            = 1: Compute singular vectors of upper   
                 bidiagonal matrix in compact form.   

    NL     (input) INTEGER   
           The row dimension of the upper block. NL >= 1.   

    NR     (input) INTEGER   
           The row dimension of the lower block. NR >= 1.   

    SQRE   (input) INTEGER   
           = 0: the lower block is an NR-by-NR square matrix.   
           = 1: the lower block is an NR-by-(NR+1) rectangular matrix.   

           The bidiagonal matrix has   
           N = NL + NR + 1 rows and   
           M = N + SQRE >= N columns.   

    K      (output) INTEGER   
           Contains the dimension of the non-deflated matrix, this is   
           the order of the related secular equation. 1 <= K <=N.   

    D      (input/output) REAL array, dimension ( N )   
           On entry D contains the singular values of the two submatrices   
           to be combined. On exit D contains the trailing (N-K) updated   
           singular values (those which were deflated) sorted into   
           increasing order.   

    Z      (output) REAL array, dimension ( M )   
           On exit Z contains the updating row vector in the secular   
           equation.   

    ZW     (workspace) REAL array, dimension ( M )   
           Workspace for Z.   

    VF     (input/output) REAL array, dimension ( M )   
           On entry, VF(1:NL+1) contains the first components of all   
           right singular vectors of the upper block; and VF(NL+2:M)   
           contains the first components of all right singular vectors   
           of the lower block. On exit, VF contains the first components   
           of all right singular vectors of the bidiagonal matrix.   

    VFW    (workspace) REAL array, dimension ( M )   
           Workspace for VF.   

    VL     (input/output) REAL array, dimension ( M )   
           On entry, VL(1:NL+1) contains the  last components of all   
           right singular vectors of the upper block; and VL(NL+2:M)   
           contains the last components of all right singular vectors   
           of the lower block. On exit, VL contains the last components   
           of all right singular vectors of the bidiagonal matrix.   

    VLW    (workspace) REAL array, dimension ( M )   
           Workspace for VL.   

    ALPHA  (input) REAL   
           Contains the diagonal element associated with the added row.   

    BETA   (input) REAL   
           Contains the off-diagonal element associated with the added   
           row.   

    DSIGMA (output) REAL array, dimension ( N )   
           Contains a copy of the diagonal elements (K-1 singular values   
           and one zero) in the secular equation.   

    IDX    (workspace) INTEGER array, dimension ( N )   
           This will contain the permutation used to sort the contents of   
           D into ascending order.   

    IDXP   (workspace) INTEGER array, dimension ( N )   
           This will contain the permutation used to place deflated   
           values of D at the end of the array. On output IDXP(2:K)   
           points to the nondeflated D-values and IDXP(K+1:N)   
           points to the deflated singular values.   

    IDXQ   (input) INTEGER array, dimension ( N )   
           This contains the permutation which separately sorts the two   
           sub-problems in D into ascending order.  Note that entries in   
           the first half of this permutation must first be moved one   
           position backward; and entries in the second half   
           must first have NL+1 added to their values.   

    PERM   (output) INTEGER array, dimension ( N )   
           The permutations (from deflation and sorting) to be applied   
           to each singular block. Not referenced if ICOMPQ = 0.   

    GIVPTR (output) INTEGER   
           The number of Givens rotations which took place in this   
           subproblem. Not referenced if ICOMPQ = 0.   

    GIVCOL (output) INTEGER array, dimension ( LDGCOL, 2 )   
           Each pair of numbers indicates a pair of columns to take place   
           in a Givens rotation. Not referenced if ICOMPQ = 0.   

    LDGCOL (input) INTEGER   
           The leading dimension of GIVCOL, must be at least N.   

    GIVNUM (output) REAL array, dimension ( LDGNUM, 2 )   
           Each number indicates the C or S value to be used in the   
           corresponding Givens rotation. Not referenced if ICOMPQ = 0.   

    LDGNUM (input) INTEGER   
           The leading dimension of GIVNUM, must be at least N.   

    C      (output) REAL   
           C contains garbage if SQRE =0 and the C-value of a Givens   
           rotation related to the right null space if SQRE = 1.   

    S      (output) REAL   
           S contains garbage if SQRE =0 and the S-value of a Givens   
           rotation related to the right null space if SQRE = 1.   

    INFO   (output) INTEGER   
           = 0:  successful exit.   
           < 0:  if INFO = -i, the i-th argument had an illegal value.   

    Further Details   
    ===============   

    Based on contributions by   
       Ming Gu and Huan Ren, Computer Science Division, University of   
       California at Berkeley, USA   

    =====================================================================   



       Test the input parameters.   

       Parameter adjustments */
    --d__;
    --z__;
    --zw;
    --vf;
    --vfw;
    --vl;
    --vlw;
    --dsigma;
    --idx;
    --idxp;
    --idxq;
    --perm;
    givcol_dim1 = *ldgcol;
    givcol_offset = 1 + givcol_dim1 * 1;
    givcol -= givcol_offset;
    givnum_dim1 = *ldgnum;
    givnum_offset = 1 + givnum_dim1 * 1;
    givnum -= givnum_offset;

    /* Function Body */
    *info = 0;
    n = *nl + *nr + 1;
    m = n + *sqre;

    if (*icompq < 0 || *icompq > 1) {
	*info = -1;
    } else if (*nl < 1) {
	*info = -2;
    } else if (*nr < 1) {
	*info = -3;
    } else if (*sqre < 0 || *sqre > 1) {
	*info = -4;
    } else if (*ldgcol < n) {
	*info = -22;
    } else if (*ldgnum < n) {
	*info = -24;
    }
    if (*info != 0) {
	i__1 = -(*info);
	xerbla_("SLASD7", &i__1);
	return 0;
    }

    nlp1 = *nl + 1;
    nlp2 = *nl + 2;
    if (*icompq == 1) {
	*givptr = 0;
    }

/*     Generate the first part of the vector Z and move the singular   
       values in the first part of D one position backward. */

    latime_1.ops += (real) (*nl + 1);
    z1 = *alpha * vl[nlp1];
    vl[nlp1] = 0.f;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -