libflame revision_anchor
Functions
FLA_Svd_uv_unb_var1.c File Reference

(r)

Functions

FLA_Error FLA_Svd_uv_unb_var1 (dim_t n_iter_max, FLA_Obj A, FLA_Obj s, FLA_Obj U, FLA_Obj V, dim_t k_accum, dim_t b_alg)
 

Function Documentation

◆ FLA_Svd_uv_unb_var1()

FLA_Error FLA_Svd_uv_unb_var1 ( dim_t  n_iter_max,
FLA_Obj  A,
FLA_Obj  s,
FLA_Obj  U,
FLA_Obj  V,
dim_t  k_accum,
dim_t  b_alg 
)
14{
19 FLA_Obj scale, T, S, rL, rR, d, e, G, H;
20 dim_t m_A, n_A;
22 dim_t n_GH;
23 double crossover_ratio = 17.0 / 9.0;
24
25 n_GH = k_accum;
26
27 m_A = FLA_Obj_length( A );
28 n_A = FLA_Obj_width( A );
33
34 // Create matrices to hold block Householder transformations.
36
37 // Create vectors to hold the realifying scalars.
38 FLA_Obj_create( dt, min_m_n, 1, 0, 0, &rL );
39 FLA_Obj_create( dt, min_m_n, 1, 0, 0, &rR );
40
41 // Create vectors to hold the diagonal and sub-diagonal.
42 FLA_Obj_create( dt_real, min_m_n, 1, 0, 0, &d );
43 FLA_Obj_create( dt_real, min_m_n-1, 1, 0, 0, &e );
44
45 // Create matrices to hold the left and right Givens scalars.
46 FLA_Obj_create( dt_comp, min_m_n-1, n_GH, 0, 0, &G );
47 FLA_Obj_create( dt_comp, min_m_n-1, n_GH, 0, 0, &H );
48
49 // Create a real scaling factor.
50 FLA_Obj_create( dt_real, 1, 1, 0, 0, &scale );
51
52 // Compute a scaling factor; If none is needed, sigma will be set to one.
54
55 // Scale the matrix if scale is non-unit.
56 if ( !FLA_Obj_equals( scale, FLA_ONE ) )
57 FLA_Scal( scale, A );
58
59 if ( m_A < crossover_ratio * n_A )
60 {
61 // Reduce the matrix to bidiagonal form.
62 // Apply scalars to rotate elements on the superdiagonal to the real domain.
63 // Extract the diagonal and superdiagonal from A.
64 FLA_Bidiag_UT( A, T, S );
67
68 // Form U and V.
71
72 // Apply the realifying scalars in rL and rR to U and V, respectively.
73 {
74 FLA_Obj UL, UR;
75 FLA_Obj VL, VR;
76
79
82 }
83
84 // Perform a singular value decomposition on the bidiagonal matrix.
86 }
87 else // if ( crossover_ratio * n_A <= m_A )
88 {
89 FLA_Obj TQ, R;
90 FLA_Obj AT,
91 AB;
92 FLA_Obj UL, UR;
93
94 // Perform a QR factorization on A and form Q in U.
96 FLA_QR_UT( A, TQ );
98 FLA_Obj_free( &TQ );
99
100 // Set the lower triangle of R to zero and then copy the upper
101 // triangle of A to R.
102 FLA_Part_2x1( A, &AT,
103 &AB, n_A, FLA_TOP );
104 FLA_Obj_create( dt, n_A, n_A, 0, 0, &R );
107
108 // Reduce the matrix to bidiagonal form.
109 // Apply scalars to rotate elements on the superdiagonal to the real domain.
110 // Extract the diagonal and superdiagonal from A.
111 FLA_Bidiag_UT( R, T, S );
114
115 // Form V from right Householder vectors in upper triangle of R.
117
118 // Form U in R.
120
121 // Apply the realifying scalars in rL and rR to U and V, respectively.
124
125 // Perform a singular value decomposition on the bidiagonal matrix.
127
128 // Multiply R into U, storing the result in A and then copying back
129 // to U.
130 FLA_Part_1x2( U, &UL, &UR, n_A, FLA_LEFT );
132 FLA_ONE, UL, R, FLA_ZERO, A );
133 FLA_Copy( A, UL );
134
135 FLA_Obj_free( &R );
136 }
137
138 // Copy the converged eigenvalues to the output vector.
139 FLA_Copy( d, s );
140
141 // Sort the singular values and singular vectors in descending order.
143
144 // If the matrix was scaled, rescale the singular values.
145 if ( !FLA_Obj_equals( scale, FLA_ONE ) )
146 FLA_Inv_scal( scale, s );
147
149 FLA_Obj_free( &T );
150 FLA_Obj_free( &S );
151 FLA_Obj_free( &rL );
152 FLA_Obj_free( &rR );
153 FLA_Obj_free( &d );
154 FLA_Obj_free( &e );
155 FLA_Obj_free( &G );
156 FLA_Obj_free( &H );
157
158 return r_val;
159}
FLA_Error FLA_Bidiag_UT(FLA_Obj A, FLA_Obj TU, FLA_Obj TV)
Definition FLA_Bidiag_UT.c:17
FLA_Error FLA_Bidiag_UT_form_V(FLA_Obj A, FLA_Obj S, FLA_Obj V)
Definition FLA_Bidiag_UT_form_V.c:13
FLA_Error FLA_Bidiag_UT_extract_real_diagonals(FLA_Obj A, FLA_Obj d, FLA_Obj e)
Definition FLA_Bidiag_UT_extract_real_diagonals.c:13
FLA_Error FLA_Bidiag_UT_form_U(FLA_Obj A, FLA_Obj T, FLA_Obj U)
Definition FLA_Bidiag_UT_form_U.c:13
FLA_Error FLA_Bidiag_UT_create_T(FLA_Obj A, FLA_Obj *TU, FLA_Obj *TV)
Definition FLA_Bidiag_UT_create_T.c:13
FLA_Error FLA_Bidiag_UT_realify(FLA_Obj A, FLA_Obj d, FLA_Obj e)
Definition FLA_Bidiag_UT_realify.c:13
FLA_Error FLA_Bsvd_v_opt_var1(dim_t n_iter_max, FLA_Obj d, FLA_Obj e, FLA_Obj G, FLA_Obj H, FLA_Obj U, FLA_Obj V, dim_t b_alg)
Definition FLA_Bsvd_v_opt_var1.c:15
FLA_Error FLA_QR_UT_form_Q(FLA_Obj A, FLA_Obj T, FLA_Obj Q)
Definition FLA_QR_UT_form_Q.c:13
FLA_Error FLA_QR_UT_create_T(FLA_Obj A, FLA_Obj *T)
Definition FLA_QR_UT_create_T.c:13
FLA_Error FLA_Svd_compute_scaling(FLA_Obj A, FLA_Obj sigma)
Definition FLA_Svd_compute_scaling.c:13
FLA_Error FLA_Copy(FLA_Obj A, FLA_Obj B)
Definition FLA_Copy.c:15
FLA_Error FLA_Scal(FLA_Obj alpha, FLA_Obj A)
Definition FLA_Scal.c:15
FLA_Error FLA_Inv_scal(FLA_Obj alpha, FLA_Obj A)
Definition FLA_Inv_scal.c:13
FLA_Error FLA_Copyr(FLA_Uplo uplo, FLA_Obj A, FLA_Obj B)
Definition FLA_Copyr.c:15
FLA_Error FLA_Gemm(FLA_Trans transa, FLA_Trans transb, FLA_Obj alpha, FLA_Obj A, FLA_Obj B, FLA_Obj beta, FLA_Obj C)
Definition FLA_Gemm.c:15
FLA_Obj FLA_ZERO
Definition FLA_Init.c:20
FLA_Obj FLA_ONE
Definition FLA_Init.c:18
FLA_Error FLA_QR_UT(FLA_Obj A, FLA_Obj T)
Definition FLA_QR_UT.c:15
FLA_Datatype FLA_Obj_datatype_proj_to_complex(FLA_Obj A)
Definition FLA_Query.c:37
dim_t FLA_Obj_width(FLA_Obj obj)
Definition FLA_Query.c:123
FLA_Error FLA_Obj_create(FLA_Datatype datatype, dim_t m, dim_t n, dim_t rs, dim_t cs, FLA_Obj *obj)
Definition FLA_Obj.c:55
FLA_Error FLA_Part_1x2(FLA_Obj A, FLA_Obj *A1, FLA_Obj *A2, dim_t nb, FLA_Side side)
Definition FLA_View.c:110
FLA_Error FLA_Part_2x1(FLA_Obj A, FLA_Obj *A1, FLA_Obj *A2, dim_t mb, FLA_Side side)
Definition FLA_View.c:76
FLA_Datatype FLA_Obj_datatype_proj_to_real(FLA_Obj A)
Definition FLA_Query.c:23
dim_t FLA_Obj_length(FLA_Obj obj)
Definition FLA_Query.c:116
FLA_Bool FLA_Obj_equals(FLA_Obj A, FLA_Obj B)
Definition FLA_Query.c:507
dim_t FLA_Obj_min_dim(FLA_Obj obj)
Definition FLA_Query.c:153
FLA_Error FLA_Obj_free(FLA_Obj *obj)
Definition FLA_Obj.c:588
FLA_Datatype FLA_Obj_datatype(FLA_Obj obj)
Definition FLA_Query.c:13
int FLA_Error
Definition FLA_type_defs.h:47
int FLA_Datatype
Definition FLA_type_defs.h:49
unsigned long dim_t
Definition FLA_type_defs.h:71
FLA_Error FLA_Setr(FLA_Uplo uplo, FLA_Obj alpha, FLA_Obj A)
Definition FLA_Setr.c:13
FLA_Error FLA_Apply_diag_matrix(FLA_Side side, FLA_Conj conj, FLA_Obj x, FLA_Obj A)
Definition FLA_Apply_diag_matrix.c:13
FLA_Error FLA_Sort_svd(FLA_Direct direct, FLA_Obj s, FLA_Obj U, FLA_Obj V)
Definition FLA_Sort_svd.c:13
int i
Definition bl1_axmyv2.c:145
Definition FLA_type_defs.h:159

References FLA_Apply_diag_matrix(), FLA_Bidiag_UT(), FLA_Bidiag_UT_create_T(), FLA_Bidiag_UT_extract_real_diagonals(), FLA_Bidiag_UT_form_U(), FLA_Bidiag_UT_form_V(), FLA_Bidiag_UT_realify(), FLA_Bsvd_v_opt_var1(), FLA_Copy(), FLA_Copyr(), FLA_Gemm(), FLA_Inv_scal(), FLA_Obj_create(), FLA_Obj_datatype(), FLA_Obj_datatype_proj_to_complex(), FLA_Obj_datatype_proj_to_real(), FLA_Obj_equals(), FLA_Obj_free(), FLA_Obj_length(), FLA_Obj_min_dim(), FLA_Obj_width(), FLA_ONE, FLA_Part_1x2(), FLA_Part_2x1(), FLA_QR_UT(), FLA_QR_UT_create_T(), FLA_QR_UT_form_Q(), FLA_Scal(), FLA_Setr(), FLA_Sort_svd(), FLA_Svd_compute_scaling(), FLA_ZERO, and i.