libflame revision_anchor
Functions
FLA_util_base_prototypes.h File Reference

(r)

Go to the source code of this file.

Functions

float FLA_random_float (void)
double FLA_random_double (void)
scomplex FLA_random_scomplex (void)
dcomplex FLA_random_dcomplex (void)
FLA_Error FLA_Absolute_square (FLA_Obj alpha)
FLA_Error FLA_Absolute_value (FLA_Obj alpha)
double FLA_Clock (void)
FLA_Error FLA_Conjugate (FLA_Obj A)
FLA_Error FLA_Conjugate_r (FLA_Uplo uplo, FLA_Obj A)
FLA_Error FLA_Hermitianize (FLA_Uplo uplo, FLA_Obj A)
FLA_Error FLA_Invert (FLA_Conj conj, FLA_Obj x)
FLA_Error FLA_Max_abs_value (FLA_Obj A, FLA_Obj amax)
double FLA_Max_elemwise_diff (FLA_Obj A, FLA_Obj B)
FLA_Error FLA_Mult_add (FLA_Obj alpha, FLA_Obj beta, FLA_Obj gamma)
FLA_Error FLA_Negate (FLA_Obj x)
FLA_Error FLA_Norm1 (FLA_Obj A, FLA_Obj norm)
FLA_Error FLA_Norm_inf (FLA_Obj A, FLA_Obj norm)
FLA_Error FLA_Norm_frob (FLA_Obj A, FLA_Obj norm)
FLA_Error FLA_Random_matrix (FLA_Obj A)
FLA_Error FLA_Random_herm_matrix (FLA_Uplo uplo, FLA_Obj A)
FLA_Error FLA_Random_symm_matrix (FLA_Uplo uplo, FLA_Obj A)
FLA_Error FLA_Random_spd_matrix (FLA_Uplo uplo, FLA_Obj A)
FLA_Error FLA_Random_tri_matrix (FLA_Uplo uplo, FLA_Diag diag, FLA_Obj A)
FLA_Error FLA_Scal_elemwise (FLA_Trans trans, FLA_Obj A, FLA_Obj B)
FLA_Error FLA_Shift_pivots_to_check (FLA_Pivot_type ptype, FLA_Obj p)
FLA_Error FLA_Sqrt (FLA_Obj alpha)
FLA_Error FLA_Symmetrize (FLA_Uplo uplo, FLA_Obj A)
FLA_Error FLA_Triangularize (FLA_Uplo uplo, FLA_Diag diag, FLA_Obj A)
FLA_Error FLA_Transpose (FLA_Obj A)
FLA_Error FLA_Absolute_square_check (FLA_Obj alpha)
FLA_Error FLA_Absolute_value_check (FLA_Obj alpha)
FLA_Error FLA_Conjugate_check (FLA_Obj A)
FLA_Error FLA_Conjugate_r_check (FLA_Uplo uplo, FLA_Obj A)
FLA_Error FLA_Hermitianize_check (FLA_Uplo uplo, FLA_Obj A)
FLA_Error FLA_Invert_check (FLA_Conj conj, FLA_Obj x)
FLA_Error FLA_Max_abs_value_check (FLA_Obj A, FLA_Obj amax)
FLA_Error FLA_Max_elemwise_diff_check (FLA_Obj A, FLA_Obj B)
FLA_Error FLA_Mult_add_check (FLA_Obj alpha, FLA_Obj beta, FLA_Obj gamma)
FLA_Error FLA_Negate_check (FLA_Obj x)
FLA_Error FLA_Norm1_check (FLA_Obj A, FLA_Obj norm)
FLA_Error FLA_Norm_inf_check (FLA_Obj A, FLA_Obj norm)
FLA_Error FLA_Norm_frob_check (FLA_Obj A, FLA_Obj norm)
FLA_Error FLA_Random_matrix_check (FLA_Obj A)
FLA_Error FLA_Random_herm_matrix_check (FLA_Uplo uplo, FLA_Obj A)
FLA_Error FLA_Random_symm_matrix_check (FLA_Uplo uplo, FLA_Obj A)
FLA_Error FLA_Random_spd_matrix_check (FLA_Uplo uplo, FLA_Obj A)
FLA_Error FLA_Random_tri_matrix_check (FLA_Uplo uplo, FLA_Diag diag, FLA_Obj A)
FLA_Error FLA_Scal_elemwise_check (FLA_Trans trans, FLA_Obj A, FLA_Obj B)
FLA_Error FLA_Sqrt_check (FLA_Obj alpha)
FLA_Error FLA_Symmetrize_check (FLA_Uplo uplo, FLA_Obj A)
FLA_Error FLA_Triangularize_check (FLA_Uplo uplo, FLA_Diag diag, FLA_Obj A)
FLA_Error FLA_Transpose_check (FLA_Obj A)
FLA_Error FLA_Transpose_blk_var1 (FLA_Obj A, fla_tpose_t *cntl)
FLA_Error FLA_Transpose_blk_var2 (FLA_Obj A, fla_tpose_t *cntl)
FLA_Error FLA_Transpose_unb_var1 (FLA_Obj A)
FLA_Error FLA_Transpose_unb_var2 (FLA_Obj A)
FLA_Error FLA_Swap_t_blk_var1 (FLA_Obj A, FLA_Obj B, fla_swap_t *cntl)
FLA_Error FLA_Swap_t_blk_var2 (FLA_Obj A, FLA_Obj B, fla_swap_t *cntl)

Function Documentation

FLA_Error FLA_Absolute_square ( FLA_Obj  alpha)

References FLA_Absolute_square_check(), FLA_Check_error_level(), FLA_Obj_datatype(), dcomplex::imag, scomplex::imag, dcomplex::real, and scomplex::real.

Referenced by FLA_Ttmm_l_unb_var1(), FLA_Ttmm_l_unb_var2(), FLA_Ttmm_l_unb_var3(), FLA_Ttmm_u_unb_var1(), FLA_Ttmm_u_unb_var2(), and FLA_Ttmm_u_unb_var3().

{
  FLA_Datatype datatype;

  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
    FLA_Absolute_square_check( alpha );

  datatype = FLA_Obj_datatype( alpha );
  
  switch ( datatype ){

  case FLA_FLOAT:
  {
    float *buff_alpha = ( float * ) FLA_FLOAT_PTR( alpha );

    *buff_alpha = (*buff_alpha) * (*buff_alpha);

    break;
  }

  case FLA_DOUBLE:
  {
    double *buff_alpha = ( double * ) FLA_DOUBLE_PTR( alpha );

    *buff_alpha = (*buff_alpha) * (*buff_alpha);

    break;
  }

  case FLA_COMPLEX:
  {
    scomplex *buff_alpha = ( scomplex * ) FLA_COMPLEX_PTR( alpha );

    buff_alpha->real = buff_alpha->real * buff_alpha->real + 
                       buff_alpha->imag * buff_alpha->imag; 
    buff_alpha->imag = 0.0F; 

    break;
  }

  case FLA_DOUBLE_COMPLEX:
  {
    dcomplex *buff_alpha = ( dcomplex * ) FLA_DOUBLE_COMPLEX_PTR( alpha );

    buff_alpha->real = buff_alpha->real * buff_alpha->real + 
                       buff_alpha->imag * buff_alpha->imag; 
    buff_alpha->imag = 0.0; 

    break;
  }

  }

  return FLA_SUCCESS;
}
FLA_Error FLA_Absolute_square_check ( FLA_Obj  alpha)

References FLA_Check_floating_object(), FLA_Check_if_scalar(), and FLA_Check_nonconstant_object().

Referenced by FLA_Absolute_square().

{
  FLA_Error e_val;

  e_val = FLA_Check_floating_object( alpha );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_nonconstant_object( alpha );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_if_scalar( alpha );
  FLA_Check_error_code( e_val );

  return FLA_SUCCESS;
}
FLA_Error FLA_Absolute_value ( FLA_Obj  alpha)

References FLA_Absolute_value_check(), FLA_Check_error_level(), FLA_Obj_datatype(), dcomplex::imag, scomplex::imag, dcomplex::real, and scomplex::real.

Referenced by FLA_Bidiag_UT_l_realify_unb(), FLA_Bidiag_UT_u_realify_unb(), FLA_Tridiag_UT_l_realify_unb(), and FLA_Tridiag_UT_u_realify_unb().

{
  FLA_Datatype datatype;

  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
    FLA_Absolute_value_check( alpha );

  datatype = FLA_Obj_datatype( alpha );
  
  switch ( datatype ){

  case FLA_FLOAT:
  {
    float *buff_alpha = ( float * ) FLA_FLOAT_PTR( alpha );

    *buff_alpha = ( float ) fabs( ( double ) *buff_alpha );

    break;
  }

  case FLA_DOUBLE:
  {
    double *buff_alpha = ( double * ) FLA_DOUBLE_PTR( alpha );

    *buff_alpha = fabs( *buff_alpha );

    break;
  }

  case FLA_COMPLEX:
  {
    scomplex *buff_alpha = ( scomplex * ) FLA_COMPLEX_PTR( alpha );

    buff_alpha->real = ( float ) sqrt( ( double ) buff_alpha->real * buff_alpha->real + 
                                                  buff_alpha->imag * buff_alpha->imag );
    buff_alpha->imag = 0.0F; 


    break;
  }

  case FLA_DOUBLE_COMPLEX:
  {
    dcomplex *buff_alpha = ( dcomplex * ) FLA_DOUBLE_COMPLEX_PTR( alpha );

    buff_alpha->real = sqrt( buff_alpha->real * buff_alpha->real + 
                             buff_alpha->imag * buff_alpha->imag );
    buff_alpha->imag = 0.0; 

    break;
  }

  }

  return FLA_SUCCESS;
}
FLA_Error FLA_Absolute_value_check ( FLA_Obj  alpha)

References FLA_Check_floating_object(), FLA_Check_if_scalar(), and FLA_Check_nonconstant_object().

Referenced by FLA_Absolute_value().

{
  FLA_Error e_val;

  e_val = FLA_Check_floating_object( alpha );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_nonconstant_object( alpha );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_if_scalar( alpha );
  FLA_Check_error_code( e_val );

  return FLA_SUCCESS;
}
double FLA_Clock ( void  )
FLA_Error FLA_Conjugate ( FLA_Obj  A)

References bli_cconjm(), bli_zconjm(), FLA_Check_error_level(), FLA_Conjugate_check(), FLA_Obj_col_stride(), FLA_Obj_datatype(), FLA_Obj_has_zero_dim(), FLA_Obj_is_real(), FLA_Obj_length(), FLA_Obj_row_stride(), and FLA_Obj_width().

Referenced by FLA_Bidiag_UT_u_step_unb_var3(), and FLA_Bidiag_UT_u_step_unb_var4().

{
  FLA_Datatype datatype;
  int          m_A, n_A;
  int          rs_A, cs_A;

  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING ) 
    FLA_Conjugate_check( A );

  if ( FLA_Obj_has_zero_dim( A ) ) return FLA_SUCCESS;

  if ( FLA_Obj_is_real( A ) ) return FLA_SUCCESS;

  datatype = FLA_Obj_datatype( A );

  m_A      = FLA_Obj_length( A );
  n_A      = FLA_Obj_width( A );
  rs_A     = FLA_Obj_row_stride( A );
  cs_A     = FLA_Obj_col_stride( A );


  switch ( datatype ){

  case FLA_COMPLEX:
  {
    scomplex *buff_A = ( scomplex * ) FLA_COMPLEX_PTR( A );

    bli_cconjm( m_A,
                n_A,
                buff_A, rs_A, cs_A );

    break;
  }

  case FLA_DOUBLE_COMPLEX:
  { 
    dcomplex *buff_A = ( dcomplex * ) FLA_DOUBLE_COMPLEX_PTR( A );

    bli_zconjm( m_A,
                n_A,
                buff_A, rs_A, cs_A );

    break;
  }

  }
  
  return FLA_SUCCESS;
}
FLA_Error FLA_Conjugate_check ( FLA_Obj  A)

References FLA_Check_floating_object(), and FLA_Check_nonconstant_object().

Referenced by FLA_Conjugate().

{
  FLA_Error e_val;

  e_val = FLA_Check_floating_object( A );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_nonconstant_object( A );
  FLA_Check_error_code( e_val );

  return FLA_SUCCESS;
}
FLA_Error FLA_Conjugate_r ( FLA_Uplo  uplo,
FLA_Obj  A 
)

References bli_cconjmr(), bli_zconjmr(), FLA_Check_error_level(), FLA_Conjugate_r_check(), FLA_Obj_col_stride(), FLA_Obj_datatype(), FLA_Obj_is_real(), FLA_Obj_length(), FLA_Obj_row_stride(), FLA_Obj_width(), and FLA_Param_map_flame_to_blis_uplo().

{
  FLA_Datatype datatype;
  int          m_A, n_A;
  int          rs_A, cs_A;
  char         blis_uplo;

  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
    FLA_Conjugate_r_check( uplo, A );

  if ( FLA_Obj_is_real( A ) ) return FLA_SUCCESS;

  datatype = FLA_Obj_datatype( A );

  m_A      = FLA_Obj_length( A );
  n_A      = FLA_Obj_width( A );
  rs_A     = FLA_Obj_row_stride( A );
  cs_A     = FLA_Obj_col_stride( A );

  FLA_Param_map_flame_to_blis_uplo( uplo, &blis_uplo );

  switch ( datatype ){

  case FLA_COMPLEX:
  {
    scomplex *buff_A = ( scomplex * ) FLA_COMPLEX_PTR( A );

    bli_cconjmr( blis_uplo,
                 m_A,
                 n_A,
                 buff_A, rs_A, cs_A );

    break;
  }

  case FLA_DOUBLE_COMPLEX:
  {
    dcomplex *buff_A = ( dcomplex * ) FLA_DOUBLE_COMPLEX_PTR( A );

    bli_zconjmr( blis_uplo,
                 m_A,
                 n_A,
                 buff_A, rs_A, cs_A );

    break;
  }

  }

  return FLA_SUCCESS;
}
FLA_Error FLA_Conjugate_r_check ( FLA_Uplo  uplo,
FLA_Obj  A 
)

References FLA_Check_floating_object(), FLA_Check_nonconstant_object(), and FLA_Check_valid_uplo().

Referenced by FLA_Conjugate_r().

{
  FLA_Error e_val;

  e_val = FLA_Check_valid_uplo( uplo );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_floating_object( A );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_nonconstant_object( A );
  FLA_Check_error_code( e_val );

  return FLA_SUCCESS;
}
FLA_Error FLA_Hermitianize ( FLA_Uplo  uplo,
FLA_Obj  A 
)

References bli_csymmize(), bli_dsymmize(), bli_ssymmize(), bli_zsymmize(), FLA_Check_error_level(), FLA_Hermitianize_check(), FLA_Obj_col_stride(), FLA_Obj_datatype(), FLA_Obj_row_stride(), FLA_Obj_width(), FLA_Param_map_flame_to_blis_conj(), and FLA_Param_map_flame_to_blis_uplo().

Referenced by FLA_Random_herm_matrix(), and FLASH_Hermitianize().

{
  FLA_Datatype datatype;
  dim_t        n_A;
  dim_t        rs_A, cs_A;
  char         blis_conj;
  char         blis_uplo;

  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
    FLA_Hermitianize_check( uplo, A );

  datatype = FLA_Obj_datatype( A );

  n_A      = FLA_Obj_width( A );
  rs_A     = FLA_Obj_row_stride( A );
  cs_A     = FLA_Obj_col_stride( A );

  FLA_Param_map_flame_to_blis_conj( FLA_CONJUGATE, &blis_conj );
  FLA_Param_map_flame_to_blis_uplo( uplo,          &blis_uplo );


  switch ( datatype ){

  case FLA_FLOAT:
  {
    float *buff_A = ( float * ) FLA_FLOAT_PTR( A );

    bli_ssymmize( blis_conj,
                  blis_uplo,
                  n_A,
                  buff_A, rs_A, cs_A );

    break;
  }

  case FLA_DOUBLE:
  {
    double *buff_A = ( double * ) FLA_DOUBLE_PTR( A );

    bli_dsymmize( blis_conj,
                  blis_uplo,
                  n_A,
                  buff_A, rs_A, cs_A );

    break;
  }

  case FLA_COMPLEX:
  {
    scomplex *buff_A = ( scomplex * ) FLA_COMPLEX_PTR( A );

    bli_csymmize( blis_conj,
                  blis_uplo,
                  n_A,
                  buff_A, rs_A, cs_A );

    break;
  }

  case FLA_DOUBLE_COMPLEX:
  {
    dcomplex *buff_A = ( dcomplex * ) FLA_DOUBLE_COMPLEX_PTR( A );

    bli_zsymmize( blis_conj,
                  blis_uplo,
                  n_A,
                  buff_A, rs_A, cs_A );

    break;
  }

  }

  return FLA_SUCCESS;
}
FLA_Error FLA_Hermitianize_check ( FLA_Uplo  uplo,
FLA_Obj  A 
)

References FLA_Check_floating_object(), FLA_Check_nonconstant_object(), FLA_Check_square(), and FLA_Check_valid_uplo().

Referenced by FLA_Hermitianize().

{
  FLA_Error e_val;

  e_val = FLA_Check_valid_uplo( uplo );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_floating_object( A );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_nonconstant_object( A );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_square( A );
  FLA_Check_error_code( e_val );

  return FLA_SUCCESS;
}
FLA_Error FLA_Invert ( FLA_Conj  conj,
FLA_Obj  x 
)

References bli_cinvertv(), bli_dinvertv(), bli_sinvertv(), bli_zinvertv(), FLA_Check_error_level(), FLA_Invert_check(), FLA_Obj_datatype(), FLA_Obj_has_zero_dim(), FLA_Obj_vector_dim(), FLA_Obj_vector_inc(), and FLA_Param_map_flame_to_blis_conj().

Referenced by FLA_Trinv_ln_unb_var1(), FLA_Trinv_ln_unb_var2(), FLA_Trinv_ln_unb_var3(), FLA_Trinv_ln_unb_var4(), FLA_Trinv_un_unb_var1(), FLA_Trinv_un_unb_var2(), FLA_Trinv_un_unb_var3(), and FLA_Trinv_un_unb_var4().

{
  FLA_Datatype datatype;
  int          n_elem;
  int          inc_x;
  char         blis_conj;

  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING ) 
    FLA_Invert_check( conj, x );

  if ( FLA_Obj_has_zero_dim( x ) ) return FLA_SUCCESS;

  datatype = FLA_Obj_datatype( x );

  n_elem   = FLA_Obj_vector_dim( x );
  inc_x    = FLA_Obj_vector_inc( x );

  FLA_Param_map_flame_to_blis_conj( conj, &blis_conj );


  switch ( datatype ){

  case FLA_FLOAT:
  {
    float *buff_x = ( float * ) FLA_FLOAT_PTR( x );

    bli_sinvertv( blis_conj,
                  n_elem,
                  buff_x, inc_x );

    break;
  }

  case FLA_DOUBLE:
  {
    double *buff_x = ( double * ) FLA_DOUBLE_PTR( x );

    bli_dinvertv( blis_conj,
                  n_elem,
                  buff_x, inc_x );

    break;
  }

  case FLA_COMPLEX:
  {
    scomplex *buff_x = ( scomplex * ) FLA_COMPLEX_PTR( x );

    bli_cinvertv( blis_conj,
                  n_elem,
                  buff_x, inc_x );

    break;
  }

  case FLA_DOUBLE_COMPLEX:
  { 
    dcomplex *buff_x = ( dcomplex * ) FLA_DOUBLE_COMPLEX_PTR( x );

    bli_zinvertv( blis_conj,
                  n_elem,
                  buff_x, inc_x );

    break;
  }

  }
  
  return FLA_SUCCESS;
}
FLA_Error FLA_Invert_check ( FLA_Conj  conj,
FLA_Obj  x 
)

References FLA_Check_floating_object(), FLA_Check_if_vector(), FLA_Check_nonconstant_object(), and FLA_Check_valid_conj().

Referenced by FLA_Invert().

{
  FLA_Error e_val;

  e_val = FLA_Check_valid_conj( conj );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_floating_object( x );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_nonconstant_object( x );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_if_vector( x );
  FLA_Check_error_code( e_val );

  return FLA_SUCCESS;
}
FLA_Error FLA_Max_abs_value ( FLA_Obj  A,
FLA_Obj  amax 
)

References FLA_Check_error_level(), FLA_Max_abs_value_check(), FLA_Obj_col_stride(), FLA_Obj_datatype(), FLA_Obj_length(), FLA_Obj_row_stride(), FLA_Obj_width(), dcomplex::imag, scomplex::imag, dcomplex::real, and scomplex::real.

Referenced by FLA_Norm1(), and FLA_Norm_inf().

{
  FLA_Datatype datatype;
  FLA_Datatype dt_amax;
  dim_t        i, j;
  dim_t        m_A, n_A;
  dim_t        rs_A, cs_A;

  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
    FLA_Max_abs_value_check( A, amax );

  datatype = FLA_Obj_datatype( A );
  dt_amax  = FLA_Obj_datatype( amax );

  m_A      = FLA_Obj_length( A );
  n_A      = FLA_Obj_width( A );
  rs_A     = FLA_Obj_row_stride( A );
  cs_A     = FLA_Obj_col_stride( A );
 
 
  switch ( datatype ){

  case FLA_FLOAT:
  {
    float *buff_A     = ( float * ) FLA_FLOAT_PTR( A );
    float *buff_amax  = ( float * ) FLA_FLOAT_PTR( amax );
    float  curr_amax;
    float  temp_amax;

    // Initialize the search with the absolute value of the first element.
    curr_amax = ( float ) fabs( buff_A[0] );

    // Inspect each element, saving values in curr_amax that are larger than
    // the previous elements.
    for( j = 0; j < n_A; j++ )
    {
      for( i = 0; i < m_A; i++ )
      {
        temp_amax = ( float ) fabs( buff_A[ j*cs_A + i*rs_A ] );

        if ( curr_amax < temp_amax )
          curr_amax = temp_amax;
      }
    }

    // Copy the result into the amax object buffer.
    *buff_amax = curr_amax;

    break;
  }

  case FLA_DOUBLE:
  {
    double *buff_A     = ( double * ) FLA_DOUBLE_PTR( A );
    double *buff_amax  = ( double * ) FLA_DOUBLE_PTR( amax );
    double  curr_amax;
    double  temp_amax;

    // Initialize the search with the absolute value of the first element.
    curr_amax = ( double ) fabs( buff_A[0] );

    // Inspect each element, saving values in curr_amax that are larger than
    // the previous elements.
    for( j = 0; j < n_A; j++ )
    {
      for( i = 0; i < m_A; i++ )
      {
        temp_amax = ( double ) fabs( buff_A[ j*cs_A + i*rs_A ] );

        if ( curr_amax < temp_amax )
          curr_amax = temp_amax;
      }
    }

    // Copy the result into the amax object buffer.
    *buff_amax = curr_amax;


    break;
  }

  case FLA_COMPLEX:
  {
    if ( dt_amax == FLA_FLOAT )
    {
      scomplex *buff_A     = ( scomplex * ) FLA_COMPLEX_PTR( A );
      float    *buff_amax  = ( float    * ) FLA_FLOAT_PTR( amax );
      scomplex *temp_value;
      float     curr_amax;
      float     temp_amax;

      // Initialize the search with the absolute value of the first element.
      temp_value = buff_A;
      curr_amax = ( float  ) sqrt( temp_value->real * temp_value->real + 
                                   temp_value->imag * temp_value->imag ); 

      // Inspect each element, saving values in curr_amax that are larger than
      // the previous elements.
      for( j = 0; j < n_A; j++ )
      {
        for( i = 0; i < m_A; i++ )
        {
          temp_value = buff_A + j*cs_A + i*rs_A;
          temp_amax = ( float  ) sqrt( temp_value->real * temp_value->real + 
                                       temp_value->imag * temp_value->imag ); 
          if ( curr_amax < temp_amax )
            curr_amax = temp_amax;
        }
      }

      // Copy the result into the amax object buffer.
      *buff_amax = curr_amax;
    }
    else if ( dt_amax == FLA_COMPLEX )
    {
      scomplex *buff_A     = ( scomplex * ) FLA_COMPLEX_PTR( A );
      scomplex *buff_amax  = ( scomplex * ) FLA_COMPLEX_PTR( amax );
      scomplex *temp_value;
      float     curr_amax;
      float     temp_amax;

      // Initialize the search with the absolute value of the first element.
      temp_value = buff_A;
      curr_amax = ( float  ) sqrt( temp_value->real * temp_value->real + 
                                   temp_value->imag * temp_value->imag ); 

      // Inspect each element, saving values in curr_amax that are larger than
      // the previous elements.
      for( j = 0; j < n_A; j++ )
      {
        for( i = 0; i < m_A; i++ )
        {
          temp_value = buff_A + j*cs_A + i*rs_A;
          temp_amax = ( float  ) sqrt( temp_value->real * temp_value->real + 
                                       temp_value->imag * temp_value->imag ); 
          if ( curr_amax < temp_amax )
            curr_amax = temp_amax;
        }
      }

      // Copy the result into the amax object buffer.
      buff_amax->real = curr_amax;
      buff_amax->imag = 0.0F;
    }

    break;
  }

  case FLA_DOUBLE_COMPLEX:
  {
    if ( dt_amax == FLA_DOUBLE )
    {
      dcomplex *buff_A     = ( dcomplex * ) FLA_DOUBLE_COMPLEX_PTR( A );
      double   *buff_amax  = ( double   * ) FLA_DOUBLE_PTR( amax );
      dcomplex *temp_value;
      double    curr_amax;
      double    temp_amax;

      // Initialize the search with the absolute value of the first element.
      temp_value = buff_A;
      curr_amax = ( double ) sqrt( temp_value->real * temp_value->real + 
                                   temp_value->imag * temp_value->imag ); 

      // Inspect each element, saving values in curr_amax that are larger than
      // the previous elements.
      for( j = 0; j < n_A; j++ )
      {
        for( i = 0; i < m_A; i++ )
        {
          temp_value = buff_A + j*cs_A + i*rs_A;
          temp_amax = ( double ) sqrt( temp_value->real * temp_value->real + 
                                       temp_value->imag * temp_value->imag ); 
          if ( curr_amax < temp_amax )
            curr_amax = temp_amax;
        }
      }

      // Copy the result into the amax object buffer.
      *buff_amax = curr_amax;
    }
    else if ( dt_amax == FLA_DOUBLE_COMPLEX )
    {
      dcomplex *buff_A     = ( dcomplex * ) FLA_DOUBLE_COMPLEX_PTR( A );
      dcomplex *buff_amax  = ( dcomplex * ) FLA_DOUBLE_COMPLEX_PTR( amax );
      dcomplex *temp_value;
      double    curr_amax;
      double    temp_amax;

      // Initialize the search with the absolute value of the first element.
      temp_value = buff_A;
      curr_amax = ( double ) sqrt( temp_value->real * temp_value->real + 
                                   temp_value->imag * temp_value->imag ); 

      // Inspect each element, saving values in curr_amax that are larger than
      // the previous elements.
      for( j = 0; j < n_A; j++ )
      {
        for( i = 0; i < m_A; i++ )
        {
          temp_value = buff_A + j*cs_A + i*rs_A;
          temp_amax = ( double ) sqrt( temp_value->real * temp_value->real + 
                                       temp_value->imag * temp_value->imag ); 
          if ( curr_amax < temp_amax )
            curr_amax = temp_amax;
        }
      }

      // Copy the result into the amax object buffer.
      buff_amax->real = curr_amax;
      buff_amax->imag = 0.0;
    }

    break;
  }

  }

  return FLA_SUCCESS;
}
FLA_Error FLA_Max_abs_value_check ( FLA_Obj  A,
FLA_Obj  amax 
)

References FLA_Check_floating_object(), FLA_Check_identical_object_precision(), FLA_Check_if_scalar(), and FLA_Check_nonconstant_object().

Referenced by FLA_Max_abs_value().

{
  FLA_Error e_val;

  e_val = FLA_Check_floating_object( A );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_nonconstant_object( A );
  FLA_Check_error_code( e_val );

//  e_val = FLA_Check_real_object( amax );
//  FLA_Check_error_code( e_val );

  e_val = FLA_Check_identical_object_precision( A, amax );
  FLA_Check_error_code( e_val );
  
  e_val = FLA_Check_if_scalar( amax );
  FLA_Check_error_code( e_val );
  
  return FLA_SUCCESS;
}
double FLA_Max_elemwise_diff ( FLA_Obj  A,
FLA_Obj  B 
)

References FLA_Check_error_level(), FLA_Max_elemwise_diff_check(), FLA_Obj_col_stride(), FLA_Obj_datatype(), FLA_Obj_length(), FLA_Obj_row_stride(), and FLA_Obj_width().

Referenced by FLASH_Max_elemwise_diff().

{
  FLA_Datatype datatype;
  dim_t        i, j;
  dim_t        m_A, n_A;
  dim_t        rs_A, cs_A;
  dim_t        rs_B, cs_B;
  double       diff;
  double       d_max = 0.0;

  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
    FLA_Max_elemwise_diff_check( A, B );

  datatype = FLA_Obj_datatype( A );

  m_A      = FLA_Obj_length( A );
  n_A      = FLA_Obj_width( A );
  rs_A     = FLA_Obj_row_stride( A );
  cs_A     = FLA_Obj_col_stride( A );

  rs_B     = FLA_Obj_row_stride( B );
  cs_B     = FLA_Obj_col_stride( B );
  
  switch ( datatype ){

  case FLA_FLOAT:
  {
    float *buff_a = ( float * ) FLA_FLOAT_PTR( A );
    float *buff_b = ( float * ) FLA_FLOAT_PTR( B );

    for( j = 0; j < n_A; j++ )
    {
      for( i = 0; i < m_A; i++ )
      {
        diff = ( double ) ( buff_a[ j*cs_A + i*rs_A ] - buff_b[ j*cs_B + i*rs_B ] );

        if( fabs(diff) > d_max )
          d_max = fabs(diff);
      }
    }

    break;
  }

  case FLA_DOUBLE:
  {
    double *buff_a = ( double * ) FLA_DOUBLE_PTR( A );
    double *buff_b = ( double * ) FLA_DOUBLE_PTR( B );

    for( j = 0; j < n_A; j++ )
    {
      for( i = 0; i < m_A; i++ )
      {
        diff = ( double ) ( buff_a[ j*cs_A + i*rs_A ] - buff_b[ j*cs_B + i*rs_B ] );

        if( fabs(diff) > d_max )
          d_max = fabs(diff);
      }
    }

    break;
  }

  case FLA_COMPLEX:
  {
    scomplex *buff_a = ( scomplex * ) FLA_COMPLEX_PTR( A );
    scomplex *buff_b = ( scomplex * ) FLA_COMPLEX_PTR( B );

    for( j = 0; j < n_A; j++ )
    {
      for( i = 0; i < m_A; i++ )
      {
        diff = ( double ) ( buff_a[ j*cs_A + i*rs_A ].real - buff_b[ j*cs_B + i*rs_B ].real );

        if( fabs(diff) > d_max )
          d_max = fabs(diff);

        diff = ( double ) ( buff_a[ j*cs_A + i*rs_A ].imag - buff_b[ j*cs_B + i*rs_B ].imag );

        if( fabs(diff) > d_max )
          d_max = fabs(diff);
      }
    }

    break;
  }

  case FLA_DOUBLE_COMPLEX:
  {
    dcomplex *buff_a = ( dcomplex * ) FLA_DOUBLE_COMPLEX_PTR( A );
    dcomplex *buff_b = ( dcomplex * ) FLA_DOUBLE_COMPLEX_PTR( B );

    for( j = 0; j < n_A; j++ )
    {
      for( i = 0; i < m_A; i++ )
      {
        diff = ( double ) ( buff_a[ j*cs_A + i*rs_A ].real - buff_b[ j*cs_B + i*rs_B ].real );

        if( fabs(diff) > d_max )
          d_max = fabs(diff);

        diff = ( double ) ( buff_a[ j*cs_A + i*rs_A ].imag - buff_b[ j*cs_B + i*rs_B ].imag );

        if( fabs(diff) > d_max )
          d_max = fabs(diff);
      }
    }

    break;
  }

  }

  
  return d_max;
}
FLA_Error FLA_Max_elemwise_diff_check ( FLA_Obj  A,
FLA_Obj  B 
)

References FLA_Check_conformal_dims(), FLA_Check_floating_object(), FLA_Check_identical_object_datatype(), and FLA_Check_nonconstant_object().

Referenced by FLA_Max_elemwise_diff().

{
  FLA_Error e_val;

  e_val = FLA_Check_floating_object( A );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_nonconstant_object( A );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_identical_object_datatype( A, B );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_conformal_dims( FLA_NO_TRANSPOSE, A, B );
  FLA_Check_error_code( e_val );

  return FLA_SUCCESS;
}
FLA_Error FLA_Mult_add ( FLA_Obj  alpha,
FLA_Obj  beta,
FLA_Obj  gamma 
)

References FLA_Check_error_level(), FLA_Mult_add_check(), FLA_Obj_datatype(), dcomplex::imag, scomplex::imag, dcomplex::real, and scomplex::real.

Referenced by FLA_Bidiag_UT_u_step_unb_var3(), FLA_Bidiag_UT_u_step_unb_var4(), FLA_Lyap_h_unb_var1(), FLA_Lyap_h_unb_var2(), FLA_Lyap_h_unb_var3(), FLA_Lyap_h_unb_var4(), FLA_Lyap_n_unb_var1(), FLA_Lyap_n_unb_var2(), FLA_Lyap_n_unb_var3(), and FLA_Lyap_n_unb_var4().

{
  FLA_Datatype datatype;

  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
    FLA_Mult_add_check( alpha, beta, gamma );

  datatype = FLA_Obj_datatype( gamma );
  
  switch ( datatype ){

  case FLA_FLOAT:
  {
    float *buff_alpha = ( float * ) FLA_FLOAT_PTR( alpha );
    float *buff_beta  = ( float * ) FLA_FLOAT_PTR( beta );
    float *buff_gamma = ( float * ) FLA_FLOAT_PTR( gamma );

    *buff_gamma = *buff_gamma + *buff_alpha * *buff_beta;

    break;
  }

  case FLA_DOUBLE:
  {
    double *buff_alpha = ( double * ) FLA_DOUBLE_PTR( alpha );
    double *buff_beta  = ( double * ) FLA_DOUBLE_PTR( beta );
    double *buff_gamma = ( double * ) FLA_DOUBLE_PTR( gamma );

    *buff_gamma = *buff_gamma + *buff_alpha * *buff_beta;

    break;
  }

  case FLA_COMPLEX:
  {
    scomplex *buff_alpha = ( scomplex * ) FLA_COMPLEX_PTR( alpha );
    scomplex *buff_beta  = ( scomplex * ) FLA_COMPLEX_PTR( beta );
    scomplex *buff_gamma = ( scomplex * ) FLA_COMPLEX_PTR( gamma );
    scomplex  alphabeta;

    alphabeta.real = buff_alpha->real * buff_beta->real -
                     buff_alpha->imag * buff_beta->imag;

    alphabeta.imag = buff_alpha->real * buff_beta->imag +
                     buff_alpha->imag * buff_beta->real;

    buff_gamma->real = buff_gamma->real + alphabeta.real;
    buff_gamma->imag = buff_gamma->imag + alphabeta.imag;

    break;
  }

  case FLA_DOUBLE_COMPLEX:
  {
    dcomplex *buff_alpha = ( dcomplex * ) FLA_DOUBLE_COMPLEX_PTR( alpha );
    dcomplex *buff_beta  = ( dcomplex * ) FLA_DOUBLE_COMPLEX_PTR( beta );
    dcomplex *buff_gamma = ( dcomplex * ) FLA_DOUBLE_COMPLEX_PTR( gamma );
    dcomplex  alphabeta;

    alphabeta.real = buff_alpha->real * buff_beta->real -
                     buff_alpha->imag * buff_beta->imag;

    alphabeta.imag = buff_alpha->real * buff_beta->imag +
                     buff_alpha->imag * buff_beta->real;

    buff_gamma->real = buff_gamma->real + alphabeta.real;
    buff_gamma->imag = buff_gamma->imag + alphabeta.imag;

    break;
  }

  }

  return FLA_SUCCESS;
}
FLA_Error FLA_Mult_add_check ( FLA_Obj  alpha,
FLA_Obj  beta,
FLA_Obj  gamma 
)

References FLA_Check_floating_object(), FLA_Check_if_scalar(), and FLA_Check_nonconstant_object().

Referenced by FLA_Mult_add().

{
  FLA_Error e_val;

  e_val = FLA_Check_floating_object( alpha );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_floating_object( beta );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_floating_object( gamma );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_if_scalar( alpha );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_if_scalar( beta );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_if_scalar( gamma );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_nonconstant_object( gamma );
  FLA_Check_error_code( e_val );

  return FLA_SUCCESS;
}
FLA_Error FLA_Negate ( FLA_Obj  x)

References FLA_Check_error_level(), FLA_MINUS_ONE, FLA_Negate_check(), and FLA_Scal().

{
  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
    FLA_Negate_check( x );

  return FLA_Scal( FLA_MINUS_ONE, x );
}
FLA_Error FLA_Negate_check ( FLA_Obj  x)

References FLA_Check_floating_object(), and FLA_Check_nonconstant_object().

Referenced by FLA_Negate().

{
  FLA_Error e_val;

  e_val = FLA_Check_floating_object( x );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_nonconstant_object( x );
  FLA_Check_error_code( e_val );

  return FLA_SUCCESS;
}
FLA_Error FLA_Norm1 ( FLA_Obj  A,
FLA_Obj  norm 
)

References FLA_Asum(), FLA_Check_error_level(), FLA_Cont_with_1x3_to_1x2(), FLA_Max_abs_value(), FLA_Norm1_check(), FLA_Obj_create(), FLA_Obj_datatype(), FLA_Obj_free(), FLA_Obj_width(), FLA_Part_1x2(), and FLA_Repart_1x2_to_1x3().

Referenced by FLASH_Norm1().

{
  FLA_Obj AL,   AR,       A0,  a1,  A2;

  FLA_Obj b;
  FLA_Obj bL,   bR,       b0,  beta1,  b2;

  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
    FLA_Norm1_check( A, norm );

  FLA_Obj_create( FLA_Obj_datatype( A ), 1, FLA_Obj_width( A ), 0, 0, &b );

  FLA_Part_1x2( A,    &AL,  &AR,      0, FLA_LEFT );

  FLA_Part_1x2( b,    &bL,  &bR,      0, FLA_LEFT );

  while ( FLA_Obj_width( AL ) < FLA_Obj_width( A ) ){

    FLA_Repart_1x2_to_1x3( AL,  /**/ AR,        &A0, /**/ &a1, &A2,
                           1, FLA_RIGHT );

    FLA_Repart_1x2_to_1x3( bL,  /**/ bR,        &b0, /**/ &beta1, &b2,
                           1, FLA_RIGHT );

    /*------------------------------------------------------------*/

    FLA_Asum( a1, beta1 );

    /*------------------------------------------------------------*/

    FLA_Cont_with_1x3_to_1x2( &AL,  /**/ &AR,        A0, a1, /**/ A2,
                              FLA_LEFT );

    FLA_Cont_with_1x3_to_1x2( &bL,  /**/ &bR,        b0, beta1, /**/ b2,
                              FLA_LEFT );
  }

  FLA_Max_abs_value( b, norm );

  FLA_Obj_free( &b );

  return FLA_SUCCESS;
}
FLA_Error FLA_Norm1_check ( FLA_Obj  A,
FLA_Obj  norm 
)

References FLA_Check_floating_object(), FLA_Check_identical_object_precision(), FLA_Check_if_scalar(), and FLA_Check_nonconstant_object().

Referenced by FLA_Norm1().

{
  FLA_Error e_val;

  e_val = FLA_Check_floating_object( A );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_nonconstant_object( A );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_identical_object_precision( A, norm );
  FLA_Check_error_code( e_val );
  
  e_val = FLA_Check_if_scalar( norm );
  FLA_Check_error_code( e_val );

  return FLA_SUCCESS;
}
FLA_Error FLA_Norm_frob ( FLA_Obj  A,
FLA_Obj  norm 
)

References bli_cfnorm(), bli_dfnorm(), bli_sfnorm(), bli_zfnorm(), FLA_Check_error_level(), FLA_Norm_frob_check(), FLA_Obj_col_stride(), FLA_Obj_datatype(), FLA_Obj_length(), FLA_Obj_row_stride(), and FLA_Obj_width().

{
  FLA_Datatype datatype;
  int          m_A, n_A;
  int          rs_A, cs_A;

  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
    FLA_Norm_frob_check( A, norm );

  datatype = FLA_Obj_datatype( A );

  m_A      = FLA_Obj_length( A );
  n_A      = FLA_Obj_width( A );
  rs_A     = FLA_Obj_row_stride( A );
  cs_A     = FLA_Obj_col_stride( A );
 
 
  switch ( datatype ){

  case FLA_FLOAT:
  {
    float *buff_A     = ( float * ) FLA_FLOAT_PTR( A );
    float *buff_norm  = ( float * ) FLA_FLOAT_PTR( norm );

    bli_sfnorm( m_A,
                n_A,
                buff_A, rs_A, cs_A,
                buff_norm );

    break;
  }

  case FLA_DOUBLE:
  {
    double *buff_A     = ( double * ) FLA_DOUBLE_PTR( A );
    double *buff_norm  = ( double * ) FLA_DOUBLE_PTR( norm );

    bli_dfnorm( m_A,
                n_A,
                buff_A, rs_A, cs_A,
                buff_norm );

    break;
  }

  case FLA_COMPLEX:
  {
    scomplex *buff_A     = ( scomplex * ) FLA_COMPLEX_PTR( A );
    float    *buff_norm  = ( float    * ) FLA_FLOAT_PTR( norm );

    bli_cfnorm( m_A,
                n_A,
                buff_A, rs_A, cs_A,
                buff_norm );

    break;
  }

  case FLA_DOUBLE_COMPLEX:
  {
    dcomplex *buff_A     = ( dcomplex * ) FLA_DOUBLE_COMPLEX_PTR( A );
    double   *buff_norm  = ( double   * ) FLA_DOUBLE_PTR( norm );

    bli_zfnorm( m_A,
                n_A,
                buff_A, rs_A, cs_A,
                buff_norm );

    break;
  }

  }

  return FLA_SUCCESS;
}
FLA_Error FLA_Norm_frob_check ( FLA_Obj  A,
FLA_Obj  norm 
)

References FLA_Check_floating_object(), FLA_Check_identical_object_precision(), FLA_Check_if_scalar(), FLA_Check_nonconstant_object(), and FLA_Check_real_object().

Referenced by FLA_Norm_frob().

{
  FLA_Error e_val;

  e_val = FLA_Check_floating_object( A );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_nonconstant_object( A );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_real_object( norm );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_identical_object_precision( A, norm );
  FLA_Check_error_code( e_val );
  
  e_val = FLA_Check_if_scalar( norm );
  FLA_Check_error_code( e_val );

  return FLA_SUCCESS;
}
FLA_Error FLA_Norm_inf ( FLA_Obj  A,
FLA_Obj  norm 
)

References FLA_Asum(), FLA_Check_error_level(), FLA_Cont_with_3x1_to_2x1(), FLA_Max_abs_value(), FLA_Norm_inf_check(), FLA_Obj_create(), FLA_Obj_datatype(), FLA_Obj_free(), FLA_Obj_length(), FLA_Part_2x1(), and FLA_Repart_2x1_to_3x1().

{
  FLA_Obj AT,              A0,
          AB,              a1t,
                           A2;

  FLA_Obj bT,              b0,
          bB,              beta1,
                           b2;
  FLA_Obj b;

  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
    FLA_Norm_inf_check( A, norm );

  FLA_Obj_create( FLA_Obj_datatype( A ), FLA_Obj_length( A ), 1, 0, 0, &b );

  FLA_Part_2x1( A,    &AT, 
                      &AB,            0, FLA_TOP );

  FLA_Part_2x1( b,    &bT, 
                      &bB,            0, FLA_TOP );

  while ( FLA_Obj_length( AT ) < FLA_Obj_length( A ) ){

    FLA_Repart_2x1_to_3x1( AT,                &A0, 
                        /* ** */            /* *** */
                                              &a1t, 
                           AB,                &A2,        1, FLA_BOTTOM );

    FLA_Repart_2x1_to_3x1( bT,                &b0, 
                        /* ** */            /* ***** */
                                              &beta1, 
                           bB,                &b2,        1, FLA_BOTTOM );

    /*------------------------------------------------------------*/

    FLA_Asum( a1t, beta1 );

    /*------------------------------------------------------------*/

    FLA_Cont_with_3x1_to_2x1( &AT,                A0, 
                                                  a1t, 
                            /* ** */           /* *** */
                              &AB,                A2,     FLA_TOP );

    FLA_Cont_with_3x1_to_2x1( &bT,                b0, 
                                                  beta1, 
                            /* ** */           /* ***** */
                              &bB,                b2,     FLA_TOP );

  }

  FLA_Max_abs_value( b, norm );

  FLA_Obj_free( &b );

  return FLA_SUCCESS;
}
FLA_Error FLA_Norm_inf_check ( FLA_Obj  A,
FLA_Obj  norm 
)

References FLA_Check_floating_object(), FLA_Check_identical_object_precision(), FLA_Check_if_scalar(), FLA_Check_nonconstant_object(), and FLA_Check_real_object().

Referenced by FLA_Norm_inf().

{
  FLA_Error e_val;

  e_val = FLA_Check_floating_object( A );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_nonconstant_object( A );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_real_object( norm );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_identical_object_precision( A, norm );
  FLA_Check_error_code( e_val );
  
  e_val = FLA_Check_if_scalar( norm );
  FLA_Check_error_code( e_val );

  return FLA_SUCCESS;
}
dcomplex FLA_random_dcomplex ( void  )
double FLA_random_double ( void  )

Referenced by FLA_random_dcomplex().

{
  return ( ( double ) rand() / ( double ) RAND_MAX ) * 2.0 - 1.0;
}
float FLA_random_float ( void  )

Referenced by FLA_random_scomplex().

{
  return ( float )( ( ( double ) rand() / ( double ) RAND_MAX ) * 2.0 - 1.0 );
}
FLA_Error FLA_Random_herm_matrix ( FLA_Uplo  uplo,
FLA_Obj  A 
)

References FLA_Check_error_level(), FLA_Hermitianize(), FLA_Random_herm_matrix_check(), and FLA_Random_tri_matrix().

{
  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
    FLA_Random_herm_matrix_check( uplo, A );

  FLA_Random_tri_matrix( uplo, FLA_NONUNIT_DIAG, A );

  FLA_Hermitianize( uplo, A );

  return FLA_SUCCESS;
}
FLA_Error FLA_Random_herm_matrix_check ( FLA_Uplo  uplo,
FLA_Obj  A 
)

References FLA_Check_floating_object(), FLA_Check_nonconstant_object(), FLA_Check_square(), and FLA_Check_valid_uplo().

Referenced by FLA_Random_herm_matrix().

{
  FLA_Error e_val;

  e_val = FLA_Check_valid_uplo( uplo );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_floating_object( A );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_nonconstant_object( A );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_square( A );
  FLA_Check_error_code( e_val );

  return FLA_SUCCESS;
}
FLA_Error FLA_Random_matrix ( FLA_Obj  A)

References bli_crandm(), bli_drandm(), bli_srandm(), bli_zrandm(), FLA_Check_error_level(), FLA_Obj_col_stride(), FLA_Obj_datatype(), FLA_Obj_length(), FLA_Obj_row_stride(), FLA_Obj_width(), and FLA_Random_matrix_check().

Referenced by FLASH_Random_matrix().

{
  FLA_Datatype datatype;
  int          m_A, n_A;
  int          rs_A, cs_A;

  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
    FLA_Random_matrix_check( A );

  datatype = FLA_Obj_datatype( A );

  m_A      = FLA_Obj_length( A );
  n_A      = FLA_Obj_width( A );
  rs_A     = FLA_Obj_row_stride( A );
  cs_A     = FLA_Obj_col_stride( A );


  switch( datatype ){

  case FLA_FLOAT:
  {
    float *buff_A = ( float * ) FLA_FLOAT_PTR( A );

    bli_srandm( m_A,
                n_A,
                buff_A, rs_A, cs_A );

    break;
  }

  case FLA_DOUBLE:
  {
    double *buff_A = ( double * ) FLA_DOUBLE_PTR( A );

    bli_drandm( m_A,
                n_A,
                buff_A, rs_A, cs_A );

    break;
  }

  case FLA_COMPLEX:
  {
    scomplex *buff_A = ( scomplex * ) FLA_COMPLEX_PTR( A );

    bli_crandm( m_A,
                n_A,
                buff_A, rs_A, cs_A );

    break;
  }

  case FLA_DOUBLE_COMPLEX:
  {
    dcomplex *buff_A = ( dcomplex * ) FLA_DOUBLE_COMPLEX_PTR( A );

    bli_zrandm( m_A,
                n_A,
                buff_A, rs_A, cs_A );

    break;
  }

  }

  return FLA_SUCCESS;
}
FLA_Error FLA_Random_matrix_check ( FLA_Obj  A)

References FLA_Check_floating_object(), and FLA_Check_nonconstant_object().

Referenced by FLA_Random_matrix().

{
  FLA_Error e_val;

  e_val = FLA_Check_floating_object( A );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_nonconstant_object( A );
  FLA_Check_error_code( e_val );

  return FLA_SUCCESS;
}
scomplex FLA_random_scomplex ( void  )
FLA_Error FLA_Random_spd_matrix ( FLA_Uplo  uplo,
FLA_Obj  A 
)

References FLA_Check_error_level(), FLA_Herk_external(), FLA_Obj_create_conf_to(), FLA_Obj_free(), FLA_ONE, FLA_Random_spd_matrix_check(), FLA_Random_tri_matrix(), and FLA_ZERO.

Referenced by FLASH_Random_spd_matrix().

{
  FLA_Obj R;

  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
    FLA_Random_spd_matrix_check( uplo, A );

  // Create a temporary object R conformal to A.
  FLA_Obj_create_conf_to( FLA_NO_TRANSPOSE, A, &R );

  // Randomize R to be an uplo-triangular matrix. Note that the diagonal of R
  // needs to be positive to ensure that R * R' is SPD/HPD.
  FLA_Random_tri_matrix( uplo, FLA_NONUNIT_DIAG, R );
    
  if ( uplo == FLA_LOWER_TRIANGULAR )
  {
    // A = R * R';
    FLA_Herk_external( uplo, FLA_NO_TRANSPOSE, FLA_ONE, R, FLA_ZERO, A );
  }
  else // if ( uplo == FLA_UPPER_TRIANGULAR )
  {
    // A = R' * R;
    FLA_Herk_external( uplo, FLA_CONJ_TRANSPOSE, FLA_ONE, R, FLA_ZERO, A );
  }

  // Free R.
  FLA_Obj_free( &R );

  return FLA_SUCCESS;
}
FLA_Error FLA_Random_spd_matrix_check ( FLA_Uplo  uplo,
FLA_Obj  A 
)

References FLA_Check_floating_object(), FLA_Check_nonconstant_object(), FLA_Check_square(), and FLA_Check_valid_uplo().

Referenced by FLA_Random_spd_matrix().

{
  FLA_Error e_val;

  e_val = FLA_Check_valid_uplo( uplo );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_floating_object( A );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_nonconstant_object( A );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_square( A );
  FLA_Check_error_code( e_val );

  return FLA_SUCCESS;
}
FLA_Error FLA_Random_symm_matrix ( FLA_Uplo  uplo,
FLA_Obj  A 
)

References FLA_Check_error_level(), FLA_Random_symm_matrix_check(), FLA_Random_tri_matrix(), and FLA_Symmetrize().

{
  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
    FLA_Random_symm_matrix_check( uplo, A );

  FLA_Random_tri_matrix( uplo, FLA_NONUNIT_DIAG, A );

  FLA_Symmetrize( uplo, A );

  return FLA_SUCCESS;
}
FLA_Error FLA_Random_symm_matrix_check ( FLA_Uplo  uplo,
FLA_Obj  A 
)

References FLA_Check_floating_object(), FLA_Check_nonconstant_object(), FLA_Check_square(), and FLA_Check_valid_uplo().

Referenced by FLA_Random_symm_matrix().

{
  FLA_Error e_val;

  e_val = FLA_Check_valid_uplo( uplo );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_floating_object( A );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_nonconstant_object( A );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_square( A );
  FLA_Check_error_code( e_val );

  return FLA_SUCCESS;
}
FLA_Error FLA_Random_tri_matrix ( FLA_Uplo  uplo,
FLA_Diag  diag,
FLA_Obj  A 
)

References bli_crandmr(), bli_drandmr(), bli_srandmr(), bli_zrandmr(), FLA_Check_error_level(), FLA_Obj_col_stride(), FLA_Obj_datatype(), FLA_Obj_length(), FLA_Obj_row_stride(), FLA_Obj_width(), FLA_Param_map_flame_to_blis_diag(), FLA_Param_map_flame_to_blis_uplo(), and FLA_Random_tri_matrix_check().

Referenced by FLA_Random_herm_matrix(), FLA_Random_spd_matrix(), and FLA_Random_symm_matrix().

{
  FLA_Datatype datatype;
  int          m_A, n_A;
  int          rs_A, cs_A;
  char         blis_uplo;
  char         blis_diag;

  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
    FLA_Random_tri_matrix_check( uplo, diag, A );

  datatype = FLA_Obj_datatype( A );

  m_A      = FLA_Obj_length( A );
  n_A      = FLA_Obj_width( A );
  rs_A     = FLA_Obj_row_stride( A );
  cs_A     = FLA_Obj_col_stride( A );

  FLA_Param_map_flame_to_blis_uplo( uplo, &blis_uplo );
  FLA_Param_map_flame_to_blis_diag( diag, &blis_diag );


  switch( datatype ){

  case FLA_FLOAT:
  {
    float *buff_A = ( float * ) FLA_FLOAT_PTR( A );

    bli_srandmr( blis_uplo,
                 blis_diag,
                 m_A,
                 n_A,
                 buff_A, rs_A, cs_A );

    break;
  }

  case FLA_DOUBLE:
  {
    double *buff_A = ( double * ) FLA_DOUBLE_PTR( A );

    bli_drandmr( blis_uplo,
                 blis_diag,
                 m_A,
                 n_A,
                 buff_A, rs_A, cs_A );

    break;
  }

  case FLA_COMPLEX:
  {
    scomplex *buff_A = ( scomplex * ) FLA_COMPLEX_PTR( A );

    bli_crandmr( blis_uplo,
                 blis_diag,
                 m_A,
                 n_A,
                 buff_A, rs_A, cs_A );

    break;
  }

  case FLA_DOUBLE_COMPLEX:
  {
    dcomplex *buff_A = ( dcomplex * ) FLA_DOUBLE_COMPLEX_PTR( A );

    bli_zrandmr( blis_uplo,
                 blis_diag,
                 m_A,
                 n_A,
                 buff_A, rs_A, cs_A );

    break;
  }

  }

  return FLA_SUCCESS;
}
FLA_Error FLA_Random_tri_matrix_check ( FLA_Uplo  uplo,
FLA_Diag  diag,
FLA_Obj  A 
)

References FLA_Check_floating_object(), FLA_Check_nonconstant_object(), FLA_Check_valid_diag(), and FLA_Check_valid_uplo().

Referenced by FLA_Random_tri_matrix().

{
  FLA_Error e_val;

  e_val = FLA_Check_valid_uplo( uplo );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_valid_diag( diag );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_floating_object( A );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_nonconstant_object( A );
  FLA_Check_error_code( e_val );

  return FLA_SUCCESS;
}
FLA_Error FLA_Scal_elemwise ( FLA_Trans  trans,
FLA_Obj  A,
FLA_Obj  B 
)

References bli_cewscalmt(), bli_dewscalmt(), bli_sewscalmt(), bli_zewscalmt(), FLA_Check_error_level(), FLA_Obj_col_stride(), FLA_Obj_datatype(), FLA_Obj_has_zero_dim(), FLA_Obj_length(), FLA_Obj_row_stride(), FLA_Obj_width(), FLA_Param_map_flame_to_blis_trans(), and FLA_Scal_elemwise_check().

{
  FLA_Datatype datatype;
  int          m_B, n_B;
  int          rs_A, cs_A;
  int          rs_B, cs_B;
  char         blis_trans;

  if ( FLA_Check_error_level() == FLA_FULL_ERROR_CHECKING ) 
    FLA_Scal_elemwise_check( trans, A, B );

  if ( FLA_Obj_has_zero_dim( A ) ) return FLA_SUCCESS;

  datatype = FLA_Obj_datatype( A );

  rs_A     = FLA_Obj_row_stride( A );
  cs_A     = FLA_Obj_col_stride( A );

  m_B      = FLA_Obj_length( B );
  n_B      = FLA_Obj_width( B );
  rs_B     = FLA_Obj_row_stride( B );
  cs_B     = FLA_Obj_col_stride( B );

  FLA_Param_map_flame_to_blis_trans( trans, &blis_trans );

  switch ( datatype ){

  case FLA_FLOAT:
  {
    float *buff_A     = ( float * ) FLA_FLOAT_PTR( A );
    float *buff_B     = ( float * ) FLA_FLOAT_PTR( B );

    bli_sewscalmt( blis_trans,
                   m_B,
                   n_B,
                   buff_A, rs_A, cs_A,
                   buff_B, rs_B, cs_B );

    break;
  }

  case FLA_DOUBLE:
  {
    double *buff_A     = ( double * ) FLA_DOUBLE_PTR( A );
    double *buff_B     = ( double * ) FLA_DOUBLE_PTR( B );

    bli_dewscalmt( blis_trans,
                   m_B,
                   n_B,
                   buff_A, rs_A, cs_A,
                   buff_B, rs_B, cs_B );

    break;
  }

  case FLA_COMPLEX:
  {
    scomplex *buff_A =     ( scomplex * ) FLA_COMPLEX_PTR( A );
    scomplex *buff_B =     ( scomplex * ) FLA_COMPLEX_PTR( B );

    bli_cewscalmt( blis_trans,
                   m_B,
                   n_B,
                   buff_A, rs_A, cs_A,
                   buff_B, rs_B, cs_B );

    break;
  }

  case FLA_DOUBLE_COMPLEX:
  {
    dcomplex *buff_A     = ( dcomplex * ) FLA_DOUBLE_COMPLEX_PTR( A );
    dcomplex *buff_B     = ( dcomplex * ) FLA_DOUBLE_COMPLEX_PTR( B );

    bli_zewscalmt( blis_trans,
                   m_B,
                   n_B,
                   buff_A, rs_A, cs_A,
                   buff_B, rs_B, cs_B );

    break;
  }

  }
  
  return FLA_SUCCESS;
}
FLA_Error FLA_Scal_elemwise_check ( FLA_Trans  trans,
FLA_Obj  A,
FLA_Obj  B 
)

References FLA_Check_conformal_dims(), FLA_Check_floating_object(), FLA_Check_identical_object_datatype(), FLA_Check_nonconstant_object(), and FLA_Check_valid_trans().

Referenced by FLA_Scal_elemwise().

{
  FLA_Error e_val;

  e_val = FLA_Check_valid_trans( trans );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_floating_object( A );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_nonconstant_object( A );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_identical_object_datatype( A, B );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_conformal_dims( trans, A, B );
  FLA_Check_error_code( e_val );

  return FLA_SUCCESS;
}
FLA_Error FLA_Shift_pivots_to_check ( FLA_Pivot_type  ptype,
FLA_Obj  p 
)
{
  FLA_Error e_val;

  e_val = FLA_Check_valid_pivot_type( ptype );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_int_object( p );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_nonconstant_object( p );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_col_vector( p );
  FLA_Check_error_code( e_val );

  return FLA_SUCCESS;
}
FLA_Error FLA_Sqrt ( FLA_Obj  alpha)

References FLA_Check_error_level(), FLA_Obj_datatype(), FLA_Sqrt_check(), dcomplex::real, and scomplex::real.

Referenced by FLA_Chol_l_unb_var1(), FLA_Chol_l_unb_var2(), FLA_Chol_l_unb_var3(), FLA_Chol_u_unb_var1(), FLA_Chol_u_unb_var2(), and FLA_Chol_u_unb_var3().

{
  FLA_Datatype datatype;
  int          r_val = FLA_SUCCESS;

  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
    FLA_Sqrt_check( alpha );

  datatype = FLA_Obj_datatype( alpha );
  
  switch ( datatype ){

  case FLA_FLOAT:
  {
    float *buff_alpha = ( float * ) FLA_FLOAT_PTR( alpha );

    if ( *buff_alpha < 0.0F )
      r_val = FLA_FAILURE;
    else
      *buff_alpha = ( float ) sqrt( *buff_alpha );
    
    break;
  }

  case FLA_DOUBLE:
  {
    double *buff_alpha = ( double * ) FLA_DOUBLE_PTR( alpha );

    if ( *buff_alpha < 0.0 )
      r_val = FLA_FAILURE;
    else
      *buff_alpha = ( double ) sqrt( *buff_alpha );
    
    break;
  }

  case FLA_COMPLEX:
  {
    scomplex *buff_alpha = ( scomplex * ) FLA_COMPLEX_PTR( alpha );

    if ( buff_alpha->real < 0.0F )
      r_val = FLA_FAILURE;
    else
      buff_alpha->real = ( float ) sqrt( buff_alpha->real );
    
    break;
  }

  case FLA_DOUBLE_COMPLEX:
  {
    dcomplex *buff_alpha = ( dcomplex * ) FLA_DOUBLE_COMPLEX_PTR( alpha );

    if ( buff_alpha->real < 0.0 )
      r_val = FLA_FAILURE;
    else
      buff_alpha->real = ( double ) sqrt( buff_alpha->real );
    
    break;
  }

  }

  return r_val;
}
FLA_Error FLA_Sqrt_check ( FLA_Obj  alpha)

References FLA_Check_floating_object(), FLA_Check_if_scalar(), and FLA_Check_nonconstant_object().

Referenced by FLA_Sqrt().

{
  FLA_Error e_val;

  e_val = FLA_Check_floating_object( alpha );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_nonconstant_object( alpha );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_if_scalar( alpha );
  FLA_Check_error_code( e_val );

  return FLA_SUCCESS;
}
FLA_Error FLA_Swap_t_blk_var1 ( FLA_Obj  A,
FLA_Obj  B,
fla_swap_t cntl 
)

References FLA_Cont_with_1x3_to_1x2(), FLA_Cont_with_3x1_to_2x1(), FLA_Determine_blocksize(), FLA_Obj_width(), FLA_Part_1x2(), FLA_Part_2x1(), FLA_Repart_1x2_to_1x3(), FLA_Repart_2x1_to_3x1(), and FLA_Swapt_external().

Referenced by FLA_Transpose_blk_var1().

{
  FLA_Obj AL,    AR,       A0,  A1,  A2;

  FLA_Obj BT,              B0,
          BB,              B1,
                           B2;

  dim_t b;

  FLA_Part_1x2( A,    &AL,  &AR,      0, FLA_LEFT );

  FLA_Part_2x1( B,    &BT, 
                      &BB,            0, FLA_TOP );

  while ( FLA_Obj_width( AL ) < FLA_Obj_width( A ) ){

    b = FLA_Determine_blocksize( AR, FLA_RIGHT, FLA_Cntl_blocksize( cntl ) );

    FLA_Repart_1x2_to_1x3( AL,  /**/ AR,        &A0, /**/ &A1, &A2,
                           b, FLA_RIGHT );

    FLA_Repart_2x1_to_3x1( BT,                &B0, 
                        /* ** */            /* ** */
                                              &B1, 
                           BB,                &B2,        b, FLA_BOTTOM );

    /*------------------------------------------------------------*/

    FLA_Swapt_external( FLA_TRANSPOSE, A1, B1 );

    /*------------------------------------------------------------*/

    FLA_Cont_with_1x3_to_1x2( &AL,  /**/ &AR,        A0, A1, /**/ A2,
                              FLA_LEFT );

    FLA_Cont_with_3x1_to_2x1( &BT,                B0, 
                                                  B1, 
                            /* ** */           /* ** */
                              &BB,                B2,     FLA_TOP );

  }

  return FLA_SUCCESS;
}
FLA_Error FLA_Swap_t_blk_var2 ( FLA_Obj  A,
FLA_Obj  B,
fla_swap_t cntl 
)

References FLA_Cont_with_1x3_to_1x2(), FLA_Cont_with_3x1_to_2x1(), FLA_Determine_blocksize(), FLA_Obj_length(), FLA_Part_1x2(), FLA_Part_2x1(), FLA_Repart_1x2_to_1x3(), FLA_Repart_2x1_to_3x1(), and FLA_Swapt_external().

Referenced by FLA_Transpose_blk_var2().

{
  FLA_Obj AT,              A0,
          AB,              A1,
                           A2;

  FLA_Obj BL,    BR,       B0,  B1,  B2;

  dim_t b;

  FLA_Part_2x1( A,    &AT, 
                      &AB,            0, FLA_TOP );

  FLA_Part_1x2( B,    &BL,  &BR,      0, FLA_LEFT );

  while ( FLA_Obj_length( AT ) < FLA_Obj_length( A ) ){

    b = FLA_Determine_blocksize( AB, FLA_BOTTOM, FLA_Cntl_blocksize( cntl ) );

    FLA_Repart_2x1_to_3x1( AT,                &A0, 
                        /* ** */            /* ** */
                                              &A1, 
                           AB,                &A2,        b, FLA_BOTTOM );

    FLA_Repart_1x2_to_1x3( BL,  /**/ BR,        &B0, /**/ &B1, &B2,
                           b, FLA_RIGHT );

    /*------------------------------------------------------------*/

    FLA_Swapt_external( FLA_TRANSPOSE, A1, B1 );

    /*------------------------------------------------------------*/

    FLA_Cont_with_3x1_to_2x1( &AT,                A0, 
                                                  A1, 
                            /* ** */           /* ** */
                              &AB,                A2,     FLA_TOP );

    FLA_Cont_with_1x3_to_1x2( &BL,  /**/ &BR,        B0, B1, /**/ B2,
                              FLA_LEFT );

  }

  return FLA_SUCCESS;
}
FLA_Error FLA_Symmetrize ( FLA_Uplo  uplo,
FLA_Obj  A 
)

References bli_csymmize(), bli_dsymmize(), bli_ssymmize(), bli_zsymmize(), FLA_Check_error_level(), FLA_Obj_col_stride(), FLA_Obj_datatype(), FLA_Obj_row_stride(), FLA_Obj_width(), FLA_Param_map_flame_to_blis_conj(), FLA_Param_map_flame_to_blis_uplo(), and FLA_Symmetrize_check().

Referenced by FLA_Random_symm_matrix().

{
  FLA_Datatype datatype;
  dim_t        n_A;
  dim_t        rs_A, cs_A;
  char         blis_conj;
  char         blis_uplo;

  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
    FLA_Symmetrize_check( uplo, A );

  datatype = FLA_Obj_datatype( A );

  n_A      = FLA_Obj_width( A );
  rs_A     = FLA_Obj_row_stride( A );
  cs_A     = FLA_Obj_col_stride( A );

  FLA_Param_map_flame_to_blis_conj( FLA_NO_CONJUGATE, &blis_conj );
  FLA_Param_map_flame_to_blis_uplo( uplo,             &blis_uplo );


  switch ( datatype ){

  case FLA_FLOAT:
  {
    float *buff_A = ( float * ) FLA_FLOAT_PTR( A );

    bli_ssymmize( blis_conj,
                  blis_uplo,
                  n_A,
                  buff_A, rs_A, cs_A );

    break;
  }

  case FLA_DOUBLE:
  {
    double *buff_A = ( double * ) FLA_DOUBLE_PTR( A );

    bli_dsymmize( blis_conj,
                  blis_uplo,
                  n_A,
                  buff_A, rs_A, cs_A );

    break;
  }

  case FLA_COMPLEX:
  {
    scomplex *buff_A = ( scomplex * ) FLA_COMPLEX_PTR( A );

    bli_csymmize( blis_conj,
                  blis_uplo,
                  n_A,
                  buff_A, rs_A, cs_A );

    break;
  }

  case FLA_DOUBLE_COMPLEX:
  {
    dcomplex *buff_A = ( dcomplex * ) FLA_DOUBLE_COMPLEX_PTR( A );

    bli_zsymmize( blis_conj,
                  blis_uplo,
                  n_A,
                  buff_A, rs_A, cs_A );

    break;
  }

  }

  return FLA_SUCCESS;
}
FLA_Error FLA_Symmetrize_check ( FLA_Uplo  uplo,
FLA_Obj  A 
)

References FLA_Check_floating_object(), FLA_Check_nonconstant_object(), FLA_Check_square(), and FLA_Check_valid_uplo().

Referenced by FLA_Symmetrize().

{
  FLA_Error e_val;

  e_val = FLA_Check_valid_uplo( uplo );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_floating_object( A );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_nonconstant_object( A );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_square( A );
  FLA_Check_error_code( e_val );

  return FLA_SUCCESS;
}
FLA_Error FLA_Transpose ( FLA_Obj  A)

References FLA_Check_error_level(), FLA_Transpose_blk_var2(), and FLA_Transpose_check().

{
  FLA_Error r_val;

  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
    FLA_Transpose_check( A );

  r_val = FLA_Transpose_blk_var2( A, fla_tpose_cntl );

  return r_val;
}
FLA_Error FLA_Transpose_blk_var1 ( FLA_Obj  A,
fla_tpose_t cntl 
)

References FLA_Cont_with_3x3_to_2x2(), FLA_Determine_blocksize(), FLA_Obj_length(), FLA_Part_2x2(), FLA_Repart_2x2_to_3x3(), FLA_Swap_t_blk_var1(), and FLA_Transpose_unb_var1().

{
  FLA_Obj ATL,   ATR,      A00, A01, A02, 
          ABL,   ABR,      A10, A11, A12,
                           A20, A21, A22;

  dim_t b;

  FLA_Part_2x2( A,    &ATL, &ATR,
                      &ABL, &ABR,     0, 0, FLA_TL );

  while ( FLA_Obj_length( ATL ) < FLA_Obj_length( A ) ){

    b = FLA_Determine_blocksize( ABR, FLA_BR, FLA_Cntl_blocksize( cntl ) );

    FLA_Repart_2x2_to_3x3( ATL, /**/ ATR,       &A00, /**/ &A01, &A02,
                        /* ************* */   /* ******************** */
                                                &A10, /**/ &A11, &A12,
                           ABL, /**/ ABR,       &A20, /**/ &A21, &A22,
                           b, b, FLA_BR );

    /*------------------------------------------------------------*/

    FLA_Transpose_unb_var1( A11 );

    FLA_Swap_t_blk_var1( A10, A01,
                         FLA_Cntl_sub_swap( cntl ) );

    /*------------------------------------------------------------*/

    FLA_Cont_with_3x3_to_2x2( &ATL, /**/ &ATR,       A00, A01, /**/ A02,
                                                     A10, A11, /**/ A12,
                            /* ************** */  /* ****************** */
                              &ABL, /**/ &ABR,       A20, A21, /**/ A22,
                              FLA_TL );

  }

  return FLA_SUCCESS;
}
FLA_Error FLA_Transpose_blk_var2 ( FLA_Obj  A,
fla_tpose_t cntl 
)

References FLA_Cont_with_3x3_to_2x2(), FLA_Determine_blocksize(), FLA_Obj_length(), FLA_Part_2x2(), FLA_Repart_2x2_to_3x3(), FLA_Swap_t_blk_var2(), and FLA_Transpose_unb_var2().

Referenced by FLA_Transpose().

{
  FLA_Obj ATL,   ATR,      A00, A01, A02, 
          ABL,   ABR,      A10, A11, A12,
                           A20, A21, A22;

  dim_t b;

  FLA_Part_2x2( A,    &ATL, &ATR,
                      &ABL, &ABR,     0, 0, FLA_TL );

  while ( FLA_Obj_length( ATL ) < FLA_Obj_length( A ) ){

    b = FLA_Determine_blocksize( ABR, FLA_BR, FLA_Cntl_blocksize( cntl ) );

    FLA_Repart_2x2_to_3x3( ATL, /**/ ATR,       &A00, /**/ &A01, &A02,
                        /* ************* */   /* ******************** */
                                                &A10, /**/ &A11, &A12,
                           ABL, /**/ ABR,       &A20, /**/ &A21, &A22,
                           b, b, FLA_BR );

    /*------------------------------------------------------------*/

    FLA_Transpose_unb_var2( A11 );

    FLA_Swap_t_blk_var2( A21, A12,
                         FLA_Cntl_sub_swap( cntl ) );

    /*------------------------------------------------------------*/

    FLA_Cont_with_3x3_to_2x2( &ATL, /**/ &ATR,       A00, A01, /**/ A02,
                                                     A10, A11, /**/ A12,
                            /* ************** */  /* ****************** */
                              &ABL, /**/ &ABR,       A20, A21, /**/ A22,
                              FLA_TL );

  }

  return FLA_SUCCESS;
}
FLA_Error FLA_Transpose_check ( FLA_Obj  A)

References FLA_Check_floating_object(), FLA_Check_nonconstant_object(), and FLA_Check_square().

Referenced by FLA_Transpose().

{
  FLA_Error e_val;

  e_val = FLA_Check_floating_object( A );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_nonconstant_object( A );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_square( A );
  FLA_Check_error_code( e_val );

  return FLA_SUCCESS;
}
FLA_Error FLA_Transpose_unb_var1 ( FLA_Obj  A)

References FLA_Cont_with_3x3_to_2x2(), FLA_Obj_length(), FLA_Part_2x2(), FLA_Repart_2x2_to_3x3(), and FLA_Swapt_external().

Referenced by FLA_Transpose_blk_var1().

{
  FLA_Obj ATL,   ATR,      A00,  a01,     A02, 
          ABL,   ABR,      a10t, alpha11, a12t,
                           A20,  a21,     A22;

  FLA_Part_2x2( A,    &ATL, &ATR,
                      &ABL, &ABR,     0, 0, FLA_TL );

  while ( FLA_Obj_length( ATL ) < FLA_Obj_length( A ) ){

    FLA_Repart_2x2_to_3x3( ATL, /**/ ATR,       &A00,  /**/ &a01,     &A02,
                        /* ************* */   /* ************************** */
                                                &a10t, /**/ &alpha11, &a12t,
                           ABL, /**/ ABR,       &A20,  /**/ &a21,     &A22,
                           1, 1, FLA_BR );

    /*------------------------------------------------------------*/

    FLA_Swapt_external( FLA_TRANSPOSE, a10t, a01 );

    /*------------------------------------------------------------*/

    FLA_Cont_with_3x3_to_2x2( &ATL, /**/ &ATR,       A00,  a01,     /**/ A02,
                                                     a10t, alpha11, /**/ a12t,
                            /* ************** */  /* ************************ */
                              &ABL, /**/ &ABR,       A20,  a21,     /**/ A22,
                              FLA_TL );

  }

  return FLA_SUCCESS;
}
FLA_Error FLA_Transpose_unb_var2 ( FLA_Obj  A)

References FLA_Cont_with_3x3_to_2x2(), FLA_Obj_length(), FLA_Part_2x2(), FLA_Repart_2x2_to_3x3(), and FLA_Swapt_external().

Referenced by FLA_Transpose_blk_var2().

{
  FLA_Obj ATL,   ATR,      A00,  a01,     A02, 
          ABL,   ABR,      a10t, alpha11, a12t,
                           A20,  a21,     A22;

  FLA_Part_2x2( A,    &ATL, &ATR,
                      &ABL, &ABR,     0, 0, FLA_TL );

  while ( FLA_Obj_length( ATL ) < FLA_Obj_length( A ) ){

    FLA_Repart_2x2_to_3x3( ATL, /**/ ATR,       &A00,  /**/ &a01,     &A02,
                        /* ************* */   /* ************************** */
                                                &a10t, /**/ &alpha11, &a12t,
                           ABL, /**/ ABR,       &A20,  /**/ &a21,     &A22,
                           1, 1, FLA_BR );

    /*------------------------------------------------------------*/

    FLA_Swapt_external( FLA_TRANSPOSE, a21, a12t );

    /*------------------------------------------------------------*/

    FLA_Cont_with_3x3_to_2x2( &ATL, /**/ &ATR,       A00,  a01,     /**/ A02,
                                                     a10t, alpha11, /**/ a12t,
                            /* ************** */  /* ************************ */
                              &ABL, /**/ &ABR,       A20,  a21,     /**/ A22,
                              FLA_TL );

  }

  return FLA_SUCCESS;
}
FLA_Error FLA_Triangularize ( FLA_Uplo  uplo,
FLA_Diag  diag,
FLA_Obj  A 
)

References bli_csetdiag(), bli_csetmr(), bli_dsetdiag(), bli_dsetmr(), bli_ssetdiag(), bli_ssetmr(), bli_zsetdiag(), bli_zsetmr(), FLA_Check_error_level(), FLA_Obj_col_stride(), FLA_Obj_datatype(), FLA_Obj_length(), FLA_Obj_row_stride(), FLA_Obj_width(), FLA_ONE, FLA_Param_map_flame_to_blis_uplo(), FLA_Triangularize_check(), and FLA_ZERO.

Referenced by FLA_Bidiag_UT_u_blk_var4(), FLA_Bidiag_UT_u_blk_var5(), FLA_Hess_UT_blk_var1(), FLA_Hess_UT_blk_var2(), FLA_Hess_UT_blk_var3(), FLA_Hess_UT_blk_var4(), FLA_SA_LU_unb(), FLA_Tridiag_UT_l_blk_var3(), and FLASH_Triangularize().

{
  FLA_Datatype datatype;
  int          m_A, n_A;
  int          rs_A, cs_A;
  char         blis_uplo;

  if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING )
    FLA_Triangularize_check( uplo, diag, A );

  datatype = FLA_Obj_datatype( A );

  m_A      = FLA_Obj_length( A );
  n_A      = FLA_Obj_width( A );
  rs_A     = FLA_Obj_row_stride( A );
  cs_A     = FLA_Obj_col_stride( A );

  // We have to toggle the uplo parameter because we will use it to specify
  // which triangle to zero out.
  if ( uplo == FLA_LOWER_TRIANGULAR ) uplo = FLA_UPPER_TRIANGULAR;
  else                                uplo = FLA_LOWER_TRIANGULAR;

  FLA_Param_map_flame_to_blis_uplo( uplo, &blis_uplo );

  switch ( datatype ){

  case FLA_FLOAT:
  {
    float *buff_A = ( float * ) FLA_FLOAT_PTR( A );
    float *buff_0 = ( float * ) FLA_FLOAT_PTR( FLA_ZERO );
    float *buff_1 = ( float * ) FLA_FLOAT_PTR( FLA_ONE );

    bli_ssetmr( blis_uplo,
                m_A,
                n_A,
                buff_0,
                buff_A, rs_A, cs_A );

    if ( diag == FLA_UNIT_DIAG )
      bli_ssetdiag( 0,
                    m_A,
                    n_A,
                    buff_1,
                    buff_A, rs_A, cs_A );
    else if ( diag == FLA_ZERO_DIAG )
      bli_ssetdiag( 0,
                    m_A,
                    n_A,
                    buff_0,
                    buff_A, rs_A, cs_A );

    break;
  }

  case FLA_DOUBLE:
  {
    double *buff_A = ( double * ) FLA_DOUBLE_PTR( A );
    double *buff_0 = ( double * ) FLA_DOUBLE_PTR( FLA_ZERO );
    double *buff_1 = ( double * ) FLA_DOUBLE_PTR( FLA_ONE );

    bli_dsetmr( blis_uplo,
                m_A,
                n_A,
                buff_0,
                buff_A, rs_A, cs_A );

    if ( diag == FLA_UNIT_DIAG )
      bli_dsetdiag( 0,
                    m_A,
                    n_A,
                    buff_1,
                    buff_A, rs_A, cs_A );
    else if ( diag == FLA_ZERO_DIAG )
      bli_dsetdiag( 0,
                    m_A,
                    n_A,
                    buff_0,
                    buff_A, rs_A, cs_A );

    break;
  }

  case FLA_COMPLEX:
  {
    scomplex *buff_A = ( scomplex * ) FLA_COMPLEX_PTR( A );
    scomplex *buff_0 = ( scomplex * ) FLA_COMPLEX_PTR( FLA_ZERO );
    scomplex *buff_1 = ( scomplex * ) FLA_COMPLEX_PTR( FLA_ONE );

    bli_csetmr( blis_uplo,
                m_A,
                n_A,
                buff_0,
                buff_A, rs_A, cs_A );

    if ( diag == FLA_UNIT_DIAG )
      bli_csetdiag( 0,
                    m_A,
                    n_A,
                    buff_1,
                    buff_A, rs_A, cs_A );
    else if ( diag == FLA_ZERO_DIAG )
      bli_csetdiag( 0,
                    m_A,
                    n_A,
                    buff_0,
                    buff_A, rs_A, cs_A );

    break;
  }

  case FLA_DOUBLE_COMPLEX:
  {
    dcomplex *buff_A = ( dcomplex * ) FLA_DOUBLE_COMPLEX_PTR( A );
    dcomplex *buff_0 = ( dcomplex * ) FLA_DOUBLE_COMPLEX_PTR( FLA_ZERO );
    dcomplex *buff_1 = ( dcomplex * ) FLA_DOUBLE_COMPLEX_PTR( FLA_ONE );

    bli_zsetmr( blis_uplo,
                m_A,
                n_A,
                buff_0,
                buff_A, rs_A, cs_A );

    if ( diag == FLA_UNIT_DIAG )
      bli_zsetdiag( 0,
                    m_A,
                    n_A,
                    buff_1,
                    buff_A, rs_A, cs_A );
    else if ( diag == FLA_ZERO_DIAG )
      bli_zsetdiag( 0,
                    m_A,
                    n_A,
                    buff_0,
                    buff_A, rs_A, cs_A );

    break;
  }

  }

  return FLA_SUCCESS;
}
FLA_Error FLA_Triangularize_check ( FLA_Uplo  uplo,
FLA_Diag  diag,
FLA_Obj  A 
)

References FLA_Check_floating_object(), FLA_Check_nonconstant_object(), FLA_Check_valid_diag(), and FLA_Check_valid_uplo().

Referenced by FLA_Triangularize().

{
  FLA_Error e_val;

  e_val = FLA_Check_valid_uplo( uplo );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_valid_diag( diag );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_floating_object( A );
  FLA_Check_error_code( e_val );

  e_val = FLA_Check_nonconstant_object( A );
  FLA_Check_error_code( e_val );

  return FLA_SUCCESS;
}