libflame  revision_anchor
Functions
FLA_Hevd_lv.h File Reference

(r)

Go to the source code of this file.

Functions

FLA_Error FLA_Hevd_lv_unb_var1 (dim_t n_iter_max, FLA_Obj A, FLA_Obj l, dim_t k_accum, dim_t b_alg)
 
FLA_Error FLA_Hevd_lv_unb_var2 (dim_t n_iter_max, FLA_Obj A, FLA_Obj l, dim_t k_accum, dim_t b_alg)
 

Function Documentation

◆ FLA_Hevd_lv_unb_var1()

FLA_Error FLA_Hevd_lv_unb_var1 ( dim_t  n_iter_max,
FLA_Obj  A,
FLA_Obj  l,
dim_t  k_accum,
dim_t  b_alg 
)

References FLA_Apply_diag_matrix(), FLA_Copy(), FLA_Hevd_compute_scaling(), 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_row_stride(), FLA_ONE, FLA_Scalr(), FLA_Set(), FLA_Sort_evd(), FLA_Tevd_v_opt_var1(), FLA_Tridiag_UT(), FLA_Tridiag_UT_create_T(), FLA_Tridiag_UT_extract_real_diagonals(), FLA_Tridiag_UT_form_Q(), and FLA_Tridiag_UT_realify().

Referenced by FLA_Hevd().

14 {
15  FLA_Uplo uplo = FLA_LOWER_TRIANGULAR;
16  FLA_Datatype dt;
17  FLA_Datatype dt_real;
18  FLA_Datatype dt_comp;
19  FLA_Obj scale, T, r, d, e, G;
20  dim_t mn_A;
21  dim_t n_G = k_accum;
22  FLA_Error r_val;
23 
24  mn_A = FLA_Obj_length( A );
25  dt = FLA_Obj_datatype( A );
26  dt_real = FLA_Obj_datatype_proj_to_real( A );
27  dt_comp = FLA_Obj_datatype_proj_to_complex( A );
28 
29  // Make sure the matrix is column-stored.
30  if ( FLA_Obj_row_stride( A ) != 1 )
31  {
32  FLA_Check_error_code( FLA_NOT_YET_IMPLEMENTED );
33  }
34 
35  // If the matrix is a scalar, then the EVD is easy.
36  if ( mn_A == 1 )
37  {
38  FLA_Copy( A, l );
39  FLA_Set( FLA_ONE, A );
40 
41  return FLA_SUCCESS;
42  }
43 
44  // Create a matrix to hold block Householder transformations.
45  FLA_Tridiag_UT_create_T( A, &T );
46 
47  // Create a vector to hold the realifying scalars.
48  FLA_Obj_create( dt, mn_A, 1, 0, 0, &r );
49 
50  // Create vectors to hold the diagonal and sub-diagonal.
51  FLA_Obj_create( dt_real, mn_A, 1, 0, 0, &d );
52  FLA_Obj_create( dt_real, mn_A-1, 1, 0, 0, &e );
53  FLA_Obj_create( dt_comp, mn_A-1, n_G, 0, 0, &G );
54 
55  // Create a real scaling factor.
56  FLA_Obj_create( dt_real, 1, 1, 0, 0, &scale );
57 
58  // Compute a scaling factor; If none is needed, sigma will be set to one.
59  FLA_Hevd_compute_scaling( uplo, A, scale );
60 
61  // Scale the matrix if scale is non-unit.
62  if ( !FLA_Obj_equals( scale, FLA_ONE ) )
63  FLA_Scalr( uplo, scale, A );
64 
65  // Reduce the matrix to tridiagonal form.
66  FLA_Tridiag_UT( uplo, A, T );
67 
68  // Apply scalars to rotate elements on the sub-diagonal to the real domain.
69  FLA_Tridiag_UT_realify( uplo, A, r );
70 
71  // Extract the diagonal and sub-diagonal from A.
73 
74  // Form Q, overwriting A.
75  FLA_Tridiag_UT_form_Q( uplo, A, T, A );
76 
77  // Apply the scalars in r to Q.
78  FLA_Apply_diag_matrix( FLA_RIGHT, FLA_CONJUGATE, r, A );
79 
80  // Perform an eigenvalue decomposition on the tridiagonal matrix.
81  r_val = FLA_Tevd_v_opt_var1( n_iter_max, d, e, G, A, b_alg );
82 
83  // Copy the converged eigenvalues to the output vector.
84  FLA_Copy( d, l );
85 
86  // Sort the eigenvalues and eigenvectors in ascending order.
87  FLA_Sort_evd( FLA_FORWARD, l, A );
88 
89  // If the matrix was scaled, rescale the eigenvalues.
90  if ( !FLA_Obj_equals( scale, FLA_ONE ) )
91  FLA_Inv_scal( scale, l );
92 
93  FLA_Obj_free( &scale );
94  FLA_Obj_free( &T );
95  FLA_Obj_free( &r );
96  FLA_Obj_free( &d );
97  FLA_Obj_free( &e );
98  FLA_Obj_free( &G );
99 
100  return r_val;
101 }
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_Datatype FLA_Obj_datatype_proj_to_complex(FLA_Obj A)
Definition: FLA_Query.c:37
FLA_Error FLA_Tridiag_UT_extract_real_diagonals(FLA_Uplo uplo, FLA_Obj A, FLA_Obj d, FLA_Obj e)
Definition: FLA_Tridiag_UT_extract_real_diagonals.c:13
unsigned long dim_t
Definition: FLA_type_defs.h:71
FLA_Error FLA_Obj_free(FLA_Obj *obj)
Definition: FLA_Obj.c:588
FLA_Error FLA_Copy(FLA_Obj A, FLA_Obj B)
Definition: FLA_Copy.c:15
dim_t FLA_Obj_row_stride(FLA_Obj obj)
Definition: FLA_Query.c:167
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_Obj FLA_ONE
Definition: FLA_Init.c:18
int FLA_Error
Definition: FLA_type_defs.h:47
FLA_Error FLA_Sort_evd(FLA_Direct direct, FLA_Obj l, FLA_Obj V)
Definition: FLA_Sort_evd.c:13
FLA_Error FLA_Tevd_v_opt_var1(dim_t n_iter_max, FLA_Obj d, FLA_Obj e, FLA_Obj G, FLA_Obj U, dim_t b_alg)
Definition: FLA_Tevd_v_opt_var1.c:13
FLA_Error FLA_Tridiag_UT(FLA_Uplo uplo, FLA_Obj A, FLA_Obj T)
Definition: FLA_Tridiag_UT.c:17
FLA_Datatype FLA_Obj_datatype(FLA_Obj obj)
Definition: FLA_Query.c:13
FLA_Error FLA_Scalr(FLA_Uplo uplo, FLA_Obj alpha, FLA_Obj A)
Definition: FLA_Scalr.c:15
FLA_Error FLA_Tridiag_UT_realify(FLA_Uplo uplo, FLA_Obj A, FLA_Obj d)
Definition: FLA_Tridiag_UT_realify.c:13
Definition: FLA_type_defs.h:158
FLA_Error FLA_Set(FLA_Obj alpha, FLA_Obj A)
Definition: FLA_Set.c:13
FLA_Error FLA_Tridiag_UT_create_T(FLA_Obj A, FLA_Obj *T)
Definition: FLA_Tridiag_UT_create_T.c:13
FLA_Bool FLA_Obj_equals(FLA_Obj A, FLA_Obj B)
Definition: FLA_Query.c:507
FLA_Datatype FLA_Obj_datatype_proj_to_real(FLA_Obj A)
Definition: FLA_Query.c:23
FLA_Error FLA_Inv_scal(FLA_Obj alpha, FLA_Obj A)
Definition: FLA_Inv_scal.c:13
int FLA_Uplo
Definition: FLA_type_defs.h:52
int FLA_Datatype
Definition: FLA_type_defs.h:49
FLA_Error FLA_Tridiag_UT_form_Q(FLA_Uplo uplo, FLA_Obj A, FLA_Obj T, FLA_Obj Q)
Definition: FLA_Tridiag_UT_form_Q.c:14
dim_t FLA_Obj_length(FLA_Obj obj)
Definition: FLA_Query.c:116
FLA_Error FLA_Hevd_compute_scaling(FLA_Uplo uplo, FLA_Obj A, FLA_Obj sigma)
Definition: FLA_Hevd_compute_scaling.c:13

◆ FLA_Hevd_lv_unb_var2()

FLA_Error FLA_Hevd_lv_unb_var2 ( dim_t  n_iter_max,
FLA_Obj  A,
FLA_Obj  l,
dim_t  k_accum,
dim_t  b_alg 
)

References FLA_Apply_diag_matrix(), FLA_Copy(), FLA_Hevd_compute_scaling(), 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_ONE, FLA_Scalr(), FLA_Set(), FLA_Sort_evd(), FLA_Tevd_v_opt_var2(), FLA_Tridiag_UT(), FLA_Tridiag_UT_create_T(), FLA_Tridiag_UT_extract_real_diagonals(), FLA_Tridiag_UT_form_Q(), and FLA_Tridiag_UT_realify().

14 {
15  FLA_Error r_val;
16  FLA_Uplo uplo = FLA_LOWER_TRIANGULAR;
17  FLA_Datatype dt;
18  FLA_Datatype dt_real;
19  FLA_Datatype dt_comp;
20  FLA_Obj scale, T, r, d, e, G, R, W;
21  dim_t mn_A;
22  dim_t n_G = k_accum;
23 
24  mn_A = FLA_Obj_length( A );
25  dt = FLA_Obj_datatype( A );
26  dt_real = FLA_Obj_datatype_proj_to_real( A );
27  dt_comp = FLA_Obj_datatype_proj_to_complex( A );
28 
29  // If the matrix is a scalar, then the EVD is easy.
30  if ( mn_A == 1 )
31  {
32  FLA_Copy( A, l );
33  FLA_Set( FLA_ONE, A );
34 
35  return FLA_SUCCESS;
36  }
37 
38  // Create a matrix to hold block Householder transformations.
39  FLA_Tridiag_UT_create_T( A, &T );
40 
41  // Create a vector to hold the realifying scalars.
42  FLA_Obj_create( dt, mn_A, 1, 0, 0, &r );
43 
44  // Create vectors to hold the diagonal and sub-diagonal.
45  FLA_Obj_create( dt_real, mn_A, 1, 0, 0, &d );
46  FLA_Obj_create( dt_real, mn_A-1, 1, 0, 0, &e );
47  FLA_Obj_create( dt_comp, mn_A-1, n_G, 0, 0, &G );
48  FLA_Obj_create( dt_real, mn_A, mn_A, 0, 0, &R );
49  FLA_Obj_create( dt, mn_A, mn_A, 0, 0, &W );
50 
51  // Create a real scaling factor.
52  FLA_Obj_create( dt_real, 1, 1, 0, 0, &scale );
53 
54  // Compute a scaling factor; If none is needed, sigma will be set to one.
55  FLA_Hevd_compute_scaling( uplo, A, scale );
56 
57  // Scale the matrix if scale is non-unit.
58  if ( !FLA_Obj_equals( scale, FLA_ONE ) )
59  FLA_Scalr( uplo, scale, A );
60 
61  // Reduce the matrix to tridiagonal form.
62  FLA_Tridiag_UT( uplo, A, T );
63 
64  // Apply scalars to rotate elements on the sub-diagonal to the real domain.
65  FLA_Tridiag_UT_realify( uplo, A, r );
66 
67  // Extract the diagonal and sub-diagonal from A.
69 
70  // Form Q, overwriting A.
71  FLA_Tridiag_UT_form_Q( uplo, A, T, A );
72 
73  // Apply the scalars in r to Q.
74  FLA_Apply_diag_matrix( FLA_RIGHT, FLA_CONJUGATE, r, A );
75 
76  // Perform an eigenvalue decomposition on the tridiagonal matrix.
77  r_val = FLA_Tevd_v_opt_var2( n_iter_max, d, e, G, R, W, A, b_alg );
78 
79  // Copy the converged eigenvalues to the output vector.
80  FLA_Copy( d, l );
81 
82  // Sort the eigenvalues and eigenvectors in ascending order.
83  FLA_Sort_evd( FLA_FORWARD, l, A );
84 
85  // If the matrix was scaled, rescale the eigenvalues.
86  if ( !FLA_Obj_equals( scale, FLA_ONE ) )
87  FLA_Inv_scal( scale, l );
88 
89  FLA_Obj_free( &scale );
90  FLA_Obj_free( &T );
91  FLA_Obj_free( &r );
92  FLA_Obj_free( &d );
93  FLA_Obj_free( &e );
94  FLA_Obj_free( &G );
95  FLA_Obj_free( &R );
96  FLA_Obj_free( &W );
97 
98  return r_val;
99 }
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_Datatype FLA_Obj_datatype_proj_to_complex(FLA_Obj A)
Definition: FLA_Query.c:37
FLA_Error FLA_Tridiag_UT_extract_real_diagonals(FLA_Uplo uplo, FLA_Obj A, FLA_Obj d, FLA_Obj e)
Definition: FLA_Tridiag_UT_extract_real_diagonals.c:13
unsigned long dim_t
Definition: FLA_type_defs.h:71
FLA_Error FLA_Obj_free(FLA_Obj *obj)
Definition: FLA_Obj.c:588
FLA_Error FLA_Copy(FLA_Obj A, FLA_Obj B)
Definition: FLA_Copy.c:15
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_Obj FLA_ONE
Definition: FLA_Init.c:18
int FLA_Error
Definition: FLA_type_defs.h:47
FLA_Error FLA_Sort_evd(FLA_Direct direct, FLA_Obj l, FLA_Obj V)
Definition: FLA_Sort_evd.c:13
FLA_Error FLA_Tridiag_UT(FLA_Uplo uplo, FLA_Obj A, FLA_Obj T)
Definition: FLA_Tridiag_UT.c:17
FLA_Datatype FLA_Obj_datatype(FLA_Obj obj)
Definition: FLA_Query.c:13
FLA_Error FLA_Scalr(FLA_Uplo uplo, FLA_Obj alpha, FLA_Obj A)
Definition: FLA_Scalr.c:15
FLA_Error FLA_Tridiag_UT_realify(FLA_Uplo uplo, FLA_Obj A, FLA_Obj d)
Definition: FLA_Tridiag_UT_realify.c:13
Definition: FLA_type_defs.h:158
FLA_Error FLA_Set(FLA_Obj alpha, FLA_Obj A)
Definition: FLA_Set.c:13
FLA_Error FLA_Tridiag_UT_create_T(FLA_Obj A, FLA_Obj *T)
Definition: FLA_Tridiag_UT_create_T.c:13
FLA_Bool FLA_Obj_equals(FLA_Obj A, FLA_Obj B)
Definition: FLA_Query.c:507
FLA_Datatype FLA_Obj_datatype_proj_to_real(FLA_Obj A)
Definition: FLA_Query.c:23
FLA_Error FLA_Inv_scal(FLA_Obj alpha, FLA_Obj A)
Definition: FLA_Inv_scal.c:13
int FLA_Uplo
Definition: FLA_type_defs.h:52
FLA_Error FLA_Tevd_v_opt_var2(dim_t n_iter_max, FLA_Obj d, FLA_Obj e, FLA_Obj G, FLA_Obj R, FLA_Obj W, FLA_Obj U, dim_t b_alg)
Definition: FLA_Tevd_v_opt_var2.c:13
int FLA_Datatype
Definition: FLA_type_defs.h:49
FLA_Error FLA_Tridiag_UT_form_Q(FLA_Uplo uplo, FLA_Obj A, FLA_Obj T, FLA_Obj Q)
Definition: FLA_Tridiag_UT_form_Q.c:14
dim_t FLA_Obj_length(FLA_Obj obj)
Definition: FLA_Query.c:116
FLA_Error FLA_Hevd_compute_scaling(FLA_Uplo uplo, FLA_Obj A, FLA_Obj sigma)
Definition: FLA_Hevd_compute_scaling.c:13