Unpacking of the main and secondary diagonals of bidiagonal decomposition of matrix A. Input parameters: B - output of RMatrixBD subroutine. M - number of rows in matrix B. N - number of columns in matrix B. Output parameters: IsUpper - True, if the matrix is upper bidiagonal. otherwise IsUpper is False. D - the main diagonal.
| 2014 | Bochkanov Sergey |
| 2015 | *************************************************************************/ |
| 2016 | void rmatrixbdunpackdiagonals(const ap::real_2d_array& b, |
| 2017 | int m, |
| 2018 | int n, |
| 2019 | bool& isupper, |
| 2020 | ap::real_1d_array& d, |
| 2021 | ap::real_1d_array& e) |
| 2022 | { |
| 2023 | int i; |
| 2024 | |
| 2025 | isupper = m>=n; |
| 2026 | if( m<=0||n<=0 ) |
| 2027 | { |
| 2028 | return; |
| 2029 | } |
| 2030 | if( isupper ) |
| 2031 | { |
| 2032 | d.setlength(n); |
| 2033 | e.setlength(n); |
| 2034 | for(i = 0; i <= n-2; i++) |
| 2035 | { |
| 2036 | d(i) = b(i,i); |
| 2037 | e(i) = b(i,i+1); |
| 2038 | } |
| 2039 | d(n-1) = b(n-1,n-1); |
| 2040 | } |
| 2041 | else |
| 2042 | { |
| 2043 | d.setlength(m); |
| 2044 | e.setlength(m); |
| 2045 | for(i = 0; i <= m-2; i++) |
| 2046 | { |
| 2047 | d(i) = b(i,i); |
| 2048 | e(i) = b(i+1,i); |
| 2049 | } |
| 2050 | d(m-1) = b(m-1,m-1); |
| 2051 | } |
| 2052 | } |
| 2053 | |
| 2054 | |
| 2055 | /************************************************************************* |