Rate This Document
Findability
Accuracy
Completeness
Readability

?bdsdc

Compute the SVD of an N*N upper/lower bidiagonal matrix B using a divide-and-conquer method.

Interface Definition

C interface:

void sbdsdc_(const char *uplo, const char *compq, const int *n, float *d, float *e, float *u, const int *ldu, float *vt, const int *ldvt, float *q, int *iq,

float *work, int *iwork, int *info);

void dbdsdc_(const char *uplo, const char *compq, const int *n, double *d, double *e, double *u, const int *ldu, double *vt, const int *ldvt, double *q,

int *iq, double *work, int *iwork, int *info);

Fortran interface:

SBDSDC(UPLO, COMPQ, N, D, E, U, LDU, VT, Q, IQ, WORK, IWORK, INFO)

DBDSDC(UPLO, COMPQ, N, D, E, U, LDU, VT, Q, IQ, WORK, IWORK, INFO)

Parameters

Parameter

Type

Description

Input/Output

uplo

Character

  • 'U': B is an upper bidiagonal matrix.
  • 'L': B is a lower bidiagonal matrix.

Input

compq

Character

  • 'N': computes only singular values.
  • 'P': compute singular values and singular vectors in a compact form.
  • 'I': computes singular values and singular vectors.

Input

n

Integer

Order of matrix B.

Input

d

  • A single-precision real array for sbdsdc
  • A double-precision real array for dbdsdc
  • On entry: It contains the diagonal elements of B.
  • On exit: It contains the singular values of B.

Input/Output

e

  • A single-precision real array for sbdsdc
  • A double-precision real array for dbdsdc
  • On entry: It contains the non-diagonal elements of matrix B.
  • On exit: e is destroyed.

Input/Output

u

  • A single-precision real array for sbdsdc
  • A double-precision real array for dbdsdc
  • The dimension is LDU x N.
  • If COMPQ = 'I', U contains the left singular vectors on exit.
  • If COMPQ is set to any other value, U is not defined.

Output

ldu

Integer

  • Leading dimension of U. LDU ≥ 1.
  • If singular vectors are required. LDU ≥ max(1, N).

Input

vt

  • A single-precision real array for sbdsdc
  • A double-precision real array for dbdsdc
  • Dimension ldvt*n.
  • If COMPQ = 'I', vt contains the right singular vectors on exit.
  • If COMPQ is set to any other value, vt is not defined.

Output

ldvt

Integer

  • Leading dimension of vt. ldvt ≥ 1.
  • If singular vectors are required, ldvt ≥ max(1, N).

Input

q

  • A single-precision real array for sbdsdc
  • A double-precision real array for dbdsdc
  • If COMPQ = 'P', Q and IQ store the left and right eigenvectors in a compact form, requiring only NlogN space instead of 2N^2.
  • If COMPQ is set to any other value, Q is not defined.

Output

iq

  • A single-precision real array for sbdsdc
  • A double-precision real array for dbdsdc
  • If COMPQ = 'P', Q and IQ store the left and right eigenvectors in a compact form, requiring only NlogN space instead of 2N^2.
  • If COMPQ is set to any other value, IQ is not defined.

Output

work

  • A single-precision real array for sbdsdc
  • A double-precision real array for dbdsdc
  • Dimension (MAX (1, LWORK)).
  • If COMPQ = 'N', LWORK ≥ (4 x N).
  • If COMPQ = 'P', LWORK ≥ (6*N).
  • If COMPQ = 'I', LWORK ≥ (3*N**2 + 4*N).

Output

lwork

Integer array

Size (8*N).

Output

info

Integer

  • 0: The execution is successful.
  • Smaller than 0: If info = -i, the i-th parameter has an illegal value.
  • Greater than 0: An error occurs during computation.

Output

Dependencies

#include "klapack.h"

Examples

C Interface

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const char uplo = 'l';
const char compq = 'i';
const int n = 5;
const int ldu = 5;
const int ldvt = 5;

double d[] = {-151.409804,-96.158378,30.604367,-49.958984,-65.000480};
double e[] = {187.838419,-61.829661,47.241856,4.133032};
double *u = (double*)malloc(ldu * n * sizeof(double));
double *vt = (double*)malloc(ldvt * n * sizeof(double));
double *q = (double*)malloc(sizeof(double));
int *iq = (int*)malloc(sizeof(int));
double *work = (double*)malloc(4 * n * sizeof(double));
double *iwork = (double*)malloc(8 * n * sizeof(double));

int info = 0;

dbdsdc_(&uplo, &compq, &n, d, e, u, &ldu, vt, &ldvt, q, iq, work, iwork, &info);
if (info != 0) {
    printf("Error, info = %d\n", info);
    return info;
}

* output:
* d:
* 254.071515      87.547400       67.835074       64.370735       14.897476
* e:
* 0.000000        0.000000        0.000000        0.000000
* u:
* 0.562230        -0.822915       -0.081874       -0.001979       0.000007        0.504441        0.270668        0.734742        0.363253        -0.021916       * -0.297298       -0.191539       -0.135822       0.802484       -0.460975       -0.148954       -0.098365       -0.044364       0.423397        0.887076        * -0.564680       -0.450761       0.658054        -0.211655       -0.010871
* vt:
* -0.943444       -0.291675       0.133196        0.063327        0.055560        0.331373        -0.816196       0.395311        0.189552        0.178367        * -0.010230       0.452864        0.497591        0.289640        0.680678        0.000389        -0.208325       -0.619098       -0.271648       0.706772        * -0.000002       0.016272        0.441712        -0.895754       0.047431

Fortran Interface

CHARACTER :: uplo = "L"
CHARACTER :: compq = "i"
PARAMETER (n = 5)  
PARAMETER (ldu = 5)
PARAMETER (ldvt = 5)
INTEGER :: info = 0 
REAL(8) :: d(n)
REAL(8) :: e(n-1) 
REAL(8) :: u(ldu, n)
REAL(8) :: vt(ldvt, n)
REAL(8) :: iwork(8, m)
REAL(8), ALLOCATABLE :: q(:) 
INTEGER, ALLOCATABLE :: iq(:)
REAL(8) :: work(4*n)
REAL(8) :: iwork(8*n)
  
DATA d / -151.409804,-96.158378,30.604367,-49.958984,-65.000480 /
DATA e / 187.838419,-61.829661,47.241856,4.133032 /
EXTERNAL DBDSDC
CALL DBDSDC(uplo, compq, n, d, e, u, ldu, vt, ldvt, q, iq, work, iwork, info);

* output:
* d:
* 254.071515      87.547400       67.835074       64.370735       14.897476
* e:
* 0.000000        0.000000        0.000000        0.000000
* u:
* 0.562230        -0.822915       -0.081874       -0.001979       0.000007        0.504441        0.270668        0.734742        0.363253        -0.021916       * -0.297298       -0.191539       -0.135822       0.802484       -0.460975       -0.148954       -0.098365       -0.044364       0.423397        0.887076        * -0.564680       -0.450761       0.658054        -0.211655       -0.010871
* vt:
* -0.943444       -0.291675       0.133196        0.063327        0.055560        0.331373        -0.816196       0.395311        0.189552        0.178367        * -0.010230       0.452864        0.497591        0.289640        0.680678        0.000389        -0.208325       -0.619098       -0.271648       0.706772        * -0.000002       0.016272        0.441712        -0.895754       0.047431