libflame  revision_anchor
Functions
FLA_Hevd.h File Reference

(r)

Go to the source code of this file.

Functions

FLA_Error FLA_Hevd_compute_scaling (FLA_Uplo uplo, FLA_Obj A, FLA_Obj sigma)
 
FLA_Error FLA_Hevd (FLA_Evd_type jobz, FLA_Uplo uplo, FLA_Obj A, FLA_Obj l)
 

Function Documentation

◆ FLA_Hevd()

FLA_Error FLA_Hevd ( FLA_Evd_type  jobz,
FLA_Uplo  uplo,
FLA_Obj  A,
FLA_Obj  l 
)

References FLA_Check_error_level(), FLA_Hevd_check(), and FLA_Hevd_lv_unb_var1().

14 {
15  FLA_Error r_val = FLA_SUCCESS;
16  dim_t n_iter_max = 30;
17  dim_t k_accum = 32;
18  dim_t b_alg = 512;
19 
20  // Check parameters.
21  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
22  FLA_Hevd_check( jobz, uplo, A, l );
23 
24  // Invoke FLA_Hevd_external() for now.
25  if ( jobz == FLA_EVD_WITH_VECTORS )
26  {
27  if ( uplo == FLA_LOWER_TRIANGULAR )
28  {
29  r_val = FLA_Hevd_lv_unb_var1( n_iter_max, A, l, k_accum, b_alg );
30  }
31  else // if ( uplo == FLA_UPPER_TRIANGULAR )
32  {
33  FLA_Check_error_code( FLA_NOT_YET_IMPLEMENTED );
34  }
35  }
36  else // if ( jobz == FLA_EVD_WITHOUT_VECTORS )
37  {
38  if ( uplo == FLA_LOWER_TRIANGULAR )
39  {
40  FLA_Check_error_code( FLA_NOT_YET_IMPLEMENTED );
41  }
42  else // if ( uplo == FLA_UPPER_TRIANGULAR )
43  {
44  FLA_Check_error_code( FLA_NOT_YET_IMPLEMENTED );
45  }
46  }
47 
48  return r_val;
49 }
unsigned long dim_t
Definition: FLA_type_defs.h:71
int FLA_Error
Definition: FLA_type_defs.h:47
FLA_Error FLA_Hevd_check(FLA_Evd_type jobz, FLA_Uplo uplo, FLA_Obj A, FLA_Obj e)
Definition: FLA_Hevd_check.c:13
unsigned int FLA_Check_error_level(void)
Definition: FLA_Check.c:18
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)
Definition: FLA_Hevd_lv_unb_var1.c:13

◆ FLA_Hevd_compute_scaling()

FLA_Error FLA_Hevd_compute_scaling ( FLA_Uplo  uplo,
FLA_Obj  A,
FLA_Obj  sigma 
)

References FLA_Check_error_level(), FLA_Copy(), FLA_Hevd_compute_scaling_check(), FLA_Inv_scal(), FLA_Invert(), FLA_Mach_params(), FLA_Max_abs_value_herm(), FLA_Obj_create(), FLA_Obj_datatype_proj_to_real(), FLA_Obj_free(), FLA_Obj_gt(), FLA_Obj_lt(), FLA_ONE, FLA_Sqrt(), and FLA_ZERO.

Referenced by FLA_Hevd_lv_unb_var1(), and FLA_Hevd_lv_unb_var2().

14 {
15  FLA_Datatype dt_real;
16  FLA_Obj norm;
17  FLA_Obj safmin;
18  FLA_Obj prec;
19  FLA_Obj rmin;
20  FLA_Obj rmax;
21 
22  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
23  FLA_Hevd_compute_scaling_check( uplo, A, sigma );
24 
25  dt_real = FLA_Obj_datatype_proj_to_real( A );
26 
27  FLA_Obj_create( dt_real, 1, 1, 0, 0, &norm );
28  FLA_Obj_create( dt_real, 1, 1, 0, 0, &safmin );
29  FLA_Obj_create( dt_real, 1, 1, 0, 0, &prec );
30  FLA_Obj_create( dt_real, 1, 1, 0, 0, &rmin );
31  FLA_Obj_create( dt_real, 1, 1, 0, 0, &rmax );
32 
33  // Query safmin, precision.
34  FLA_Mach_params( FLA_MACH_SFMIN, safmin );
35  FLA_Mach_params( FLA_MACH_PREC, prec );
36 
37 //FLA_Obj_show( "safmin", safmin, "%20.12e", "" );
38 //FLA_Obj_show( "prec", prec, "%20.12e", "" );
39 
40  // rmin = sqrt( safmin / prec );
41  FLA_Copy( safmin, rmin );
42  FLA_Inv_scal( prec, rmin );
43  FLA_Copy( rmin, rmax );
44  FLA_Sqrt( rmin );
45 
46  // rmax = sqrt( 1 / ( safmin / prec ) );
47  FLA_Invert( FLA_NO_CONJUGATE, rmax );
48  FLA_Sqrt( rmax );
49 
50 //FLA_Obj_show( "rmin", rmin, "%20.12e", "" );
51 //FLA_Obj_show( "rmax", rmax, "%20.12e", "" );
52 
53  // Find the maximum absolute value of A.
54  FLA_Max_abs_value_herm( uplo, A, norm );
55 
56  if ( FLA_Obj_gt( norm, FLA_ZERO ) && FLA_Obj_lt( norm, rmin ) )
57  {
58  // sigma = rmin / norm;
59  FLA_Copy( rmin, sigma );
60  FLA_Inv_scal( norm, sigma );
61  }
62  else if ( FLA_Obj_gt( norm, rmax ) )
63  {
64  // sigma = rmax / norm;
65  FLA_Copy( rmax, sigma );
66  FLA_Inv_scal( norm, sigma );
67  }
68  else
69  {
70  // sigma = 1.0;
71  FLA_Copy( FLA_ONE, sigma );
72  }
73 
74  FLA_Obj_free( &norm );
75  FLA_Obj_free( &safmin );
76  FLA_Obj_free( &prec );
77  FLA_Obj_free( &rmin );
78  FLA_Obj_free( &rmax );
79 
80  return FLA_SUCCESS;
81 }
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_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_Bool FLA_Obj_gt(FLA_Obj A, FLA_Obj B)
Definition: FLA_Query.c:658
FLA_Obj FLA_ONE
Definition: FLA_Init.c:18
FLA_Error FLA_Max_abs_value_herm(FLA_Uplo uplo, FLA_Obj A, FLA_Obj maxabs)
Definition: FLA_Max_abs_value_herm.c:13
FLA_Bool FLA_Obj_lt(FLA_Obj A, FLA_Obj B)
Definition: FLA_Query.c:813
FLA_Error FLA_Mach_params(FLA_Machval machval, FLA_Obj val)
Definition: FLA_Mach_params.c:13
Definition: FLA_type_defs.h:158
FLA_Error FLA_Invert(FLA_Conj conj, FLA_Obj x)
Definition: FLA_Invert.c:13
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
unsigned int FLA_Check_error_level(void)
Definition: FLA_Check.c:18
FLA_Error FLA_Hevd_compute_scaling_check(FLA_Uplo uplo, FLA_Obj A, FLA_Obj sigma)
Definition: FLA_Hevd_compute_scaling_check.c:13
int FLA_Datatype
Definition: FLA_type_defs.h:49
FLA_Error FLA_Sqrt(FLA_Obj alpha)
Definition: FLA_Sqrt.c:13
FLA_Obj FLA_ZERO
Definition: FLA_Init.c:20