libflame
revision_anchor
|
00001 /* 00002 00003 Copyright (C) 2014, The University of Texas at Austin 00004 00005 This file is part of libflame and is available under the 3-Clause 00006 BSD license, which can be found in the LICENSE file at the top-level 00007 directory, or at http://opensource.org/licenses/BSD-3-Clause 00008 00009 */ 00010 00011 FLA_Error FLA_Givens2( FLA_Obj chi_1, FLA_Obj chi_2, FLA_Obj gamma, FLA_Obj sigma, FLA_Obj chi_1_new ); 00012 FLA_Error FLA_Givens2_ops( float* chi_1, 00013 float* chi_2, 00014 float* gamma, 00015 float* sigma, 00016 float* chi_1_new ); 00017 FLA_Error FLA_Givens2_opd( double* chi_1, 00018 double* chi_2, 00019 double* gamma, 00020 double* sigma, 00021 double* chi_1_new ); 00022 #define MAC_Givens2_ops( chi_1, chi_2, gamma, sigma, chi_1_new ) \ 00023 { \ 00024 float chi_1_orig = *(chi_1); \ 00025 float chi_2_orig = *(chi_2); \ 00026 float g, s; \ 00027 float norm_x; \ 00028 \ 00029 norm_x = ( float ) sqrt( ( float ) ( chi_1_orig * chi_1_orig + \ 00030 chi_2_orig * chi_2_orig ) ); \ 00031 \ 00032 g = chi_1_orig / norm_x; \ 00033 s = chi_2_orig / norm_x; \ 00034 \ 00035 if ( fabs( chi_1_orig ) > fabs( chi_2_orig ) && g < 0.0F ) \ 00036 { \ 00037 g = -g; \ 00038 s = -s; \ 00039 norm_x = -norm_x; \ 00040 } \ 00041 \ 00042 *(gamma) = g; \ 00043 *(sigma) = s; \ 00044 *(chi_1_new) = norm_x; \ 00045 \ 00046 } 00047 00048 #define MAC_Givens2_opd( chi_1, chi_2, gamma, sigma, chi_1_new ) \ 00049 { \ 00050 double chi_1_orig = *(chi_1); \ 00051 double chi_2_orig = *(chi_2); \ 00052 double g, s; \ 00053 double norm_x; \ 00054 \ 00055 norm_x = ( double ) sqrt( chi_1_orig * chi_1_orig + \ 00056 chi_2_orig * chi_2_orig ); \ 00057 \ 00058 g = chi_1_orig / norm_x; \ 00059 s = chi_2_orig / norm_x; \ 00060 \ 00061 if ( fabs( chi_1_orig ) > fabs( chi_2_orig ) && g < 0.0 ) \ 00062 { \ 00063 g = -g; \ 00064 s = -s; \ 00065 norm_x = -norm_x; \ 00066 } \ 00067 \ 00068 *(gamma) = g; \ 00069 *(sigma) = s; \ 00070 *(chi_1_new) = norm_x; \ 00071 \ 00072 } 00073