Télécharger dlasr.eso

Retour à la liste

Numérotation des lignes :

dlasr
  1. C DLASR SOURCE FANDEUR 22/05/02 21:15:09 11359
  2. *> \brief \b DLASR applies a sequence of plane rotations to a general rectangular matrix.
  3. *
  4. * =========== DOCUMENTATION ===========
  5. *
  6. * Online html documentation available at
  7. * http://www.netlib.org/lapack/explore-html/
  8. *
  9. *> \htmlonly
  10. *> Download DLASR + dependencies
  11. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/dlasr.f">
  12. *> [TGZ]</a>
  13. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/dlasr.f">
  14. *> [ZIP]</a>
  15. *> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/dlasr.f">
  16. *> [TXT]</a>
  17. *> \endhtmlonly
  18. *
  19. * Definition:
  20. * ===========
  21. *
  22. * SUBROUTINE DLASR( SIDE, PIVOT, DIRECT, M, N, C, S, A, LDA )
  23. *
  24. * .. Scalar Arguments ..
  25. * CHARACTER DIRECT, PIVOT, SIDE
  26. * INTEGER LDA, M, N
  27. * ..
  28. * .. Array Arguments ..
  29. * REAL*8 A( LDA, * ), C( * ), S( * )
  30. * ..
  31. *
  32. *
  33. *> \par Purpose:
  34. * =============
  35. *>
  36. *> \verbatim
  37. *>
  38. *> DLASR applies a sequence of plane rotations to a real matrix A,
  39. *> from either the left or the right.
  40. *>
  41. *> When SIDE = 'L', the transformation takes the form
  42. *>
  43. *> A := P*A
  44. *>
  45. *> and when SIDE = 'R', the transformation takes the form
  46. *>
  47. *> A := A*P**T
  48. *>
  49. *> where P is an orthogonal matrix consisting of a sequence of z plane
  50. *> rotations, with z = M when SIDE = 'L' and z = N when SIDE = 'R',
  51. *> and P**T is the transpose of P.
  52. *>
  53. *> When DIRECT = 'F' (Forward sequence), then
  54. *>
  55. *> P = P(z-1) * ... * P(2) * P(1)
  56. *>
  57. *> and when DIRECT = 'B' (Backward sequence), then
  58. *>
  59. *> P = P(1) * P(2) * ... * P(z-1)
  60. *>
  61. *> where P(k) is a plane rotation matrix defined by the 2-by-2 rotation
  62. *>
  63. *> R(k) = ( c(k) s(k) )
  64. *> = ( -s(k) c(k) ).
  65. *>
  66. *> When PIVOT = 'V' (Variable pivot), the rotation is performed
  67. *> for the plane (k,k+1), i.e., P(k) has the form
  68. *>
  69. *> P(k) = ( 1 )
  70. *> ( ... )
  71. *> ( 1 )
  72. *> ( c(k) s(k) )
  73. *> ( -s(k) c(k) )
  74. *> ( 1 )
  75. *> ( ... )
  76. *> ( 1 )
  77. *>
  78. *> where R(k) appears as a rank-2 modification to the identity matrix in
  79. *> rows and columns k and k+1.
  80. *>
  81. *> When PIVOT = 'T' (Top pivot), the rotation is performed for the
  82. *> plane (1,k+1), so P(k) has the form
  83. *>
  84. *> P(k) = ( c(k) s(k) )
  85. *> ( 1 )
  86. *> ( ... )
  87. *> ( 1 )
  88. *> ( -s(k) c(k) )
  89. *> ( 1 )
  90. *> ( ... )
  91. *> ( 1 )
  92. *>
  93. *> where R(k) appears in rows and columns 1 and k+1.
  94. *>
  95. *> Similarly, when PIVOT = 'B' (Bottom pivot), the rotation is
  96. *> performed for the plane (k,z), giving P(k) the form
  97. *>
  98. *> P(k) = ( 1 )
  99. *> ( ... )
  100. *> ( 1 )
  101. *> ( c(k) s(k) )
  102. *> ( 1 )
  103. *> ( ... )
  104. *> ( 1 )
  105. *> ( -s(k) c(k) )
  106. *>
  107. *> where R(k) appears in rows and columns k and z. The rotations are
  108. *> performed without ever forming P(k) explicitly.
  109. *> \endverbatim
  110. *
  111. * Arguments:
  112. * ==========
  113. *
  114. *> \param[in] SIDE
  115. *> \verbatim
  116. *> SIDE is CHARACTER*1
  117. *> Specifies whether the plane rotation matrix P is applied to
  118. *> A on the left or the right.
  119. *> = 'L': Left, compute A := P*A
  120. *> = 'R': Right, compute A:= A*P**T
  121. *> \endverbatim
  122. *>
  123. *> \param[in] PIVOT
  124. *> \verbatim
  125. *> PIVOT is CHARACTER*1
  126. *> Specifies the plane for which P(k) is a plane rotation
  127. *> matrix.
  128. *> = 'V': Variable pivot, the plane (k,k+1)
  129. *> = 'T': Top pivot, the plane (1,k+1)
  130. *> = 'B': Bottom pivot, the plane (k,z)
  131. *> \endverbatim
  132. *>
  133. *> \param[in] DIRECT
  134. *> \verbatim
  135. *> DIRECT is CHARACTER*1
  136. *> Specifies whether P is a forward or backward sequence of
  137. *> plane rotations.
  138. *> = 'F': Forward, P = P(z-1)*...*P(2)*P(1)
  139. *> = 'B': Backward, P = P(1)*P(2)*...*P(z-1)
  140. *> \endverbatim
  141. *>
  142. *> \param[in] M
  143. *> \verbatim
  144. *> M is INTEGER
  145. *> The number of rows of the matrix A. If m <= 1, an immediate
  146. *> return is effected.
  147. *> \endverbatim
  148. *>
  149. *> \param[in] N
  150. *> \verbatim
  151. *> N is INTEGER
  152. *> The number of columns of the matrix A. If n <= 1, an
  153. *> immediate return is effected.
  154. *> \endverbatim
  155. *>
  156. *> \param[in] C
  157. *> \verbatim
  158. *> C is DOUBLE PRECISION array, dimension
  159. *> (M-1) if SIDE = 'L'
  160. *> (N-1) if SIDE = 'R'
  161. *> The cosines c(k) of the plane rotations.
  162. *> \endverbatim
  163. *>
  164. *> \param[in] S
  165. *> \verbatim
  166. *> S is DOUBLE PRECISION array, dimension
  167. *> (M-1) if SIDE = 'L'
  168. *> (N-1) if SIDE = 'R'
  169. *> The sines s(k) of the plane rotations. The 2-by-2 plane
  170. *> rotation part of the matrix P(k), R(k), has the form
  171. *> R(k) = ( c(k) s(k) )
  172. *> ( -s(k) c(k) ).
  173. *> \endverbatim
  174. *>
  175. *> \param[in,out] A
  176. *> \verbatim
  177. *> A is DOUBLE PRECISION array, dimension (LDA,N)
  178. *> The M-by-N matrix A. On exit, A is overwritten by P*A if
  179. *> SIDE = 'R' or by A*P**T if SIDE = 'L'.
  180. *> \endverbatim
  181. *>
  182. *> \param[in] LDA
  183. *> \verbatim
  184. *> LDA is INTEGER
  185. *> The leading dimension of the array A. LDA >= max(1,M).
  186. *> \endverbatim
  187. *
  188. * Authors:
  189. * ========
  190. *
  191. *> \author Univ. of Tennessee
  192. *> \author Univ. of California Berkeley
  193. *> \author Univ. of Colorado Denver
  194. *> \author NAG Ltd.
  195. *
  196. *> \date December 2016
  197. *
  198. *> \ingroup OTHERauxiliary
  199. *
  200. * =====================================================================
  201. SUBROUTINE DLASR( SIDE, PIVOT, DIRECT, M, N, C, S, A, LDA )
  202. *
  203. * -- LAPACK auxiliary routine (version 3.7.0) --
  204. * -- LAPACK is a software package provided by Univ. of Tennessee, --
  205. * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
  206. * December 2016
  207. *
  208. * .. Scalar Arguments ..
  209. CHARACTER DIRECT, PIVOT, SIDE
  210. INTEGER LDA, M, N
  211. * ..
  212. * .. Array Arguments ..
  213. REAL*8 A( LDA, * ), C( * ), S( * )
  214. * ..
  215. *
  216. * =====================================================================
  217. *
  218. * .. Parameters ..
  219. REAL*8 ONE, ZERO
  220. PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 )
  221. * ..
  222. * .. Local Scalars ..
  223. INTEGER I, INFO, J
  224. REAL*8 CTEMP, STEMP, TEMP
  225. * ..
  226. * .. External Functions ..
  227. LOGICAL LSAME
  228. EXTERNAL LSAME
  229. * ..
  230. * .. External Subroutines ..
  231. EXTERNAL XERBLA
  232. * ..
  233. ** .. Intrinsic Functions ..
  234. * INTRINSIC MAX
  235. ** ..
  236. ** .. Executable Statements ..
  237. *
  238. * Test the input parameters
  239. *
  240. INFO = 0
  241. IF( .NOT.( LSAME( SIDE, 'L' ) .OR.
  242. & LSAME( SIDE, 'R' ) ) ) THEN
  243. INFO = 1
  244. ELSE IF( .NOT.( LSAME( PIVOT, 'V' ) .OR.
  245. & LSAME( PIVOT, 'T' ) .OR.
  246. & LSAME( PIVOT, 'B' ) ) ) THEN
  247. INFO = 2
  248. ELSE IF( .NOT.( LSAME( DIRECT, 'F' ) .OR.
  249. & LSAME( DIRECT, 'B' ) ) )
  250. $ THEN
  251. INFO = 3
  252. ELSE IF( M.LT.0 ) THEN
  253. INFO = 4
  254. ELSE IF( N.LT.0 ) THEN
  255. INFO = 5
  256. ELSE IF( LDA.LT.MAX( 1, M ) ) THEN
  257. INFO = 9
  258. END IF
  259. IF( INFO.NE.0 ) THEN
  260. CALL XERBLA( 'DLASR ', INFO )
  261. RETURN
  262. END IF
  263. *
  264. * Quick return if possible
  265. *
  266. IF( ( M.EQ.0 ) .OR. ( N.EQ.0 ) )
  267. $ RETURN
  268. IF( LSAME( SIDE, 'L' ) ) THEN
  269. *
  270. * Form P * A
  271. *
  272. IF( LSAME( PIVOT, 'V' ) ) THEN
  273. IF( LSAME( DIRECT, 'F' ) ) THEN
  274. DO 20 J = 1, M - 1
  275. CTEMP = C( J )
  276. STEMP = S( J )
  277. IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
  278. DO 10 I = 1, N
  279. TEMP = A( J+1, I )
  280. A( J+1, I ) = CTEMP*TEMP - STEMP*A( J, I )
  281. A( J, I ) = STEMP*TEMP + CTEMP*A( J, I )
  282. 10 CONTINUE
  283. END IF
  284. 20 CONTINUE
  285. ELSE IF( LSAME( DIRECT, 'B' ) ) THEN
  286. DO 40 J = M - 1, 1, -1
  287. CTEMP = C( J )
  288. STEMP = S( J )
  289. IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
  290. DO 30 I = 1, N
  291. TEMP = A( J+1, I )
  292. A( J+1, I ) = CTEMP*TEMP - STEMP*A( J, I )
  293. A( J, I ) = STEMP*TEMP + CTEMP*A( J, I )
  294. 30 CONTINUE
  295. END IF
  296. 40 CONTINUE
  297. END IF
  298. ELSE IF( LSAME( PIVOT, 'T' ) ) THEN
  299. IF( LSAME( DIRECT, 'F' ) ) THEN
  300. DO 60 J = 2, M
  301. CTEMP = C( J-1 )
  302. STEMP = S( J-1 )
  303. IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
  304. DO 50 I = 1, N
  305. TEMP = A( J, I )
  306. A( J, I ) = CTEMP*TEMP - STEMP*A( 1, I )
  307. A( 1, I ) = STEMP*TEMP + CTEMP*A( 1, I )
  308. 50 CONTINUE
  309. END IF
  310. 60 CONTINUE
  311. ELSE IF( LSAME( DIRECT, 'B' ) ) THEN
  312. DO 80 J = M, 2, -1
  313. CTEMP = C( J-1 )
  314. STEMP = S( J-1 )
  315. IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
  316. DO 70 I = 1, N
  317. TEMP = A( J, I )
  318. A( J, I ) = CTEMP*TEMP - STEMP*A( 1, I )
  319. A( 1, I ) = STEMP*TEMP + CTEMP*A( 1, I )
  320. 70 CONTINUE
  321. END IF
  322. 80 CONTINUE
  323. END IF
  324. ELSE IF( LSAME( PIVOT, 'B' ) ) THEN
  325. IF( LSAME( DIRECT, 'F' ) ) THEN
  326. DO 100 J = 1, M - 1
  327. CTEMP = C( J )
  328. STEMP = S( J )
  329. IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
  330. DO 90 I = 1, N
  331. TEMP = A( J, I )
  332. A( J, I ) = STEMP*A( M, I ) + CTEMP*TEMP
  333. A( M, I ) = CTEMP*A( M, I ) - STEMP*TEMP
  334. 90 CONTINUE
  335. END IF
  336. 100 CONTINUE
  337. ELSE IF( LSAME( DIRECT, 'B' ) ) THEN
  338. DO 120 J = M - 1, 1, -1
  339. CTEMP = C( J )
  340. STEMP = S( J )
  341. IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
  342. DO 110 I = 1, N
  343. TEMP = A( J, I )
  344. A( J, I ) = STEMP*A( M, I ) + CTEMP*TEMP
  345. A( M, I ) = CTEMP*A( M, I ) - STEMP*TEMP
  346. 110 CONTINUE
  347. END IF
  348. 120 CONTINUE
  349. END IF
  350. END IF
  351. ELSE IF( LSAME( SIDE, 'R' ) ) THEN
  352. *
  353. * Form A * P**T
  354. *
  355. IF( LSAME( PIVOT, 'V' ) ) THEN
  356. IF( LSAME( DIRECT, 'F' ) ) THEN
  357. DO 140 J = 1, N - 1
  358. CTEMP = C( J )
  359. STEMP = S( J )
  360. IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
  361. DO 130 I = 1, M
  362. TEMP = A( I, J+1 )
  363. A( I, J+1 ) = CTEMP*TEMP - STEMP*A( I, J )
  364. A( I, J ) = STEMP*TEMP + CTEMP*A( I, J )
  365. 130 CONTINUE
  366. END IF
  367. 140 CONTINUE
  368. ELSE IF( LSAME( DIRECT, 'B' ) ) THEN
  369. DO 160 J = N - 1, 1, -1
  370. CTEMP = C( J )
  371. STEMP = S( J )
  372. IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
  373. DO 150 I = 1, M
  374. TEMP = A( I, J+1 )
  375. A( I, J+1 ) = CTEMP*TEMP - STEMP*A( I, J )
  376. A( I, J ) = STEMP*TEMP + CTEMP*A( I, J )
  377. 150 CONTINUE
  378. END IF
  379. 160 CONTINUE
  380. END IF
  381. ELSE IF( LSAME( PIVOT, 'T' ) ) THEN
  382. IF( LSAME( DIRECT, 'F' ) ) THEN
  383. DO 180 J = 2, N
  384. CTEMP = C( J-1 )
  385. STEMP = S( J-1 )
  386. IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
  387. DO 170 I = 1, M
  388. TEMP = A( I, J )
  389. A( I, J ) = CTEMP*TEMP - STEMP*A( I, 1 )
  390. A( I, 1 ) = STEMP*TEMP + CTEMP*A( I, 1 )
  391. 170 CONTINUE
  392. END IF
  393. 180 CONTINUE
  394. ELSE IF( LSAME( DIRECT, 'B' ) ) THEN
  395. DO 200 J = N, 2, -1
  396. CTEMP = C( J-1 )
  397. STEMP = S( J-1 )
  398. IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
  399. DO 190 I = 1, M
  400. TEMP = A( I, J )
  401. A( I, J ) = CTEMP*TEMP - STEMP*A( I, 1 )
  402. A( I, 1 ) = STEMP*TEMP + CTEMP*A( I, 1 )
  403. 190 CONTINUE
  404. END IF
  405. 200 CONTINUE
  406. END IF
  407. ELSE IF( LSAME( PIVOT, 'B' ) ) THEN
  408. IF( LSAME( DIRECT, 'F' ) ) THEN
  409. DO 220 J = 1, N - 1
  410. CTEMP = C( J )
  411. STEMP = S( J )
  412. IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
  413. DO 210 I = 1, M
  414. TEMP = A( I, J )
  415. A( I, J ) = STEMP*A( I, N ) + CTEMP*TEMP
  416. A( I, N ) = CTEMP*A( I, N ) - STEMP*TEMP
  417. 210 CONTINUE
  418. END IF
  419. 220 CONTINUE
  420. ELSE IF( LSAME( DIRECT, 'B' ) ) THEN
  421. DO 240 J = N - 1, 1, -1
  422. CTEMP = C( J )
  423. STEMP = S( J )
  424. IF( ( CTEMP.NE.ONE ) .OR. ( STEMP.NE.ZERO ) ) THEN
  425. DO 230 I = 1, M
  426. TEMP = A( I, J )
  427. A( I, J ) = STEMP*A( I, N ) + CTEMP*TEMP
  428. A( I, N ) = CTEMP*A( I, N ) - STEMP*TEMP
  429. 230 CONTINUE
  430. END IF
  431. 240 CONTINUE
  432. END IF
  433. END IF
  434. END IF
  435. *
  436. RETURN
  437. *
  438. * End of DLASR
  439. *
  440. END
  441.  
  442.  
  443.  
  444.  

© Cast3M 2003 - Tous droits réservés.
Mentions légales