Application of a sequence of elementary rotations to a matrix The algorithm post-multiplies the matrix by a sequence of rotation transformations which is given by arrays C and S. Depending on the value of the IsForward parameter either 1 and 2, 3 and 4 and so on (if IsForward=true) rows are rotated, or the rows N and N-1, N-2 and N-3 and so on are rotated. Not the whole matrix but only a part o
| 189 | Utility subroutine. |
| 190 | *************************************************************************/ |
| 191 | void applyrotationsfromtheright(bool isforward, |
| 192 | int m1, |
| 193 | int m2, |
| 194 | int n1, |
| 195 | int n2, |
| 196 | const ap::real_1d_array& c, |
| 197 | const ap::real_1d_array& s, |
| 198 | ap::real_2d_array& a, |
| 199 | ap::real_1d_array& work) |
| 200 | { |
| 201 | int j; |
| 202 | int jp1; |
| 203 | double ctemp; |
| 204 | double stemp; |
| 205 | double temp; |
| 206 | |
| 207 | |
| 208 | // |
| 209 | // Form A * P' |
| 210 | // |
| 211 | if( isforward ) |
| 212 | { |
| 213 | if( m1!=m2 ) |
| 214 | { |
| 215 | |
| 216 | // |
| 217 | // Common case: M1<>M2 |
| 218 | // |
| 219 | for(j = n1; j <= n2-1; j++) |
| 220 | { |
| 221 | ctemp = c(j-n1+1); |
| 222 | stemp = s(j-n1+1); |
| 223 | if( ap::fp_neq(ctemp,1)||ap::fp_neq(stemp,0) ) |
| 224 | { |
| 225 | jp1 = j+1; |
| 226 | ap::vmove(&work(m1), 1, &a(m1, jp1), a.getstride(), ap::vlen(m1,m2), ctemp); |
| 227 | ap::vsub(&work(m1), 1, &a(m1, j), a.getstride(), ap::vlen(m1,m2), stemp); |
| 228 | ap::vmul(&a(m1, j), a.getstride(), ap::vlen(m1,m2), ctemp); |
| 229 | ap::vadd(&a(m1, j), a.getstride(), &a(m1, jp1), a.getstride(), ap::vlen(m1,m2), stemp); |
| 230 | ap::vmove(&a(m1, jp1), a.getstride(), &work(m1), 1, ap::vlen(m1,m2)); |
| 231 | } |
| 232 | } |
| 233 | } |
| 234 | else |
| 235 | { |
| 236 | |
| 237 | // |
| 238 | // Special case: M1=M2 |
| 239 | // |
| 240 | for(j = n1; j <= n2-1; j++) |
| 241 | { |
| 242 | ctemp = c(j-n1+1); |
| 243 | stemp = s(j-n1+1); |
| 244 | if( ap::fp_neq(ctemp,1)||ap::fp_neq(stemp,0) ) |
| 245 | { |
| 246 | temp = a(m1,j+1); |
| 247 | a(m1,j+1) = ctemp*temp-stemp*a(m1,j); |
| 248 | a(m1,j) = stemp*temp+ctemp*a(m1,j); |