Functions | |
FLA_Error | FLA_Max_abs_value (FLA_Obj A, FLA_Obj amax) |
void FLA_F2C() | fla_max_abs_value_f (F_INT *A, F_INT *amax, F_INT *IERROR) |
References FLA_Check_error_level(), FLA_Max_abs_value_check(), FLA_Obj_datatype(), FLA_Obj_ldim(), FLA_Obj_length(), FLA_Obj_width(), dcomplex::imag, scomplex::imag, dcomplex::real, and scomplex::real.
Referenced by fla_max_abs_value_f(), FLA_Norm1(), and FLA_Norm_inf().
00036 { 00037 FLA_Datatype datatype; 00038 int m_A, n_A, ldim_A; 00039 int i, j; 00040 00041 if ( FLA_Check_error_level() >= FLA_MIN_ERROR_CHECKING ) 00042 FLA_Max_abs_value_check( A, amax ); 00043 00044 m_A = FLA_Obj_length( A ); 00045 n_A = FLA_Obj_width( A ); 00046 ldim_A = FLA_Obj_ldim( A ); 00047 00048 datatype = FLA_Obj_datatype( A ); 00049 00050 switch ( datatype ){ 00051 00052 case FLA_FLOAT: 00053 { 00054 float *buff_A = ( float * ) FLA_FLOAT_PTR( A ); 00055 float *buff_amax = ( float * ) FLA_FLOAT_PTR( amax ); 00056 float curr_amax; 00057 float temp_amax; 00058 00059 // Initialize the search with the absolute value of the first element. 00060 curr_amax = ( float ) fabs( buff_A[0] ); 00061 00062 // Inspect each element, saving values in curr_amax that are larger than 00063 // the previous elements. 00064 for( j = 0; j < n_A; j++ ) 00065 { 00066 for( i = 0; i < m_A; i++ ) 00067 { 00068 temp_amax = ( float ) fabs( buff_A[ j * ldim_A + i ] ); 00069 00070 if ( curr_amax < temp_amax ) 00071 curr_amax = temp_amax; 00072 } 00073 } 00074 00075 // Copy the result into the amax object buffer. 00076 *buff_amax = curr_amax; 00077 00078 break; 00079 } 00080 00081 case FLA_DOUBLE: 00082 { 00083 double *buff_A = ( double * ) FLA_DOUBLE_PTR( A ); 00084 double *buff_amax = ( double * ) FLA_DOUBLE_PTR( amax ); 00085 double curr_amax; 00086 double temp_amax; 00087 00088 // Initialize the search with the absolute value of the first element. 00089 curr_amax = ( double ) fabs( buff_A[0] ); 00090 00091 // Inspect each element, saving values in curr_amax that are larger than 00092 // the previous elements. 00093 for( j = 0; j < n_A; j++ ) 00094 { 00095 for( i = 0; i < m_A; i++ ) 00096 { 00097 temp_amax = ( double ) fabs( buff_A[ j * ldim_A + i ] ); 00098 00099 if ( curr_amax < temp_amax ) 00100 curr_amax = temp_amax; 00101 } 00102 } 00103 00104 // Copy the result into the amax object buffer. 00105 *buff_amax = curr_amax; 00106 00107 00108 break; 00109 } 00110 00111 case FLA_COMPLEX: 00112 { 00113 scomplex *buff_A = ( scomplex * ) FLA_COMPLEX_PTR( A ); 00114 float *buff_amax = ( float * ) FLA_FLOAT_PTR( amax ); 00115 scomplex *curr_value; 00116 scomplex *temp_value; 00117 float curr_amax; 00118 float temp_amax; 00119 00120 curr_value = buff_A; 00121 00122 // Initialize the search with the absolute value of the first element. 00123 curr_amax = ( float ) sqrt( curr_value->real * curr_value->real + 00124 curr_value->imag * curr_value->imag ); 00125 00126 // Inspect each element, saving values in curr_amax that are larger than 00127 // the previous elements. 00128 for( j = 0; j < n_A; j++ ) 00129 { 00130 for( i = 0; i < m_A; i++ ) 00131 { 00132 temp_value = buff_A + j * ldim_A + i; 00133 00134 temp_amax = ( float ) sqrt( temp_value->real * temp_value->real + 00135 temp_value->imag * temp_value->imag ); 00136 00137 if ( curr_amax < temp_amax ) 00138 curr_amax = temp_amax; 00139 } 00140 } 00141 00142 // Copy the result into the amax object buffer. 00143 *buff_amax = curr_amax; 00144 00145 break; 00146 } 00147 00148 case FLA_DOUBLE_COMPLEX: 00149 { 00150 dcomplex *buff_A = ( dcomplex * ) FLA_DOUBLE_COMPLEX_PTR( A ); 00151 double *buff_amax = ( double * ) FLA_DOUBLE_PTR( amax ); 00152 dcomplex *curr_value; 00153 dcomplex *temp_value; 00154 double curr_amax; 00155 double temp_amax; 00156 00157 curr_value = buff_A; 00158 00159 // Initialize the search with the absolute value of the first element. 00160 curr_amax = ( double ) sqrt( curr_value->real * curr_value->real + 00161 curr_value->imag * curr_value->imag ); 00162 00163 // Inspect each element, saving values in curr_amax that are larger than 00164 // the previous elements. 00165 for( j = 0; j < n_A; j++ ) 00166 { 00167 for( i = 0; i < m_A; i++ ) 00168 { 00169 temp_value = buff_A + j * ldim_A + i; 00170 00171 temp_amax = ( double ) sqrt( temp_value->real * temp_value->real + 00172 temp_value->imag * temp_value->imag ); 00173 00174 if ( curr_amax < temp_amax ) 00175 curr_amax = temp_amax; 00176 } 00177 } 00178 00179 // Copy the result into the amax object buffer. 00180 *buff_amax = curr_amax; 00181 00182 break; 00183 } 00184 00185 } 00186 00187 return FLA_SUCCESS; 00188 }
void FLA_F2C() fla_max_abs_value_f | ( | F_INT * | A, | |
F_INT * | amax, | |||
F_INT * | IERROR | |||
) |
References FLA_Max_abs_value().
00192 { 00193 *IERROR = FLA_Max_abs_value( *( ( FLA_Obj * ) A ), 00194 *( ( FLA_Obj * ) amax ) ); 00195 }