libflame revision_anchor
FLA_Bsvd.h File Reference

(r)

Go to the source code of this file.

Functions

FLA_Error FLA_Bsvd_create_workspace (FLA_Obj d, FLA_Obj *G, FLA_Obj *H)
 
FLA_Error FLA_Bsvd (FLA_Uplo uplo, FLA_Obj d, FLA_Obj e, FLA_Obj G, FLA_Obj H, FLA_Svd_type jobu, FLA_Obj U, FLA_Svd_type jobv, FLA_Obj V)
 
FLA_Error FLA_Bsvd_ext (FLA_Uplo uplo, FLA_Obj d, FLA_Obj e, FLA_Obj G, FLA_Obj H, FLA_Svd_type jobu, FLA_Obj U, FLA_Svd_type jobv, FLA_Obj V, FLA_Bool apply_Uh2C, FLA_Obj C)
 

Function Documentation

◆ FLA_Bsvd()

FLA_Error FLA_Bsvd ( FLA_Uplo uplo,
FLA_Obj d,
FLA_Obj e,
FLA_Obj G,
FLA_Obj H,
FLA_Svd_type jobu,
FLA_Obj U,
FLA_Svd_type jobv,
FLA_Obj V )
17{
18 FLA_Error r_val = FLA_SUCCESS;
19 dim_t n_iter_max = 30;
20 dim_t b_alg = 512;
21 dim_t m_d = FLA_Obj_vector_dim( d );
22 FLA_Obj C; // dummy variable
23
24 // Check parameters.
25 if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
26 FLA_Bsvd_check( uplo, d, e, G, H, jobu, U, jobv, V );
27
28 // Partition U and V properly to account for the diagonal dimension.
29 if ( jobu == FLA_SVD_VECTORS_MIN_COPY ||
30 jobu == FLA_SVD_VECTORS_MIN_OVERWRITE )
31 FLA_Part_1x2( U, &U, &C, m_d, FLA_LEFT );
32
33 if ( jobv == FLA_SVD_VECTORS_MIN_COPY ||
34 jobv == FLA_SVD_VECTORS_MIN_OVERWRITE )
35 FLA_Part_1x2( V, &V, &C, m_d, FLA_LEFT );
36
37 // The current Bsvd is implemented for the upper triangular matrix only.
38 // If uplo is lower triangular, swap U and V.
39 if ( uplo == FLA_LOWER_TRIANGULAR )
40 exchange( U, V, C );
41
42 r_val = FLA_Bsvd_ext_opt_var1 ( n_iter_max, d, e, G, H,
43 jobu, U, jobv, V,
44 FALSE, C,
45 b_alg );
46
47 return r_val;
48}
FLA_Error FLA_Bsvd_check(FLA_Uplo uplo, FLA_Obj d, FLA_Obj e, FLA_Obj G, FLA_Obj H, FLA_Svd_type jobu, FLA_Obj U, FLA_Svd_type jobv, FLA_Obj V)
Definition FLA_Bsvd_check.c:13
FLA_Error FLA_Bsvd_ext_opt_var1(dim_t n_iter_max, FLA_Obj d, FLA_Obj e, FLA_Obj G, FLA_Obj H, FLA_Svd_type jobu, FLA_Obj U, FLA_Svd_type jobv, FLA_Obj V, FLA_Bool apply_Uh2C, FLA_Obj C, dim_t b_alg)
Definition FLA_Bsvd_ext_opt_var1.c:13
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
unsigned int FLA_Check_error_level(void)
Definition FLA_Check.c:18
dim_t FLA_Obj_vector_dim(FLA_Obj obj)
Definition FLA_Query.c:137
int FLA_Error
Definition FLA_type_defs.h:47
unsigned long dim_t
Definition FLA_type_defs.h:71
Definition FLA_type_defs.h:159

References FLA_Bsvd_check(), FLA_Bsvd_ext_opt_var1(), FLA_Check_error_level(), FLA_Obj_vector_dim(), and FLA_Part_1x2().

◆ FLA_Bsvd_create_workspace()

FLA_Error FLA_Bsvd_create_workspace ( FLA_Obj d,
FLA_Obj * G,
FLA_Obj * H )
14{
15 FLA_Error e_val = FLA_SUCCESS;
16
17 if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
18 {
19 e_val = FLA_Check_real_object( d );
20 FLA_Check_error_code( e_val );
21
23 FLA_Check_error_code( e_val );
24 }
25
26 // G and H stores the left and right Givens scalars.
28 dim_t m_d = FLA_Obj_vector_dim( d );
29 dim_t k_accum = min( 32, m_d );
30
31 if ( G != NULL ) FLA_Obj_create( dt_comp, m_d-1, k_accum, 0, 0, G );
32 if ( H != NULL ) FLA_Obj_create( dt_comp, m_d-1, k_accum, 0, 0, H );
33
34 return FLA_SUCCESS;
35}
FLA_Datatype FLA_Obj_datatype_proj_to_complex(FLA_Obj A)
Definition FLA_Query.c:37
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_Check_real_object(FLA_Obj A)
Definition FLA_Check.c:258
FLA_Error FLA_Check_nonconstant_object(FLA_Obj A)
Definition FLA_Check.c:954
int FLA_Datatype
Definition FLA_type_defs.h:49

References FLA_Check_error_level(), FLA_Check_nonconstant_object(), FLA_Check_real_object(), FLA_Obj_create(), FLA_Obj_datatype_proj_to_complex(), and FLA_Obj_vector_dim().

◆ FLA_Bsvd_ext()

FLA_Error FLA_Bsvd_ext ( FLA_Uplo uplo,
FLA_Obj d,
FLA_Obj e,
FLA_Obj G,
FLA_Obj H,
FLA_Svd_type jobu,
FLA_Obj U,
FLA_Svd_type jobv,
FLA_Obj V,
FLA_Bool apply_Uh2C,
FLA_Obj C )
18{
19 FLA_Error r_val = FLA_SUCCESS;
20 dim_t n_iter_max = 30;
21 dim_t b_alg = 512;
22 dim_t m_d = FLA_Obj_vector_dim( d );
23 FLA_Obj W;
24
25 // Check parameters.
26 if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
27 FLA_Bsvd_ext_check( uplo, d, e, G, H, jobu, U, jobv, V, apply_Uh2C, C );
28
29 // Partition U and V properly to account for the diagonal dimension.
30 if ( jobu == FLA_SVD_VECTORS_MIN_COPY ||
31 jobu == FLA_SVD_VECTORS_MIN_OVERWRITE )
32 FLA_Part_1x2( U, &U, &W, m_d, FLA_LEFT );
33
34 if ( jobv == FLA_SVD_VECTORS_MIN_COPY ||
35 jobv == FLA_SVD_VECTORS_MIN_OVERWRITE )
36 FLA_Part_1x2( V, &V, &W, m_d, FLA_LEFT );
37
38 // when uplo is lower triangular, swap U and V.
39 if ( uplo == FLA_LOWER_TRIANGULAR )
40 exchange( U, V, W );
41
42 // [ U1 d e V1 ] = Bidiag( A );
43 // [ U2 d V2 ] = Bsvd( diag( d ) + subdiag( uplo, e ) );
44 // Then,
45 // A = U1 U2 d V2^H V1^H;
46 // solving AX = C, it would be convenient that
47 // d (V1 V2)^H = apply(U2^H) apply(U1^H) C
48 // Here apply(.) is implicitly made and (V1 V2)^H is explicitly overwritten on the A.
49 // So, apply_Uh2C is a memory efficient way to solve a system of equations.
50 r_val = FLA_Bsvd_ext_opt_var1( n_iter_max,
51 d, e, G, H,
52 jobu, U, jobv, V,
53 apply_Uh2C, C,
54 b_alg );
55
56 return r_val;
57}
FLA_Error FLA_Bsvd_ext_check(FLA_Uplo uplo, FLA_Obj d, FLA_Obj e, FLA_Obj G, FLA_Obj H, FLA_Svd_type jobu, FLA_Obj U, FLA_Svd_type jobv, FLA_Obj V, FLA_Bool apply_Uh2C, FLA_Obj C)
Definition FLA_Bsvd_ext_check.c:13

References FLA_Bsvd_ext_check(), FLA_Bsvd_ext_opt_var1(), FLA_Check_error_level(), FLA_Obj_vector_dim(), and FLA_Part_1x2().