dlarz.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /* dlarz.f -- translated by f2c (version 20061008).
  2. You must link the resulting object file with libf2c:
  3. on Microsoft Windows system, link with libf2c.lib;
  4. on Linux or Unix systems, link with .../path/to/libf2c.a -lm
  5. or, if you install libf2c.a in a standard place, with -lf2c -lm
  6. -- in that order, at the end of the command line, as in
  7. cc *.o -lf2c -lm
  8. Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
  9. http://www.netlib.org/f2c/libf2c.zip
  10. */
  11. #include "f2c.h"
  12. #include "blaswrap.h"
  13. /* Table of constant values */
  14. static integer c__1 = 1;
  15. static doublereal c_b5 = 1.;
  16. /* Subroutine */ int _starpu_dlarz_(char *side, integer *m, integer *n, integer *l,
  17. doublereal *v, integer *incv, doublereal *tau, doublereal *c__,
  18. integer *ldc, doublereal *work)
  19. {
  20. /* System generated locals */
  21. integer c_dim1, c_offset;
  22. doublereal d__1;
  23. /* Local variables */
  24. extern /* Subroutine */ int _starpu_dger_(integer *, integer *, doublereal *,
  25. doublereal *, integer *, doublereal *, integer *, doublereal *,
  26. integer *);
  27. extern logical _starpu_lsame_(char *, char *);
  28. extern /* Subroutine */ int _starpu_dgemv_(char *, integer *, integer *,
  29. doublereal *, doublereal *, integer *, doublereal *, integer *,
  30. doublereal *, doublereal *, integer *), _starpu_dcopy_(integer *,
  31. doublereal *, integer *, doublereal *, integer *), _starpu_daxpy_(integer
  32. *, doublereal *, doublereal *, integer *, doublereal *, integer *)
  33. ;
  34. /* -- LAPACK routine (version 3.2) -- */
  35. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  36. /* November 2006 */
  37. /* .. Scalar Arguments .. */
  38. /* .. */
  39. /* .. Array Arguments .. */
  40. /* .. */
  41. /* Purpose */
  42. /* ======= */
  43. /* DLARZ applies a real elementary reflector H to a real M-by-N */
  44. /* matrix C, from either the left or the right. H is represented in the */
  45. /* form */
  46. /* H = I - tau * v * v' */
  47. /* where tau is a real scalar and v is a real vector. */
  48. /* If tau = 0, then H is taken to be the unit matrix. */
  49. /* H is a product of k elementary reflectors as returned by DTZRZF. */
  50. /* Arguments */
  51. /* ========= */
  52. /* SIDE (input) CHARACTER*1 */
  53. /* = 'L': form H * C */
  54. /* = 'R': form C * H */
  55. /* M (input) INTEGER */
  56. /* The number of rows of the matrix C. */
  57. /* N (input) INTEGER */
  58. /* The number of columns of the matrix C. */
  59. /* L (input) INTEGER */
  60. /* The number of entries of the vector V containing */
  61. /* the meaningful part of the Householder vectors. */
  62. /* If SIDE = 'L', M >= L >= 0, if SIDE = 'R', N >= L >= 0. */
  63. /* V (input) DOUBLE PRECISION array, dimension (1+(L-1)*abs(INCV)) */
  64. /* The vector v in the representation of H as returned by */
  65. /* DTZRZF. V is not used if TAU = 0. */
  66. /* INCV (input) INTEGER */
  67. /* The increment between elements of v. INCV <> 0. */
  68. /* TAU (input) DOUBLE PRECISION */
  69. /* The value tau in the representation of H. */
  70. /* C (input/output) DOUBLE PRECISION array, dimension (LDC,N) */
  71. /* On entry, the M-by-N matrix C. */
  72. /* On exit, C is overwritten by the matrix H * C if SIDE = 'L', */
  73. /* or C * H if SIDE = 'R'. */
  74. /* LDC (input) INTEGER */
  75. /* The leading dimension of the array C. LDC >= max(1,M). */
  76. /* WORK (workspace) DOUBLE PRECISION array, dimension */
  77. /* (N) if SIDE = 'L' */
  78. /* or (M) if SIDE = 'R' */
  79. /* Further Details */
  80. /* =============== */
  81. /* Based on contributions by */
  82. /* A. Petitet, Computer Science Dept., Univ. of Tenn., Knoxville, USA */
  83. /* ===================================================================== */
  84. /* .. Parameters .. */
  85. /* .. */
  86. /* .. External Subroutines .. */
  87. /* .. */
  88. /* .. External Functions .. */
  89. /* .. */
  90. /* .. Executable Statements .. */
  91. /* Parameter adjustments */
  92. --v;
  93. c_dim1 = *ldc;
  94. c_offset = 1 + c_dim1;
  95. c__ -= c_offset;
  96. --work;
  97. /* Function Body */
  98. if (_starpu_lsame_(side, "L")) {
  99. /* Form H * C */
  100. if (*tau != 0.) {
  101. /* w( 1:n ) = C( 1, 1:n ) */
  102. _starpu_dcopy_(n, &c__[c_offset], ldc, &work[1], &c__1);
  103. /* w( 1:n ) = w( 1:n ) + C( m-l+1:m, 1:n )' * v( 1:l ) */
  104. _starpu_dgemv_("Transpose", l, n, &c_b5, &c__[*m - *l + 1 + c_dim1], ldc,
  105. &v[1], incv, &c_b5, &work[1], &c__1);
  106. /* C( 1, 1:n ) = C( 1, 1:n ) - tau * w( 1:n ) */
  107. d__1 = -(*tau);
  108. _starpu_daxpy_(n, &d__1, &work[1], &c__1, &c__[c_offset], ldc);
  109. /* C( m-l+1:m, 1:n ) = C( m-l+1:m, 1:n ) - ... */
  110. /* tau * v( 1:l ) * w( 1:n )' */
  111. d__1 = -(*tau);
  112. _starpu_dger_(l, n, &d__1, &v[1], incv, &work[1], &c__1, &c__[*m - *l + 1
  113. + c_dim1], ldc);
  114. }
  115. } else {
  116. /* Form C * H */
  117. if (*tau != 0.) {
  118. /* w( 1:m ) = C( 1:m, 1 ) */
  119. _starpu_dcopy_(m, &c__[c_offset], &c__1, &work[1], &c__1);
  120. /* w( 1:m ) = w( 1:m ) + C( 1:m, n-l+1:n, 1:n ) * v( 1:l ) */
  121. _starpu_dgemv_("No transpose", m, l, &c_b5, &c__[(*n - *l + 1) * c_dim1 +
  122. 1], ldc, &v[1], incv, &c_b5, &work[1], &c__1);
  123. /* C( 1:m, 1 ) = C( 1:m, 1 ) - tau * w( 1:m ) */
  124. d__1 = -(*tau);
  125. _starpu_daxpy_(m, &d__1, &work[1], &c__1, &c__[c_offset], &c__1);
  126. /* C( 1:m, n-l+1:n ) = C( 1:m, n-l+1:n ) - ... */
  127. /* tau * w( 1:m ) * v( 1:l )' */
  128. d__1 = -(*tau);
  129. _starpu_dger_(m, l, &d__1, &work[1], &c__1, &v[1], incv, &c__[(*n - *l +
  130. 1) * c_dim1 + 1], ldc);
  131. }
  132. }
  133. return 0;
  134. /* End of DLARZ */
  135. } /* _starpu_dlarz_ */