/src/lib/libqt/lapack_intfc.cc

https://gitlab.com/y-shao/psi4public · C++ · 20287 lines · 1308 code · 190 blank · 18789 comment · 0 complexity · 5f62f5e55b7d33b0f1c546d75ddc1322 MD5 · raw file

  1. /*
  2. *@BEGIN LICENSE
  3. *
  4. * PSI4: an ab initio quantum chemistry software package
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. *@END LICENSE
  21. */
  22. /**!
  23. ** \file
  24. ** \brief Interface to all LAPACK routines
  25. ** \ingroup QT
  26. **
  27. ** Autogenerated by Rob Parrish on 1/23/2011
  28. **
  29. */
  30. #include "qt.h"
  31. #include "lapack_intfc_mangle.h"
  32. extern "C" {
  33. extern int F_DBDSDC(char*, char*, int*, double*, double*, double*, int*, double*, int*, double*, int*, double*, int*, int*);
  34. extern int F_DBDSQR(char*, int*, int*, int*, int*, double*, double*, double*, int*, double*, int*, double*, int*, double*, int*);
  35. extern int F_DDISNA(char*, int*, int*, double*, double*, int*);
  36. extern int F_DGBBRD(char*, int*, int*, int*, int*, int*, double*, int*, double*, double*, double*, int*, double*, int*, double*, int*, double*, int*);
  37. extern int F_DGBCON(char*, int*, int*, int*, double*, int*, int*, double*, double*, double*, int*, int*);
  38. extern int F_DGBEQU(int*, int*, int*, int*, double*, int*, double*, double*, double*, double*, double*, int*);
  39. extern int F_DGBRFS(char*, int*, int*, int*, int*, double*, int*, double*, int*, int*, double*, int*, double*, int*, double*, double*, double*, int*, int*);
  40. extern int F_DGBSV(int*, int*, int*, int*, double*, int*, int*, double*, int*, int*);
  41. extern int F_DGBSVX(char*, char*, int*, int*, int*, int*, double*, int*, double*, int*, int*, char*, double*, double*, double*, int*, double*, int*, double*, double*, double*, double*, int*, int*);
  42. extern int F_DGBTRF(int*, int*, int*, int*, double*, int*, int*, int*);
  43. extern int F_DGBTRS(char*, int*, int*, int*, int*, double*, int*, int*, double*, int*, int*);
  44. extern int F_DGEBAK(char*, char*, int*, int*, int*, double*, int*, double*, int*, int*);
  45. extern int F_DGEBAL(char*, int*, double*, int*, int*, int*, double*, int*);
  46. extern int F_DGEBRD(int*, int*, double*, int*, double*, double*, double*, double*, double*, int*, int*);
  47. extern int F_DGECON(char*, int*, double*, int*, double*, double*, double*, int*, int*);
  48. extern int F_DGEEQU(int*, int*, double*, int*, double*, double*, double*, double*, double*, int*);
  49. extern int F_DGEES(char*, char*, int*, double*, int*, int*, double*, double*, double*, int*, double*, int*, int*);
  50. extern int F_DGEESX(char*, char*, char*, int*, double*, int*, int*, double*, double*, double*, int*, double*, double*, double*, int*, int*, int*, int*);
  51. extern int F_DGEEV(char*, char*, int*, double*, int*, double*, double*, double*, int*, double*, int*, double*, int*, int*);
  52. extern int F_DGEEVX(char*, char*, char*, char*, int*, double*, int*, double*, double*, double*, int*, double*, int*, int*, int*, double*, double*, double*, double*, double*, int*, int*, int*);
  53. extern int F_DGEGS(char*, char*, int*, double*, int*, double*, int*, double*, double*, double*, double*, int*, double*, int*, double*, int*, int*);
  54. extern int F_DGEGV(char*, char*, int*, double*, int*, double*, int*, double*, double*, double*, double*, int*, double*, int*, double*, int*, int*);
  55. extern int F_DGEHRD(int*, int*, int*, double*, int*, double*, double*, int*, int*);
  56. extern int F_DGELQF(int*, int*, double*, int*, double*, double*, int*, int*);
  57. extern int F_DGELS(char*, int*, int*, int*, double*, int*, double*, int*, double*, int*, int*);
  58. extern int F_DGELSD(int*, int*, int*, double*, int*, double*, int*, double*, double*, int*, double*, int*, int*, int*);
  59. extern int F_DGELSS(int*, int*, int*, double*, int*, double*, int*, double*, double*, int*, double*, int*, int*);
  60. extern int F_DGELSX(int*, int*, int*, double*, int*, double*, int*, int*, double*, int*, double*, int*);
  61. extern int F_DGELSY(int*, int*, int*, double*, int*, double*, int*, int*, double*, int*, double*, int*, int*);
  62. extern int F_DGEQLF(int*, int*, double*, int*, double*, double*, int*, int*);
  63. extern int F_DGEQP3(int*, int*, double*, int*, int*, double*, double*, int*, int*);
  64. extern int F_DGEQPF(int*, int*, double*, int*, int*, double*, double*, int*);
  65. extern int F_DGEQRF(int*, int*, double*, int*, double*, double*, int*, int*);
  66. extern int F_DGERFS(char*, int*, int*, double*, int*, double*, int*, int*, double*, int*, double*, int*, double*, double*, double*, int*, int*);
  67. extern int F_DGERQF(int*, int*, double*, int*, double*, double*, int*, int*);
  68. extern int F_DGESDD(char*, int*, int*, double*, int*, double*, double*, int*, double*, int*, double*, int*, int*, int*);
  69. extern int F_DGESV(int*, int*, double*, int*, int*, double*, int*, int*);
  70. extern int F_DGESVX(char*, char*, int*, int*, double*, int*, double*, int*, int*, char*, double*, double*, double*, int*, double*, int*, double*, double*, double*, double*, int*, int*);
  71. extern int F_DGETRF(int*, int*, double*, int*, int*, int*);
  72. extern int F_DGETRI(int*, double*, int*, int*, double*, int*, int*);
  73. extern int F_DGETRS(char*, int*, int*, double*, int*, int*, double*, int*, int*);
  74. extern int F_DGGBAK(char*, char*, int*, int*, int*, double*, double*, int*, double*, int*, int*);
  75. extern int F_DGGBAL(char*, int*, double*, int*, double*, int*, int*, int*, double*, double*, double*, int*);
  76. extern int F_DGGES(char*, char*, char*, int*, double*, int*, double*, int*, int*, double*, double*, double*, double*, int*, double*, int*, double*, int*, int*);
  77. extern int F_DGGESX(char*, char*, char*, char*, int*, double*, int*, double*, int*, int*, double*, double*, double*, double*, int*, double*, int*, double*, double*, double*, int*, int*, int*, int*);
  78. extern int F_DGGEV(char*, char*, int*, double*, int*, double*, int*, double*, double*, double*, double*, int*, double*, int*, double*, int*, int*);
  79. extern int F_DGGEVX(char*, char*, char*, char*, int*, double*, int*, double*, int*, double*, double*, double*, double*, int*, double*, int*, int*, int*, double*, double*, double*, double*, double*, double*, double*, int*, int*, int*);
  80. extern int F_DGGGLM(int*, int*, int*, double*, int*, double*, int*, double*, double*, double*, double*, int*, int*);
  81. extern int F_DGGHRD(char*, char*, int*, int*, int*, double*, int*, double*, int*, double*, int*, double*, int*, int*);
  82. extern int F_DGGLSE(int*, int*, int*, double*, int*, double*, int*, double*, double*, double*, double*, int*, int*);
  83. extern int F_DGGQRF(int*, int*, int*, double*, int*, double*, double*, int*, double*, double*, int*, int*);
  84. extern int F_DGGRQF(int*, int*, int*, double*, int*, double*, double*, int*, double*, double*, int*, int*);
  85. extern int F_DGGSVD(char*, char*, char*, int*, int*, int*, int*, int*, double*, int*, double*, int*, double*, double*, double*, int*, double*, int*, double*, int*, double*, int*, int*);
  86. extern int F_DGGSVP(char*, char*, char*, int*, int*, int*, double*, int*, double*, int*, double*, double*, int*, int*, double*, int*, double*, int*, double*, int*, int*, double*, double*, int*);
  87. extern int F_DGTCON(char*, int*, double*, double*, double*, double*, int*, double*, double*, double*, int*, int*);
  88. extern int F_DGTRFS(char*, int*, int*, double*, double*, double*, double*, double*, double*, double*, int*, double*, int*, double*, int*, double*, double*, double*, int*, int*);
  89. extern int F_DGTSV(int*, int*, double*, double*, double*, double*, int*, int*);
  90. extern int F_DGTSVX(char*, char*, int*, int*, double*, double*, double*, double*, double*, double*, double*, int*, double*, int*, double*, int*, double*, int*);
  91. extern int F_DGTTRF(int*, double*, double*, double*, double*, int*, int*);
  92. extern int F_DGTTRS(char*, int*, int*, double*, double*, double*, double*, int*, double*, int*, int*);
  93. extern int F_DHGEQZ(char*, char*, char*, int*, int*, int*, double*, int*, double*, int*, double*, double*, double*, double*, int*, double*, int*, double*, int*, int*);
  94. extern int F_DHSEIN(char*, char*, char*, int*, double*, int*, double*, double*, double*, int*, double*, int*, int*, int*, double*, int*, int*, int*);
  95. extern int F_DHSEQR(char*, char*, int*, int*, int*, double*, int*, double*, double*, double*, int*, double*, int*, int*);
  96. extern int F_DOPGTR(char*, int*, double*, double*, double*, int*, double*, int*);
  97. extern int F_DOPMTR(char*, char*, char*, int*, int*, double*, double*, double*, int*, double*, int*);
  98. extern int F_DORGBR(char*, int*, int*, int*, double*, int*, double*, double*, int*, int*);
  99. extern int F_DORGHR(int*, int*, int*, double*, int*, double*, double*, int*, int*);
  100. extern int F_DORGLQ(int*, int*, int*, double*, int*, double*, double*, int*, int*);
  101. extern int F_DORGQL(int*, int*, int*, double*, int*, double*, double*, int*, int*);
  102. extern int F_DORGQR(int*, int*, int*, double*, int*, double*, double*, int*, int*);
  103. extern int F_DORGRQ(int*, int*, int*, double*, int*, double*, double*, int*, int*);
  104. extern int F_DORGTR(char*, int*, double*, int*, double*, double*, int*, int*);
  105. extern int F_DORMBR(char*, char*, char*, int*, int*, int*, double*, int*, double*, double*, int*, double*, int*, int*);
  106. extern int F_DORMHR(char*, char*, int*, int*, int*, int*, double*, int*, double*, double*, int*, double*, int*, int*);
  107. extern int F_DORMLQ(char*, char*, int*, int*, int*, double*, int*, double*, double*, int*, double*, int*, int*);
  108. extern int F_DORMQL(char*, char*, int*, int*, int*, double*, int*, double*, double*, int*, double*, int*, int*);
  109. extern int F_DORMQR(char*, char*, int*, int*, int*, double*, int*, double*, double*, int*, double*, int*, int*);
  110. extern int F_DORMR3(char*, char*, int*, int*, int*, int*, double*, int*, double*, double*, int*, double*, int*);
  111. extern int F_DORMRQ(char*, char*, int*, int*, int*, double*, int*, double*, double*, int*, double*, int*, int*);
  112. extern int F_DORMRZ(char*, char*, int*, int*, int*, int*, double*, int*, double*, double*, int*, double*, int*, int*);
  113. extern int F_DORMTR(char*, char*, char*, int*, int*, double*, int*, double*, double*, int*, double*, int*, int*);
  114. extern int F_DPBCON(char*, int*, int*, double*, int*, double*, double*, double*, int*, int*);
  115. extern int F_DPBEQU(char*, int*, int*, double*, int*, double*, double*, double*, int*);
  116. extern int F_DPBRFS(char*, int*, int*, int*, double*, int*, double*, int*, double*, int*, double*, int*, double*, double*, double*, int*, int*);
  117. extern int F_DPBSTF(char*, int*, int*, double*, int*, int*);
  118. extern int F_DPBSV(char*, int*, int*, int*, double*, int*, double*, int*, int*);
  119. extern int F_DPBSVX(char*, char*, int*, int*, int*, double*, int*, double*, int*, char*, double*, double*, int*, double*, int*, double*, double*, double*, double*, int*, int*);
  120. extern int F_DPBTRF(char*, int*, int*, double*, int*, int*);
  121. extern int F_DPBTRS(char*, int*, int*, int*, double*, int*, double*, int*, int*);
  122. extern int F_DPOCON(char*, int*, double*, int*, double*, double*, double*, int*, int*);
  123. extern int F_DPOEQU(int*, double*, int*, double*, double*, double*, int*);
  124. extern int F_DPORFS(char*, int*, int*, double*, int*, double*, int*, double*, int*, double*, int*, double*, double*, double*, int*, int*);
  125. extern int F_DPOSV(char*, int*, int*, double*, int*, double*, int*, int*);
  126. extern int F_DPOSVX(char*, char*, int*, int*, double*, int*, double*, int*, char*, double*, double*, int*, double*, int*, double*, double*, double*, double*, int*, int*);
  127. extern int F_DPOTRF(char*, int*, double*, int*, int*);
  128. extern int F_DPOTRI(char*, int*, double*, int*, int*);
  129. extern int F_DPOTRS(char*, int*, int*, double*, int*, double*, int*, int*);
  130. extern int F_DPPCON(char*, int*, double*, double*, double*, double*, int*, int*);
  131. extern int F_DPPEQU(char*, int*, double*, double*, double*, double*, int*);
  132. extern int F_DPPRFS(char*, int*, int*, double*, double*, double*, int*, double*, int*, double*, double*, double*, int*, int*);
  133. extern int F_DPPSV(char*, int*, int*, double*, double*, int*, int*);
  134. extern int F_DPPSVX(char*, char*, int*, int*, double*, double*, char*, double*, double*, int*, double*, int*, double*, double*, double*, double*, int*, int*);
  135. extern int F_DPPTRF(char*, int*, double*, int*);
  136. extern int F_DPPTRI(char*, int*, double*, int*);
  137. extern int F_DPPTRS(char*, int*, int*, double*, double*, int*, int*);
  138. extern int F_DPTCON(int*, double*, double*, double*, double*, double*, int*);
  139. extern int F_DPTEQR(char*, int*, double*, double*, double*, int*, double*, int*);
  140. extern int F_DPTRFS(int*, int*, double*, double*, double*, double*, double*, int*, double*, int*, double*, double*, double*, int*);
  141. extern int F_DPTSV(int*, int*, double*, double*, double*, int*, int*);
  142. extern int F_DPTSVX(char*, int*, int*, double*, double*, double*, double*, double*, int*, double*, int*, double*, double*, double*, double*, int*);
  143. extern int F_DPTTRF(int*, double*, double*, int*);
  144. extern int F_DPTTRS(int*, int*, double*, double*, double*, int*, int*);
  145. extern int F_DSBEV(char*, char*, int*, int*, double*, int*, double*, double*, int*, double*, int*);
  146. extern int F_DSBEVD(char*, char*, int*, int*, double*, int*, double*, double*, int*, double*, int*, int*, int*, int*);
  147. extern int F_DSBEVX(char*, char*, char*, int*, int*, double*, int*, double*, int*, double*, double*, int*, int*, double*, int*, double*, double*, int*, double*, int*, int*, int*);
  148. extern int F_DSBGST(char*, char*, int*, int*, int*, double*, int*, double*, int*, double*, int*, double*, int*);
  149. extern int F_DSBGV(char*, char*, int*, int*, int*, double*, int*, double*, int*, double*, double*, int*, double*, int*);
  150. extern int F_DSBGVD(char*, char*, int*, int*, int*, double*, int*, double*, int*, double*, double*, int*, double*, int*, int*, int*, int*);
  151. extern int F_DSBGVX(char*, char*, char*, int*, int*, int*, double*, int*, double*, int*, double*, int*, double*, double*, int*, int*, double*, int*, double*, double*, int*, double*, int*, int*, int*);
  152. extern int F_DSBTRD(char*, char*, int*, int*, double*, int*, double*, double*, double*, int*, double*, int*);
  153. extern int F_DSGESV(int*, int*, double*, int*, int*, double*, int*, double*, int*, double*, int*, int*);
  154. extern int F_DSPCON(char*, int*, double*, int*, double*, double*, double*, int*, int*);
  155. extern int F_DSPEV(char*, char*, int*, double*, double*, double*, int*, double*, int*);
  156. extern int F_DSPEVD(char*, char*, int*, double*, double*, double*, int*, double*, int*, int*, int*, int*);
  157. extern int F_DSPEVX(char*, char*, char*, int*, double*, double*, double*, int*, int*, double*, int*, double*, double*, int*, double*, int*, int*, int*);
  158. extern int F_DSPGST(int*, char*, int*, double*, double*, int*);
  159. extern int F_DSPGV(int*, char*, char*, int*, double*, double*, double*, double*, int*, double*, int*);
  160. extern int F_DSPGVD(int*, char*, char*, int*, double*, double*, double*, double*, int*, double*, int*, int*, int*, int*);
  161. extern int F_DSPGVX(int*, char*, char*, char*, int*, double*, double*, double*, double*, int*, int*, double*, int*, double*, double*, int*, double*, int*, int*, int*);
  162. extern int F_DSPRFS(char*, int*, int*, double*, double*, int*, double*, int*, double*, int*, double*, double*, double*, int*, int*);
  163. extern int F_DSPSV(char*, int*, int*, double*, int*, double*, int*, int*);
  164. extern int F_DSPSVX(char*, char*, int*, int*, double*, double*, int*, double*, int*, double*, int*, double*, int*);
  165. extern int F_DSPTRD(char*, int*, double*, double*, double*, double*, int*);
  166. extern int F_DSPTRF(char*, int*, double*, int*, int*);
  167. extern int F_DSPTRI(char*, int*, double*, int*, double*, int*);
  168. extern int F_DSPTRS(char*, int*, int*, double*, int*, double*, int*, int*);
  169. extern int F_DSTEBZ(char*, char*, int*, double*, double*, int*, int*, double*, double*, double*, int*, int*, double*, int*, int*, double*, int*, int*);
  170. extern int F_DSTEDC(char*, int*, double*, double*, double*, int*, double*, int*, int*, int*, int*);
  171. extern int F_DSTEGR(char*, char*, int*, double*, double*, double*, double*, int*, int*, double*, int*, double*, double*, int*, int*, double*, int*, int*, int*, int*);
  172. extern int F_DSTEIN(int*, double*, double*, int*, double*, int*, int*, double*, int*, double*, int*, int*, int*);
  173. extern int F_DSTEQR(char*, int*, double*, double*, double*, int*, double*, int*);
  174. extern int F_DSTERF(int*, double*, double*, int*);
  175. extern int F_DSTEV(char*, int*, double*, double*, double*, int*, double*, int*);
  176. extern int F_DSTEVD(char*, int*, double*, double*, double*, int*, double*, int*, int*, int*, int*);
  177. extern int F_DSTEVR(char*, char*, int*, double*, double*, double*, double*, int*, int*, double*, int*, double*, double*, int*, int*, double*, int*, int*, int*, int*);
  178. extern int F_DSTEVX(char*, char*, int*, double*, double*, double*, double*, int*, int*, double*, int*, double*, double*, int*, double*, int*, int*, int*);
  179. extern int F_DSYCON(char*, int*, double*, int*, int*, double*, double*, double*, int*, int*);
  180. extern int F_DSYEV(char*, char*, int*, double*, int*, double*, double*, int*, int*);
  181. extern int F_DSYEVD(char*, char*, int*, double*, int*, double*, double*, int*, int*, int*, int*);
  182. extern int F_DSYEVR(char*, char*, char*, int*, double*, int*, double*, double*, int*, int*, double*, int*, double*, double*, int*, int*, double*, int*, int*, int*, int*);
  183. extern int F_DSYEVX(char*, char*, char*, int*, double*, int*, double*, double*, int*, int*, double*, int*, double*, double*, int*, double*, int*, int*, int*, int*);
  184. extern int F_DSYGST(int*, char*, int*, double*, int*, double*, int*, int*);
  185. extern int F_DSYGV(int*, char*, char*, int*, double*, int*, double*, int*, double*, double*, int*, int*);
  186. extern int F_DSYGVD(int*, char*, char*, int*, double*, int*, double*, int*, double*, double*, int*, int*, int*, int*);
  187. extern int F_DSYGVX(int*, char*, char*, char*, int*, double*, int*, double*, int*, double*, double*, int*, int*, double*, int*, double*, double*, int*, double*, int*, int*, int*, int*);
  188. extern int F_DSYRFS(char*, int*, int*, double*, int*, double*, int*, int*, double*, int*, double*, int*, double*, double*, double*, int*, int*);
  189. extern int F_DSYSV(char*, int*, int*, double*, int*, int*, double*, int*, double*, int*, int*);
  190. extern int F_DSYSVX(char*, char*, int*, int*, double*, int*, double*, int*, int*, double*, int*, double*, int*, double*, int*);
  191. extern int F_DSYTRD(char*, int*, double*, int*, double*, double*, double*, double*, int*, int*);
  192. extern int F_DSYTRF(char*, int*, double*, int*, int*, double*, int*, int*);
  193. extern int F_DSYTRI(char*, int*, double*, int*, int*, double*, int*);
  194. extern int F_DSYTRS(char*, int*, int*, double*, int*, int*, double*, int*, int*);
  195. extern int F_DTBCON(char*, char*, char*, int*, int*, double*, int*, double*, double*, int*, int*);
  196. extern int F_DTBRFS(char*, char*, char*, int*, int*, int*, double*, int*, double*, int*, double*, int*, double*, double*, double*, int*, int*);
  197. extern int F_DTBTRS(char*, char*, char*, int*, int*, int*, double*, int*, double*, int*, int*);
  198. extern int F_DTGEVC(char*, char*, int*, double*, int*, double*, int*, double*, int*, double*, int*, int*, int*, double*, int*);
  199. extern int F_DTGEXC(int*, double*, int*, double*, int*, double*, int*, double*, int*, int*, int*, double*, int*, int*);
  200. extern int F_DTGSEN(int*, int*, double*, int*, double*, int*, double*, double*, double*, double*, int*, double*, int*, int*, double*, double*, double*, double*, int*, int*, int*, int*);
  201. extern int F_DTGSJA(char*, char*, char*, int*, int*, int*, int*, int*, double*, int*, double*, int*, double*, double*, double*, double*, double*, int*, double*, int*, double*, int*, double*, int*, int*);
  202. extern int F_DTGSNA(char*, char*, int*, double*, int*, double*, int*, double*, int*, double*, int*, double*, double*, int*, int*, double*, int*, int*, int*);
  203. extern int F_DTGSYL(char*, int*, int*, int*, double*, int*, double*, int*, double*, int*, double*, int*, double*, int*, double*, int*, double*, double*, double*, int*, int*, int*);
  204. extern int F_DTPCON(char*, char*, char*, int*, double*, double*, double*, int*, int*);
  205. extern int F_DTPRFS(char*, char*, char*, int*, int*, double*, double*, int*, double*, int*, double*, double*, double*, int*, int*);
  206. extern int F_DTPTRI(char*, char*, int*, double*, int*);
  207. extern int F_DTPTRS(char*, char*, char*, int*, int*, double*, double*, int*, int*);
  208. extern int F_DTRCON(char*, char*, char*, int*, double*, int*, double*, double*, int*, int*);
  209. extern int F_DTREVC(char*, char*, int*, double*, int*, double*, int*, double*, int*, int*, int*, double*, int*);
  210. extern int F_DTREXC(char*, int*, double*, int*, double*, int*, int*, int*, double*, int*);
  211. extern int F_DTRRFS(char*, char*, char*, int*, int*, double*, int*, double*, int*, double*, int*, double*, double*, double*, int*, int*);
  212. extern int F_DTRSEN(char*, char*, int*, double*, int*, double*, int*, double*, double*, int*, double*, double*, double*, int*, int*, int*, int*);
  213. extern int F_DTRSNA(char*, char*, int*, double*, int*, double*, int*, double*, int*, double*, double*, int*, int*, double*, int*, int*, int*);
  214. extern int F_DTRSYL(char*, char*, int*, int*, int*, double*, int*, double*, int*, double*, int*, double*, int*);
  215. extern int F_DTRTRI(char*, char*, int*, double*, int*, int*);
  216. extern int F_DTRTRS(char*, char*, char*, int*, int*, double*, int*, double*, int*, int*);
  217. extern int F_DTZRQF(int*, int*, double*, int*, double*, int*);
  218. extern int F_DTZRZF(int*, int*, double*, int*, double*, double*, int*, int*);
  219. }
  220. namespace psi {
  221. /**
  222. * Purpose
  223. * =======
  224. *
  225. * DBDSDC computes the singular value decomposition (SVD) of a real
  226. * N-by-N (upper or lower) bidiagonal matrix B: B = U * S * VT,
  227. * using a divide and conquer method, where S is a diagonal matrix
  228. * with non-negative diagonal elements (the singular values of B), and
  229. * U and VT are orthogonal matrices of left and right singular vectors,
  230. * respectively. DBDSDC can be used to compute all singular values,
  231. * and optionally, singular vectors or singular vectors in compact form.
  232. *
  233. * This code makes very mild assumptions about floating point
  234. * arithmetic. It will work on machines with a guard digit in
  235. * add/subtract, or on those binary machines without guard digits
  236. * which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or Cray-2.
  237. * It could conceivably fail on hexadecimal or decimal machines
  238. * without guard digits, but we know of none. See DLASD3 for details.
  239. *
  240. * The code currently calls DLASDQ if singular values only are desired.
  241. * However, it can be slightly modified to compute singular values
  242. * using the divide and conquer method.
  243. *
  244. * Arguments
  245. * =========
  246. *
  247. * UPLO (input) CHARACTER*1
  248. * = 'U': B is upper bidiagonal.
  249. * = 'L': B is lower bidiagonal.
  250. *
  251. * COMPQ (input) CHARACTER*1
  252. * Specifies whether singular vectors are to be computed
  253. * as follows:
  254. * = 'N': Compute singular values only;
  255. * = 'P': Compute singular values and compute singular
  256. * vectors in compact form;
  257. * = 'I': Compute singular values and singular vectors.
  258. *
  259. * N (input) INTEGER
  260. * The order of the matrix B. N >= 0.
  261. *
  262. * D (input/output) DOUBLE PRECISION array, dimension (N)
  263. * On entry, the n diagonal elements of the bidiagonal matrix B.
  264. * On exit, if INFO=0, the singular values of B.
  265. *
  266. * E (input/output) DOUBLE PRECISION array, dimension (N-1)
  267. * On entry, the elements of E contain the offdiagonal
  268. * elements of the bidiagonal matrix whose SVD is desired.
  269. * On exit, E has been destroyed.
  270. *
  271. * U (output) DOUBLE PRECISION array, dimension (LDU,N)
  272. * If COMPQ = 'I', then:
  273. * On exit, if INFO = 0, U contains the left singular vectors
  274. * of the bidiagonal matrix.
  275. * For other values of COMPQ, U is not referenced.
  276. *
  277. * LDU (input) INTEGER
  278. * The leading dimension of the array U. LDU >= 1.
  279. * If singular vectors are desired, then LDU >= max( 1, N ).
  280. *
  281. * VT (output) DOUBLE PRECISION array, dimension (LDVT,N)
  282. * If COMPQ = 'I', then:
  283. * On exit, if INFO = 0, VT' contains the right singular
  284. * vectors of the bidiagonal matrix.
  285. * For other values of COMPQ, VT is not referenced.
  286. *
  287. * LDVT (input) INTEGER
  288. * The leading dimension of the array VT. LDVT >= 1.
  289. * If singular vectors are desired, then LDVT >= max( 1, N ).
  290. *
  291. * Q (output) DOUBLE PRECISION array, dimension (LDQ)
  292. * If COMPQ = 'P', then:
  293. * On exit, if INFO = 0, Q and IQ contain the left
  294. * and right singular vectors in a compact form,
  295. * requiring O(N log N) space instead of 2*N**2.
  296. * In particular, Q contains all the DOUBLE PRECISION data in
  297. * LDQ >= N*(11 + 2*SMLSIZ + 8*INT(LOG_2(N/(SMLSIZ+1))))
  298. * words of memory, where SMLSIZ is returned by ILAENV and
  299. * is equal to the maximum size of the subproblems at the
  300. * bottom of the computation tree (usually about 25).
  301. * For other values of COMPQ, Q is not referenced.
  302. *
  303. * IQ (output) INTEGER array, dimension (LDIQ)
  304. * If COMPQ = 'P', then:
  305. * On exit, if INFO = 0, Q and IQ contain the left
  306. * and right singular vectors in a compact form,
  307. * requiring O(N log N) space instead of 2*N**2.
  308. * In particular, IQ contains all INTEGER data in
  309. * LDIQ >= N*(3 + 3*INT(LOG_2(N/(SMLSIZ+1))))
  310. * words of memory, where SMLSIZ is returned by ILAENV and
  311. * is equal to the maximum size of the subproblems at the
  312. * bottom of the computation tree (usually about 25).
  313. * For other values of COMPQ, IQ is not referenced.
  314. *
  315. * WORK (workspace) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  316. * If COMPQ = 'N' then LWORK >= (4 * N).
  317. * If COMPQ = 'P' then LWORK >= (6 * N).
  318. * If COMPQ = 'I' then LWORK >= (3 * N**2 + 4 * N).
  319. *
  320. * IWORK (workspace) INTEGER array, dimension (8*N)
  321. *
  322. * C++ Return value: INFO (output) INTEGER
  323. * = 0: successful exit.
  324. * < 0: if INFO = -i, the i-th argument had an illegal value.
  325. * > 0: The algorithm failed to compute a singular value.
  326. * The update process of divide and conquer failed.
  327. *
  328. * Further Details
  329. * ===============
  330. *
  331. * Based on contributions by
  332. * Ming Gu and Huan Ren, Computer Science Division, University of
  333. * California at Berkeley, USA
  334. *
  335. * =====================================================================
  336. * Changed dimension statement in comment describing E from (N) to
  337. * (N-1). Sven, 17 Feb 05.
  338. * =====================================================================
  339. *
  340. * .. Parameters ..
  341. **/
  342. int C_DBDSDC(char uplo, char compq, int n, double* d, double* e, double* u, int ldu, double* vt, int ldvt, double* q, int* iq, double* work, int* iwork)
  343. {
  344. int info;
  345. ::F_DBDSDC(&uplo, &compq, &n, d, e, u, &ldu, vt, &ldvt, q, iq, work, iwork, &info);
  346. return info;
  347. }
  348. /**
  349. * Purpose
  350. * =======
  351. *
  352. * DBDSQR computes the singular values and, optionally, the right and/or
  353. * left singular vectors from the singular value decomposition (SVD) of
  354. * a real N-by-N (upper or lower) bidiagonal matrix B using the implicit
  355. * zero-shift QR algorithm. The SVD of B has the form
  356. *
  357. * B = Q * S * P**T
  358. *
  359. * where S is the diagonal matrix of singular values, Q is an orthogonal
  360. * matrix of left singular vectors, and P is an orthogonal matrix of
  361. * right singular vectors. If left singular vectors are requested, this
  362. * subroutine actually returns U*Q instead of Q, and, if right singular
  363. * vectors are requested, this subroutine returns P**T*VT instead of
  364. * P**T, for given real input matrices U and VT. When U and VT are the
  365. * orthogonal matrices that reduce a general matrix A to bidiagonal
  366. * form: A = U*B*VT, as computed by DGEBRD, then
  367. *
  368. * A = (U*Q) * S * (P**T*VT)
  369. *
  370. * is the SVD of A. Optionally, the subroutine may also compute Q**T*C
  371. * for a given real input matrix C.
  372. *
  373. * See "Computing Small Singular Values of Bidiagonal Matrices With
  374. * Guaranteed High Relative Accuracy," by J. Demmel and W. Kahan,
  375. * LAPACK Working Note #3 (or SIAM J. Sci. Statist. Comput. vol. 11,
  376. * no. 5, pp. 873-912, Sept 1990) and
  377. * "Accurate singular values and differential qd algorithms," by
  378. * B. Parlett and V. Fernando, Technical Report CPAM-554, Mathematics
  379. * Department, University of California at Berkeley, July 1992
  380. * for a detailed description of the algorithm.
  381. *
  382. * Arguments
  383. * =========
  384. *
  385. * UPLO (input) CHARACTER*1
  386. * = 'U': B is upper bidiagonal;
  387. * = 'L': B is lower bidiagonal.
  388. *
  389. * N (input) INTEGER
  390. * The order of the matrix B. N >= 0.
  391. *
  392. * NCVT (input) INTEGER
  393. * The number of columns of the matrix VT. NCVT >= 0.
  394. *
  395. * NRU (input) INTEGER
  396. * The number of rows of the matrix U. NRU >= 0.
  397. *
  398. * NCC (input) INTEGER
  399. * The number of columns of the matrix C. NCC >= 0.
  400. *
  401. * D (input/output) DOUBLE PRECISION array, dimension (N)
  402. * On entry, the n diagonal elements of the bidiagonal matrix B.
  403. * On exit, if INFO=0, the singular values of B in decreasing
  404. * order.
  405. *
  406. * E (input/output) DOUBLE PRECISION array, dimension (N-1)
  407. * On entry, the N-1 offdiagonal elements of the bidiagonal
  408. * matrix B.
  409. * On exit, if INFO = 0, E is destroyed; if INFO > 0, D and E
  410. * will contain the diagonal and superdiagonal elements of a
  411. * bidiagonal matrix orthogonally equivalent to the one given
  412. * as input.
  413. *
  414. * VT (input/output) DOUBLE PRECISION array, dimension (LDVT, NCVT)
  415. * On entry, an N-by-NCVT matrix VT.
  416. * On exit, VT is overwritten by P**T * VT.
  417. * Not referenced if NCVT = 0.
  418. *
  419. * LDVT (input) INTEGER
  420. * The leading dimension of the array VT.
  421. * LDVT >= max(1,N) if NCVT > 0; LDVT >= 1 if NCVT = 0.
  422. *
  423. * U (input/output) DOUBLE PRECISION array, dimension (LDU, N)
  424. * On entry, an NRU-by-N matrix U.
  425. * On exit, U is overwritten by U * Q.
  426. * Not referenced if NRU = 0.
  427. *
  428. * LDU (input) INTEGER
  429. * The leading dimension of the array U. LDU >= max(1,NRU).
  430. *
  431. * C (input/output) DOUBLE PRECISION array, dimension (LDC, NCC)
  432. * On entry, an N-by-NCC matrix C.
  433. * On exit, C is overwritten by Q**T * C.
  434. * Not referenced if NCC = 0.
  435. *
  436. * LDC (input) INTEGER
  437. * The leading dimension of the array C.
  438. * LDC >= max(1,N) if NCC > 0; LDC >=1 if NCC = 0.
  439. *
  440. * WORK (workspace) DOUBLE PRECISION array, dimension (4*N)
  441. *
  442. * C++ Return value: INFO (output) INTEGER
  443. * = 0: successful exit
  444. * < 0: If INFO = -i, the i-th argument had an illegal value
  445. * > 0:
  446. * if NCVT = NRU = NCC = 0,
  447. * = 1, a split was marked by a positive value in E
  448. * = 2, current block of Z not diagonalized after 30*N
  449. * iterations (in inner while loop)
  450. * = 3, termination criterion of outer while loop not met
  451. * (program created more than N unreduced blocks)
  452. * else NCVT = NRU = NCC = 0,
  453. * the algorithm did not converge; D and E contain the
  454. * elements of a bidiagonal matrix which is orthogonally
  455. * similar to the input matrix B; if INFO = i, i
  456. * elements of E have not converged to zero.
  457. *
  458. * Internal Parameters
  459. * ===================
  460. *
  461. * TOLMUL DOUBLE PRECISION, default = max(10,min(100,EPS**(-1/8)))
  462. * TOLMUL controls the convergence criterion of the QR loop.
  463. * If it is positive, TOLMUL*EPS is the desired relative
  464. * precision in the computed singular values.
  465. * If it is negative, abs(TOLMUL*EPS*sigma_max) is the
  466. * desired absolute accuracy in the computed singular
  467. * values (corresponds to relative accuracy
  468. * abs(TOLMUL*EPS) in the largest singular value.
  469. * abs(TOLMUL) should be between 1 and 1/EPS, and preferably
  470. * between 10 (for fast convergence) and .1/EPS
  471. * (for there to be some accuracy in the results).
  472. * Default is to lose at either one eighth or 2 of the
  473. * available decimal digits in each computed singular value
  474. * (whichever is smaller).
  475. *
  476. * MAXITR INTEGER, default = 6
  477. * MAXITR controls the maximum number of passes of the
  478. * algorithm through its inner loop. The algorithms stops
  479. * (and so fails to converge) if the number of passes
  480. * through the inner loop exceeds MAXITR*N**2.
  481. *
  482. * =====================================================================
  483. *
  484. * .. Parameters ..
  485. **/
  486. int C_DBDSQR(char uplo, int n, int ncvt, int nru, int ncc, double* d, double* e, double* vt, int ldvt, double* u, int ldu, double* c, int ldc, double* work)
  487. {
  488. int info;
  489. ::F_DBDSQR(&uplo, &n, &ncvt, &nru, &ncc, d, e, vt, &ldvt, u, &ldu, c, &ldc, work, &info);
  490. return info;
  491. }
  492. /**
  493. * Purpose
  494. * =======
  495. *
  496. * DDISNA computes the reciprocal condition numbers for the eigenvectors
  497. * of a real symmetric or complex Hermitian matrix or for the left or
  498. * right singular vectors of a general m-by-n matrix. The reciprocal
  499. * condition number is the 'gap' between the corresponding eigenvalue or
  500. * singular value and the nearest other one.
  501. *
  502. * The bound on the error, measured by angle in radians, in the I-th
  503. * computed vector is given by
  504. *
  505. * DLAMCH( 'E' ) * ( ANORM / SEP( I ) )
  506. *
  507. * where ANORM = 2-norm(A) = max( abs( D(j) ) ). SEP(I) is not allowed
  508. * to be smaller than DLAMCH( 'E' )*ANORM in order to limit the size of
  509. * the error bound.
  510. *
  511. * DDISNA may also be used to compute error bounds for eigenvectors of
  512. * the generalized symmetric definite eigenproblem.
  513. *
  514. * Arguments
  515. * =========
  516. *
  517. * JOB (input) CHARACTER*1
  518. * Specifies for which problem the reciprocal condition numbers
  519. * should be computed:
  520. * = 'E': the eigenvectors of a symmetric/Hermitian matrix;
  521. * = 'L': the left singular vectors of a general matrix;
  522. * = 'R': the right singular vectors of a general matrix.
  523. *
  524. * M (input) INTEGER
  525. * The number of rows of the matrix. M >= 0.
  526. *
  527. * N (input) INTEGER
  528. * If JOB = 'L' or 'R', the number of columns of the matrix,
  529. * in which case N >= 0. Ignored if JOB = 'E'.
  530. *
  531. * D (input) DOUBLE PRECISION array, dimension (M) if JOB = 'E'
  532. * dimension (min(M,N)) if JOB = 'L' or 'R'
  533. * The eigenvalues (if JOB = 'E') or singular values (if JOB =
  534. * 'L' or 'R') of the matrix, in either increasing or decreasing
  535. * order. If singular values, they must be non-negative.
  536. *
  537. * SEP (output) DOUBLE PRECISION array, dimension (M) if JOB = 'E'
  538. * dimension (min(M,N)) if JOB = 'L' or 'R'
  539. * The reciprocal condition numbers of the vectors.
  540. *
  541. * C++ Return value: INFO (output) INTEGER
  542. * = 0: successful exit.
  543. * < 0: if INFO = -i, the i-th argument had an illegal value.
  544. *
  545. * =====================================================================
  546. *
  547. * .. Parameters ..
  548. **/
  549. int C_DDISNA(char job, int m, int n, double* d, double* sep)
  550. {
  551. int info;
  552. ::F_DDISNA(&job, &m, &n, d, sep, &info);
  553. return info;
  554. }
  555. /**
  556. * Purpose
  557. * =======
  558. *
  559. * DGBBRD reduces a real general m-by-n band matrix A to upper
  560. * bidiagonal form B by an orthogonal transformation: Q' * A * P = B.
  561. *
  562. * The routine computes B, and optionally forms Q or P', or computes
  563. * Q'*C for a given matrix C.
  564. *
  565. * Arguments
  566. * =========
  567. *
  568. * VECT (input) CHARACTER*1
  569. * Specifies whether or not the matrices Q and P' are to be
  570. * formed.
  571. * = 'N': do not form Q or P';
  572. * = 'Q': form Q only;
  573. * = 'P': form P' only;
  574. * = 'B': form both.
  575. *
  576. * M (input) INTEGER
  577. * The number of rows of the matrix A. M >= 0.
  578. *
  579. * N (input) INTEGER
  580. * The number of columns of the matrix A. N >= 0.
  581. *
  582. * NCC (input) INTEGER
  583. * The number of columns of the matrix C. NCC >= 0.
  584. *
  585. * KL (input) INTEGER
  586. * The number of subdiagonals of the matrix A. KL >= 0.
  587. *
  588. * KU (input) INTEGER
  589. * The number of superdiagonals of the matrix A. KU >= 0.
  590. *
  591. * AB (input/output) DOUBLE PRECISION array, dimension (LDAB,N)
  592. * On entry, the m-by-n band matrix A, stored in rows 1 to
  593. * KL+KU+1. The j-th column of A is stored in the j-th column of
  594. * the array AB as follows:
  595. * AB(ku+1+i-j,j) = A(i,j) for max(1,j-ku)<=i<=min(m,j+kl).
  596. * On exit, A is overwritten by values generated during the
  597. * reduction.
  598. *
  599. * LDAB (input) INTEGER
  600. * The leading dimension of the array A. LDAB >= KL+KU+1.
  601. *
  602. * D (output) DOUBLE PRECISION array, dimension (min(M,N))
  603. * The diagonal elements of the bidiagonal matrix B.
  604. *
  605. * E (output) DOUBLE PRECISION array, dimension (min(M,N)-1)
  606. * The superdiagonal elements of the bidiagonal matrix B.
  607. *
  608. * Q (output) DOUBLE PRECISION array, dimension (LDQ,M)
  609. * If VECT = 'Q' or 'B', the m-by-m orthogonal matrix Q.
  610. * If VECT = 'N' or 'P', the array Q is not referenced.
  611. *
  612. * LDQ (input) INTEGER
  613. * The leading dimension of the array Q.
  614. * LDQ >= max(1,M) if VECT = 'Q' or 'B'; LDQ >= 1 otherwise.
  615. *
  616. * PT (output) DOUBLE PRECISION array, dimension (LDPT,N)
  617. * If VECT = 'P' or 'B', the n-by-n orthogonal matrix P'.
  618. * If VECT = 'N' or 'Q', the array PT is not referenced.
  619. *
  620. * LDPT (input) INTEGER
  621. * The leading dimension of the array PT.
  622. * LDPT >= max(1,N) if VECT = 'P' or 'B'; LDPT >= 1 otherwise.
  623. *
  624. * C (input/output) DOUBLE PRECISION array, dimension (LDC,NCC)
  625. * On entry, an m-by-ncc matrix C.
  626. * On exit, C is overwritten by Q'*C.
  627. * C is not referenced if NCC = 0.
  628. *
  629. * LDC (input) INTEGER
  630. * The leading dimension of the array C.
  631. * LDC >= max(1,M) if NCC > 0; LDC >= 1 if NCC = 0.
  632. *
  633. * WORK (workspace) DOUBLE PRECISION array, dimension (2*max(M,N))
  634. *
  635. * C++ Return value: INFO (output) INTEGER
  636. * = 0: successful exit.
  637. * < 0: if INFO = -i, the i-th argument had an illegal value.
  638. *
  639. * =====================================================================
  640. *
  641. * .. Parameters ..
  642. **/
  643. int C_DGBBRD(char vect, int m, int n, int ncc, int kl, int ku, double* ab, int ldab, double* d, double* e, double* q, int ldq, double* pt, int ldpt, double* c, int ldc, double* work)
  644. {
  645. int info;
  646. ::F_DGBBRD(&vect, &m, &n, &ncc, &kl, &ku, ab, &ldab, d, e, q, &ldq, pt, &ldpt, c, &ldc, work, &info);
  647. return info;
  648. }
  649. /**
  650. * Purpose
  651. * =======
  652. *
  653. * DGBCON estimates the reciprocal of the condition number of a real
  654. * general band matrix A, in either the 1-norm or the infinity-norm,
  655. * using the LU factorization computed by DGBTRF.
  656. *
  657. * An estimate is obtained for norm(inv(A)), and the reciprocal of the
  658. * condition number is computed as
  659. * RCOND = 1 / ( norm(A) * norm(inv(A)) ).
  660. *
  661. * Arguments
  662. * =========
  663. *
  664. * NORM (input) CHARACTER*1
  665. * Specifies whether the 1-norm condition number or the
  666. * infinity-norm condition number is required:
  667. * = '1' or 'O': 1-norm;
  668. * = 'I': Infinity-norm.
  669. *
  670. * N (input) INTEGER
  671. * The order of the matrix A. N >= 0.
  672. *
  673. * KL (input) INTEGER
  674. * The number of subdiagonals within the band of A. KL >= 0.
  675. *
  676. * KU (input) INTEGER
  677. * The number of superdiagonals within the band of A. KU >= 0.
  678. *
  679. * AB (input) DOUBLE PRECISION array, dimension (LDAB,N)
  680. * Details of the LU factorization of the band matrix A, as
  681. * computed by DGBTRF. U is stored as an upper triangular band
  682. * matrix with KL+KU superdiagonals in rows 1 to KL+KU+1, and
  683. * the multipliers used during the factorization are stored in
  684. * rows KL+KU+2 to 2*KL+KU+1.
  685. *
  686. * LDAB (input) INTEGER
  687. * The leading dimension of the array AB. LDAB >= 2*KL+KU+1.
  688. *
  689. * IPIV (input) INTEGER array, dimension (N)
  690. * The pivot indices; for 1 <= i <= N, row i of the matrix was
  691. * interchanged with row IPIV(i).
  692. *
  693. * ANORM (input) DOUBLE PRECISION
  694. * If NORM = '1' or 'O', the 1-norm of the original matrix A.
  695. * If NORM = 'I', the infinity-norm of the original matrix A.
  696. *
  697. * RCOND (output) DOUBLE PRECISION
  698. * The reciprocal of the condition number of the matrix A,
  699. * computed as RCOND = 1/(norm(A) * norm(inv(A))).
  700. *
  701. * WORK (workspace) DOUBLE PRECISION array, dimension (3*N)
  702. *
  703. * IWORK (workspace) INTEGER array, dimension (N)
  704. *
  705. * C++ Return value: INFO (output) INTEGER
  706. * = 0: successful exit
  707. * < 0: if INFO = -i, the i-th argument had an illegal value
  708. *
  709. * =====================================================================
  710. *
  711. * .. Parameters ..
  712. **/
  713. int C_DGBCON(char norm, int n, int kl, int ku, double* ab, int ldab, int* ipiv, double anorm, double* rcond, double* work, int* iwork)
  714. {
  715. int info;
  716. ::F_DGBCON(&norm, &n, &kl, &ku, ab, &ldab, ipiv, &anorm, rcond, work, iwork, &info);
  717. return info;
  718. }
  719. /**
  720. * Purpose
  721. * =======
  722. *
  723. * DGBEQU computes row and column scalings intended to equilibrate an
  724. * M-by-N band matrix A and reduce its condition number. R returns the
  725. * row scale factors and C the column scale factors, chosen to try to
  726. * make the largest element in each row and column of the matrix B with
  727. * elements B(i,j)=R(i)*A(i,j)*C(j) have absolute value 1.
  728. *
  729. * R(i) and C(j) are restricted to be between SMLNUM = smallest safe
  730. * number and BIGNUM = largest safe number. Use of these scaling
  731. * factors is not guaranteed to reduce the condition number of A but
  732. * works well in practice.
  733. *
  734. * Arguments
  735. * =========
  736. *
  737. * M (input) INTEGER
  738. * The number of rows of the matrix A. M >= 0.
  739. *
  740. * N (input) INTEGER
  741. * The number of columns of the matrix A. N >= 0.
  742. *
  743. * KL (input) INTEGER
  744. * The number of subdiagonals within the band of A. KL >= 0.
  745. *
  746. * KU (input) INTEGER
  747. * The number of superdiagonals within the band of A. KU >= 0.
  748. *
  749. * AB (input) DOUBLE PRECISION array, dimension (LDAB,N)
  750. * The band matrix A, stored in rows 1 to KL+KU+1. The j-th
  751. * column of A is stored in the j-th column of the array AB as
  752. * follows:
  753. * AB(ku+1+i-j,j) = A(i,j) for max(1,j-ku)<=i<=min(m,j+kl).
  754. *
  755. * LDAB (input) INTEGER
  756. * The leading dimension of the array AB. LDAB >= KL+KU+1.
  757. *
  758. * R (output) DOUBLE PRECISION array, dimension (M)
  759. * If INFO = 0, or INFO > M, R contains the row scale factors
  760. * for A.
  761. *
  762. * C (output) DOUBLE PRECISION array, dimension (N)
  763. * If INFO = 0, C contains the column scale factors for A.
  764. *
  765. * ROWCND (output) DOUBLE PRECISION
  766. * If INFO = 0 or INFO > M, ROWCND contains the ratio of the
  767. * smallest R(i) to the largest R(i). If ROWCND >= 0.1 and
  768. * AMAX is neither too large nor too small, it is not worth
  769. * scaling by R.
  770. *
  771. * COLCND (output) DOUBLE PRECISION
  772. * If INFO = 0, COLCND contains the ratio of the smallest
  773. * C(i) to the largest C(i). If COLCND >= 0.1, it is not
  774. * worth scaling by C.
  775. *
  776. * AMAX (output) DOUBLE PRECISION
  777. * Absolute value of largest matrix element. If AMAX is very
  778. * close to overflow or very close to underflow, the matrix
  779. * should be scaled.
  780. *
  781. * C++ Return value: INFO (output) INTEGER
  782. * = 0: successful exit
  783. * < 0: if INFO = -i, the i-th argument had an illegal value
  784. * > 0: if INFO = i, and i is
  785. * <= M: the i-th row of A is exactly zero
  786. * > M: the (i-M)-th column of A is exactly zero
  787. *
  788. * =====================================================================
  789. *
  790. * .. Parameters ..
  791. **/
  792. int C_DGBEQU(int m, int n, int kl, int ku, double* ab, int ldab, double* r, double* c, double* rowcnd, double* colcnd, double* amax)
  793. {
  794. int info;
  795. ::F_DGBEQU(&m, &n, &kl, &ku, ab, &ldab, r, c, rowcnd, colcnd, amax, &info);
  796. return info;
  797. }
  798. /**
  799. * Purpose
  800. * =======
  801. *
  802. * DGBRFS improves the computed solution to a system of linear
  803. * equations when the coefficient matrix is banded, and provides
  804. * error bounds and backward error estimates for the solution.
  805. *
  806. * Arguments
  807. * =========
  808. *
  809. * TRANS (input) CHARACTER*1
  810. * Specifies the form of the system of equations:
  811. * = 'N': A * X = B (No transpose)
  812. * = 'T': A**T * X = B (Transpose)
  813. * = 'C': A**H * X = B (Conjugate transpose = Transpose)
  814. *
  815. * N (input) INTEGER
  816. * The order of the matrix A. N >= 0.
  817. *
  818. * KL (input) INTEGER
  819. * The number of subdiagonals within the band of A. KL >= 0.
  820. *
  821. * KU (input) INTEGER
  822. * The number of superdiagonals within the band of A. KU >= 0.
  823. *
  824. * NRHS (input) INTEGER
  825. * The number of right hand sides, i.e., the number of columns
  826. * of the matrices B and X. NRHS >= 0.
  827. *
  828. * AB (input) DOUBLE PRECISION array, dimension (LDAB,N)
  829. * The original band matrix A, stored in rows 1 to KL+KU+1.
  830. * The j-th column of A is stored in the j-th column of the
  831. * array AB as follows:
  832. * AB(ku+1+i-j,j) = A(i,j) for max(1,j-ku)<=i<=min(n,j+kl).
  833. *
  834. * LDAB (input) INTEGER
  835. * The leading dimension of the array AB. LDAB >= KL+KU+1.
  836. *
  837. * AFB (input) DOUBLE PRECISION array, dimension (LDAFB,N)
  838. * Details of the LU factorization of the band matrix A, as
  839. * computed by DGBTRF. U is stored as an upper triangular band
  840. * matrix with KL+KU superdiagonals in rows 1 to KL+KU+1, and
  841. * the multipliers used during the factorization are stored in
  842. * rows KL+KU+2 to 2*KL+KU+1.
  843. *
  844. * LDAFB (input) INTEGER
  845. * The leading dimension of the array AFB. LDAFB >= 2*KL*KU+1.
  846. *
  847. * IPIV (input) INTEGER array, dimension (N)
  848. * The pivot indices from DGBTRF; for 1<=i<=N, row i of the
  849. * matrix was interchanged with row IPIV(i).
  850. *
  851. * B (input) DOUBLE PRECISION array, dimension (LDB,NRHS)
  852. * The right hand side matrix B.
  853. *
  854. * LDB (input) INTEGER
  855. * The leading dimension of the array B. LDB >= max(1,N).
  856. *
  857. * X (input/output) DOUBLE PRECISION array, dimension (LDX,NRHS)
  858. * On entry, the solution matrix X, as computed by DGBTRS.
  859. * On exit, the improved solution matrix X.
  860. *
  861. * LDX (input) INTEGER
  862. * The leading dimension of the array X. LDX >= max(1,N).
  863. *
  864. * FERR (output) DOUBLE PRECISION array, dimension (NRHS)
  865. * The estimated forward error bound for each solution vector
  866. * X(j) (the j-th column of the solution matrix X).
  867. * If XTRUE is the true solution corresponding to X(j), FERR(j)
  868. * is an estimated upper bound for the magnitude of the largest
  869. * element in (X(j) - XTRUE) divided by the magnitude of the
  870. * largest element in X(j). The estimate is as reliable as
  871. * the estimate for RCOND, and is almost always a slight
  872. * overestimate of the true error.
  873. *
  874. * BERR (output) DOUBLE PRECISION array, dimension (NRHS)
  875. * The componentwise relative backward error of each solution
  876. * vector X(j) (i.e., the smallest relative change in
  877. * any element of A or B that makes X(j) an exact solution).
  878. *
  879. * WORK (workspace) DOUBLE PRECISION array, dimension (3*N)
  880. *
  881. * IWORK (workspace) INTEGER array, dimension (N)
  882. *
  883. * C++ Return value: INFO (output) INTEGER
  884. * = 0: successful exit
  885. * < 0: if INFO = -i, the i-th argument had an illegal value
  886. *
  887. * Internal Parameters
  888. * ===================
  889. *
  890. * ITMAX is the maximum number of steps of iterative refinement.
  891. *
  892. * =====================================================================
  893. *
  894. * .. Parameters ..
  895. **/
  896. int C_DGBRFS(char trans, int n, int kl, int ku, int nrhs, double* ab, int ldab, double* afb, int ldafb, int* ipiv, double* b, int ldb, double* x, int ldx, double* ferr, double* berr, double* work, int* iwork)
  897. {
  898. int info;
  899. ::F_DGBRFS(&trans, &n, &kl, &ku, &nrhs, ab, &ldab, afb, &ldafb, ipiv, b, &ldb, x, &ldx, ferr, berr, work, iwork, &info);
  900. return info;
  901. }
  902. /**
  903. * Purpose
  904. * =======
  905. *
  906. * DGBSV computes the solution to a real system of linear equations
  907. * A * X = B, where A is a band matrix of order N with KL subdiagonals
  908. * and KU superdiagonals, and X and B are N-by-NRHS matrices.
  909. *
  910. * The LU decomposition with partial pivoting and row interchanges is
  911. * used to factor A as A = L * U, where L is a product of permutation
  912. * and unit lower triangular matrices with KL subdiagonals, and U is
  913. * upper triangular with KL+KU superdiagonals. The factored form of A
  914. * is then used to solve the system of equations A * X = B.
  915. *
  916. * Arguments
  917. * =========
  918. *
  919. * N (input) INTEGER
  920. * The number of linear equations, i.e., the order of the
  921. * matrix A. N >= 0.
  922. *
  923. * KL (input) INTEGER
  924. * The number of subdiagonals within the band of A. KL >= 0.
  925. *
  926. * KU (input) INTEGER
  927. * The number of superdiagonals within the band of A. KU >= 0.
  928. *
  929. * NRHS (input) INTEGER
  930. * The number of right hand sides, i.e., the number of columns
  931. * of the matrix B. NRHS >= 0.
  932. *
  933. * AB (input/output) DOUBLE PRECISION array, dimension (LDAB,N)
  934. * On entry, the matrix A in band storage, in rows KL+1 to
  935. * 2*KL+KU+1; rows 1 to KL of the array need not be set.
  936. * The j-th column of A is stored in the j-th column of the
  937. * array AB as follows:
  938. * AB(KL+KU+1+i-j,j) = A(i,j) for max(1,j-KU)<=i<=min(N,j+KL)
  939. * On exit, details of the factorization: U is stored as an
  940. * upper triangular band matrix with KL+KU superdiagonals in
  941. * rows 1 to KL+KU+1, and the multipliers used during the
  942. * factorization are stored in rows KL+KU+2 to 2*KL+KU+1.
  943. * See below for further details.
  944. *
  945. * LDAB (input) INTEGER
  946. * The leading dimension of the array AB. LDAB >= 2*KL+KU+1.
  947. *
  948. * IPIV (output) INTEGER array, dimension (N)
  949. * The pivot indices that define the permutation matrix P;
  950. * row i of the matrix was interchanged with row IPIV(i).
  951. *
  952. * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
  953. * On entry, the N-by-NRHS right hand side matrix B.
  954. * On exit, if INFO = 0, the N-by-NRHS solution matrix X.
  955. *
  956. * LDB (input) INTEGER
  957. * The leading dimension of the array B. LDB >= max(1,N).
  958. *
  959. * C++ Return value: INFO (output) INTEGER
  960. * = 0: successful exit
  961. * < 0: if INFO = -i, the i-th argument had an illegal value
  962. * > 0: if INFO = i, U(i,i) is exactly zero. The factorization
  963. * has been completed, but the factor U is exactly
  964. * singular, and the solution has not been computed.
  965. *
  966. * Further Details
  967. * ===============
  968. *
  969. * The band storage scheme is illustrated by the following example, when
  970. * M = N = 6, KL = 2, KU = 1:
  971. *
  972. * On entry: On exit:
  973. *
  974. * * * * + + + * * * u14 u25 u36
  975. * * * + + + + * * u13 u24 u35 u46
  976. * * a12 a23 a34 a45 a56 * u12 u23 u34 u45 u56
  977. * a11 a22 a33 a44 a55 a66 u11 u22 u33 u44 u55 u66
  978. * a21 a32 a43 a54 a65 * m21 m32 m43 m54 m65 *
  979. * a31 a42 a53 a64 * * m31 m42 m53 m64 * *
  980. *
  981. * Array elements marked * are not used by the routine; elements marked
  982. * + need not be set on entry, but are required by the routine to store
  983. * elements of U because of fill-in resulting from the row interchanges.
  984. *
  985. * =====================================================================
  986. *
  987. * .. External Subroutines ..
  988. **/
  989. int C_DGBSV(int n, int kl, int ku, int nrhs, double* ab, int ldab, int* ipiv, double* b, int ldb)
  990. {
  991. int info;
  992. ::F_DGBSV(&n, &kl, &ku, &nrhs, ab, &ldab, ipiv, b, &ldb, &info);
  993. return info;
  994. }
  995. /**
  996. * Purpose
  997. * =======
  998. *
  999. * DGBSVX uses the LU factorization to compute the solution to a real
  1000. * system of linear equations A * X = B, A**T * X = B, or A**H * X = B,
  1001. * where A is a band matrix of order N with KL subdiagonals and KU
  1002. * superdiagonals, and X and B are N-by-NRHS matrices.
  1003. *
  1004. * Error bounds on the solution and a condition estimate are also
  1005. * provided.
  1006. *
  1007. * Description
  1008. * ===========
  1009. *
  1010. * The following steps are performed by this subroutine:
  1011. *
  1012. * 1. If FACT = 'E', real scaling factors are computed to equilibrate
  1013. * the system:
  1014. * TRANS = 'N': diag(R)*A*diag(C) *inv(diag(C))*X = diag(R)*B
  1015. * TRANS = 'T': (diag(R)*A*diag(C))**T *inv(diag(R))*X = diag(C)*B
  1016. * TRANS = 'C': (diag(R)*A*diag(C))**H *inv(diag(R))*X = diag(C)*B
  1017. * Whether or not the system will be equilibrated depends on the
  1018. * scaling of the matrix A, but if equilibration is used, A is
  1019. * overwritten by diag(R)*A*diag(C) and B by diag(R)*B (if TRANS='N')
  1020. * or diag(C)*B (if TRANS = 'T' or 'C').
  1021. *
  1022. * 2. If FACT = 'N' or 'E', the LU decomposition is used to factor the
  1023. * matrix A (after equilibration if FACT = 'E') as
  1024. * A = L * U,
  1025. * where L is a product of permutation and unit lower triangular
  1026. * matrices with KL subdiagonals, and U is upper triangular with
  1027. * KL+KU superdiagonals.
  1028. *
  1029. * 3. If some U(i,i)=0, so that U is exactly singular, then the routine
  1030. * returns with INFO = i. Otherwise, the factored form of A is used
  1031. * to estimate the condition number of the matrix A. If the
  1032. * reciprocal of the condition number is less than machine precision,
  1033. * C++ Return value: INFO (output) INTEGER
  1034. * to solve for X and compute error bounds as described below.
  1035. *
  1036. * 4. The system of equations is solved for X using the factored form
  1037. * of A.
  1038. *
  1039. * 5. Iterative refinement is applied to improve the computed solution
  1040. * matrix and calculate error bounds and backward error estimates
  1041. * for it.
  1042. *
  1043. * 6. If equilibration was used, the matrix X is premultiplied by
  1044. * diag(C) (if TRANS = 'N') or diag(R) (if TRANS = 'T' or 'C') so
  1045. * that it solves the original system before equilibration.
  1046. *
  1047. * Arguments
  1048. * =========
  1049. *
  1050. * FACT (input) CHARACTER*1
  1051. * Specifies whether or not the factored form of the matrix A is
  1052. * supplied on entry, and if not, whether the matrix A should be
  1053. * equilibrated before it is factored.
  1054. * = 'F': On entry, AFB and IPIV contain the factored form of
  1055. * A. If EQUED is not 'N', the matrix A has been
  1056. * equilibrated with scaling factors given by R and C.
  1057. * AB, AFB, and IPIV are not modified.
  1058. * = 'N': The matrix A will be copied to AFB and factored.
  1059. * = 'E': The matrix A will be equilibrated if necessary, then
  1060. * copied to AFB and factored.
  1061. *
  1062. * TRANS (input) CHARACTER*1
  1063. * Specifies the form of the system of equations.
  1064. * = 'N': A * X = B (No transpose)
  1065. * = 'T': A**T * X = B (Transpose)
  1066. * = 'C': A**H * X = B (Transpose)
  1067. *
  1068. * N (input) INTEGER
  1069. * The number of linear equations, i.e., the order of the
  1070. * matrix A. N >= 0.
  1071. *
  1072. * KL (input) INTEGER
  1073. * The number of subdiagonals within the band of A. KL >= 0.
  1074. *
  1075. * KU (input) INTEGER
  1076. * The number of superdiagonals within the band of A. KU >= 0.
  1077. *
  1078. * NRHS (input) INTEGER
  1079. * The number of right hand sides, i.e., the number of columns
  1080. * of the matrices B and X. NRHS >= 0.
  1081. *
  1082. * AB (input/output) DOUBLE PRECISION array, dimension (LDAB,N)
  1083. * On entry, the matrix A in band storage, in rows 1 to KL+KU+1.
  1084. * The j-th column of A is stored in the j-th column of the
  1085. * array AB as follows:
  1086. * AB(KU+1+i-j,j) = A(i,j) for max(1,j-KU)<=i<=min(N,j+kl)
  1087. *
  1088. * If FACT = 'F' and EQUED is not 'N', then A must have been
  1089. * equilibrated by the scaling factors in R and/or C. AB is not
  1090. * modified if FACT = 'F' or 'N', or if FACT = 'E' and
  1091. * EQUED = 'N' on exit.
  1092. *
  1093. * On exit, if EQUED .ne. 'N', A is scaled as follows:
  1094. * EQUED = 'R': A := diag(R) * A
  1095. * EQUED = 'C': A := A * diag(C)
  1096. * EQUED = 'B': A := diag(R) * A * diag(C).
  1097. *
  1098. * LDAB (input) INTEGER
  1099. * The leading dimension of the array AB. LDAB >= KL+KU+1.
  1100. *
  1101. * AFB (input or output) DOUBLE PRECISION array, dimension (LDAFB,N)
  1102. * If FACT = 'F', then AFB is an input argument and on entry
  1103. * contains details of the LU factorization of the band matrix
  1104. * A, as computed by DGBTRF. U is stored as an upper triangular
  1105. * band matrix with KL+KU superdiagonals in rows 1 to KL+KU+1,
  1106. * and the multipliers used during the factorization are stored
  1107. * in rows KL+KU+2 to 2*KL+KU+1. If EQUED .ne. 'N', then AFB is
  1108. * the factored form of the equilibrated matrix A.
  1109. *
  1110. * If FACT = 'N', then AFB is an output argument and on exit
  1111. * returns details of the LU factorization of A.
  1112. *
  1113. * If FACT = 'E', then AFB is an output argument and on exit
  1114. * returns details of the LU factorization of the equilibrated
  1115. * matrix A (see the description of AB for the form of the
  1116. * equilibrated matrix).
  1117. *
  1118. * LDAFB (input) INTEGER
  1119. * The leading dimension of the array AFB. LDAFB >= 2*KL+KU+1.
  1120. *
  1121. * IPIV (input or output) INTEGER array, dimension (N)
  1122. * If FACT = 'F', then IPIV is an input argument and on entry
  1123. * contains the pivot indices from the factorization A = L*U
  1124. * as computed by DGBTRF; row i of the matrix was interchanged
  1125. * with row IPIV(i).
  1126. *
  1127. * If FACT = 'N', then IPIV is an output argument and on exit
  1128. * contains the pivot indices from the factorization A = L*U
  1129. * of the original matrix A.
  1130. *
  1131. * If FACT = 'E', then IPIV is an output argument and on exit
  1132. * contains the pivot indices from the factorization A = L*U
  1133. * of the equilibrated matrix A.
  1134. *
  1135. * EQUED (input or output) CHARACTER*1
  1136. * Specifies the form of equilibration that was done.
  1137. * = 'N': No equilibration (always true if FACT = 'N').
  1138. * = 'R': Row equilibration, i.e., A has been premultiplied by
  1139. * diag(R).
  1140. * = 'C': Column equilibration, i.e., A has been postmultiplied
  1141. * by diag(C).
  1142. * = 'B': Both row and column equilibration, i.e., A has been
  1143. * replaced by diag(R) * A * diag(C).
  1144. * EQUED is an input argument if FACT = 'F'; otherwise, it is an
  1145. * output argument.
  1146. *
  1147. * R (input or output) DOUBLE PRECISION array, dimension (N)
  1148. * The row scale factors for A. If EQUED = 'R' or 'B', A is
  1149. * multiplied on the left by diag(R); if EQUED = 'N' or 'C', R
  1150. * is not accessed. R is an input argument if FACT = 'F';
  1151. * otherwise, R is an output argument. If FACT = 'F' and
  1152. * EQUED = 'R' or 'B', each element of R must be positive.
  1153. *
  1154. * C (input or output) DOUBLE PRECISION array, dimension (N)
  1155. * The column scale factors for A. If EQUED = 'C' or 'B', A is
  1156. * multiplied on the right by diag(C); if EQUED = 'N' or 'R', C
  1157. * is not accessed. C is an input argument if FACT = 'F';
  1158. * otherwise, C is an output argument. If FACT = 'F' and
  1159. * EQUED = 'C' or 'B', each element of C must be positive.
  1160. *
  1161. * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
  1162. * On entry, the right hand side matrix B.
  1163. * On exit,
  1164. * if EQUED = 'N', B is not modified;
  1165. * if TRANS = 'N' and EQUED = 'R' or 'B', B is overwritten by
  1166. * diag(R)*B;
  1167. * if TRANS = 'T' or 'C' and EQUED = 'C' or 'B', B is
  1168. * overwritten by diag(C)*B.
  1169. *
  1170. * LDB (input) INTEGER
  1171. * The leading dimension of the array B. LDB >= max(1,N).
  1172. *
  1173. * X (output) DOUBLE PRECISION array, dimension (LDX,NRHS)
  1174. * If INFO = 0 or INFO = N+1, the N-by-NRHS solution matrix X
  1175. * to the original system of equations. Note that A and B are
  1176. * modified on exit if EQUED .ne. 'N', and the solution to the
  1177. * equilibrated system is inv(diag(C))*X if TRANS = 'N' and
  1178. * EQUED = 'C' or 'B', or inv(diag(R))*X if TRANS = 'T' or 'C'
  1179. * and EQUED = 'R' or 'B'.
  1180. *
  1181. * LDX (input) INTEGER
  1182. * The leading dimension of the array X. LDX >= max(1,N).
  1183. *
  1184. * RCOND (output) DOUBLE PRECISION
  1185. * The estimate of the reciprocal condition number of the matrix
  1186. * A after equilibration (if done). If RCOND is less than the
  1187. * machine precision (in particular, if RCOND = 0), the matrix
  1188. * is singular to working precision. This condition is
  1189. * indicated by a return code of INFO > 0.
  1190. *
  1191. * FERR (output) DOUBLE PRECISION array, dimension (NRHS)
  1192. * The estimated forward error bound for each solution vector
  1193. * X(j) (the j-th column of the solution matrix X).
  1194. * If XTRUE is the true solution corresponding to X(j), FERR(j)
  1195. * is an estimated upper bound for the magnitude of the largest
  1196. * element in (X(j) - XTRUE) divided by the magnitude of the
  1197. * largest element in X(j). The estimate is as reliable as
  1198. * the estimate for RCOND, and is almost always a slight
  1199. * overestimate of the true error.
  1200. *
  1201. * BERR (output) DOUBLE PRECISION array, dimension (NRHS)
  1202. * The componentwise relative backward error of each solution
  1203. * vector X(j) (i.e., the smallest relative change in
  1204. * any element of A or B that makes X(j) an exact solution).
  1205. *
  1206. * WORK (workspace/output) DOUBLE PRECISION array, dimension (3*N)
  1207. * On exit, WORK(1) contains the reciprocal pivot growth
  1208. * factor norm(A)/norm(U). The "max absolute element" norm is
  1209. * used. If WORK(1) is much less than 1, then the stability
  1210. * of the LU factorization of the (equilibrated) matrix A
  1211. * could be poor. This also means that the solution X, condition
  1212. * estimator RCOND, and forward error bound FERR could be
  1213. * unreliable. If factorization fails with 0<INFO<=N, then
  1214. * WORK(1) contains the reciprocal pivot growth factor for the
  1215. * leading INFO columns of A.
  1216. *
  1217. * IWORK (workspace) INTEGER array, dimension (N)
  1218. *
  1219. * C++ Return value: INFO (output) INTEGER
  1220. * = 0: successful exit
  1221. * < 0: if INFO = -i, the i-th argument had an illegal value
  1222. * > 0: if INFO = i, and i is
  1223. * <= N: U(i,i) is exactly zero. The factorization
  1224. * has been completed, but the factor U is exactly
  1225. * singular, so the solution and error bounds
  1226. * could not be computed. RCOND = 0 is returned.
  1227. * = N+1: U is nonsingular, but RCOND is less than machine
  1228. * precision, meaning that the matrix is singular
  1229. * to working precision. Nevertheless, the
  1230. * solution and error bounds are computed because
  1231. * there are a number of situations where the
  1232. * computed solution can be more accurate than the
  1233. * value of RCOND would suggest.
  1234. *
  1235. * =====================================================================
  1236. *
  1237. * .. Parameters ..
  1238. **/
  1239. int C_DGBSVX(char fact, char trans, int n, int kl, int ku, int nrhs, double* ab, int ldab, double* afb, int ldafb, int* ipiv, char equed, double* r, double* c, double* b, int ldb, double* x, int ldx, double* rcond, double* ferr, double* berr, double* work, int* iwork)
  1240. {
  1241. int info;
  1242. ::F_DGBSVX(&fact, &trans, &n, &kl, &ku, &nrhs, ab, &ldab, afb, &ldafb, ipiv, &equed, r, c, b, &ldb, x, &ldx, rcond, ferr, berr, work, iwork, &info);
  1243. return info;
  1244. }
  1245. /**
  1246. * Purpose
  1247. * =======
  1248. *
  1249. * DGBTRF computes an LU factorization of a real m-by-n band matrix A
  1250. * using partial pivoting with row interchanges.
  1251. *
  1252. * This is the blocked version of the algorithm, calling Level 3 BLAS.
  1253. *
  1254. * Arguments
  1255. * =========
  1256. *
  1257. * M (input) INTEGER
  1258. * The number of rows of the matrix A. M >= 0.
  1259. *
  1260. * N (input) INTEGER
  1261. * The number of columns of the matrix A. N >= 0.
  1262. *
  1263. * KL (input) INTEGER
  1264. * The number of subdiagonals within the band of A. KL >= 0.
  1265. *
  1266. * KU (input) INTEGER
  1267. * The number of superdiagonals within the band of A. KU >= 0.
  1268. *
  1269. * AB (input/output) DOUBLE PRECISION array, dimension (LDAB,N)
  1270. * On entry, the matrix A in band storage, in rows KL+1 to
  1271. * 2*KL+KU+1; rows 1 to KL of the array need not be set.
  1272. * The j-th column of A is stored in the j-th column of the
  1273. * array AB as follows:
  1274. * AB(kl+ku+1+i-j,j) = A(i,j) for max(1,j-ku)<=i<=min(m,j+kl)
  1275. *
  1276. * On exit, details of the factorization: U is stored as an
  1277. * upper triangular band matrix with KL+KU superdiagonals in
  1278. * rows 1 to KL+KU+1, and the multipliers used during the
  1279. * factorization are stored in rows KL+KU+2 to 2*KL+KU+1.
  1280. * See below for further details.
  1281. *
  1282. * LDAB (input) INTEGER
  1283. * The leading dimension of the array AB. LDAB >= 2*KL+KU+1.
  1284. *
  1285. * IPIV (output) INTEGER array, dimension (min(M,N))
  1286. * The pivot indices; for 1 <= i <= min(M,N), row i of the
  1287. * matrix was interchanged with row IPIV(i).
  1288. *
  1289. * C++ Return value: INFO (output) INTEGER
  1290. * = 0: successful exit
  1291. * < 0: if INFO = -i, the i-th argument had an illegal value
  1292. * > 0: if INFO = +i, U(i,i) is exactly zero. The factorization
  1293. * has been completed, but the factor U is exactly
  1294. * singular, and division by zero will occur if it is used
  1295. * to solve a system of equations.
  1296. *
  1297. * Further Details
  1298. * ===============
  1299. *
  1300. * The band storage scheme is illustrated by the following example, when
  1301. * M = N = 6, KL = 2, KU = 1:
  1302. *
  1303. * On entry: On exit:
  1304. *
  1305. * * * * + + + * * * u14 u25 u36
  1306. * * * + + + + * * u13 u24 u35 u46
  1307. * * a12 a23 a34 a45 a56 * u12 u23 u34 u45 u56
  1308. * a11 a22 a33 a44 a55 a66 u11 u22 u33 u44 u55 u66
  1309. * a21 a32 a43 a54 a65 * m21 m32 m43 m54 m65 *
  1310. * a31 a42 a53 a64 * * m31 m42 m53 m64 * *
  1311. *
  1312. * Array elements marked * are not used by the routine; elements marked
  1313. * + need not be set on entry, but are required by the routine to store
  1314. * elements of U because of fill-in resulting from the row interchanges.
  1315. *
  1316. * =====================================================================
  1317. *
  1318. * .. Parameters ..
  1319. **/
  1320. int C_DGBTRF(int m, int n, int kl, int ku, double* ab, int ldab, int* ipiv)
  1321. {
  1322. int info;
  1323. ::F_DGBTRF(&m, &n, &kl, &ku, ab, &ldab, ipiv, &info);
  1324. return info;
  1325. }
  1326. /**
  1327. * Purpose
  1328. * =======
  1329. *
  1330. * DGBTRS solves a system of linear equations
  1331. * A * X = B or A' * X = B
  1332. * with a general band matrix A using the LU factorization computed
  1333. * by DGBTRF.
  1334. *
  1335. * Arguments
  1336. * =========
  1337. *
  1338. * TRANS (input) CHARACTER*1
  1339. * Specifies the form of the system of equations.
  1340. * = 'N': A * X = B (No transpose)
  1341. * = 'T': A'* X = B (Transpose)
  1342. * = 'C': A'* X = B (Conjugate transpose = Transpose)
  1343. *
  1344. * N (input) INTEGER
  1345. * The order of the matrix A. N >= 0.
  1346. *
  1347. * KL (input) INTEGER
  1348. * The number of subdiagonals within the band of A. KL >= 0.
  1349. *
  1350. * KU (input) INTEGER
  1351. * The number of superdiagonals within the band of A. KU >= 0.
  1352. *
  1353. * NRHS (input) INTEGER
  1354. * The number of right hand sides, i.e., the number of columns
  1355. * of the matrix B. NRHS >= 0.
  1356. *
  1357. * AB (input) DOUBLE PRECISION array, dimension (LDAB,N)
  1358. * Details of the LU factorization of the band matrix A, as
  1359. * computed by DGBTRF. U is stored as an upper triangular band
  1360. * matrix with KL+KU superdiagonals in rows 1 to KL+KU+1, and
  1361. * the multipliers used during the factorization are stored in
  1362. * rows KL+KU+2 to 2*KL+KU+1.
  1363. *
  1364. * LDAB (input) INTEGER
  1365. * The leading dimension of the array AB. LDAB >= 2*KL+KU+1.
  1366. *
  1367. * IPIV (input) INTEGER array, dimension (N)
  1368. * The pivot indices; for 1 <= i <= N, row i of the matrix was
  1369. * interchanged with row IPIV(i).
  1370. *
  1371. * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
  1372. * On entry, the right hand side matrix B.
  1373. * On exit, the solution matrix X.
  1374. *
  1375. * LDB (input) INTEGER
  1376. * The leading dimension of the array B. LDB >= max(1,N).
  1377. *
  1378. * C++ Return value: INFO (output) INTEGER
  1379. * = 0: successful exit
  1380. * < 0: if INFO = -i, the i-th argument had an illegal value
  1381. *
  1382. * =====================================================================
  1383. *
  1384. * .. Parameters ..
  1385. **/
  1386. int C_DGBTRS(char trans, int n, int kl, int ku, int nrhs, double* ab, int ldab, int* ipiv, double* b, int ldb)
  1387. {
  1388. int info;
  1389. ::F_DGBTRS(&trans, &n, &kl, &ku, &nrhs, ab, &ldab, ipiv, b, &ldb, &info);
  1390. return info;
  1391. }
  1392. /**
  1393. * Purpose
  1394. * =======
  1395. *
  1396. * DGEBAK forms the right or left eigenvectors of a real general matrix
  1397. * by backward transformation on the computed eigenvectors of the
  1398. * balanced matrix output by DGEBAL.
  1399. *
  1400. * Arguments
  1401. * =========
  1402. *
  1403. * JOB (input) CHARACTER*1
  1404. * Specifies the type of backward transformation required:
  1405. * = 'N', do nothing, return immediately;
  1406. * = 'P', do backward transformation for permutation only;
  1407. * = 'S', do backward transformation for scaling only;
  1408. * = 'B', do backward transformations for both permutation and
  1409. * scaling.
  1410. * JOB must be the same as the argument JOB supplied to DGEBAL.
  1411. *
  1412. * SIDE (input) CHARACTER*1
  1413. * = 'R': V contains right eigenvectors;
  1414. * = 'L': V contains left eigenvectors.
  1415. *
  1416. * N (input) INTEGER
  1417. * The number of rows of the matrix V. N >= 0.
  1418. *
  1419. * ILO (input) INTEGER
  1420. * IHI (input) INTEGER
  1421. * The integers ILO and IHI determined by DGEBAL.
  1422. * 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0.
  1423. *
  1424. * SCALE (input) DOUBLE PRECISION array, dimension (N)
  1425. * Details of the permutation and scaling factors, as returned
  1426. * by DGEBAL.
  1427. *
  1428. * M (input) INTEGER
  1429. * The number of columns of the matrix V. M >= 0.
  1430. *
  1431. * V (input/output) DOUBLE PRECISION array, dimension (LDV,M)
  1432. * On entry, the matrix of right or left eigenvectors to be
  1433. * transformed, as returned by DHSEIN or DTREVC.
  1434. * On exit, V is overwritten by the transformed eigenvectors.
  1435. *
  1436. * LDV (input) INTEGER
  1437. * The leading dimension of the array V. LDV >= max(1,N).
  1438. *
  1439. * C++ Return value: INFO (output) INTEGER
  1440. * = 0: successful exit
  1441. * < 0: if INFO = -i, the i-th argument had an illegal value.
  1442. *
  1443. * =====================================================================
  1444. *
  1445. * .. Parameters ..
  1446. **/
  1447. int C_DGEBAK(char job, char side, int n, int ilo, int ihi, double* scale, int m, double* v, int ldv)
  1448. {
  1449. int info;
  1450. ::F_DGEBAK(&job, &side, &n, &ilo, &ihi, scale, &m, v, &ldv, &info);
  1451. return info;
  1452. }
  1453. /**
  1454. * Purpose
  1455. * =======
  1456. *
  1457. * DGEBAL balances a general real matrix A. This involves, first,
  1458. * permuting A by a similarity transformation to isolate eigenvalues
  1459. * in the first 1 to ILO-1 and last IHI+1 to N elements on the
  1460. * diagonal; and second, applying a diagonal similarity transformation
  1461. * to rows and columns ILO to IHI to make the rows and columns as
  1462. * close in norm as possible. Both steps are optional.
  1463. *
  1464. * Balancing may reduce the 1-norm of the matrix, and improve the
  1465. * accuracy of the computed eigenvalues and/or eigenvectors.
  1466. *
  1467. * Arguments
  1468. * =========
  1469. *
  1470. * JOB (input) CHARACTER*1
  1471. * Specifies the operations to be performed on A:
  1472. * = 'N': none: simply set ILO = 1, IHI = N, SCALE(I) = 1.0
  1473. * for i = 1,...,N;
  1474. * = 'P': permute only;
  1475. * = 'S': scale only;
  1476. * = 'B': both permute and scale.
  1477. *
  1478. * N (input) INTEGER
  1479. * The order of the matrix A. N >= 0.
  1480. *
  1481. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  1482. * On entry, the input matrix A.
  1483. * On exit, A is overwritten by the balanced matrix.
  1484. * If JOB = 'N', A is not referenced.
  1485. * See Further Details.
  1486. *
  1487. * LDA (input) INTEGER
  1488. * The leading dimension of the array A. LDA >= max(1,N).
  1489. *
  1490. * ILO (output) INTEGER
  1491. * IHI (output) INTEGER
  1492. * ILO and IHI are set to integers such that on exit
  1493. * A(i,j) = 0 if i > j and j = 1,...,ILO-1 or I = IHI+1,...,N.
  1494. * If JOB = 'N' or 'S', ILO = 1 and IHI = N.
  1495. *
  1496. * SCALE (output) DOUBLE PRECISION array, dimension (N)
  1497. * Details of the permutations and scaling factors applied to
  1498. * A. If P(j) is the index of the row and column interchanged
  1499. * with row and column j and D(j) is the scaling factor
  1500. * applied to row and column j, then
  1501. * SCALE(j) = P(j) for j = 1,...,ILO-1
  1502. * = D(j) for j = ILO,...,IHI
  1503. * = P(j) for j = IHI+1,...,N.
  1504. * The order in which the interchanges are made is N to IHI+1,
  1505. * then 1 to ILO-1.
  1506. *
  1507. * C++ Return value: INFO (output) INTEGER
  1508. * = 0: successful exit.
  1509. * < 0: if INFO = -i, the i-th argument had an illegal value.
  1510. *
  1511. * Further Details
  1512. * ===============
  1513. *
  1514. * The permutations consist of row and column interchanges which put
  1515. * the matrix in the form
  1516. *
  1517. * ( T1 X Y )
  1518. * P A P = ( 0 B Z )
  1519. * ( 0 0 T2 )
  1520. *
  1521. * where T1 and T2 are upper triangular matrices whose eigenvalues lie
  1522. * along the diagonal. The column indices ILO and IHI mark the starting
  1523. * and ending columns of the submatrix B. Balancing consists of applying
  1524. * a diagonal similarity transformation inv(D) * B * D to make the
  1525. * 1-norms of each row of B and its corresponding column nearly equal.
  1526. * The output matrix is
  1527. *
  1528. * ( T1 X*D Y )
  1529. * ( 0 inv(D)*B*D inv(D)*Z ).
  1530. * ( 0 0 T2 )
  1531. *
  1532. * Information about the permutations P and the diagonal matrix D is
  1533. * returned in the vector SCALE.
  1534. *
  1535. * This subroutine is based on the EISPACK routine BALANC.
  1536. *
  1537. * Modified by Tzu-Yi Chen, Computer Science Division, University of
  1538. * California at Berkeley, USA
  1539. *
  1540. * =====================================================================
  1541. *
  1542. * .. Parameters ..
  1543. **/
  1544. int C_DGEBAL(char job, int n, double* a, int lda, int* ilo, int* ihi, double* scale)
  1545. {
  1546. int info;
  1547. ::F_DGEBAL(&job, &n, a, &lda, ilo, ihi, scale, &info);
  1548. return info;
  1549. }
  1550. /**
  1551. * Purpose
  1552. * =======
  1553. *
  1554. * DGEBRD reduces a general real M-by-N matrix A to upper or lower
  1555. * bidiagonal form B by an orthogonal transformation: Q**T * A * P = B.
  1556. *
  1557. * If m >= n, B is upper bidiagonal; if m < n, B is lower bidiagonal.
  1558. *
  1559. * Arguments
  1560. * =========
  1561. *
  1562. * M (input) INTEGER
  1563. * The number of rows in the matrix A. M >= 0.
  1564. *
  1565. * N (input) INTEGER
  1566. * The number of columns in the matrix A. N >= 0.
  1567. *
  1568. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  1569. * On entry, the M-by-N general matrix to be reduced.
  1570. * On exit,
  1571. * if m >= n, the diagonal and the first superdiagonal are
  1572. * overwritten with the upper bidiagonal matrix B; the
  1573. * elements below the diagonal, with the array TAUQ, represent
  1574. * the orthogonal matrix Q as a product of elementary
  1575. * reflectors, and the elements above the first superdiagonal,
  1576. * with the array TAUP, represent the orthogonal matrix P as
  1577. * a product of elementary reflectors;
  1578. * if m < n, the diagonal and the first subdiagonal are
  1579. * overwritten with the lower bidiagonal matrix B; the
  1580. * elements below the first subdiagonal, with the array TAUQ,
  1581. * represent the orthogonal matrix Q as a product of
  1582. * elementary reflectors, and the elements above the diagonal,
  1583. * with the array TAUP, represent the orthogonal matrix P as
  1584. * a product of elementary reflectors.
  1585. * See Further Details.
  1586. *
  1587. * LDA (input) INTEGER
  1588. * The leading dimension of the array A. LDA >= max(1,M).
  1589. *
  1590. * D (output) DOUBLE PRECISION array, dimension (min(M,N))
  1591. * The diagonal elements of the bidiagonal matrix B:
  1592. * D(i) = A(i,i).
  1593. *
  1594. * E (output) DOUBLE PRECISION array, dimension (min(M,N)-1)
  1595. * The off-diagonal elements of the bidiagonal matrix B:
  1596. * if m >= n, E(i) = A(i,i+1) for i = 1,2,...,n-1;
  1597. * if m < n, E(i) = A(i+1,i) for i = 1,2,...,m-1.
  1598. *
  1599. * TAUQ (output) DOUBLE PRECISION array dimension (min(M,N))
  1600. * The scalar factors of the elementary reflectors which
  1601. * represent the orthogonal matrix Q. See Further Details.
  1602. *
  1603. * TAUP (output) DOUBLE PRECISION array, dimension (min(M,N))
  1604. * The scalar factors of the elementary reflectors which
  1605. * represent the orthogonal matrix P. See Further Details.
  1606. *
  1607. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  1608. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  1609. *
  1610. * LWORK (input) INTEGER
  1611. * The length of the array WORK. LWORK >= max(1,M,N).
  1612. * For optimum performance LWORK >= (M+N)*NB, where NB
  1613. * is the optimal blocksize.
  1614. *
  1615. * If LWORK = -1, then a workspace query is assumed; the routine
  1616. * only calculates the optimal size of the WORK array, returns
  1617. * this value as the first entry of the WORK array, and no error
  1618. * message related to LWORK is issued by XERBLA.
  1619. *
  1620. * C++ Return value: INFO (output) INTEGER
  1621. * = 0: successful exit
  1622. * < 0: if INFO = -i, the i-th argument had an illegal value.
  1623. *
  1624. * Further Details
  1625. * ===============
  1626. *
  1627. * The matrices Q and P are represented as products of elementary
  1628. * reflectors:
  1629. *
  1630. * If m >= n,
  1631. *
  1632. * Q = H(1) H(2) . . . H(n) and P = G(1) G(2) . . . G(n-1)
  1633. *
  1634. * Each H(i) and G(i) has the form:
  1635. *
  1636. * H(i) = I - tauq * v * v' and G(i) = I - taup * u * u'
  1637. *
  1638. * where tauq and taup are real scalars, and v and u are real vectors;
  1639. * v(1:i-1) = 0, v(i) = 1, and v(i+1:m) is stored on exit in A(i+1:m,i);
  1640. * u(1:i) = 0, u(i+1) = 1, and u(i+2:n) is stored on exit in A(i,i+2:n);
  1641. * tauq is stored in TAUQ(i) and taup in TAUP(i).
  1642. *
  1643. * If m < n,
  1644. *
  1645. * Q = H(1) H(2) . . . H(m-1) and P = G(1) G(2) . . . G(m)
  1646. *
  1647. * Each H(i) and G(i) has the form:
  1648. *
  1649. * H(i) = I - tauq * v * v' and G(i) = I - taup * u * u'
  1650. *
  1651. * where tauq and taup are real scalars, and v and u are real vectors;
  1652. * v(1:i) = 0, v(i+1) = 1, and v(i+2:m) is stored on exit in A(i+2:m,i);
  1653. * u(1:i-1) = 0, u(i) = 1, and u(i+1:n) is stored on exit in A(i,i+1:n);
  1654. * tauq is stored in TAUQ(i) and taup in TAUP(i).
  1655. *
  1656. * The contents of A on exit are illustrated by the following examples:
  1657. *
  1658. * m = 6 and n = 5 (m > n): m = 5 and n = 6 (m < n):
  1659. *
  1660. * ( d e u1 u1 u1 ) ( d u1 u1 u1 u1 u1 )
  1661. * ( v1 d e u2 u2 ) ( e d u2 u2 u2 u2 )
  1662. * ( v1 v2 d e u3 ) ( v1 e d u3 u3 u3 )
  1663. * ( v1 v2 v3 d e ) ( v1 v2 e d u4 u4 )
  1664. * ( v1 v2 v3 v4 d ) ( v1 v2 v3 e d u5 )
  1665. * ( v1 v2 v3 v4 v5 )
  1666. *
  1667. * where d and e denote diagonal and off-diagonal elements of B, vi
  1668. * denotes an element of the vector defining H(i), and ui an element of
  1669. * the vector defining G(i).
  1670. *
  1671. * =====================================================================
  1672. *
  1673. * .. Parameters ..
  1674. **/
  1675. int C_DGEBRD(int m, int n, double* a, int lda, double* d, double* e, double* tauq, double* taup, double* work, int lwork)
  1676. {
  1677. int info;
  1678. ::F_DGEBRD(&m, &n, a, &lda, d, e, tauq, taup, work, &lwork, &info);
  1679. return info;
  1680. }
  1681. /**
  1682. * Purpose
  1683. * =======
  1684. *
  1685. * DGECON estimates the reciprocal of the condition number of a general
  1686. * real matrix A, in either the 1-norm or the infinity-norm, using
  1687. * the LU factorization computed by DGETRF.
  1688. *
  1689. * An estimate is obtained for norm(inv(A)), and the reciprocal of the
  1690. * condition number is computed as
  1691. * RCOND = 1 / ( norm(A) * norm(inv(A)) ).
  1692. *
  1693. * Arguments
  1694. * =========
  1695. *
  1696. * NORM (input) CHARACTER*1
  1697. * Specifies whether the 1-norm condition number or the
  1698. * infinity-norm condition number is required:
  1699. * = '1' or 'O': 1-norm;
  1700. * = 'I': Infinity-norm.
  1701. *
  1702. * N (input) INTEGER
  1703. * The order of the matrix A. N >= 0.
  1704. *
  1705. * A (input) DOUBLE PRECISION array, dimension (LDA,N)
  1706. * The factors L and U from the factorization A = P*L*U
  1707. * as computed by DGETRF.
  1708. *
  1709. * LDA (input) INTEGER
  1710. * The leading dimension of the array A. LDA >= max(1,N).
  1711. *
  1712. * ANORM (input) DOUBLE PRECISION
  1713. * If NORM = '1' or 'O', the 1-norm of the original matrix A.
  1714. * If NORM = 'I', the infinity-norm of the original matrix A.
  1715. *
  1716. * RCOND (output) DOUBLE PRECISION
  1717. * The reciprocal of the condition number of the matrix A,
  1718. * computed as RCOND = 1/(norm(A) * norm(inv(A))).
  1719. *
  1720. * WORK (workspace) DOUBLE PRECISION array, dimension (4*N)
  1721. *
  1722. * IWORK (workspace) INTEGER array, dimension (N)
  1723. *
  1724. * C++ Return value: INFO (output) INTEGER
  1725. * = 0: successful exit
  1726. * < 0: if INFO = -i, the i-th argument had an illegal value
  1727. *
  1728. * =====================================================================
  1729. *
  1730. * .. Parameters ..
  1731. **/
  1732. int C_DGECON(char norm, int n, double* a, int lda, double anorm, double* rcond, double* work, int* iwork)
  1733. {
  1734. int info;
  1735. ::F_DGECON(&norm, &n, a, &lda, &anorm, rcond, work, iwork, &info);
  1736. return info;
  1737. }
  1738. /**
  1739. * Purpose
  1740. * =======
  1741. *
  1742. * DGEEQU computes row and column scalings intended to equilibrate an
  1743. * M-by-N matrix A and reduce its condition number. R returns the row
  1744. * scale factors and C the column scale factors, chosen to try to make
  1745. * the largest element in each row and column of the matrix B with
  1746. * elements B(i,j)=R(i)*A(i,j)*C(j) have absolute value 1.
  1747. *
  1748. * R(i) and C(j) are restricted to be between SMLNUM = smallest safe
  1749. * number and BIGNUM = largest safe number. Use of these scaling
  1750. * factors is not guaranteed to reduce the condition number of A but
  1751. * works well in practice.
  1752. *
  1753. * Arguments
  1754. * =========
  1755. *
  1756. * M (input) INTEGER
  1757. * The number of rows of the matrix A. M >= 0.
  1758. *
  1759. * N (input) INTEGER
  1760. * The number of columns of the matrix A. N >= 0.
  1761. *
  1762. * A (input) DOUBLE PRECISION array, dimension (LDA,N)
  1763. * The M-by-N matrix whose equilibration factors are
  1764. * to be computed.
  1765. *
  1766. * LDA (input) INTEGER
  1767. * The leading dimension of the array A. LDA >= max(1,M).
  1768. *
  1769. * R (output) DOUBLE PRECISION array, dimension (M)
  1770. * If INFO = 0 or INFO > M, R contains the row scale factors
  1771. * for A.
  1772. *
  1773. * C (output) DOUBLE PRECISION array, dimension (N)
  1774. * If INFO = 0, C contains the column scale factors for A.
  1775. *
  1776. * ROWCND (output) DOUBLE PRECISION
  1777. * If INFO = 0 or INFO > M, ROWCND contains the ratio of the
  1778. * smallest R(i) to the largest R(i). If ROWCND >= 0.1 and
  1779. * AMAX is neither too large nor too small, it is not worth
  1780. * scaling by R.
  1781. *
  1782. * COLCND (output) DOUBLE PRECISION
  1783. * If INFO = 0, COLCND contains the ratio of the smallest
  1784. * C(i) to the largest C(i). If COLCND >= 0.1, it is not
  1785. * worth scaling by C.
  1786. *
  1787. * AMAX (output) DOUBLE PRECISION
  1788. * Absolute value of largest matrix element. If AMAX is very
  1789. * close to overflow or very close to underflow, the matrix
  1790. * should be scaled.
  1791. *
  1792. * C++ Return value: INFO (output) INTEGER
  1793. * = 0: successful exit
  1794. * < 0: if INFO = -i, the i-th argument had an illegal value
  1795. * > 0: if INFO = i, and i is
  1796. * <= M: the i-th row of A is exactly zero
  1797. * > M: the (i-M)-th column of A is exactly zero
  1798. *
  1799. * =====================================================================
  1800. *
  1801. * .. Parameters ..
  1802. **/
  1803. int C_DGEEQU(int m, int n, double* a, int lda, double* r, double* c, double* rowcnd, double* colcnd, double* amax)
  1804. {
  1805. int info;
  1806. ::F_DGEEQU(&m, &n, a, &lda, r, c, rowcnd, colcnd, amax, &info);
  1807. return info;
  1808. }
  1809. /**
  1810. * Purpose
  1811. * =======
  1812. *
  1813. * DGEES computes for an N-by-N real nonsymmetric matrix A, the
  1814. * eigenvalues, the real Schur form T, and, optionally, the matrix of
  1815. * Schur vectors Z. This gives the Schur factorization A = Z*T*(Z**T).
  1816. *
  1817. * Optionally, it also orders the eigenvalues on the diagonal of the
  1818. * real Schur form so that selected eigenvalues are at the top left.
  1819. * The leading columns of Z then form an orthonormal basis for the
  1820. * invariant subspace corresponding to the selected eigenvalues.
  1821. *
  1822. * A matrix is in real Schur form if it is upper quasi-triangular with
  1823. * 1-by-1 and 2-by-2 blocks. 2-by-2 blocks will be standardized in the
  1824. * form
  1825. * [ a b ]
  1826. * [ c a ]
  1827. *
  1828. * where b*c < 0. The eigenvalues of such a block are a +- sqrt(bc).
  1829. *
  1830. * Arguments
  1831. * =========
  1832. *
  1833. * JOBVS (input) CHARACTER*1
  1834. * = 'N': Schur vectors are not computed;
  1835. * = 'V': Schur vectors are computed.
  1836. *
  1837. * SORT (input) CHARACTER*1
  1838. * Specifies whether or not to order the eigenvalues on the
  1839. * diagonal of the Schur form.
  1840. * = 'N': Eigenvalues are not ordered;
  1841. * = 'S': Eigenvalues are ordered (see SELECT).
  1842. *
  1843. * SELECT (external procedure) LOGICAL FUNCTION of two DOUBLE PRECISION arguments
  1844. * SELECT must be declared EXTERNAL in the calling subroutine.
  1845. * If SORT = 'S', SELECT is used to select eigenvalues to sort
  1846. * to the top left of the Schur form.
  1847. * If SORT = 'N', SELECT is not referenced.
  1848. * An eigenvalue WR(j)+sqrt(-1)*WI(j) is selected if
  1849. * SELECT(WR(j),WI(j)) is true; i.e., if either one of a complex
  1850. * conjugate pair of eigenvalues is selected, then both complex
  1851. * eigenvalues are selected.
  1852. * Note that a selected complex eigenvalue may no longer
  1853. * satisfy SELECT(WR(j),WI(j)) = .TRUE. after ordering, since
  1854. * ordering may change the value of complex eigenvalues
  1855. * (especially if the eigenvalue is ill-conditioned); in this
  1856. * case INFO is set to N+2 (see INFO below).
  1857. *
  1858. * N (input) INTEGER
  1859. * The order of the matrix A. N >= 0.
  1860. *
  1861. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  1862. * On entry, the N-by-N matrix A.
  1863. * On exit, A has been overwritten by its real Schur form T.
  1864. *
  1865. * LDA (input) INTEGER
  1866. * The leading dimension of the array A. LDA >= max(1,N).
  1867. *
  1868. * SDIM (output) INTEGER
  1869. * If SORT = 'N', SDIM = 0.
  1870. * If SORT = 'S', SDIM = number of eigenvalues (after sorting)
  1871. * for which SELECT is true. (Complex conjugate
  1872. * pairs for which SELECT is true for either
  1873. * eigenvalue count as 2.)
  1874. *
  1875. * WR (output) DOUBLE PRECISION array, dimension (N)
  1876. * WI (output) DOUBLE PRECISION array, dimension (N)
  1877. * WR and WI contain the real and imaginary parts,
  1878. * respectively, of the computed eigenvalues in the same order
  1879. * that they appear on the diagonal of the output Schur form T.
  1880. * Complex conjugate pairs of eigenvalues will appear
  1881. * consecutively with the eigenvalue having the positive
  1882. * imaginary part first.
  1883. *
  1884. * VS (output) DOUBLE PRECISION array, dimension (LDVS,N)
  1885. * If JOBVS = 'V', VS contains the orthogonal matrix Z of Schur
  1886. * vectors.
  1887. * If JOBVS = 'N', VS is not referenced.
  1888. *
  1889. * LDVS (input) INTEGER
  1890. * The leading dimension of the array VS. LDVS >= 1; if
  1891. * JOBVS = 'V', LDVS >= N.
  1892. *
  1893. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  1894. * On exit, if INFO = 0, WORK(1) contains the optimal LWORK.
  1895. *
  1896. * LWORK (input) INTEGER
  1897. * The dimension of the array WORK. LWORK >= max(1,3*N).
  1898. * For good performance, LWORK must generally be larger.
  1899. *
  1900. * If LWORK = -1, then a workspace query is assumed; the routine
  1901. * only calculates the optimal size of the WORK array, returns
  1902. * this value as the first entry of the WORK array, and no error
  1903. * message related to LWORK is issued by XERBLA.
  1904. *
  1905. * BWORK (workspace) LOGICAL array, dimension (N)
  1906. * Not referenced if SORT = 'N'.
  1907. *
  1908. * C++ Return value: INFO (output) INTEGER
  1909. * = 0: successful exit
  1910. * < 0: if INFO = -i, the i-th argument had an illegal value.
  1911. * > 0: if INFO = i, and i is
  1912. * <= N: the QR algorithm failed to compute all the
  1913. * eigenvalues; elements 1:ILO-1 and i+1:N of WR and WI
  1914. * contain those eigenvalues which have converged; if
  1915. * JOBVS = 'V', VS contains the matrix which reduces A
  1916. * to its partially converged Schur form.
  1917. * = N+1: the eigenvalues could not be reordered because some
  1918. * eigenvalues were too close to separate (the problem
  1919. * is very ill-conditioned);
  1920. * = N+2: after reordering, roundoff changed values of some
  1921. * complex eigenvalues so that leading eigenvalues in
  1922. * the Schur form no longer satisfy SELECT=.TRUE. This
  1923. * could also be caused by underflow due to scaling.
  1924. *
  1925. * =====================================================================
  1926. *
  1927. * .. Parameters ..
  1928. **/
  1929. int C_DGEES(char jobvs, char sort, int n, double* a, int lda, int* sdim, double* wr, double* wi, double* vs, int ldvs, double* work, int lwork)
  1930. {
  1931. int info;
  1932. ::F_DGEES(&jobvs, &sort, &n, a, &lda, sdim, wr, wi, vs, &ldvs, work, &lwork, &info);
  1933. return info;
  1934. }
  1935. /**
  1936. * Purpose
  1937. * =======
  1938. *
  1939. * DGEESX computes for an N-by-N real nonsymmetric matrix A, the
  1940. * eigenvalues, the real Schur form T, and, optionally, the matrix of
  1941. * Schur vectors Z. This gives the Schur factorization A = Z*T*(Z**T).
  1942. *
  1943. * Optionally, it also orders the eigenvalues on the diagonal of the
  1944. * real Schur form so that selected eigenvalues are at the top left;
  1945. * computes a reciprocal condition number for the average of the
  1946. * selected eigenvalues (RCONDE); and computes a reciprocal condition
  1947. * number for the right invariant subspace corresponding to the
  1948. * selected eigenvalues (RCONDV). The leading columns of Z form an
  1949. * orthonormal basis for this invariant subspace.
  1950. *
  1951. * For further explanation of the reciprocal condition numbers RCONDE
  1952. * and RCONDV, see Section 4.10 of the LAPACK Users' Guide (where
  1953. * these quantities are called s and sep respectively).
  1954. *
  1955. * A real matrix is in real Schur form if it is upper quasi-triangular
  1956. * with 1-by-1 and 2-by-2 blocks. 2-by-2 blocks will be standardized in
  1957. * the form
  1958. * [ a b ]
  1959. * [ c a ]
  1960. *
  1961. * where b*c < 0. The eigenvalues of such a block are a +- sqrt(bc).
  1962. *
  1963. * Arguments
  1964. * =========
  1965. *
  1966. * JOBVS (input) CHARACTER*1
  1967. * = 'N': Schur vectors are not computed;
  1968. * = 'V': Schur vectors are computed.
  1969. *
  1970. * SORT (input) CHARACTER*1
  1971. * Specifies whether or not to order the eigenvalues on the
  1972. * diagonal of the Schur form.
  1973. * = 'N': Eigenvalues are not ordered;
  1974. * = 'S': Eigenvalues are ordered (see SELECT).
  1975. *
  1976. * SELECT (external procedure) LOGICAL FUNCTION of two DOUBLE PRECISION arguments
  1977. * SELECT must be declared EXTERNAL in the calling subroutine.
  1978. * If SORT = 'S', SELECT is used to select eigenvalues to sort
  1979. * to the top left of the Schur form.
  1980. * If SORT = 'N', SELECT is not referenced.
  1981. * An eigenvalue WR(j)+sqrt(-1)*WI(j) is selected if
  1982. * SELECT(WR(j),WI(j)) is true; i.e., if either one of a
  1983. * complex conjugate pair of eigenvalues is selected, then both
  1984. * are. Note that a selected complex eigenvalue may no longer
  1985. * satisfy SELECT(WR(j),WI(j)) = .TRUE. after ordering, since
  1986. * ordering may change the value of complex eigenvalues
  1987. * (especially if the eigenvalue is ill-conditioned); in this
  1988. * case INFO may be set to N+3 (see INFO below).
  1989. *
  1990. * SENSE (input) CHARACTER*1
  1991. * Determines which reciprocal condition numbers are computed.
  1992. * = 'N': None are computed;
  1993. * = 'E': Computed for average of selected eigenvalues only;
  1994. * = 'V': Computed for selected right invariant subspace only;
  1995. * = 'B': Computed for both.
  1996. * If SENSE = 'E', 'V' or 'B', SORT must equal 'S'.
  1997. *
  1998. * N (input) INTEGER
  1999. * The order of the matrix A. N >= 0.
  2000. *
  2001. * A (input/output) DOUBLE PRECISION array, dimension (LDA, N)
  2002. * On entry, the N-by-N matrix A.
  2003. * On exit, A is overwritten by its real Schur form T.
  2004. *
  2005. * LDA (input) INTEGER
  2006. * The leading dimension of the array A. LDA >= max(1,N).
  2007. *
  2008. * SDIM (output) INTEGER
  2009. * If SORT = 'N', SDIM = 0.
  2010. * If SORT = 'S', SDIM = number of eigenvalues (after sorting)
  2011. * for which SELECT is true. (Complex conjugate
  2012. * pairs for which SELECT is true for either
  2013. * eigenvalue count as 2.)
  2014. *
  2015. * WR (output) DOUBLE PRECISION array, dimension (N)
  2016. * WI (output) DOUBLE PRECISION array, dimension (N)
  2017. * WR and WI contain the real and imaginary parts, respectively,
  2018. * of the computed eigenvalues, in the same order that they
  2019. * appear on the diagonal of the output Schur form T. Complex
  2020. * conjugate pairs of eigenvalues appear consecutively with the
  2021. * eigenvalue having the positive imaginary part first.
  2022. *
  2023. * VS (output) DOUBLE PRECISION array, dimension (LDVS,N)
  2024. * If JOBVS = 'V', VS contains the orthogonal matrix Z of Schur
  2025. * vectors.
  2026. * If JOBVS = 'N', VS is not referenced.
  2027. *
  2028. * LDVS (input) INTEGER
  2029. * The leading dimension of the array VS. LDVS >= 1, and if
  2030. * JOBVS = 'V', LDVS >= N.
  2031. *
  2032. * RCONDE (output) DOUBLE PRECISION
  2033. * If SENSE = 'E' or 'B', RCONDE contains the reciprocal
  2034. * condition number for the average of the selected eigenvalues.
  2035. * Not referenced if SENSE = 'N' or 'V'.
  2036. *
  2037. * RCONDV (output) DOUBLE PRECISION
  2038. * If SENSE = 'V' or 'B', RCONDV contains the reciprocal
  2039. * condition number for the selected right invariant subspace.
  2040. * Not referenced if SENSE = 'N' or 'E'.
  2041. *
  2042. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  2043. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  2044. *
  2045. * LWORK (input) INTEGER
  2046. * The dimension of the array WORK. LWORK >= max(1,3*N).
  2047. * Also, if SENSE = 'E' or 'V' or 'B',
  2048. * LWORK >= N+2*SDIM*(N-SDIM), where SDIM is the number of
  2049. * selected eigenvalues computed by this routine. Note that
  2050. * N+2*SDIM*(N-SDIM) <= N+N*N/2. Note also that an error is only
  2051. * returned if LWORK < max(1,3*N), but if SENSE = 'E' or 'V' or
  2052. * 'B' this may not be large enough.
  2053. * For good performance, LWORK must generally be larger.
  2054. *
  2055. * If LWORK = -1, then a workspace query is assumed; the routine
  2056. * only calculates upper bounds on the optimal sizes of the
  2057. * arrays WORK and IWORK, returns these values as the first
  2058. * entries of the WORK and IWORK arrays, and no error messages
  2059. * related to LWORK or LIWORK are issued by XERBLA.
  2060. *
  2061. * IWORK (workspace/output) INTEGER array, dimension (MAX(1,LIWORK))
  2062. * On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK.
  2063. *
  2064. * LIWORK (input) INTEGER
  2065. * The dimension of the array IWORK.
  2066. * LIWORK >= 1; if SENSE = 'V' or 'B', LIWORK >= SDIM*(N-SDIM).
  2067. * Note that SDIM*(N-SDIM) <= N*N/4. Note also that an error is
  2068. * only returned if LIWORK < 1, but if SENSE = 'V' or 'B' this
  2069. * may not be large enough.
  2070. *
  2071. * If LIWORK = -1, then a workspace query is assumed; the
  2072. * routine only calculates upper bounds on the optimal sizes of
  2073. * the arrays WORK and IWORK, returns these values as the first
  2074. * entries of the WORK and IWORK arrays, and no error messages
  2075. * related to LWORK or LIWORK are issued by XERBLA.
  2076. *
  2077. * BWORK (workspace) LOGICAL array, dimension (N)
  2078. * Not referenced if SORT = 'N'.
  2079. *
  2080. * C++ Return value: INFO (output) INTEGER
  2081. * = 0: successful exit
  2082. * < 0: if INFO = -i, the i-th argument had an illegal value.
  2083. * > 0: if INFO = i, and i is
  2084. * <= N: the QR algorithm failed to compute all the
  2085. * eigenvalues; elements 1:ILO-1 and i+1:N of WR and WI
  2086. * contain those eigenvalues which have converged; if
  2087. * JOBVS = 'V', VS contains the transformation which
  2088. * reduces A to its partially converged Schur form.
  2089. * = N+1: the eigenvalues could not be reordered because some
  2090. * eigenvalues were too close to separate (the problem
  2091. * is very ill-conditioned);
  2092. * = N+2: after reordering, roundoff changed values of some
  2093. * complex eigenvalues so that leading eigenvalues in
  2094. * the Schur form no longer satisfy SELECT=.TRUE. This
  2095. * could also be caused by underflow due to scaling.
  2096. *
  2097. * =====================================================================
  2098. *
  2099. * .. Parameters ..
  2100. **/
  2101. int C_DGEESX(char jobvs, char sort, char sense, int n, double* a, int lda, int* sdim, double* wr, double* wi, double* vs, int ldvs, double* rconde, double* rcondv, double* work, int lwork, int* iwork, int liwork)
  2102. {
  2103. int info;
  2104. ::F_DGEESX(&jobvs, &sort, &sense, &n, a, &lda, sdim, wr, wi, vs, &ldvs, rconde, rcondv, work, &lwork, iwork, &liwork, &info);
  2105. return info;
  2106. }
  2107. /**
  2108. * Purpose
  2109. * =======
  2110. *
  2111. * DGEEV computes for an N-by-N real nonsymmetric matrix A, the
  2112. * eigenvalues and, optionally, the left and/or right eigenvectors.
  2113. *
  2114. * The right eigenvector v(j) of A satisfies
  2115. * A * v(j) = lambda(j) * v(j)
  2116. * where lambda(j) is its eigenvalue.
  2117. * The left eigenvector u(j) of A satisfies
  2118. * u(j)**H * A = lambda(j) * u(j)**H
  2119. * where u(j)**H denotes the conjugate transpose of u(j).
  2120. *
  2121. * The computed eigenvectors are normalized to have Euclidean norm
  2122. * equal to 1 and largest component real.
  2123. *
  2124. * Arguments
  2125. * =========
  2126. *
  2127. * JOBVL (input) CHARACTER*1
  2128. * = 'N': left eigenvectors of A are not computed;
  2129. * = 'V': left eigenvectors of A are computed.
  2130. *
  2131. * JOBVR (input) CHARACTER*1
  2132. * = 'N': right eigenvectors of A are not computed;
  2133. * = 'V': right eigenvectors of A are computed.
  2134. *
  2135. * N (input) INTEGER
  2136. * The order of the matrix A. N >= 0.
  2137. *
  2138. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  2139. * On entry, the N-by-N matrix A.
  2140. * On exit, A has been overwritten.
  2141. *
  2142. * LDA (input) INTEGER
  2143. * The leading dimension of the array A. LDA >= max(1,N).
  2144. *
  2145. * WR (output) DOUBLE PRECISION array, dimension (N)
  2146. * WI (output) DOUBLE PRECISION array, dimension (N)
  2147. * WR and WI contain the real and imaginary parts,
  2148. * respectively, of the computed eigenvalues. Complex
  2149. * conjugate pairs of eigenvalues appear consecutively
  2150. * with the eigenvalue having the positive imaginary part
  2151. * first.
  2152. *
  2153. * VL (output) DOUBLE PRECISION array, dimension (LDVL,N)
  2154. * If JOBVL = 'V', the left eigenvectors u(j) are stored one
  2155. * after another in the columns of VL, in the same order
  2156. * as their eigenvalues.
  2157. * If JOBVL = 'N', VL is not referenced.
  2158. * If the j-th eigenvalue is real, then u(j) = VL(:,j),
  2159. * the j-th column of VL.
  2160. * If the j-th and (j+1)-st eigenvalues form a complex
  2161. * conjugate pair, then u(j) = VL(:,j) + i*VL(:,j+1) and
  2162. * u(j+1) = VL(:,j) - i*VL(:,j+1).
  2163. *
  2164. * LDVL (input) INTEGER
  2165. * The leading dimension of the array VL. LDVL >= 1; if
  2166. * JOBVL = 'V', LDVL >= N.
  2167. *
  2168. * VR (output) DOUBLE PRECISION array, dimension (LDVR,N)
  2169. * If JOBVR = 'V', the right eigenvectors v(j) are stored one
  2170. * after another in the columns of VR, in the same order
  2171. * as their eigenvalues.
  2172. * If JOBVR = 'N', VR is not referenced.
  2173. * If the j-th eigenvalue is real, then v(j) = VR(:,j),
  2174. * the j-th column of VR.
  2175. * If the j-th and (j+1)-st eigenvalues form a complex
  2176. * conjugate pair, then v(j) = VR(:,j) + i*VR(:,j+1) and
  2177. * v(j+1) = VR(:,j) - i*VR(:,j+1).
  2178. *
  2179. * LDVR (input) INTEGER
  2180. * The leading dimension of the array VR. LDVR >= 1; if
  2181. * JOBVR = 'V', LDVR >= N.
  2182. *
  2183. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  2184. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  2185. *
  2186. * LWORK (input) INTEGER
  2187. * The dimension of the array WORK. LWORK >= max(1,3*N), and
  2188. * if JOBVL = 'V' or JOBVR = 'V', LWORK >= 4*N. For good
  2189. * performance, LWORK must generally be larger.
  2190. *
  2191. * If LWORK = -1, then a workspace query is assumed; the routine
  2192. * only calculates the optimal size of the WORK array, returns
  2193. * this value as the first entry of the WORK array, and no error
  2194. * message related to LWORK is issued by XERBLA.
  2195. *
  2196. * C++ Return value: INFO (output) INTEGER
  2197. * = 0: successful exit
  2198. * < 0: if INFO = -i, the i-th argument had an illegal value.
  2199. * > 0: if INFO = i, the QR algorithm failed to compute all the
  2200. * eigenvalues, and no eigenvectors have been computed;
  2201. * elements i+1:N of WR and WI contain eigenvalues which
  2202. * have converged.
  2203. *
  2204. * =====================================================================
  2205. *
  2206. * .. Parameters ..
  2207. **/
  2208. int C_DGEEV(char jobvl, char jobvr, int n, double* a, int lda, double* wr, double* wi, double* vl, int ldvl, double* vr, int ldvr, double* work, int lwork)
  2209. {
  2210. int info;
  2211. ::F_DGEEV(&jobvl, &jobvr, &n, a, &lda, wr, wi, vl, &ldvl, vr, &ldvr, work, &lwork, &info);
  2212. return info;
  2213. }
  2214. /**
  2215. * Purpose
  2216. * =======
  2217. *
  2218. * DGEEVX computes for an N-by-N real nonsymmetric matrix A, the
  2219. * eigenvalues and, optionally, the left and/or right eigenvectors.
  2220. *
  2221. * Optionally also, it computes a balancing transformation to improve
  2222. * the conditioning of the eigenvalues and eigenvectors (ILO, IHI,
  2223. * SCALE, and ABNRM), reciprocal condition numbers for the eigenvalues
  2224. * (RCONDE), and reciprocal condition numbers for the right
  2225. * eigenvectors (RCONDV).
  2226. *
  2227. * The right eigenvector v(j) of A satisfies
  2228. * A * v(j) = lambda(j) * v(j)
  2229. * where lambda(j) is its eigenvalue.
  2230. * The left eigenvector u(j) of A satisfies
  2231. * u(j)**H * A = lambda(j) * u(j)**H
  2232. * where u(j)**H denotes the conjugate transpose of u(j).
  2233. *
  2234. * The computed eigenvectors are normalized to have Euclidean norm
  2235. * equal to 1 and largest component real.
  2236. *
  2237. * Balancing a matrix means permuting the rows and columns to make it
  2238. * more nearly upper triangular, and applying a diagonal similarity
  2239. * transformation D * A * D**(-1), where D is a diagonal matrix, to
  2240. * make its rows and columns closer in norm and the condition numbers
  2241. * of its eigenvalues and eigenvectors smaller. The computed
  2242. * reciprocal condition numbers correspond to the balanced matrix.
  2243. * Permuting rows and columns will not change the condition numbers
  2244. * (in exact arithmetic) but diagonal scaling will. For further
  2245. * explanation of balancing, see section 4.10.2 of the LAPACK
  2246. * Users' Guide.
  2247. *
  2248. * Arguments
  2249. * =========
  2250. *
  2251. * BALANC (input) CHARACTER*1
  2252. * Indicates how the input matrix should be diagonally scaled
  2253. * and/or permuted to improve the conditioning of its
  2254. * eigenvalues.
  2255. * = 'N': Do not diagonally scale or permute;
  2256. * = 'P': Perform permutations to make the matrix more nearly
  2257. * upper triangular. Do not diagonally scale;
  2258. * = 'S': Diagonally scale the matrix, i.e. replace A by
  2259. * D*A*D**(-1), where D is a diagonal matrix chosen
  2260. * to make the rows and columns of A more equal in
  2261. * norm. Do not permute;
  2262. * = 'B': Both diagonally scale and permute A.
  2263. *
  2264. * Computed reciprocal condition numbers will be for the matrix
  2265. * after balancing and/or permuting. Permuting does not change
  2266. * condition numbers (in exact arithmetic), but balancing does.
  2267. *
  2268. * JOBVL (input) CHARACTER*1
  2269. * = 'N': left eigenvectors of A are not computed;
  2270. * = 'V': left eigenvectors of A are computed.
  2271. * If SENSE = 'E' or 'B', JOBVL must = 'V'.
  2272. *
  2273. * JOBVR (input) CHARACTER*1
  2274. * = 'N': right eigenvectors of A are not computed;
  2275. * = 'V': right eigenvectors of A are computed.
  2276. * If SENSE = 'E' or 'B', JOBVR must = 'V'.
  2277. *
  2278. * SENSE (input) CHARACTER*1
  2279. * Determines which reciprocal condition numbers are computed.
  2280. * = 'N': None are computed;
  2281. * = 'E': Computed for eigenvalues only;
  2282. * = 'V': Computed for right eigenvectors only;
  2283. * = 'B': Computed for eigenvalues and right eigenvectors.
  2284. *
  2285. * If SENSE = 'E' or 'B', both left and right eigenvectors
  2286. * must also be computed (JOBVL = 'V' and JOBVR = 'V').
  2287. *
  2288. * N (input) INTEGER
  2289. * The order of the matrix A. N >= 0.
  2290. *
  2291. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  2292. * On entry, the N-by-N matrix A.
  2293. * On exit, A has been overwritten. If JOBVL = 'V' or
  2294. * JOBVR = 'V', A contains the real Schur form of the balanced
  2295. * version of the input matrix A.
  2296. *
  2297. * LDA (input) INTEGER
  2298. * The leading dimension of the array A. LDA >= max(1,N).
  2299. *
  2300. * WR (output) DOUBLE PRECISION array, dimension (N)
  2301. * WI (output) DOUBLE PRECISION array, dimension (N)
  2302. * WR and WI contain the real and imaginary parts,
  2303. * respectively, of the computed eigenvalues. Complex
  2304. * conjugate pairs of eigenvalues will appear consecutively
  2305. * with the eigenvalue having the positive imaginary part
  2306. * first.
  2307. *
  2308. * VL (output) DOUBLE PRECISION array, dimension (LDVL,N)
  2309. * If JOBVL = 'V', the left eigenvectors u(j) are stored one
  2310. * after another in the columns of VL, in the same order
  2311. * as their eigenvalues.
  2312. * If JOBVL = 'N', VL is not referenced.
  2313. * If the j-th eigenvalue is real, then u(j) = VL(:,j),
  2314. * the j-th column of VL.
  2315. * If the j-th and (j+1)-st eigenvalues form a complex
  2316. * conjugate pair, then u(j) = VL(:,j) + i*VL(:,j+1) and
  2317. * u(j+1) = VL(:,j) - i*VL(:,j+1).
  2318. *
  2319. * LDVL (input) INTEGER
  2320. * The leading dimension of the array VL. LDVL >= 1; if
  2321. * JOBVL = 'V', LDVL >= N.
  2322. *
  2323. * VR (output) DOUBLE PRECISION array, dimension (LDVR,N)
  2324. * If JOBVR = 'V', the right eigenvectors v(j) are stored one
  2325. * after another in the columns of VR, in the same order
  2326. * as their eigenvalues.
  2327. * If JOBVR = 'N', VR is not referenced.
  2328. * If the j-th eigenvalue is real, then v(j) = VR(:,j),
  2329. * the j-th column of VR.
  2330. * If the j-th and (j+1)-st eigenvalues form a complex
  2331. * conjugate pair, then v(j) = VR(:,j) + i*VR(:,j+1) and
  2332. * v(j+1) = VR(:,j) - i*VR(:,j+1).
  2333. *
  2334. * LDVR (input) INTEGER
  2335. * The leading dimension of the array VR. LDVR >= 1, and if
  2336. * JOBVR = 'V', LDVR >= N.
  2337. *
  2338. * ILO (output) INTEGER
  2339. * IHI (output) INTEGER
  2340. * ILO and IHI are integer values determined when A was
  2341. * balanced. The balanced A(i,j) = 0 if I > J and
  2342. * J = 1,...,ILO-1 or I = IHI+1,...,N.
  2343. *
  2344. * SCALE (output) DOUBLE PRECISION array, dimension (N)
  2345. * Details of the permutations and scaling factors applied
  2346. * when balancing A. If P(j) is the index of the row and column
  2347. * interchanged with row and column j, and D(j) is the scaling
  2348. * factor applied to row and column j, then
  2349. * SCALE(J) = P(J), for J = 1,...,ILO-1
  2350. * = D(J), for J = ILO,...,IHI
  2351. * = P(J) for J = IHI+1,...,N.
  2352. * The order in which the interchanges are made is N to IHI+1,
  2353. * then 1 to ILO-1.
  2354. *
  2355. * ABNRM (output) DOUBLE PRECISION
  2356. * The one-norm of the balanced matrix (the maximum
  2357. * of the sum of absolute values of elements of any column).
  2358. *
  2359. * RCONDE (output) DOUBLE PRECISION array, dimension (N)
  2360. * RCONDE(j) is the reciprocal condition number of the j-th
  2361. * eigenvalue.
  2362. *
  2363. * RCONDV (output) DOUBLE PRECISION array, dimension (N)
  2364. * RCONDV(j) is the reciprocal condition number of the j-th
  2365. * right eigenvector.
  2366. *
  2367. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  2368. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  2369. *
  2370. * LWORK (input) INTEGER
  2371. * The dimension of the array WORK. If SENSE = 'N' or 'E',
  2372. * LWORK >= max(1,2*N), and if JOBVL = 'V' or JOBVR = 'V',
  2373. * LWORK >= 3*N. If SENSE = 'V' or 'B', LWORK >= N*(N+6).
  2374. * For good performance, LWORK must generally be larger.
  2375. *
  2376. * If LWORK = -1, then a workspace query is assumed; the routine
  2377. * only calculates the optimal size of the WORK array, returns
  2378. * this value as the first entry of the WORK array, and no error
  2379. * message related to LWORK is issued by XERBLA.
  2380. *
  2381. * IWORK (workspace) INTEGER array, dimension (2*N-2)
  2382. * If SENSE = 'N' or 'E', not referenced.
  2383. *
  2384. * C++ Return value: INFO (output) INTEGER
  2385. * = 0: successful exit
  2386. * < 0: if INFO = -i, the i-th argument had an illegal value.
  2387. * > 0: if INFO = i, the QR algorithm failed to compute all the
  2388. * eigenvalues, and no eigenvectors or condition numbers
  2389. * have been computed; elements 1:ILO-1 and i+1:N of WR
  2390. * and WI contain eigenvalues which have converged.
  2391. *
  2392. * =====================================================================
  2393. *
  2394. * .. Parameters ..
  2395. **/
  2396. int C_DGEEVX(char balanc, char jobvl, char jobvr, char sense, int n, double* a, int lda, double* wr, double* wi, double* vl, int ldvl, double* vr, int ldvr, int* ilo, int* ihi, double* scale, double* abnrm, double* rconde, double* rcondv, double* work, int lwork, int* iwork)
  2397. {
  2398. int info;
  2399. ::F_DGEEVX(&balanc, &jobvl, &jobvr, &sense, &n, a, &lda, wr, wi, vl, &ldvl, vr, &ldvr, ilo, ihi, scale, abnrm, rconde, rcondv, work, &lwork, iwork, &info);
  2400. return info;
  2401. }
  2402. /**
  2403. * Purpose
  2404. * =======
  2405. *
  2406. * This routine is deprecated and has been replaced by routine DGGES.
  2407. *
  2408. * DGEGS computes the eigenvalues, real Schur form, and, optionally,
  2409. * left and or/right Schur vectors of a real matrix pair (A,B).
  2410. * Given two square matrices A and B, the generalized real Schur
  2411. * factorization has the form
  2412. *
  2413. * A = Q*S*Z**T, B = Q*T*Z**T
  2414. *
  2415. * where Q and Z are orthogonal matrices, T is upper triangular, and S
  2416. * is an upper quasi-triangular matrix with 1-by-1 and 2-by-2 diagonal
  2417. * blocks, the 2-by-2 blocks corresponding to complex conjugate pairs
  2418. * of eigenvalues of (A,B). The columns of Q are the left Schur vectors
  2419. * and the columns of Z are the right Schur vectors.
  2420. *
  2421. * If only the eigenvalues of (A,B) are needed, the driver routine
  2422. * DGEGV should be used instead. See DGEGV for a description of the
  2423. * eigenvalues of the generalized nonsymmetric eigenvalue problem
  2424. * (GNEP).
  2425. *
  2426. * Arguments
  2427. * =========
  2428. *
  2429. * JOBVSL (input) CHARACTER*1
  2430. * = 'N': do not compute the left Schur vectors;
  2431. * = 'V': compute the left Schur vectors (returned in VSL).
  2432. *
  2433. * JOBVSR (input) CHARACTER*1
  2434. * = 'N': do not compute the right Schur vectors;
  2435. * = 'V': compute the right Schur vectors (returned in VSR).
  2436. *
  2437. * N (input) INTEGER
  2438. * The order of the matrices A, B, VSL, and VSR. N >= 0.
  2439. *
  2440. * A (input/output) DOUBLE PRECISION array, dimension (LDA, N)
  2441. * On entry, the matrix A.
  2442. * On exit, the upper quasi-triangular matrix S from the
  2443. * generalized real Schur factorization.
  2444. *
  2445. * LDA (input) INTEGER
  2446. * The leading dimension of A. LDA >= max(1,N).
  2447. *
  2448. * B (input/output) DOUBLE PRECISION array, dimension (LDB, N)
  2449. * On entry, the matrix B.
  2450. * On exit, the upper triangular matrix T from the generalized
  2451. * real Schur factorization.
  2452. *
  2453. * LDB (input) INTEGER
  2454. * The leading dimension of B. LDB >= max(1,N).
  2455. *
  2456. * ALPHAR (output) DOUBLE PRECISION array, dimension (N)
  2457. * The real parts of each scalar alpha defining an eigenvalue
  2458. * of GNEP.
  2459. *
  2460. * ALPHAI (output) DOUBLE PRECISION array, dimension (N)
  2461. * The imaginary parts of each scalar alpha defining an
  2462. * eigenvalue of GNEP. If ALPHAI(j) is zero, then the j-th
  2463. * eigenvalue is real; if positive, then the j-th and (j+1)-st
  2464. * eigenvalues are a complex conjugate pair, with
  2465. * ALPHAI(j+1) = -ALPHAI(j).
  2466. *
  2467. * BETA (output) DOUBLE PRECISION array, dimension (N)
  2468. * The scalars beta that define the eigenvalues of GNEP.
  2469. * Together, the quantities alpha = (ALPHAR(j),ALPHAI(j)) and
  2470. * beta = BETA(j) represent the j-th eigenvalue of the matrix
  2471. * pair (A,B), in one of the forms lambda = alpha/beta or
  2472. * mu = beta/alpha. Since either lambda or mu may overflow,
  2473. * they should not, in general, be computed.
  2474. *
  2475. * VSL (output) DOUBLE PRECISION array, dimension (LDVSL,N)
  2476. * If JOBVSL = 'V', the matrix of left Schur vectors Q.
  2477. * Not referenced if JOBVSL = 'N'.
  2478. *
  2479. * LDVSL (input) INTEGER
  2480. * The leading dimension of the matrix VSL. LDVSL >=1, and
  2481. * if JOBVSL = 'V', LDVSL >= N.
  2482. *
  2483. * VSR (output) DOUBLE PRECISION array, dimension (LDVSR,N)
  2484. * If JOBVSR = 'V', the matrix of right Schur vectors Z.
  2485. * Not referenced if JOBVSR = 'N'.
  2486. *
  2487. * LDVSR (input) INTEGER
  2488. * The leading dimension of the matrix VSR. LDVSR >= 1, and
  2489. * if JOBVSR = 'V', LDVSR >= N.
  2490. *
  2491. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  2492. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  2493. *
  2494. * LWORK (input) INTEGER
  2495. * The dimension of the array WORK. LWORK >= max(1,4*N).
  2496. * For good performance, LWORK must generally be larger.
  2497. * To compute the optimal value of LWORK, call ILAENV to get
  2498. * blocksizes (for DGEQRF, DORMQR, and DORGQR.) Then compute:
  2499. * NB -- MAX of the blocksizes for DGEQRF, DORMQR, and DORGQR
  2500. * The optimal LWORK is 2*N + N*(NB+1).
  2501. *
  2502. * If LWORK = -1, then a workspace query is assumed; the routine
  2503. * only calculates the optimal size of the WORK array, returns
  2504. * this value as the first entry of the WORK array, and no error
  2505. * message related to LWORK is issued by XERBLA.
  2506. *
  2507. * C++ Return value: INFO (output) INTEGER
  2508. * = 0: successful exit
  2509. * < 0: if INFO = -i, the i-th argument had an illegal value.
  2510. * = 1,...,N:
  2511. * The QZ iteration failed. (A,B) are not in Schur
  2512. * form, but ALPHAR(j), ALPHAI(j), and BETA(j) should
  2513. * be correct for j=INFO+1,...,N.
  2514. * > N: errors that usually indicate LAPACK problems:
  2515. * =N+1: error return from DGGBAL
  2516. * =N+2: error return from DGEQRF
  2517. * =N+3: error return from DORMQR
  2518. * =N+4: error return from DORGQR
  2519. * =N+5: error return from DGGHRD
  2520. * =N+6: error return from DHGEQZ (other than failed
  2521. * iteration)
  2522. * =N+7: error return from DGGBAK (computing VSL)
  2523. * =N+8: error return from DGGBAK (computing VSR)
  2524. * =N+9: error return from DLASCL (various places)
  2525. *
  2526. * =====================================================================
  2527. *
  2528. * .. Parameters ..
  2529. **/
  2530. int C_DGEGS(char jobvsl, char jobvsr, int n, double* a, int lda, double* b, int ldb, double* alphar, double* alphai, double* beta, double* vsl, int ldvsl, double* vsr, int ldvsr, double* work, int lwork)
  2531. {
  2532. int info;
  2533. ::F_DGEGS(&jobvsl, &jobvsr, &n, a, &lda, b, &ldb, alphar, alphai, beta, vsl, &ldvsl, vsr, &ldvsr, work, &lwork, &info);
  2534. return info;
  2535. }
  2536. /**
  2537. * Purpose
  2538. * =======
  2539. *
  2540. * This routine is deprecated and has been replaced by routine DGGEV.
  2541. *
  2542. * DGEGV computes the eigenvalues and, optionally, the left and/or right
  2543. * eigenvectors of a real matrix pair (A,B).
  2544. * Given two square matrices A and B,
  2545. * the generalized nonsymmetric eigenvalue problem (GNEP) is to find the
  2546. * eigenvalues lambda and corresponding (non-zero) eigenvectors x such
  2547. * that
  2548. *
  2549. * A*x = lambda*B*x.
  2550. *
  2551. * An alternate form is to find the eigenvalues mu and corresponding
  2552. * eigenvectors y such that
  2553. *
  2554. * mu*A*y = B*y.
  2555. *
  2556. * These two forms are equivalent with mu = 1/lambda and x = y if
  2557. * neither lambda nor mu is zero. In order to deal with the case that
  2558. * lambda or mu is zero or small, two values alpha and beta are returned
  2559. * for each eigenvalue, such that lambda = alpha/beta and
  2560. * mu = beta/alpha.
  2561. *
  2562. * The vectors x and y in the above equations are right eigenvectors of
  2563. * the matrix pair (A,B). Vectors u and v satisfying
  2564. *
  2565. * u**H*A = lambda*u**H*B or mu*v**H*A = v**H*B
  2566. *
  2567. * are left eigenvectors of (A,B).
  2568. *
  2569. * Note: this routine performs "full balancing" on A and B -- see
  2570. * "Further Details", below.
  2571. *
  2572. * Arguments
  2573. * =========
  2574. *
  2575. * JOBVL (input) CHARACTER*1
  2576. * = 'N': do not compute the left generalized eigenvectors;
  2577. * = 'V': compute the left generalized eigenvectors (returned
  2578. * in VL).
  2579. *
  2580. * JOBVR (input) CHARACTER*1
  2581. * = 'N': do not compute the right generalized eigenvectors;
  2582. * = 'V': compute the right generalized eigenvectors (returned
  2583. * in VR).
  2584. *
  2585. * N (input) INTEGER
  2586. * The order of the matrices A, B, VL, and VR. N >= 0.
  2587. *
  2588. * A (input/output) DOUBLE PRECISION array, dimension (LDA, N)
  2589. * On entry, the matrix A.
  2590. * If JOBVL = 'V' or JOBVR = 'V', then on exit A
  2591. * contains the real Schur form of A from the generalized Schur
  2592. * factorization of the pair (A,B) after balancing.
  2593. * If no eigenvectors were computed, then only the diagonal
  2594. * blocks from the Schur form will be correct. See DGGHRD and
  2595. * DHGEQZ for details.
  2596. *
  2597. * LDA (input) INTEGER
  2598. * The leading dimension of A. LDA >= max(1,N).
  2599. *
  2600. * B (input/output) DOUBLE PRECISION array, dimension (LDB, N)
  2601. * On entry, the matrix B.
  2602. * If JOBVL = 'V' or JOBVR = 'V', then on exit B contains the
  2603. * upper triangular matrix obtained from B in the generalized
  2604. * Schur factorization of the pair (A,B) after balancing.
  2605. * If no eigenvectors were computed, then only those elements of
  2606. * B corresponding to the diagonal blocks from the Schur form of
  2607. * A will be correct. See DGGHRD and DHGEQZ for details.
  2608. *
  2609. * LDB (input) INTEGER
  2610. * The leading dimension of B. LDB >= max(1,N).
  2611. *
  2612. * ALPHAR (output) DOUBLE PRECISION array, dimension (N)
  2613. * The real parts of each scalar alpha defining an eigenvalue of
  2614. * GNEP.
  2615. *
  2616. * ALPHAI (output) DOUBLE PRECISION array, dimension (N)
  2617. * The imaginary parts of each scalar alpha defining an
  2618. * eigenvalue of GNEP. If ALPHAI(j) is zero, then the j-th
  2619. * eigenvalue is real; if positive, then the j-th and
  2620. * (j+1)-st eigenvalues are a complex conjugate pair, with
  2621. * ALPHAI(j+1) = -ALPHAI(j).
  2622. *
  2623. * BETA (output) DOUBLE PRECISION array, dimension (N)
  2624. * The scalars beta that define the eigenvalues of GNEP.
  2625. *
  2626. * Together, the quantities alpha = (ALPHAR(j),ALPHAI(j)) and
  2627. * beta = BETA(j) represent the j-th eigenvalue of the matrix
  2628. * pair (A,B), in one of the forms lambda = alpha/beta or
  2629. * mu = beta/alpha. Since either lambda or mu may overflow,
  2630. * they should not, in general, be computed.
  2631. *
  2632. * VL (output) DOUBLE PRECISION array, dimension (LDVL,N)
  2633. * If JOBVL = 'V', the left eigenvectors u(j) are stored
  2634. * in the columns of VL, in the same order as their eigenvalues.
  2635. * If the j-th eigenvalue is real, then u(j) = VL(:,j).
  2636. * If the j-th and (j+1)-st eigenvalues form a complex conjugate
  2637. * pair, then
  2638. * u(j) = VL(:,j) + i*VL(:,j+1)
  2639. * and
  2640. * u(j+1) = VL(:,j) - i*VL(:,j+1).
  2641. *
  2642. * Each eigenvector is scaled so that its largest component has
  2643. * abs(real part) + abs(imag. part) = 1, except for eigenvectors
  2644. * corresponding to an eigenvalue with alpha = beta = 0, which
  2645. * are set to zero.
  2646. * Not referenced if JOBVL = 'N'.
  2647. *
  2648. * LDVL (input) INTEGER
  2649. * The leading dimension of the matrix VL. LDVL >= 1, and
  2650. * if JOBVL = 'V', LDVL >= N.
  2651. *
  2652. * VR (output) DOUBLE PRECISION array, dimension (LDVR,N)
  2653. * If JOBVR = 'V', the right eigenvectors x(j) are stored
  2654. * in the columns of VR, in the same order as their eigenvalues.
  2655. * If the j-th eigenvalue is real, then x(j) = VR(:,j).
  2656. * If the j-th and (j+1)-st eigenvalues form a complex conjugate
  2657. * pair, then
  2658. * x(j) = VR(:,j) + i*VR(:,j+1)
  2659. * and
  2660. * x(j+1) = VR(:,j) - i*VR(:,j+1).
  2661. *
  2662. * Each eigenvector is scaled so that its largest component has
  2663. * abs(real part) + abs(imag. part) = 1, except for eigenvalues
  2664. * corresponding to an eigenvalue with alpha = beta = 0, which
  2665. * are set to zero.
  2666. * Not referenced if JOBVR = 'N'.
  2667. *
  2668. * LDVR (input) INTEGER
  2669. * The leading dimension of the matrix VR. LDVR >= 1, and
  2670. * if JOBVR = 'V', LDVR >= N.
  2671. *
  2672. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  2673. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  2674. *
  2675. * LWORK (input) INTEGER
  2676. * The dimension of the array WORK. LWORK >= max(1,8*N).
  2677. * For good performance, LWORK must generally be larger.
  2678. * To compute the optimal value of LWORK, call ILAENV to get
  2679. * blocksizes (for DGEQRF, DORMQR, and DORGQR.) Then compute:
  2680. * NB -- MAX of the blocksizes for DGEQRF, DORMQR, and DORGQR;
  2681. * The optimal LWORK is:
  2682. * 2*N + MAX( 6*N, N*(NB+1) ).
  2683. *
  2684. * If LWORK = -1, then a workspace query is assumed; the routine
  2685. * only calculates the optimal size of the WORK array, returns
  2686. * this value as the first entry of the WORK array, and no error
  2687. * message related to LWORK is issued by XERBLA.
  2688. *
  2689. * C++ Return value: INFO (output) INTEGER
  2690. * = 0: successful exit
  2691. * < 0: if INFO = -i, the i-th argument had an illegal value.
  2692. * = 1,...,N:
  2693. * The QZ iteration failed. No eigenvectors have been
  2694. * calculated, but ALPHAR(j), ALPHAI(j), and BETA(j)
  2695. * should be correct for j=INFO+1,...,N.
  2696. * > N: errors that usually indicate LAPACK problems:
  2697. * =N+1: error return from DGGBAL
  2698. * =N+2: error return from DGEQRF
  2699. * =N+3: error return from DORMQR
  2700. * =N+4: error return from DORGQR
  2701. * =N+5: error return from DGGHRD
  2702. * =N+6: error return from DHGEQZ (other than failed
  2703. * iteration)
  2704. * =N+7: error return from DTGEVC
  2705. * =N+8: error return from DGGBAK (computing VL)
  2706. * =N+9: error return from DGGBAK (computing VR)
  2707. * =N+10: error return from DLASCL (various calls)
  2708. *
  2709. * Further Details
  2710. * ===============
  2711. *
  2712. * Balancing
  2713. * ---------
  2714. *
  2715. * This driver calls DGGBAL to both permute and scale rows and columns
  2716. * of A and B. The permutations PL and PR are chosen so that PL*A*PR
  2717. * and PL*B*R will be upper triangular except for the diagonal blocks
  2718. * A(i:j,i:j) and B(i:j,i:j), with i and j as close together as
  2719. * possible. The diagonal scaling matrices DL and DR are chosen so
  2720. * that the pair DL*PL*A*PR*DR, DL*PL*B*PR*DR have elements close to
  2721. * one (except for the elements that start out zero.)
  2722. *
  2723. * After the eigenvalues and eigenvectors of the balanced matrices
  2724. * have been computed, DGGBAK transforms the eigenvectors back to what
  2725. * they would have been (in perfect arithmetic) if they had not been
  2726. * balanced.
  2727. *
  2728. * Contents of A and B on Exit
  2729. * -------- -- - --- - -- ----
  2730. *
  2731. * If any eigenvectors are computed (either JOBVL='V' or JOBVR='V' or
  2732. * both), then on exit the arrays A and B will contain the real Schur
  2733. * form[*] of the "balanced" versions of A and B. If no eigenvectors
  2734. * are computed, then only the diagonal blocks will be correct.
  2735. *
  2736. * [*] See DHGEQZ, DGEGS, or read the book "Matrix Computations",
  2737. * by Golub & van Loan, pub. by Johns Hopkins U. Press.
  2738. *
  2739. * =====================================================================
  2740. *
  2741. * .. Parameters ..
  2742. **/
  2743. int C_DGEGV(char jobvl, char jobvr, int n, double* a, int lda, double* b, int ldb, double* alphar, double* alphai, double* beta, double* vl, int ldvl, double* vr, int ldvr, double* work, int lwork)
  2744. {
  2745. int info;
  2746. ::F_DGEGV(&jobvl, &jobvr, &n, a, &lda, b, &ldb, alphar, alphai, beta, vl, &ldvl, vr, &ldvr, work, &lwork, &info);
  2747. return info;
  2748. }
  2749. /**
  2750. * Purpose
  2751. * =======
  2752. *
  2753. * DGEHRD reduces a real general matrix A to upper Hessenberg form H by
  2754. * an orthogonal similarity transformation: Q' * A * Q = H .
  2755. *
  2756. * Arguments
  2757. * =========
  2758. *
  2759. * N (input) INTEGER
  2760. * The order of the matrix A. N >= 0.
  2761. *
  2762. * ILO (input) INTEGER
  2763. * IHI (input) INTEGER
  2764. * It is assumed that A is already upper triangular in rows
  2765. * and columns 1:ILO-1 and IHI+1:N. ILO and IHI are normally
  2766. * set by a previous call to DGEBAL; otherwise they should be
  2767. * set to 1 and N respectively. See Further Details.
  2768. * 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0.
  2769. *
  2770. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  2771. * On entry, the N-by-N general matrix to be reduced.
  2772. * On exit, the upper triangle and the first subdiagonal of A
  2773. * are overwritten with the upper Hessenberg matrix H, and the
  2774. * elements below the first subdiagonal, with the array TAU,
  2775. * represent the orthogonal matrix Q as a product of elementary
  2776. * reflectors. See Further Details.
  2777. *
  2778. * LDA (input) INTEGER
  2779. * The leading dimension of the array A. LDA >= max(1,N).
  2780. *
  2781. * TAU (output) DOUBLE PRECISION array, dimension (N-1)
  2782. * The scalar factors of the elementary reflectors (see Further
  2783. * Details). Elements 1:ILO-1 and IHI:N-1 of TAU are set to
  2784. * zero.
  2785. *
  2786. * WORK (workspace/output) DOUBLE PRECISION array, dimension (LWORK)
  2787. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  2788. *
  2789. * LWORK (input) INTEGER
  2790. * The length of the array WORK. LWORK >= max(1,N).
  2791. * For optimum performance LWORK >= N*NB, where NB is the
  2792. * optimal blocksize.
  2793. *
  2794. * If LWORK = -1, then a workspace query is assumed; the routine
  2795. * only calculates the optimal size of the WORK array, returns
  2796. * this value as the first entry of the WORK array, and no error
  2797. * message related to LWORK is issued by XERBLA.
  2798. *
  2799. * C++ Return value: INFO (output) INTEGER
  2800. * = 0: successful exit
  2801. * < 0: if INFO = -i, the i-th argument had an illegal value.
  2802. *
  2803. * Further Details
  2804. * ===============
  2805. *
  2806. * The matrix Q is represented as a product of (ihi-ilo) elementary
  2807. * reflectors
  2808. *
  2809. * Q = H(ilo) H(ilo+1) . . . H(ihi-1).
  2810. *
  2811. * Each H(i) has the form
  2812. *
  2813. * H(i) = I - tau * v * v'
  2814. *
  2815. * where tau is a real scalar, and v is a real vector with
  2816. * v(1:i) = 0, v(i+1) = 1 and v(ihi+1:n) = 0; v(i+2:ihi) is stored on
  2817. * exit in A(i+2:ihi,i), and tau in TAU(i).
  2818. *
  2819. * The contents of A are illustrated by the following example, with
  2820. * n = 7, ilo = 2 and ihi = 6:
  2821. *
  2822. * on entry, on exit,
  2823. *
  2824. * ( a a a a a a a ) ( a a h h h h a )
  2825. * ( a a a a a a ) ( a h h h h a )
  2826. * ( a a a a a a ) ( h h h h h h )
  2827. * ( a a a a a a ) ( v2 h h h h h )
  2828. * ( a a a a a a ) ( v2 v3 h h h h )
  2829. * ( a a a a a a ) ( v2 v3 v4 h h h )
  2830. * ( a ) ( a )
  2831. *
  2832. * where a denotes an element of the original matrix A, h denotes a
  2833. * modified element of the upper Hessenberg matrix H, and vi denotes an
  2834. * element of the vector defining H(i).
  2835. *
  2836. * This file is a slight modification of LAPACK-3.0's DGEHRD
  2837. * subroutine incorporating improvements proposed by Quintana-Orti and
  2838. * Van de Geijn (2006). (See DLAHR2.)
  2839. *
  2840. * =====================================================================
  2841. *
  2842. * .. Parameters ..
  2843. **/
  2844. int C_DGEHRD(int n, int ilo, int ihi, double* a, int lda, double* tau, double* work, int lwork)
  2845. {
  2846. int info;
  2847. ::F_DGEHRD(&n, &ilo, &ihi, a, &lda, tau, work, &lwork, &info);
  2848. return info;
  2849. }
  2850. /**
  2851. * Purpose
  2852. * =======
  2853. *
  2854. * DGELQF computes an LQ factorization of a real M-by-N matrix A:
  2855. * A = L * Q.
  2856. *
  2857. * Arguments
  2858. * =========
  2859. *
  2860. * M (input) INTEGER
  2861. * The number of rows of the matrix A. M >= 0.
  2862. *
  2863. * N (input) INTEGER
  2864. * The number of columns of the matrix A. N >= 0.
  2865. *
  2866. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  2867. * On entry, the M-by-N matrix A.
  2868. * On exit, the elements on and below the diagonal of the array
  2869. * contain the m-by-min(m,n) lower trapezoidal matrix L (L is
  2870. * lower triangular if m <= n); the elements above the diagonal,
  2871. * with the array TAU, represent the orthogonal matrix Q as a
  2872. * product of elementary reflectors (see Further Details).
  2873. *
  2874. * LDA (input) INTEGER
  2875. * The leading dimension of the array A. LDA >= max(1,M).
  2876. *
  2877. * TAU (output) DOUBLE PRECISION array, dimension (min(M,N))
  2878. * The scalar factors of the elementary reflectors (see Further
  2879. * Details).
  2880. *
  2881. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  2882. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  2883. *
  2884. * LWORK (input) INTEGER
  2885. * The dimension of the array WORK. LWORK >= max(1,M).
  2886. * For optimum performance LWORK >= M*NB, where NB is the
  2887. * optimal blocksize.
  2888. *
  2889. * If LWORK = -1, then a workspace query is assumed; the routine
  2890. * only calculates the optimal size of the WORK array, returns
  2891. * this value as the first entry of the WORK array, and no error
  2892. * message related to LWORK is issued by XERBLA.
  2893. *
  2894. * C++ Return value: INFO (output) INTEGER
  2895. * = 0: successful exit
  2896. * < 0: if INFO = -i, the i-th argument had an illegal value
  2897. *
  2898. * Further Details
  2899. * ===============
  2900. *
  2901. * The matrix Q is represented as a product of elementary reflectors
  2902. *
  2903. * Q = H(k) . . . H(2) H(1), where k = min(m,n).
  2904. *
  2905. * Each H(i) has the form
  2906. *
  2907. * H(i) = I - tau * v * v'
  2908. *
  2909. * where tau is a real scalar, and v is a real vector with
  2910. * v(1:i-1) = 0 and v(i) = 1; v(i+1:n) is stored on exit in A(i,i+1:n),
  2911. * and tau in TAU(i).
  2912. *
  2913. * =====================================================================
  2914. *
  2915. * .. Local Scalars ..
  2916. **/
  2917. int C_DGELQF(int m, int n, double* a, int lda, double* tau, double* work, int lwork)
  2918. {
  2919. int info;
  2920. ::F_DGELQF(&m, &n, a, &lda, tau, work, &lwork, &info);
  2921. return info;
  2922. }
  2923. /**
  2924. * Purpose
  2925. * =======
  2926. *
  2927. * DGELS solves overdetermined or underdetermined real linear systems
  2928. * involving an M-by-N matrix A, or its transpose, using a QR or LQ
  2929. * factorization of A. It is assumed that A has full rank.
  2930. *
  2931. * The following options are provided:
  2932. *
  2933. * 1. If TRANS = 'N' and m >= n: find the least squares solution of
  2934. * an overdetermined system, i.e., solve the least squares problem
  2935. * minimize || B - A*X ||.
  2936. *
  2937. * 2. If TRANS = 'N' and m < n: find the minimum norm solution of
  2938. * an underdetermined system A * X = B.
  2939. *
  2940. * 3. If TRANS = 'T' and m >= n: find the minimum norm solution of
  2941. * an undetermined system A**T * X = B.
  2942. *
  2943. * 4. If TRANS = 'T' and m < n: find the least squares solution of
  2944. * an overdetermined system, i.e., solve the least squares problem
  2945. * minimize || B - A**T * X ||.
  2946. *
  2947. * Several right hand side vectors b and solution vectors x can be
  2948. * handled in a single call; they are stored as the columns of the
  2949. * M-by-NRHS right hand side matrix B and the N-by-NRHS solution
  2950. * matrix X.
  2951. *
  2952. * Arguments
  2953. * =========
  2954. *
  2955. * TRANS (input) CHARACTER*1
  2956. * = 'N': the linear system involves A;
  2957. * = 'T': the linear system involves A**T.
  2958. *
  2959. * M (input) INTEGER
  2960. * The number of rows of the matrix A. M >= 0.
  2961. *
  2962. * N (input) INTEGER
  2963. * The number of columns of the matrix A. N >= 0.
  2964. *
  2965. * NRHS (input) INTEGER
  2966. * The number of right hand sides, i.e., the number of
  2967. * columns of the matrices B and X. NRHS >=0.
  2968. *
  2969. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  2970. * On entry, the M-by-N matrix A.
  2971. * On exit,
  2972. * if M >= N, A is overwritten by details of its QR
  2973. * factorization as returned by DGEQRF;
  2974. * if M < N, A is overwritten by details of its LQ
  2975. * factorization as returned by DGELQF.
  2976. *
  2977. * LDA (input) INTEGER
  2978. * The leading dimension of the array A. LDA >= max(1,M).
  2979. *
  2980. * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
  2981. * On entry, the matrix B of right hand side vectors, stored
  2982. * columnwise; B is M-by-NRHS if TRANS = 'N', or N-by-NRHS
  2983. * if TRANS = 'T'.
  2984. * On exit, if INFO = 0, B is overwritten by the solution
  2985. * vectors, stored columnwise:
  2986. * if TRANS = 'N' and m >= n, rows 1 to n of B contain the least
  2987. * squares solution vectors; the residual sum of squares for the
  2988. * solution in each column is given by the sum of squares of
  2989. * elements N+1 to M in that column;
  2990. * if TRANS = 'N' and m < n, rows 1 to N of B contain the
  2991. * minimum norm solution vectors;
  2992. * if TRANS = 'T' and m >= n, rows 1 to M of B contain the
  2993. * minimum norm solution vectors;
  2994. * if TRANS = 'T' and m < n, rows 1 to M of B contain the
  2995. * least squares solution vectors; the residual sum of squares
  2996. * for the solution in each column is given by the sum of
  2997. * squares of elements M+1 to N in that column.
  2998. *
  2999. * LDB (input) INTEGER
  3000. * The leading dimension of the array B. LDB >= MAX(1,M,N).
  3001. *
  3002. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  3003. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  3004. *
  3005. * LWORK (input) INTEGER
  3006. * The dimension of the array WORK.
  3007. * LWORK >= max( 1, MN + max( MN, NRHS ) ).
  3008. * For optimal performance,
  3009. * LWORK >= max( 1, MN + max( MN, NRHS )*NB ).
  3010. * where MN = min(M,N) and NB is the optimum block size.
  3011. *
  3012. * If LWORK = -1, then a workspace query is assumed; the routine
  3013. * only calculates the optimal size of the WORK array, returns
  3014. * this value as the first entry of the WORK array, and no error
  3015. * message related to LWORK is issued by XERBLA.
  3016. *
  3017. * C++ Return value: INFO (output) INTEGER
  3018. * = 0: successful exit
  3019. * < 0: if INFO = -i, the i-th argument had an illegal value
  3020. * > 0: if INFO = i, the i-th diagonal element of the
  3021. * triangular factor of A is zero, so that A does not have
  3022. * full rank; the least squares solution could not be
  3023. * computed.
  3024. *
  3025. * =====================================================================
  3026. *
  3027. * .. Parameters ..
  3028. **/
  3029. int C_DGELS(char trans, int m, int n, int nrhs, double* a, int lda, double* b, int ldb, double* work, int lwork)
  3030. {
  3031. int info;
  3032. ::F_DGELS(&trans, &m, &n, &nrhs, a, &lda, b, &ldb, work, &lwork, &info);
  3033. return info;
  3034. }
  3035. /**
  3036. * Purpose
  3037. * =======
  3038. *
  3039. * DGELSD computes the minimum-norm solution to a real linear least
  3040. * squares problem:
  3041. * minimize 2-norm(| b - A*x |)
  3042. * using the singular value decomposition (SVD) of A. A is an M-by-N
  3043. * matrix which may be rank-deficient.
  3044. *
  3045. * Several right hand side vectors b and solution vectors x can be
  3046. * handled in a single call; they are stored as the columns of the
  3047. * M-by-NRHS right hand side matrix B and the N-by-NRHS solution
  3048. * matrix X.
  3049. *
  3050. * The problem is solved in three steps:
  3051. * (1) Reduce the coefficient matrix A to bidiagonal form with
  3052. * Householder transformations, reducing the original problem
  3053. * into a "bidiagonal least squares problem" (BLS)
  3054. * (2) Solve the BLS using a divide and conquer approach.
  3055. * (3) Apply back all the Householder tranformations to solve
  3056. * the original least squares problem.
  3057. *
  3058. * The effective rank of A is determined by treating as zero those
  3059. * singular values which are less than RCOND times the largest singular
  3060. * value.
  3061. *
  3062. * The divide and conquer algorithm makes very mild assumptions about
  3063. * floating point arithmetic. It will work on machines with a guard
  3064. * digit in add/subtract, or on those binary machines without guard
  3065. * digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or
  3066. * Cray-2. It could conceivably fail on hexadecimal or decimal machines
  3067. * without guard digits, but we know of none.
  3068. *
  3069. * Arguments
  3070. * =========
  3071. *
  3072. * M (input) INTEGER
  3073. * The number of rows of A. M >= 0.
  3074. *
  3075. * N (input) INTEGER
  3076. * The number of columns of A. N >= 0.
  3077. *
  3078. * NRHS (input) INTEGER
  3079. * The number of right hand sides, i.e., the number of columns
  3080. * of the matrices B and X. NRHS >= 0.
  3081. *
  3082. * A (input) DOUBLE PRECISION array, dimension (LDA,N)
  3083. * On entry, the M-by-N matrix A.
  3084. * On exit, A has been destroyed.
  3085. *
  3086. * LDA (input) INTEGER
  3087. * The leading dimension of the array A. LDA >= max(1,M).
  3088. *
  3089. * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
  3090. * On entry, the M-by-NRHS right hand side matrix B.
  3091. * On exit, B is overwritten by the N-by-NRHS solution
  3092. * matrix X. If m >= n and RANK = n, the residual
  3093. * sum-of-squares for the solution in the i-th column is given
  3094. * by the sum of squares of elements n+1:m in that column.
  3095. *
  3096. * LDB (input) INTEGER
  3097. * The leading dimension of the array B. LDB >= max(1,max(M,N)).
  3098. *
  3099. * S (output) DOUBLE PRECISION array, dimension (min(M,N))
  3100. * The singular values of A in decreasing order.
  3101. * The condition number of A in the 2-norm = S(1)/S(min(m,n)).
  3102. *
  3103. * RCOND (input) DOUBLE PRECISION
  3104. * RCOND is used to determine the effective rank of A.
  3105. * Singular values S(i) <= RCOND*S(1) are treated as zero.
  3106. * If RCOND < 0, machine precision is used instead.
  3107. *
  3108. * RANK (output) INTEGER
  3109. * The effective rank of A, i.e., the number of singular values
  3110. * which are greater than RCOND*S(1).
  3111. *
  3112. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  3113. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  3114. *
  3115. * LWORK (input) INTEGER
  3116. * The dimension of the array WORK. LWORK must be at least 1.
  3117. * The exact minimum amount of workspace needed depends on M,
  3118. * N and NRHS. As long as LWORK is at least
  3119. * 12*N + 2*N*SMLSIZ + 8*N*NLVL + N*NRHS + (SMLSIZ+1)**2,
  3120. * if M is greater than or equal to N or
  3121. * 12*M + 2*M*SMLSIZ + 8*M*NLVL + M*NRHS + (SMLSIZ+1)**2,
  3122. * if M is less than N, the code will execute correctly.
  3123. * SMLSIZ is returned by ILAENV and is equal to the maximum
  3124. * size of the subproblems at the bottom of the computation
  3125. * tree (usually about 25), and
  3126. * NLVL = MAX( 0, INT( LOG_2( MIN( M,N )/(SMLSIZ+1) ) ) + 1 )
  3127. * For good performance, LWORK should generally be larger.
  3128. *
  3129. * If LWORK = -1, then a workspace query is assumed; the routine
  3130. * only calculates the optimal size of the WORK array, returns
  3131. * this value as the first entry of the WORK array, and no error
  3132. * message related to LWORK is issued by XERBLA.
  3133. *
  3134. * IWORK (workspace) INTEGER array, dimension (MAX(1,LIWORK))
  3135. * LIWORK >= max(1, 3 * MINMN * NLVL + 11 * MINMN),
  3136. * where MINMN = MIN( M,N ).
  3137. * On exit, if INFO = 0, IWORK(1) returns the minimum LIWORK.
  3138. *
  3139. * C++ Return value: INFO (output) INTEGER
  3140. * = 0: successful exit
  3141. * < 0: if INFO = -i, the i-th argument had an illegal value.
  3142. * > 0: the algorithm for computing the SVD failed to converge;
  3143. * if INFO = i, i off-diagonal elements of an intermediate
  3144. * bidiagonal form did not converge to zero.
  3145. *
  3146. * Further Details
  3147. * ===============
  3148. *
  3149. * Based on contributions by
  3150. * Ming Gu and Ren-Cang Li, Computer Science Division, University of
  3151. * California at Berkeley, USA
  3152. * Osni Marques, LBNL/NERSC, USA
  3153. *
  3154. * =====================================================================
  3155. *
  3156. * .. Parameters ..
  3157. **/
  3158. int C_DGELSD(int m, int n, int nrhs, double* a, int lda, double* b, int ldb, double* s, double rcond, int* rank, double* work, int lwork, int* iwork)
  3159. {
  3160. int info;
  3161. ::F_DGELSD(&m, &n, &nrhs, a, &lda, b, &ldb, s, &rcond, rank, work, &lwork, iwork, &info);
  3162. return info;
  3163. }
  3164. /**
  3165. * Purpose
  3166. * =======
  3167. *
  3168. * DGELSS computes the minimum norm solution to a real linear least
  3169. * squares problem:
  3170. *
  3171. * Minimize 2-norm(| b - A*x |).
  3172. *
  3173. * using the singular value decomposition (SVD) of A. A is an M-by-N
  3174. * matrix which may be rank-deficient.
  3175. *
  3176. * Several right hand side vectors b and solution vectors x can be
  3177. * handled in a single call; they are stored as the columns of the
  3178. * M-by-NRHS right hand side matrix B and the N-by-NRHS solution matrix
  3179. * X.
  3180. *
  3181. * The effective rank of A is determined by treating as zero those
  3182. * singular values which are less than RCOND times the largest singular
  3183. * value.
  3184. *
  3185. * Arguments
  3186. * =========
  3187. *
  3188. * M (input) INTEGER
  3189. * The number of rows of the matrix A. M >= 0.
  3190. *
  3191. * N (input) INTEGER
  3192. * The number of columns of the matrix A. N >= 0.
  3193. *
  3194. * NRHS (input) INTEGER
  3195. * The number of right hand sides, i.e., the number of columns
  3196. * of the matrices B and X. NRHS >= 0.
  3197. *
  3198. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  3199. * On entry, the M-by-N matrix A.
  3200. * On exit, the first min(m,n) rows of A are overwritten with
  3201. * its right singular vectors, stored rowwise.
  3202. *
  3203. * LDA (input) INTEGER
  3204. * The leading dimension of the array A. LDA >= max(1,M).
  3205. *
  3206. * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
  3207. * On entry, the M-by-NRHS right hand side matrix B.
  3208. * On exit, B is overwritten by the N-by-NRHS solution
  3209. * matrix X. If m >= n and RANK = n, the residual
  3210. * sum-of-squares for the solution in the i-th column is given
  3211. * by the sum of squares of elements n+1:m in that column.
  3212. *
  3213. * LDB (input) INTEGER
  3214. * The leading dimension of the array B. LDB >= max(1,max(M,N)).
  3215. *
  3216. * S (output) DOUBLE PRECISION array, dimension (min(M,N))
  3217. * The singular values of A in decreasing order.
  3218. * The condition number of A in the 2-norm = S(1)/S(min(m,n)).
  3219. *
  3220. * RCOND (input) DOUBLE PRECISION
  3221. * RCOND is used to determine the effective rank of A.
  3222. * Singular values S(i) <= RCOND*S(1) are treated as zero.
  3223. * If RCOND < 0, machine precision is used instead.
  3224. *
  3225. * RANK (output) INTEGER
  3226. * The effective rank of A, i.e., the number of singular values
  3227. * which are greater than RCOND*S(1).
  3228. *
  3229. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  3230. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  3231. *
  3232. * LWORK (input) INTEGER
  3233. * The dimension of the array WORK. LWORK >= 1, and also:
  3234. * LWORK >= 3*min(M,N) + max( 2*min(M,N), max(M,N), NRHS )
  3235. * For good performance, LWORK should generally be larger.
  3236. *
  3237. * If LWORK = -1, then a workspace query is assumed; the routine
  3238. * only calculates the optimal size of the WORK array, returns
  3239. * this value as the first entry of the WORK array, and no error
  3240. * message related to LWORK is issued by XERBLA.
  3241. *
  3242. * C++ Return value: INFO (output) INTEGER
  3243. * = 0: successful exit
  3244. * < 0: if INFO = -i, the i-th argument had an illegal value.
  3245. * > 0: the algorithm for computing the SVD failed to converge;
  3246. * if INFO = i, i off-diagonal elements of an intermediate
  3247. * bidiagonal form did not converge to zero.
  3248. *
  3249. * =====================================================================
  3250. *
  3251. * .. Parameters ..
  3252. **/
  3253. int C_DGELSS(int m, int n, int nrhs, double* a, int lda, double* b, int ldb, double* s, double rcond, int* rank, double* work, int lwork)
  3254. {
  3255. int info;
  3256. ::F_DGELSS(&m, &n, &nrhs, a, &lda, b, &ldb, s, &rcond, rank, work, &lwork, &info);
  3257. return info;
  3258. }
  3259. /**
  3260. * Purpose
  3261. * =======
  3262. *
  3263. * This routine is deprecated and has been replaced by routine DGELSY.
  3264. *
  3265. * DGELSX computes the minimum-norm solution to a real linear least
  3266. * squares problem:
  3267. * minimize || A * X - B ||
  3268. * using a complete orthogonal factorization of A. A is an M-by-N
  3269. * matrix which may be rank-deficient.
  3270. *
  3271. * Several right hand side vectors b and solution vectors x can be
  3272. * handled in a single call; they are stored as the columns of the
  3273. * M-by-NRHS right hand side matrix B and the N-by-NRHS solution
  3274. * matrix X.
  3275. *
  3276. * The routine first computes a QR factorization with column pivoting:
  3277. * A * P = Q * [ R11 R12 ]
  3278. * [ 0 R22 ]
  3279. * with R11 defined as the largest leading submatrix whose estimated
  3280. * condition number is less than 1/RCOND. The order of R11, RANK,
  3281. * is the effective rank of A.
  3282. *
  3283. * Then, R22 is considered to be negligible, and R12 is annihilated
  3284. * by orthogonal transformations from the right, arriving at the
  3285. * complete orthogonal factorization:
  3286. * A * P = Q * [ T11 0 ] * Z
  3287. * [ 0 0 ]
  3288. * The minimum-norm solution is then
  3289. * X = P * Z' [ inv(T11)*Q1'*B ]
  3290. * [ 0 ]
  3291. * where Q1 consists of the first RANK columns of Q.
  3292. *
  3293. * Arguments
  3294. * =========
  3295. *
  3296. * M (input) INTEGER
  3297. * The number of rows of the matrix A. M >= 0.
  3298. *
  3299. * N (input) INTEGER
  3300. * The number of columns of the matrix A. N >= 0.
  3301. *
  3302. * NRHS (input) INTEGER
  3303. * The number of right hand sides, i.e., the number of
  3304. * columns of matrices B and X. NRHS >= 0.
  3305. *
  3306. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  3307. * On entry, the M-by-N matrix A.
  3308. * On exit, A has been overwritten by details of its
  3309. * complete orthogonal factorization.
  3310. *
  3311. * LDA (input) INTEGER
  3312. * The leading dimension of the array A. LDA >= max(1,M).
  3313. *
  3314. * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
  3315. * On entry, the M-by-NRHS right hand side matrix B.
  3316. * On exit, the N-by-NRHS solution matrix X.
  3317. * If m >= n and RANK = n, the residual sum-of-squares for
  3318. * the solution in the i-th column is given by the sum of
  3319. * squares of elements N+1:M in that column.
  3320. *
  3321. * LDB (input) INTEGER
  3322. * The leading dimension of the array B. LDB >= max(1,M,N).
  3323. *
  3324. * JPVT (input/output) INTEGER array, dimension (N)
  3325. * On entry, if JPVT(i) .ne. 0, the i-th column of A is an
  3326. * initial column, otherwise it is a free column. Before
  3327. * the QR factorization of A, all initial columns are
  3328. * permuted to the leading positions; only the remaining
  3329. * free columns are moved as a result of column pivoting
  3330. * during the factorization.
  3331. * On exit, if JPVT(i) = k, then the i-th column of A*P
  3332. * was the k-th column of A.
  3333. *
  3334. * RCOND (input) DOUBLE PRECISION
  3335. * RCOND is used to determine the effective rank of A, which
  3336. * is defined as the order of the largest leading triangular
  3337. * submatrix R11 in the QR factorization with pivoting of A,
  3338. * whose estimated condition number < 1/RCOND.
  3339. *
  3340. * RANK (output) INTEGER
  3341. * The effective rank of A, i.e., the order of the submatrix
  3342. * R11. This is the same as the order of the submatrix T11
  3343. * in the complete orthogonal factorization of A.
  3344. *
  3345. * WORK (workspace) DOUBLE PRECISION array, dimension
  3346. * (max( min(M,N)+3*N, 2*min(M,N)+NRHS )),
  3347. *
  3348. * C++ Return value: INFO (output) INTEGER
  3349. * = 0: successful exit
  3350. * < 0: if INFO = -i, the i-th argument had an illegal value
  3351. *
  3352. * =====================================================================
  3353. *
  3354. * .. Parameters ..
  3355. **/
  3356. int C_DGELSX(int m, int n, int nrhs, double* a, int lda, double* b, int ldb, int* jpvt, double rcond, int* rank, double* work)
  3357. {
  3358. int info;
  3359. ::F_DGELSX(&m, &n, &nrhs, a, &lda, b, &ldb, jpvt, &rcond, rank, work, &info);
  3360. return info;
  3361. }
  3362. /**
  3363. * Purpose
  3364. * =======
  3365. *
  3366. * DGELSY computes the minimum-norm solution to a real linear least
  3367. * squares problem:
  3368. * minimize || A * X - B ||
  3369. * using a complete orthogonal factorization of A. A is an M-by-N
  3370. * matrix which may be rank-deficient.
  3371. *
  3372. * Several right hand side vectors b and solution vectors x can be
  3373. * handled in a single call; they are stored as the columns of the
  3374. * M-by-NRHS right hand side matrix B and the N-by-NRHS solution
  3375. * matrix X.
  3376. *
  3377. * The routine first computes a QR factorization with column pivoting:
  3378. * A * P = Q * [ R11 R12 ]
  3379. * [ 0 R22 ]
  3380. * with R11 defined as the largest leading submatrix whose estimated
  3381. * condition number is less than 1/RCOND. The order of R11, RANK,
  3382. * is the effective rank of A.
  3383. *
  3384. * Then, R22 is considered to be negligible, and R12 is annihilated
  3385. * by orthogonal transformations from the right, arriving at the
  3386. * complete orthogonal factorization:
  3387. * A * P = Q * [ T11 0 ] * Z
  3388. * [ 0 0 ]
  3389. * The minimum-norm solution is then
  3390. * X = P * Z' [ inv(T11)*Q1'*B ]
  3391. * [ 0 ]
  3392. * where Q1 consists of the first RANK columns of Q.
  3393. *
  3394. * This routine is basically identical to the original xGELSX except
  3395. * three differences:
  3396. * o The call to the subroutine xGEQPF has been substituted by the
  3397. * the call to the subroutine xGEQP3. This subroutine is a Blas-3
  3398. * version of the QR factorization with column pivoting.
  3399. * o Matrix B (the right hand side) is updated with Blas-3.
  3400. * o The permutation of matrix B (the right hand side) is faster and
  3401. * more simple.
  3402. *
  3403. * Arguments
  3404. * =========
  3405. *
  3406. * M (input) INTEGER
  3407. * The number of rows of the matrix A. M >= 0.
  3408. *
  3409. * N (input) INTEGER
  3410. * The number of columns of the matrix A. N >= 0.
  3411. *
  3412. * NRHS (input) INTEGER
  3413. * The number of right hand sides, i.e., the number of
  3414. * columns of matrices B and X. NRHS >= 0.
  3415. *
  3416. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  3417. * On entry, the M-by-N matrix A.
  3418. * On exit, A has been overwritten by details of its
  3419. * complete orthogonal factorization.
  3420. *
  3421. * LDA (input) INTEGER
  3422. * The leading dimension of the array A. LDA >= max(1,M).
  3423. *
  3424. * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
  3425. * On entry, the M-by-NRHS right hand side matrix B.
  3426. * On exit, the N-by-NRHS solution matrix X.
  3427. *
  3428. * LDB (input) INTEGER
  3429. * The leading dimension of the array B. LDB >= max(1,M,N).
  3430. *
  3431. * JPVT (input/output) INTEGER array, dimension (N)
  3432. * On entry, if JPVT(i) .ne. 0, the i-th column of A is permuted
  3433. * to the front of AP, otherwise column i is a free column.
  3434. * On exit, if JPVT(i) = k, then the i-th column of AP
  3435. * was the k-th column of A.
  3436. *
  3437. * RCOND (input) DOUBLE PRECISION
  3438. * RCOND is used to determine the effective rank of A, which
  3439. * is defined as the order of the largest leading triangular
  3440. * submatrix R11 in the QR factorization with pivoting of A,
  3441. * whose estimated condition number < 1/RCOND.
  3442. *
  3443. * RANK (output) INTEGER
  3444. * The effective rank of A, i.e., the order of the submatrix
  3445. * R11. This is the same as the order of the submatrix T11
  3446. * in the complete orthogonal factorization of A.
  3447. *
  3448. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  3449. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  3450. *
  3451. * LWORK (input) INTEGER
  3452. * The dimension of the array WORK.
  3453. * The unblocked strategy requires that:
  3454. * LWORK >= MAX( MN+3*N+1, 2*MN+NRHS ),
  3455. * where MN = min( M, N ).
  3456. * The block algorithm requires that:
  3457. * LWORK >= MAX( MN+2*N+NB*(N+1), 2*MN+NB*NRHS ),
  3458. * where NB is an upper bound on the blocksize returned
  3459. * by ILAENV for the routines DGEQP3, DTZRZF, STZRQF, DORMQR,
  3460. * and DORMRZ.
  3461. *
  3462. * If LWORK = -1, then a workspace query is assumed; the routine
  3463. * only calculates the optimal size of the WORK array, returns
  3464. * this value as the first entry of the WORK array, and no error
  3465. * message related to LWORK is issued by XERBLA.
  3466. *
  3467. * C++ Return value: INFO (output) INTEGER
  3468. * = 0: successful exit
  3469. * < 0: If INFO = -i, the i-th argument had an illegal value.
  3470. *
  3471. * Further Details
  3472. * ===============
  3473. *
  3474. * Based on contributions by
  3475. * A. Petitet, Computer Science Dept., Univ. of Tenn., Knoxville, USA
  3476. * E. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain
  3477. * G. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain
  3478. *
  3479. * =====================================================================
  3480. *
  3481. * .. Parameters ..
  3482. **/
  3483. int C_DGELSY(int m, int n, int nrhs, double* a, int lda, double* b, int ldb, int* jpvt, double rcond, int* rank, double* work, int lwork)
  3484. {
  3485. int info;
  3486. ::F_DGELSY(&m, &n, &nrhs, a, &lda, b, &ldb, jpvt, &rcond, rank, work, &lwork, &info);
  3487. return info;
  3488. }
  3489. /**
  3490. * Purpose
  3491. * =======
  3492. *
  3493. * DGEQLF computes a QL factorization of a real M-by-N matrix A:
  3494. * A = Q * L.
  3495. *
  3496. * Arguments
  3497. * =========
  3498. *
  3499. * M (input) INTEGER
  3500. * The number of rows of the matrix A. M >= 0.
  3501. *
  3502. * N (input) INTEGER
  3503. * The number of columns of the matrix A. N >= 0.
  3504. *
  3505. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  3506. * On entry, the M-by-N matrix A.
  3507. * On exit,
  3508. * if m >= n, the lower triangle of the subarray
  3509. * A(m-n+1:m,1:n) contains the N-by-N lower triangular matrix L;
  3510. * if m <= n, the elements on and below the (n-m)-th
  3511. * superdiagonal contain the M-by-N lower trapezoidal matrix L;
  3512. * the remaining elements, with the array TAU, represent the
  3513. * orthogonal matrix Q as a product of elementary reflectors
  3514. * (see Further Details).
  3515. *
  3516. * LDA (input) INTEGER
  3517. * The leading dimension of the array A. LDA >= max(1,M).
  3518. *
  3519. * TAU (output) DOUBLE PRECISION array, dimension (min(M,N))
  3520. * The scalar factors of the elementary reflectors (see Further
  3521. * Details).
  3522. *
  3523. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  3524. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  3525. *
  3526. * LWORK (input) INTEGER
  3527. * The dimension of the array WORK. LWORK >= max(1,N).
  3528. * For optimum performance LWORK >= N*NB, where NB is the
  3529. * optimal blocksize.
  3530. *
  3531. * If LWORK = -1, then a workspace query is assumed; the routine
  3532. * only calculates the optimal size of the WORK array, returns
  3533. * this value as the first entry of the WORK array, and no error
  3534. * message related to LWORK is issued by XERBLA.
  3535. *
  3536. * C++ Return value: INFO (output) INTEGER
  3537. * = 0: successful exit
  3538. * < 0: if INFO = -i, the i-th argument had an illegal value
  3539. *
  3540. * Further Details
  3541. * ===============
  3542. *
  3543. * The matrix Q is represented as a product of elementary reflectors
  3544. *
  3545. * Q = H(k) . . . H(2) H(1), where k = min(m,n).
  3546. *
  3547. * Each H(i) has the form
  3548. *
  3549. * H(i) = I - tau * v * v'
  3550. *
  3551. * where tau is a real scalar, and v is a real vector with
  3552. * v(m-k+i+1:m) = 0 and v(m-k+i) = 1; v(1:m-k+i-1) is stored on exit in
  3553. * A(1:m-k+i-1,n-k+i), and tau in TAU(i).
  3554. *
  3555. * =====================================================================
  3556. *
  3557. * .. Local Scalars ..
  3558. **/
  3559. int C_DGEQLF(int m, int n, double* a, int lda, double* tau, double* work, int lwork)
  3560. {
  3561. int info;
  3562. ::F_DGEQLF(&m, &n, a, &lda, tau, work, &lwork, &info);
  3563. return info;
  3564. }
  3565. /**
  3566. * Purpose
  3567. * =======
  3568. *
  3569. * DGEQP3 computes a QR factorization with column pivoting of a
  3570. * matrix A: A*P = Q*R using Level 3 BLAS.
  3571. *
  3572. * Arguments
  3573. * =========
  3574. *
  3575. * M (input) INTEGER
  3576. * The number of rows of the matrix A. M >= 0.
  3577. *
  3578. * N (input) INTEGER
  3579. * The number of columns of the matrix A. N >= 0.
  3580. *
  3581. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  3582. * On entry, the M-by-N matrix A.
  3583. * On exit, the upper triangle of the array contains the
  3584. * min(M,N)-by-N upper trapezoidal matrix R; the elements below
  3585. * the diagonal, together with the array TAU, represent the
  3586. * orthogonal matrix Q as a product of min(M,N) elementary
  3587. * reflectors.
  3588. *
  3589. * LDA (input) INTEGER
  3590. * The leading dimension of the array A. LDA >= max(1,M).
  3591. *
  3592. * JPVT (input/output) INTEGER array, dimension (N)
  3593. * On entry, if JPVT(J).ne.0, the J-th column of A is permuted
  3594. * to the front of A*P (a leading column); if JPVT(J)=0,
  3595. * the J-th column of A is a free column.
  3596. * On exit, if JPVT(J)=K, then the J-th column of A*P was the
  3597. * the K-th column of A.
  3598. *
  3599. * TAU (output) DOUBLE PRECISION array, dimension (min(M,N))
  3600. * The scalar factors of the elementary reflectors.
  3601. *
  3602. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  3603. * On exit, if INFO=0, WORK(1) returns the optimal LWORK.
  3604. *
  3605. * LWORK (input) INTEGER
  3606. * The dimension of the array WORK. LWORK >= 3*N+1.
  3607. * For optimal performance LWORK >= 2*N+( N+1 )*NB, where NB
  3608. * is the optimal blocksize.
  3609. *
  3610. * If LWORK = -1, then a workspace query is assumed; the routine
  3611. * only calculates the optimal size of the WORK array, returns
  3612. * this value as the first entry of the WORK array, and no error
  3613. * message related to LWORK is issued by XERBLA.
  3614. *
  3615. * C++ Return value: INFO (output) INTEGER
  3616. * = 0: successful exit.
  3617. * < 0: if INFO = -i, the i-th argument had an illegal value.
  3618. *
  3619. * Further Details
  3620. * ===============
  3621. *
  3622. * The matrix Q is represented as a product of elementary reflectors
  3623. *
  3624. * Q = H(1) H(2) . . . H(k), where k = min(m,n).
  3625. *
  3626. * Each H(i) has the form
  3627. *
  3628. * H(i) = I - tau * v * v'
  3629. *
  3630. * where tau is a real/complex scalar, and v is a real/complex vector
  3631. * with v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in
  3632. * A(i+1:m,i), and tau in TAU(i).
  3633. *
  3634. * Based on contributions by
  3635. * G. Quintana-Orti, Depto. de Informatica, Universidad Jaime I, Spain
  3636. * X. Sun, Computer Science Dept., Duke University, USA
  3637. *
  3638. * =====================================================================
  3639. *
  3640. * .. Parameters ..
  3641. **/
  3642. int C_DGEQP3(int m, int n, double* a, int lda, int* jpvt, double* tau, double* work, int lwork)
  3643. {
  3644. int info;
  3645. ::F_DGEQP3(&m, &n, a, &lda, jpvt, tau, work, &lwork, &info);
  3646. return info;
  3647. }
  3648. /**
  3649. * Purpose
  3650. * =======
  3651. *
  3652. * This routine is deprecated and has been replaced by routine DGEQP3.
  3653. *
  3654. * DGEQPF computes a QR factorization with column pivoting of a
  3655. * real M-by-N matrix A: A*P = Q*R.
  3656. *
  3657. * Arguments
  3658. * =========
  3659. *
  3660. * M (input) INTEGER
  3661. * The number of rows of the matrix A. M >= 0.
  3662. *
  3663. * N (input) INTEGER
  3664. * The number of columns of the matrix A. N >= 0
  3665. *
  3666. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  3667. * On entry, the M-by-N matrix A.
  3668. * On exit, the upper triangle of the array contains the
  3669. * min(M,N)-by-N upper triangular matrix R; the elements
  3670. * below the diagonal, together with the array TAU,
  3671. * represent the orthogonal matrix Q as a product of
  3672. * min(m,n) elementary reflectors.
  3673. *
  3674. * LDA (input) INTEGER
  3675. * The leading dimension of the array A. LDA >= max(1,M).
  3676. *
  3677. * JPVT (input/output) INTEGER array, dimension (N)
  3678. * On entry, if JPVT(i) .ne. 0, the i-th column of A is permuted
  3679. * to the front of A*P (a leading column); if JPVT(i) = 0,
  3680. * the i-th column of A is a free column.
  3681. * On exit, if JPVT(i) = k, then the i-th column of A*P
  3682. * was the k-th column of A.
  3683. *
  3684. * TAU (output) DOUBLE PRECISION array, dimension (min(M,N))
  3685. * The scalar factors of the elementary reflectors.
  3686. *
  3687. * WORK (workspace) DOUBLE PRECISION array, dimension (3*N)
  3688. *
  3689. * C++ Return value: INFO (output) INTEGER
  3690. * = 0: successful exit
  3691. * < 0: if INFO = -i, the i-th argument had an illegal value
  3692. *
  3693. * Further Details
  3694. * ===============
  3695. *
  3696. * The matrix Q is represented as a product of elementary reflectors
  3697. *
  3698. * Q = H(1) H(2) . . . H(n)
  3699. *
  3700. * Each H(i) has the form
  3701. *
  3702. * H = I - tau * v * v'
  3703. *
  3704. * where tau is a real scalar, and v is a real vector with
  3705. * v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i).
  3706. *
  3707. * The matrix P is represented in jpvt as follows: If
  3708. * jpvt(j) = i
  3709. * then the jth column of P is the ith canonical unit vector.
  3710. *
  3711. * Partial column norm updating strategy modified by
  3712. * Z. Drmac and Z. Bujanovic, Dept. of Mathematics,
  3713. * University of Zagreb, Croatia.
  3714. * June 2010
  3715. * For more details see LAPACK Working Note 176.
  3716. *
  3717. * =====================================================================
  3718. *
  3719. * .. Parameters ..
  3720. **/
  3721. int C_DGEQPF(int m, int n, double* a, int lda, int* jpvt, double* tau, double* work)
  3722. {
  3723. int info;
  3724. ::F_DGEQPF(&m, &n, a, &lda, jpvt, tau, work, &info);
  3725. return info;
  3726. }
  3727. /**
  3728. * Purpose
  3729. * =======
  3730. *
  3731. * DGEQRF computes a QR factorization of a real M-by-N matrix A:
  3732. * A = Q * R.
  3733. *
  3734. * Arguments
  3735. * =========
  3736. *
  3737. * M (input) INTEGER
  3738. * The number of rows of the matrix A. M >= 0.
  3739. *
  3740. * N (input) INTEGER
  3741. * The number of columns of the matrix A. N >= 0.
  3742. *
  3743. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  3744. * On entry, the M-by-N matrix A.
  3745. * On exit, the elements on and above the diagonal of the array
  3746. * contain the min(M,N)-by-N upper trapezoidal matrix R (R is
  3747. * upper triangular if m >= n); the elements below the diagonal,
  3748. * with the array TAU, represent the orthogonal matrix Q as a
  3749. * product of min(m,n) elementary reflectors (see Further
  3750. * Details).
  3751. *
  3752. * LDA (input) INTEGER
  3753. * The leading dimension of the array A. LDA >= max(1,M).
  3754. *
  3755. * TAU (output) DOUBLE PRECISION array, dimension (min(M,N))
  3756. * The scalar factors of the elementary reflectors (see Further
  3757. * Details).
  3758. *
  3759. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  3760. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  3761. *
  3762. * LWORK (input) INTEGER
  3763. * The dimension of the array WORK. LWORK >= max(1,N).
  3764. * For optimum performance LWORK >= N*NB, where NB is
  3765. * the optimal blocksize.
  3766. *
  3767. * If LWORK = -1, then a workspace query is assumed; the routine
  3768. * only calculates the optimal size of the WORK array, returns
  3769. * this value as the first entry of the WORK array, and no error
  3770. * message related to LWORK is issued by XERBLA.
  3771. *
  3772. * C++ Return value: INFO (output) INTEGER
  3773. * = 0: successful exit
  3774. * < 0: if INFO = -i, the i-th argument had an illegal value
  3775. *
  3776. * Further Details
  3777. * ===============
  3778. *
  3779. * The matrix Q is represented as a product of elementary reflectors
  3780. *
  3781. * Q = H(1) H(2) . . . H(k), where k = min(m,n).
  3782. *
  3783. * Each H(i) has the form
  3784. *
  3785. * H(i) = I - tau * v * v'
  3786. *
  3787. * where tau is a real scalar, and v is a real vector with
  3788. * v(1:i-1) = 0 and v(i) = 1; v(i+1:m) is stored on exit in A(i+1:m,i),
  3789. * and tau in TAU(i).
  3790. *
  3791. * =====================================================================
  3792. *
  3793. * .. Local Scalars ..
  3794. **/
  3795. int C_DGEQRF(int m, int n, double* a, int lda, double* tau, double* work, int lwork)
  3796. {
  3797. int info;
  3798. ::F_DGEQRF(&m, &n, a, &lda, tau, work, &lwork, &info);
  3799. return info;
  3800. }
  3801. /**
  3802. * Purpose
  3803. * =======
  3804. *
  3805. * DGERFS improves the computed solution to a system of linear
  3806. * equations and provides error bounds and backward error estimates for
  3807. * the solution.
  3808. *
  3809. * Arguments
  3810. * =========
  3811. *
  3812. * TRANS (input) CHARACTER*1
  3813. * Specifies the form of the system of equations:
  3814. * = 'N': A * X = B (No transpose)
  3815. * = 'T': A**T * X = B (Transpose)
  3816. * = 'C': A**H * X = B (Conjugate transpose = Transpose)
  3817. *
  3818. * N (input) INTEGER
  3819. * The order of the matrix A. N >= 0.
  3820. *
  3821. * NRHS (input) INTEGER
  3822. * The number of right hand sides, i.e., the number of columns
  3823. * of the matrices B and X. NRHS >= 0.
  3824. *
  3825. * A (input) DOUBLE PRECISION array, dimension (LDA,N)
  3826. * The original N-by-N matrix A.
  3827. *
  3828. * LDA (input) INTEGER
  3829. * The leading dimension of the array A. LDA >= max(1,N).
  3830. *
  3831. * AF (input) DOUBLE PRECISION array, dimension (LDAF,N)
  3832. * The factors L and U from the factorization A = P*L*U
  3833. * as computed by DGETRF.
  3834. *
  3835. * LDAF (input) INTEGER
  3836. * The leading dimension of the array AF. LDAF >= max(1,N).
  3837. *
  3838. * IPIV (input) INTEGER array, dimension (N)
  3839. * The pivot indices from DGETRF; for 1<=i<=N, row i of the
  3840. * matrix was interchanged with row IPIV(i).
  3841. *
  3842. * B (input) DOUBLE PRECISION array, dimension (LDB,NRHS)
  3843. * The right hand side matrix B.
  3844. *
  3845. * LDB (input) INTEGER
  3846. * The leading dimension of the array B. LDB >= max(1,N).
  3847. *
  3848. * X (input/output) DOUBLE PRECISION array, dimension (LDX,NRHS)
  3849. * On entry, the solution matrix X, as computed by DGETRS.
  3850. * On exit, the improved solution matrix X.
  3851. *
  3852. * LDX (input) INTEGER
  3853. * The leading dimension of the array X. LDX >= max(1,N).
  3854. *
  3855. * FERR (output) DOUBLE PRECISION array, dimension (NRHS)
  3856. * The estimated forward error bound for each solution vector
  3857. * X(j) (the j-th column of the solution matrix X).
  3858. * If XTRUE is the true solution corresponding to X(j), FERR(j)
  3859. * is an estimated upper bound for the magnitude of the largest
  3860. * element in (X(j) - XTRUE) divided by the magnitude of the
  3861. * largest element in X(j). The estimate is as reliable as
  3862. * the estimate for RCOND, and is almost always a slight
  3863. * overestimate of the true error.
  3864. *
  3865. * BERR (output) DOUBLE PRECISION array, dimension (NRHS)
  3866. * The componentwise relative backward error of each solution
  3867. * vector X(j) (i.e., the smallest relative change in
  3868. * any element of A or B that makes X(j) an exact solution).
  3869. *
  3870. * WORK (workspace) DOUBLE PRECISION array, dimension (3*N)
  3871. *
  3872. * IWORK (workspace) INTEGER array, dimension (N)
  3873. *
  3874. * C++ Return value: INFO (output) INTEGER
  3875. * = 0: successful exit
  3876. * < 0: if INFO = -i, the i-th argument had an illegal value
  3877. *
  3878. * Internal Parameters
  3879. * ===================
  3880. *
  3881. * ITMAX is the maximum number of steps of iterative refinement.
  3882. *
  3883. * =====================================================================
  3884. *
  3885. * .. Parameters ..
  3886. **/
  3887. int C_DGERFS(char trans, int n, int nrhs, double* a, int lda, double* af, int ldaf, int* ipiv, double* b, int ldb, double* x, int ldx, double* ferr, double* berr, double* work, int* iwork)
  3888. {
  3889. int info;
  3890. ::F_DGERFS(&trans, &n, &nrhs, a, &lda, af, &ldaf, ipiv, b, &ldb, x, &ldx, ferr, berr, work, iwork, &info);
  3891. return info;
  3892. }
  3893. /**
  3894. * Purpose
  3895. * =======
  3896. *
  3897. * DGERQF computes an RQ factorization of a real M-by-N matrix A:
  3898. * A = R * Q.
  3899. *
  3900. * Arguments
  3901. * =========
  3902. *
  3903. * M (input) INTEGER
  3904. * The number of rows of the matrix A. M >= 0.
  3905. *
  3906. * N (input) INTEGER
  3907. * The number of columns of the matrix A. N >= 0.
  3908. *
  3909. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  3910. * On entry, the M-by-N matrix A.
  3911. * On exit,
  3912. * if m <= n, the upper triangle of the subarray
  3913. * A(1:m,n-m+1:n) contains the M-by-M upper triangular matrix R;
  3914. * if m >= n, the elements on and above the (m-n)-th subdiagonal
  3915. * contain the M-by-N upper trapezoidal matrix R;
  3916. * the remaining elements, with the array TAU, represent the
  3917. * orthogonal matrix Q as a product of min(m,n) elementary
  3918. * reflectors (see Further Details).
  3919. *
  3920. * LDA (input) INTEGER
  3921. * The leading dimension of the array A. LDA >= max(1,M).
  3922. *
  3923. * TAU (output) DOUBLE PRECISION array, dimension (min(M,N))
  3924. * The scalar factors of the elementary reflectors (see Further
  3925. * Details).
  3926. *
  3927. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  3928. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  3929. *
  3930. * LWORK (input) INTEGER
  3931. * The dimension of the array WORK. LWORK >= max(1,M).
  3932. * For optimum performance LWORK >= M*NB, where NB is
  3933. * the optimal blocksize.
  3934. *
  3935. * If LWORK = -1, then a workspace query is assumed; the routine
  3936. * only calculates the optimal size of the WORK array, returns
  3937. * this value as the first entry of the WORK array, and no error
  3938. * message related to LWORK is issued by XERBLA.
  3939. *
  3940. * C++ Return value: INFO (output) INTEGER
  3941. * = 0: successful exit
  3942. * < 0: if INFO = -i, the i-th argument had an illegal value
  3943. *
  3944. * Further Details
  3945. * ===============
  3946. *
  3947. * The matrix Q is represented as a product of elementary reflectors
  3948. *
  3949. * Q = H(1) H(2) . . . H(k), where k = min(m,n).
  3950. *
  3951. * Each H(i) has the form
  3952. *
  3953. * H(i) = I - tau * v * v'
  3954. *
  3955. * where tau is a real scalar, and v is a real vector with
  3956. * v(n-k+i+1:n) = 0 and v(n-k+i) = 1; v(1:n-k+i-1) is stored on exit in
  3957. * A(m-k+i,1:n-k+i-1), and tau in TAU(i).
  3958. *
  3959. * =====================================================================
  3960. *
  3961. * .. Local Scalars ..
  3962. **/
  3963. int C_DGERQF(int m, int n, double* a, int lda, double* tau, double* work, int lwork)
  3964. {
  3965. int info;
  3966. ::F_DGERQF(&m, &n, a, &lda, tau, work, &lwork, &info);
  3967. return info;
  3968. }
  3969. /**
  3970. * Purpose
  3971. * =======
  3972. *
  3973. * DGESDD computes the singular value decomposition (SVD) of a real
  3974. * M-by-N matrix A, optionally computing the left and right singular
  3975. * vectors. If singular vectors are desired, it uses a
  3976. * divide-and-conquer algorithm.
  3977. *
  3978. * The SVD is written
  3979. *
  3980. * A = U * SIGMA * transpose(V)
  3981. *
  3982. * where SIGMA is an M-by-N matrix which is zero except for its
  3983. * min(m,n) diagonal elements, U is an M-by-M orthogonal matrix, and
  3984. * V is an N-by-N orthogonal matrix. The diagonal elements of SIGMA
  3985. * are the singular values of A; they are real and non-negative, and
  3986. * are returned in descending order. The first min(m,n) columns of
  3987. * U and V are the left and right singular vectors of A.
  3988. *
  3989. * Note that the routine returns VT = V**T, not V.
  3990. *
  3991. * The divide and conquer algorithm makes very mild assumptions about
  3992. * floating point arithmetic. It will work on machines with a guard
  3993. * digit in add/subtract, or on those binary machines without guard
  3994. * digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or
  3995. * Cray-2. It could conceivably fail on hexadecimal or decimal machines
  3996. * without guard digits, but we know of none.
  3997. *
  3998. * Arguments
  3999. * =========
  4000. *
  4001. * JOBZ (input) CHARACTER*1
  4002. * Specifies options for computing all or part of the matrix U:
  4003. * = 'A': all M columns of U and all N rows of V**T are
  4004. * returned in the arrays U and VT;
  4005. * = 'S': the first min(M,N) columns of U and the first
  4006. * min(M,N) rows of V**T are returned in the arrays U
  4007. * and VT;
  4008. * = 'O': If M >= N, the first N columns of U are overwritten
  4009. * on the array A and all rows of V**T are returned in
  4010. * the array VT;
  4011. * otherwise, all columns of U are returned in the
  4012. * array U and the first M rows of V**T are overwritten
  4013. * in the array A;
  4014. * = 'N': no columns of U or rows of V**T are computed.
  4015. *
  4016. * M (input) INTEGER
  4017. * The number of rows of the input matrix A. M >= 0.
  4018. *
  4019. * N (input) INTEGER
  4020. * The number of columns of the input matrix A. N >= 0.
  4021. *
  4022. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  4023. * On entry, the M-by-N matrix A.
  4024. * On exit,
  4025. * if JOBZ = 'O', A is overwritten with the first N columns
  4026. * of U (the left singular vectors, stored
  4027. * columnwise) if M >= N;
  4028. * A is overwritten with the first M rows
  4029. * of V**T (the right singular vectors, stored
  4030. * rowwise) otherwise.
  4031. * if JOBZ .ne. 'O', the contents of A are destroyed.
  4032. *
  4033. * LDA (input) INTEGER
  4034. * The leading dimension of the array A. LDA >= max(1,M).
  4035. *
  4036. * S (output) DOUBLE PRECISION array, dimension (min(M,N))
  4037. * The singular values of A, sorted so that S(i) >= S(i+1).
  4038. *
  4039. * U (output) DOUBLE PRECISION array, dimension (LDU,UCOL)
  4040. * UCOL = M if JOBZ = 'A' or JOBZ = 'O' and M < N;
  4041. * UCOL = min(M,N) if JOBZ = 'S'.
  4042. * If JOBZ = 'A' or JOBZ = 'O' and M < N, U contains the M-by-M
  4043. * orthogonal matrix U;
  4044. * if JOBZ = 'S', U contains the first min(M,N) columns of U
  4045. * (the left singular vectors, stored columnwise);
  4046. * if JOBZ = 'O' and M >= N, or JOBZ = 'N', U is not referenced.
  4047. *
  4048. * LDU (input) INTEGER
  4049. * The leading dimension of the array U. LDU >= 1; if
  4050. * JOBZ = 'S' or 'A' or JOBZ = 'O' and M < N, LDU >= M.
  4051. *
  4052. * VT (output) DOUBLE PRECISION array, dimension (LDVT,N)
  4053. * If JOBZ = 'A' or JOBZ = 'O' and M >= N, VT contains the
  4054. * N-by-N orthogonal matrix V**T;
  4055. * if JOBZ = 'S', VT contains the first min(M,N) rows of
  4056. * V**T (the right singular vectors, stored rowwise);
  4057. * if JOBZ = 'O' and M < N, or JOBZ = 'N', VT is not referenced.
  4058. *
  4059. * LDVT (input) INTEGER
  4060. * The leading dimension of the array VT. LDVT >= 1; if
  4061. * JOBZ = 'A' or JOBZ = 'O' and M >= N, LDVT >= N;
  4062. * if JOBZ = 'S', LDVT >= min(M,N).
  4063. *
  4064. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  4065. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK;
  4066. *
  4067. * LWORK (input) INTEGER
  4068. * The dimension of the array WORK. LWORK >= 1.
  4069. * If JOBZ = 'N',
  4070. * LWORK >= 3*min(M,N) + max(max(M,N),7*min(M,N)).
  4071. * If JOBZ = 'O',
  4072. * LWORK >= 3*min(M,N) +
  4073. * max(max(M,N),5*min(M,N)*min(M,N)+4*min(M,N)).
  4074. * If JOBZ = 'S' or 'A'
  4075. * LWORK >= 3*min(M,N) +
  4076. * max(max(M,N),4*min(M,N)*min(M,N)+4*min(M,N)).
  4077. * For good performance, LWORK should generally be larger.
  4078. * If LWORK = -1 but other input arguments are legal, WORK(1)
  4079. * returns the optimal LWORK.
  4080. *
  4081. * IWORK (workspace) INTEGER array, dimension (8*min(M,N))
  4082. *
  4083. * C++ Return value: INFO (output) INTEGER
  4084. * = 0: successful exit.
  4085. * < 0: if INFO = -i, the i-th argument had an illegal value.
  4086. * > 0: DBDSDC did not converge, updating process failed.
  4087. *
  4088. * Further Details
  4089. * ===============
  4090. *
  4091. * Based on contributions by
  4092. * Ming Gu and Huan Ren, Computer Science Division, University of
  4093. * California at Berkeley, USA
  4094. *
  4095. * =====================================================================
  4096. *
  4097. * .. Parameters ..
  4098. **/
  4099. int C_DGESDD(char jobz, int m, int n, double* a, int lda, double* s, double* u, int ldu, double* vt, int ldvt, double* work, int lwork, int* iwork)
  4100. {
  4101. int info;
  4102. ::F_DGESDD(&jobz, &m, &n, a, &lda, s, u, &ldu, vt, &ldvt, work, &lwork, iwork, &info);
  4103. return info;
  4104. }
  4105. /**
  4106. * Purpose
  4107. * =======
  4108. *
  4109. * DGESV computes the solution to a real system of linear equations
  4110. * A * X = B,
  4111. * where A is an N-by-N matrix and X and B are N-by-NRHS matrices.
  4112. *
  4113. * The LU decomposition with partial pivoting and row interchanges is
  4114. * used to factor A as
  4115. * A = P * L * U,
  4116. * where P is a permutation matrix, L is unit lower triangular, and U is
  4117. * upper triangular. The factored form of A is then used to solve the
  4118. * system of equations A * X = B.
  4119. *
  4120. * Arguments
  4121. * =========
  4122. *
  4123. * N (input) INTEGER
  4124. * The number of linear equations, i.e., the order of the
  4125. * matrix A. N >= 0.
  4126. *
  4127. * NRHS (input) INTEGER
  4128. * The number of right hand sides, i.e., the number of columns
  4129. * of the matrix B. NRHS >= 0.
  4130. *
  4131. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  4132. * On entry, the N-by-N coefficient matrix A.
  4133. * On exit, the factors L and U from the factorization
  4134. * A = P*L*U; the unit diagonal elements of L are not stored.
  4135. *
  4136. * LDA (input) INTEGER
  4137. * The leading dimension of the array A. LDA >= max(1,N).
  4138. *
  4139. * IPIV (output) INTEGER array, dimension (N)
  4140. * The pivot indices that define the permutation matrix P;
  4141. * row i of the matrix was interchanged with row IPIV(i).
  4142. *
  4143. * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
  4144. * On entry, the N-by-NRHS matrix of right hand side matrix B.
  4145. * On exit, if INFO = 0, the N-by-NRHS solution matrix X.
  4146. *
  4147. * LDB (input) INTEGER
  4148. * The leading dimension of the array B. LDB >= max(1,N).
  4149. *
  4150. * C++ Return value: INFO (output) INTEGER
  4151. * = 0: successful exit
  4152. * < 0: if INFO = -i, the i-th argument had an illegal value
  4153. * > 0: if INFO = i, U(i,i) is exactly zero. The factorization
  4154. * has been completed, but the factor U is exactly
  4155. * singular, so the solution could not be computed.
  4156. *
  4157. * =====================================================================
  4158. *
  4159. * .. External Subroutines ..
  4160. **/
  4161. int C_DGESV(int n, int nrhs, double* a, int lda, int* ipiv, double* b, int ldb)
  4162. {
  4163. int info;
  4164. ::F_DGESV(&n, &nrhs, a, &lda, ipiv, b, &ldb, &info);
  4165. return info;
  4166. }
  4167. /**
  4168. * Purpose
  4169. * =======
  4170. *
  4171. * DGESVX uses the LU factorization to compute the solution to a real
  4172. * system of linear equations
  4173. * A * X = B,
  4174. * where A is an N-by-N matrix and X and B are N-by-NRHS matrices.
  4175. *
  4176. * Error bounds on the solution and a condition estimate are also
  4177. * provided.
  4178. *
  4179. * Description
  4180. * ===========
  4181. *
  4182. * The following steps are performed:
  4183. *
  4184. * 1. If FACT = 'E', real scaling factors are computed to equilibrate
  4185. * the system:
  4186. * TRANS = 'N': diag(R)*A*diag(C) *inv(diag(C))*X = diag(R)*B
  4187. * TRANS = 'T': (diag(R)*A*diag(C))**T *inv(diag(R))*X = diag(C)*B
  4188. * TRANS = 'C': (diag(R)*A*diag(C))**H *inv(diag(R))*X = diag(C)*B
  4189. * Whether or not the system will be equilibrated depends on the
  4190. * scaling of the matrix A, but if equilibration is used, A is
  4191. * overwritten by diag(R)*A*diag(C) and B by diag(R)*B (if TRANS='N')
  4192. * or diag(C)*B (if TRANS = 'T' or 'C').
  4193. *
  4194. * 2. If FACT = 'N' or 'E', the LU decomposition is used to factor the
  4195. * matrix A (after equilibration if FACT = 'E') as
  4196. * A = P * L * U,
  4197. * where P is a permutation matrix, L is a unit lower triangular
  4198. * matrix, and U is upper triangular.
  4199. *
  4200. * 3. If some U(i,i)=0, so that U is exactly singular, then the routine
  4201. * returns with INFO = i. Otherwise, the factored form of A is used
  4202. * to estimate the condition number of the matrix A. If the
  4203. * reciprocal of the condition number is less than machine precision,
  4204. * C++ Return value: INFO (output) INTEGER
  4205. * to solve for X and compute error bounds as described below.
  4206. *
  4207. * 4. The system of equations is solved for X using the factored form
  4208. * of A.
  4209. *
  4210. * 5. Iterative refinement is applied to improve the computed solution
  4211. * matrix and calculate error bounds and backward error estimates
  4212. * for it.
  4213. *
  4214. * 6. If equilibration was used, the matrix X is premultiplied by
  4215. * diag(C) (if TRANS = 'N') or diag(R) (if TRANS = 'T' or 'C') so
  4216. * that it solves the original system before equilibration.
  4217. *
  4218. * Arguments
  4219. * =========
  4220. *
  4221. * FACT (input) CHARACTER*1
  4222. * Specifies whether or not the factored form of the matrix A is
  4223. * supplied on entry, and if not, whether the matrix A should be
  4224. * equilibrated before it is factored.
  4225. * = 'F': On entry, AF and IPIV contain the factored form of A.
  4226. * If EQUED is not 'N', the matrix A has been
  4227. * equilibrated with scaling factors given by R and C.
  4228. * A, AF, and IPIV are not modified.
  4229. * = 'N': The matrix A will be copied to AF and factored.
  4230. * = 'E': The matrix A will be equilibrated if necessary, then
  4231. * copied to AF and factored.
  4232. *
  4233. * TRANS (input) CHARACTER*1
  4234. * Specifies the form of the system of equations:
  4235. * = 'N': A * X = B (No transpose)
  4236. * = 'T': A**T * X = B (Transpose)
  4237. * = 'C': A**H * X = B (Transpose)
  4238. *
  4239. * N (input) INTEGER
  4240. * The number of linear equations, i.e., the order of the
  4241. * matrix A. N >= 0.
  4242. *
  4243. * NRHS (input) INTEGER
  4244. * The number of right hand sides, i.e., the number of columns
  4245. * of the matrices B and X. NRHS >= 0.
  4246. *
  4247. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  4248. * On entry, the N-by-N matrix A. If FACT = 'F' and EQUED is
  4249. * not 'N', then A must have been equilibrated by the scaling
  4250. * factors in R and/or C. A is not modified if FACT = 'F' or
  4251. * 'N', or if FACT = 'E' and EQUED = 'N' on exit.
  4252. *
  4253. * On exit, if EQUED .ne. 'N', A is scaled as follows:
  4254. * EQUED = 'R': A := diag(R) * A
  4255. * EQUED = 'C': A := A * diag(C)
  4256. * EQUED = 'B': A := diag(R) * A * diag(C).
  4257. *
  4258. * LDA (input) INTEGER
  4259. * The leading dimension of the array A. LDA >= max(1,N).
  4260. *
  4261. * AF (input or output) DOUBLE PRECISION array, dimension (LDAF,N)
  4262. * If FACT = 'F', then AF is an input argument and on entry
  4263. * contains the factors L and U from the factorization
  4264. * A = P*L*U as computed by DGETRF. If EQUED .ne. 'N', then
  4265. * AF is the factored form of the equilibrated matrix A.
  4266. *
  4267. * If FACT = 'N', then AF is an output argument and on exit
  4268. * returns the factors L and U from the factorization A = P*L*U
  4269. * of the original matrix A.
  4270. *
  4271. * If FACT = 'E', then AF is an output argument and on exit
  4272. * returns the factors L and U from the factorization A = P*L*U
  4273. * of the equilibrated matrix A (see the description of A for
  4274. * the form of the equilibrated matrix).
  4275. *
  4276. * LDAF (input) INTEGER
  4277. * The leading dimension of the array AF. LDAF >= max(1,N).
  4278. *
  4279. * IPIV (input or output) INTEGER array, dimension (N)
  4280. * If FACT = 'F', then IPIV is an input argument and on entry
  4281. * contains the pivot indices from the factorization A = P*L*U
  4282. * as computed by DGETRF; row i of the matrix was interchanged
  4283. * with row IPIV(i).
  4284. *
  4285. * If FACT = 'N', then IPIV is an output argument and on exit
  4286. * contains the pivot indices from the factorization A = P*L*U
  4287. * of the original matrix A.
  4288. *
  4289. * If FACT = 'E', then IPIV is an output argument and on exit
  4290. * contains the pivot indices from the factorization A = P*L*U
  4291. * of the equilibrated matrix A.
  4292. *
  4293. * EQUED (input or output) CHARACTER*1
  4294. * Specifies the form of equilibration that was done.
  4295. * = 'N': No equilibration (always true if FACT = 'N').
  4296. * = 'R': Row equilibration, i.e., A has been premultiplied by
  4297. * diag(R).
  4298. * = 'C': Column equilibration, i.e., A has been postmultiplied
  4299. * by diag(C).
  4300. * = 'B': Both row and column equilibration, i.e., A has been
  4301. * replaced by diag(R) * A * diag(C).
  4302. * EQUED is an input argument if FACT = 'F'; otherwise, it is an
  4303. * output argument.
  4304. *
  4305. * R (input or output) DOUBLE PRECISION array, dimension (N)
  4306. * The row scale factors for A. If EQUED = 'R' or 'B', A is
  4307. * multiplied on the left by diag(R); if EQUED = 'N' or 'C', R
  4308. * is not accessed. R is an input argument if FACT = 'F';
  4309. * otherwise, R is an output argument. If FACT = 'F' and
  4310. * EQUED = 'R' or 'B', each element of R must be positive.
  4311. *
  4312. * C (input or output) DOUBLE PRECISION array, dimension (N)
  4313. * The column scale factors for A. If EQUED = 'C' or 'B', A is
  4314. * multiplied on the right by diag(C); if EQUED = 'N' or 'R', C
  4315. * is not accessed. C is an input argument if FACT = 'F';
  4316. * otherwise, C is an output argument. If FACT = 'F' and
  4317. * EQUED = 'C' or 'B', each element of C must be positive.
  4318. *
  4319. * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
  4320. * On entry, the N-by-NRHS right hand side matrix B.
  4321. * On exit,
  4322. * if EQUED = 'N', B is not modified;
  4323. * if TRANS = 'N' and EQUED = 'R' or 'B', B is overwritten by
  4324. * diag(R)*B;
  4325. * if TRANS = 'T' or 'C' and EQUED = 'C' or 'B', B is
  4326. * overwritten by diag(C)*B.
  4327. *
  4328. * LDB (input) INTEGER
  4329. * The leading dimension of the array B. LDB >= max(1,N).
  4330. *
  4331. * X (output) DOUBLE PRECISION array, dimension (LDX,NRHS)
  4332. * If INFO = 0 or INFO = N+1, the N-by-NRHS solution matrix X
  4333. * to the original system of equations. Note that A and B are
  4334. * modified on exit if EQUED .ne. 'N', and the solution to the
  4335. * equilibrated system is inv(diag(C))*X if TRANS = 'N' and
  4336. * EQUED = 'C' or 'B', or inv(diag(R))*X if TRANS = 'T' or 'C'
  4337. * and EQUED = 'R' or 'B'.
  4338. *
  4339. * LDX (input) INTEGER
  4340. * The leading dimension of the array X. LDX >= max(1,N).
  4341. *
  4342. * RCOND (output) DOUBLE PRECISION
  4343. * The estimate of the reciprocal condition number of the matrix
  4344. * A after equilibration (if done). If RCOND is less than the
  4345. * machine precision (in particular, if RCOND = 0), the matrix
  4346. * is singular to working precision. This condition is
  4347. * indicated by a return code of INFO > 0.
  4348. *
  4349. * FERR (output) DOUBLE PRECISION array, dimension (NRHS)
  4350. * The estimated forward error bound for each solution vector
  4351. * X(j) (the j-th column of the solution matrix X).
  4352. * If XTRUE is the true solution corresponding to X(j), FERR(j)
  4353. * is an estimated upper bound for the magnitude of the largest
  4354. * element in (X(j) - XTRUE) divided by the magnitude of the
  4355. * largest element in X(j). The estimate is as reliable as
  4356. * the estimate for RCOND, and is almost always a slight
  4357. * overestimate of the true error.
  4358. *
  4359. * BERR (output) DOUBLE PRECISION array, dimension (NRHS)
  4360. * The componentwise relative backward error of each solution
  4361. * vector X(j) (i.e., the smallest relative change in
  4362. * any element of A or B that makes X(j) an exact solution).
  4363. *
  4364. * WORK (workspace/output) DOUBLE PRECISION array, dimension (4*N)
  4365. * On exit, WORK(1) contains the reciprocal pivot growth
  4366. * factor norm(A)/norm(U). The "max absolute element" norm is
  4367. * used. If WORK(1) is much less than 1, then the stability
  4368. * of the LU factorization of the (equilibrated) matrix A
  4369. * could be poor. This also means that the solution X, condition
  4370. * estimator RCOND, and forward error bound FERR could be
  4371. * unreliable. If factorization fails with 0<INFO<=N, then
  4372. * WORK(1) contains the reciprocal pivot growth factor for the
  4373. * leading INFO columns of A.
  4374. *
  4375. * IWORK (workspace) INTEGER array, dimension (N)
  4376. *
  4377. * C++ Return value: INFO (output) INTEGER
  4378. * = 0: successful exit
  4379. * < 0: if INFO = -i, the i-th argument had an illegal value
  4380. * > 0: if INFO = i, and i is
  4381. * <= N: U(i,i) is exactly zero. The factorization has
  4382. * been completed, but the factor U is exactly
  4383. * singular, so the solution and error bounds
  4384. * could not be computed. RCOND = 0 is returned.
  4385. * = N+1: U is nonsingular, but RCOND is less than machine
  4386. * precision, meaning that the matrix is singular
  4387. * to working precision. Nevertheless, the
  4388. * solution and error bounds are computed because
  4389. * there are a number of situations where the
  4390. * computed solution can be more accurate than the
  4391. * value of RCOND would suggest.
  4392. *
  4393. * =====================================================================
  4394. *
  4395. * .. Parameters ..
  4396. **/
  4397. int C_DGESVX(char fact, char trans, int n, int nrhs, double* a, int lda, double* af, int ldaf, int* ipiv, char equed, double* r, double* c, double* b, int ldb, double* x, int ldx, double* rcond, double* ferr, double* berr, double* work, int* iwork)
  4398. {
  4399. int info;
  4400. ::F_DGESVX(&fact, &trans, &n, &nrhs, a, &lda, af, &ldaf, ipiv, &equed, r, c, b, &ldb, x, &ldx, rcond, ferr, berr, work, iwork, &info);
  4401. return info;
  4402. }
  4403. /**
  4404. * Purpose
  4405. * =======
  4406. *
  4407. * DGETRF computes an LU factorization of a general M-by-N matrix A
  4408. * using partial pivoting with row interchanges.
  4409. *
  4410. * The factorization has the form
  4411. * A = P * L * U
  4412. * where P is a permutation matrix, L is lower triangular with unit
  4413. * diagonal elements (lower trapezoidal if m > n), and U is upper
  4414. * triangular (upper trapezoidal if m < n).
  4415. *
  4416. * This is the right-looking Level 3 BLAS version of the algorithm.
  4417. *
  4418. * Arguments
  4419. * =========
  4420. *
  4421. * M (input) INTEGER
  4422. * The number of rows of the matrix A. M >= 0.
  4423. *
  4424. * N (input) INTEGER
  4425. * The number of columns of the matrix A. N >= 0.
  4426. *
  4427. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  4428. * On entry, the M-by-N matrix to be factored.
  4429. * On exit, the factors L and U from the factorization
  4430. * A = P*L*U; the unit diagonal elements of L are not stored.
  4431. *
  4432. * LDA (input) INTEGER
  4433. * The leading dimension of the array A. LDA >= max(1,M).
  4434. *
  4435. * IPIV (output) INTEGER array, dimension (min(M,N))
  4436. * The pivot indices; for 1 <= i <= min(M,N), row i of the
  4437. * matrix was interchanged with row IPIV(i).
  4438. *
  4439. * C++ Return value: INFO (output) INTEGER
  4440. * = 0: successful exit
  4441. * < 0: if INFO = -i, the i-th argument had an illegal value
  4442. * > 0: if INFO = i, U(i,i) is exactly zero. The factorization
  4443. * has been completed, but the factor U is exactly
  4444. * singular, and division by zero will occur if it is used
  4445. * to solve a system of equations.
  4446. *
  4447. * =====================================================================
  4448. *
  4449. * .. Parameters ..
  4450. **/
  4451. int C_DGETRF(int m, int n, double* a, int lda, int* ipiv)
  4452. {
  4453. int info;
  4454. ::F_DGETRF(&m, &n, a, &lda, ipiv, &info);
  4455. return info;
  4456. }
  4457. /**
  4458. * Purpose
  4459. * =======
  4460. *
  4461. * DGETRI computes the inverse of a matrix using the LU factorization
  4462. * computed by DGETRF.
  4463. *
  4464. * This method inverts U and then computes inv(A) by solving the system
  4465. * inv(A)*L = inv(U) for inv(A).
  4466. *
  4467. * Arguments
  4468. * =========
  4469. *
  4470. * N (input) INTEGER
  4471. * The order of the matrix A. N >= 0.
  4472. *
  4473. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  4474. * On entry, the factors L and U from the factorization
  4475. * A = P*L*U as computed by DGETRF.
  4476. * On exit, if INFO = 0, the inverse of the original matrix A.
  4477. *
  4478. * LDA (input) INTEGER
  4479. * The leading dimension of the array A. LDA >= max(1,N).
  4480. *
  4481. * IPIV (input) INTEGER array, dimension (N)
  4482. * The pivot indices from DGETRF; for 1<=i<=N, row i of the
  4483. * matrix was interchanged with row IPIV(i).
  4484. *
  4485. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  4486. * On exit, if INFO=0, then WORK(1) returns the optimal LWORK.
  4487. *
  4488. * LWORK (input) INTEGER
  4489. * The dimension of the array WORK. LWORK >= max(1,N).
  4490. * For optimal performance LWORK >= N*NB, where NB is
  4491. * the optimal blocksize returned by ILAENV.
  4492. *
  4493. * If LWORK = -1, then a workspace query is assumed; the routine
  4494. * only calculates the optimal size of the WORK array, returns
  4495. * this value as the first entry of the WORK array, and no error
  4496. * message related to LWORK is issued by XERBLA.
  4497. *
  4498. * C++ Return value: INFO (output) INTEGER
  4499. * = 0: successful exit
  4500. * < 0: if INFO = -i, the i-th argument had an illegal value
  4501. * > 0: if INFO = i, U(i,i) is exactly zero; the matrix is
  4502. * singular and its inverse could not be computed.
  4503. *
  4504. * =====================================================================
  4505. *
  4506. * .. Parameters ..
  4507. **/
  4508. int C_DGETRI(int n, double* a, int lda, int* ipiv, double* work, int lwork)
  4509. {
  4510. int info;
  4511. ::F_DGETRI(&n, a, &lda, ipiv, work, &lwork, &info);
  4512. return info;
  4513. }
  4514. /**
  4515. * Purpose
  4516. * =======
  4517. *
  4518. * DGETRS solves a system of linear equations
  4519. * A * X = B or A' * X = B
  4520. * with a general N-by-N matrix A using the LU factorization computed
  4521. * by DGETRF.
  4522. *
  4523. * Arguments
  4524. * =========
  4525. *
  4526. * TRANS (input) CHARACTER*1
  4527. * Specifies the form of the system of equations:
  4528. * = 'N': A * X = B (No transpose)
  4529. * = 'T': A'* X = B (Transpose)
  4530. * = 'C': A'* X = B (Conjugate transpose = Transpose)
  4531. *
  4532. * N (input) INTEGER
  4533. * The order of the matrix A. N >= 0.
  4534. *
  4535. * NRHS (input) INTEGER
  4536. * The number of right hand sides, i.e., the number of columns
  4537. * of the matrix B. NRHS >= 0.
  4538. *
  4539. * A (input) DOUBLE PRECISION array, dimension (LDA,N)
  4540. * The factors L and U from the factorization A = P*L*U
  4541. * as computed by DGETRF.
  4542. *
  4543. * LDA (input) INTEGER
  4544. * The leading dimension of the array A. LDA >= max(1,N).
  4545. *
  4546. * IPIV (input) INTEGER array, dimension (N)
  4547. * The pivot indices from DGETRF; for 1<=i<=N, row i of the
  4548. * matrix was interchanged with row IPIV(i).
  4549. *
  4550. * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
  4551. * On entry, the right hand side matrix B.
  4552. * On exit, the solution matrix X.
  4553. *
  4554. * LDB (input) INTEGER
  4555. * The leading dimension of the array B. LDB >= max(1,N).
  4556. *
  4557. * C++ Return value: INFO (output) INTEGER
  4558. * = 0: successful exit
  4559. * < 0: if INFO = -i, the i-th argument had an illegal value
  4560. *
  4561. * =====================================================================
  4562. *
  4563. * .. Parameters ..
  4564. **/
  4565. int C_DGETRS(char trans, int n, int nrhs, double* a, int lda, int* ipiv, double* b, int ldb)
  4566. {
  4567. int info;
  4568. ::F_DGETRS(&trans, &n, &nrhs, a, &lda, ipiv, b, &ldb, &info);
  4569. return info;
  4570. }
  4571. /**
  4572. * Purpose
  4573. * =======
  4574. *
  4575. * DGGBAK forms the right or left eigenvectors of a real generalized
  4576. * eigenvalue problem A*x = lambda*B*x, by backward transformation on
  4577. * the computed eigenvectors of the balanced pair of matrices output by
  4578. * DGGBAL.
  4579. *
  4580. * Arguments
  4581. * =========
  4582. *
  4583. * JOB (input) CHARACTER*1
  4584. * Specifies the type of backward transformation required:
  4585. * = 'N': do nothing, return immediately;
  4586. * = 'P': do backward transformation for permutation only;
  4587. * = 'S': do backward transformation for scaling only;
  4588. * = 'B': do backward transformations for both permutation and
  4589. * scaling.
  4590. * JOB must be the same as the argument JOB supplied to DGGBAL.
  4591. *
  4592. * SIDE (input) CHARACTER*1
  4593. * = 'R': V contains right eigenvectors;
  4594. * = 'L': V contains left eigenvectors.
  4595. *
  4596. * N (input) INTEGER
  4597. * The number of rows of the matrix V. N >= 0.
  4598. *
  4599. * ILO (input) INTEGER
  4600. * IHI (input) INTEGER
  4601. * The integers ILO and IHI determined by DGGBAL.
  4602. * 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0.
  4603. *
  4604. * LSCALE (input) DOUBLE PRECISION array, dimension (N)
  4605. * Details of the permutations and/or scaling factors applied
  4606. * to the left side of A and B, as returned by DGGBAL.
  4607. *
  4608. * RSCALE (input) DOUBLE PRECISION array, dimension (N)
  4609. * Details of the permutations and/or scaling factors applied
  4610. * to the right side of A and B, as returned by DGGBAL.
  4611. *
  4612. * M (input) INTEGER
  4613. * The number of columns of the matrix V. M >= 0.
  4614. *
  4615. * V (input/output) DOUBLE PRECISION array, dimension (LDV,M)
  4616. * On entry, the matrix of right or left eigenvectors to be
  4617. * transformed, as returned by DTGEVC.
  4618. * On exit, V is overwritten by the transformed eigenvectors.
  4619. *
  4620. * LDV (input) INTEGER
  4621. * The leading dimension of the matrix V. LDV >= max(1,N).
  4622. *
  4623. * C++ Return value: INFO (output) INTEGER
  4624. * = 0: successful exit.
  4625. * < 0: if INFO = -i, the i-th argument had an illegal value.
  4626. *
  4627. * Further Details
  4628. * ===============
  4629. *
  4630. * See R.C. Ward, Balancing the generalized eigenvalue problem,
  4631. * SIAM J. Sci. Stat. Comp. 2 (1981), 141-152.
  4632. *
  4633. * =====================================================================
  4634. *
  4635. * .. Local Scalars ..
  4636. **/
  4637. int C_DGGBAK(char job, char side, int n, int ilo, int ihi, double* lscale, double* rscale, int m, double* v, int ldv)
  4638. {
  4639. int info;
  4640. ::F_DGGBAK(&job, &side, &n, &ilo, &ihi, lscale, rscale, &m, v, &ldv, &info);
  4641. return info;
  4642. }
  4643. /**
  4644. * Purpose
  4645. * =======
  4646. *
  4647. * DGGBAL balances a pair of general real matrices (A,B). This
  4648. * involves, first, permuting A and B by similarity transformations to
  4649. * isolate eigenvalues in the first 1 to ILO$-$1 and last IHI+1 to N
  4650. * elements on the diagonal; and second, applying a diagonal similarity
  4651. * transformation to rows and columns ILO to IHI to make the rows
  4652. * and columns as close in norm as possible. Both steps are optional.
  4653. *
  4654. * Balancing may reduce the 1-norm of the matrices, and improve the
  4655. * accuracy of the computed eigenvalues and/or eigenvectors in the
  4656. * generalized eigenvalue problem A*x = lambda*B*x.
  4657. *
  4658. * Arguments
  4659. * =========
  4660. *
  4661. * JOB (input) CHARACTER*1
  4662. * Specifies the operations to be performed on A and B:
  4663. * = 'N': none: simply set ILO = 1, IHI = N, LSCALE(I) = 1.0
  4664. * and RSCALE(I) = 1.0 for i = 1,...,N.
  4665. * = 'P': permute only;
  4666. * = 'S': scale only;
  4667. * = 'B': both permute and scale.
  4668. *
  4669. * N (input) INTEGER
  4670. * The order of the matrices A and B. N >= 0.
  4671. *
  4672. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  4673. * On entry, the input matrix A.
  4674. * On exit, A is overwritten by the balanced matrix.
  4675. * If JOB = 'N', A is not referenced.
  4676. *
  4677. * LDA (input) INTEGER
  4678. * The leading dimension of the array A. LDA >= max(1,N).
  4679. *
  4680. * B (input/output) DOUBLE PRECISION array, dimension (LDB,N)
  4681. * On entry, the input matrix B.
  4682. * On exit, B is overwritten by the balanced matrix.
  4683. * If JOB = 'N', B is not referenced.
  4684. *
  4685. * LDB (input) INTEGER
  4686. * The leading dimension of the array B. LDB >= max(1,N).
  4687. *
  4688. * ILO (output) INTEGER
  4689. * IHI (output) INTEGER
  4690. * ILO and IHI are set to integers such that on exit
  4691. * A(i,j) = 0 and B(i,j) = 0 if i > j and
  4692. * j = 1,...,ILO-1 or i = IHI+1,...,N.
  4693. * If JOB = 'N' or 'S', ILO = 1 and IHI = N.
  4694. *
  4695. * LSCALE (output) DOUBLE PRECISION array, dimension (N)
  4696. * Details of the permutations and scaling factors applied
  4697. * to the left side of A and B. If P(j) is the index of the
  4698. * row interchanged with row j, and D(j)
  4699. * is the scaling factor applied to row j, then
  4700. * LSCALE(j) = P(j) for J = 1,...,ILO-1
  4701. * = D(j) for J = ILO,...,IHI
  4702. * = P(j) for J = IHI+1,...,N.
  4703. * The order in which the interchanges are made is N to IHI+1,
  4704. * then 1 to ILO-1.
  4705. *
  4706. * RSCALE (output) DOUBLE PRECISION array, dimension (N)
  4707. * Details of the permutations and scaling factors applied
  4708. * to the right side of A and B. If P(j) is the index of the
  4709. * column interchanged with column j, and D(j)
  4710. * is the scaling factor applied to column j, then
  4711. * LSCALE(j) = P(j) for J = 1,...,ILO-1
  4712. * = D(j) for J = ILO,...,IHI
  4713. * = P(j) for J = IHI+1,...,N.
  4714. * The order in which the interchanges are made is N to IHI+1,
  4715. * then 1 to ILO-1.
  4716. *
  4717. * WORK (workspace) DOUBLE PRECISION array, dimension (lwork)
  4718. * lwork must be at least max(1,6*N) when JOB = 'S' or 'B', and
  4719. * at least 1 when JOB = 'N' or 'P'.
  4720. *
  4721. * C++ Return value: INFO (output) INTEGER
  4722. * = 0: successful exit
  4723. * < 0: if INFO = -i, the i-th argument had an illegal value.
  4724. *
  4725. * Further Details
  4726. * ===============
  4727. *
  4728. * See R.C. WARD, Balancing the generalized eigenvalue problem,
  4729. * SIAM J. Sci. Stat. Comp. 2 (1981), 141-152.
  4730. *
  4731. * =====================================================================
  4732. *
  4733. * .. Parameters ..
  4734. **/
  4735. int C_DGGBAL(char job, int n, double* a, int lda, double* b, int ldb, int* ilo, int* ihi, double* lscale, double* rscale, double* work)
  4736. {
  4737. int info;
  4738. ::F_DGGBAL(&job, &n, a, &lda, b, &ldb, ilo, ihi, lscale, rscale, work, &info);
  4739. return info;
  4740. }
  4741. /**
  4742. * Purpose
  4743. * =======
  4744. *
  4745. * DGGES computes for a pair of N-by-N real nonsymmetric matrices (A,B),
  4746. * the generalized eigenvalues, the generalized real Schur form (S,T),
  4747. * optionally, the left and/or right matrices of Schur vectors (VSL and
  4748. * VSR). This gives the generalized Schur factorization
  4749. *
  4750. * (A,B) = ( (VSL)*S*(VSR)**T, (VSL)*T*(VSR)**T )
  4751. *
  4752. * Optionally, it also orders the eigenvalues so that a selected cluster
  4753. * of eigenvalues appears in the leading diagonal blocks of the upper
  4754. * quasi-triangular matrix S and the upper triangular matrix T.The
  4755. * leading columns of VSL and VSR then form an orthonormal basis for the
  4756. * corresponding left and right eigenspaces (deflating subspaces).
  4757. *
  4758. * (If only the generalized eigenvalues are needed, use the driver
  4759. * DGGEV instead, which is faster.)
  4760. *
  4761. * A generalized eigenvalue for a pair of matrices (A,B) is a scalar w
  4762. * or a ratio alpha/beta = w, such that A - w*B is singular. It is
  4763. * usually represented as the pair (alpha,beta), as there is a
  4764. * reasonable interpretation for beta=0 or both being zero.
  4765. *
  4766. * A pair of matrices (S,T) is in generalized real Schur form if T is
  4767. * upper triangular with non-negative diagonal and S is block upper
  4768. * triangular with 1-by-1 and 2-by-2 blocks. 1-by-1 blocks correspond
  4769. * to real generalized eigenvalues, while 2-by-2 blocks of S will be
  4770. * "standardized" by making the corresponding elements of T have the
  4771. * form:
  4772. * [ a 0 ]
  4773. * [ 0 b ]
  4774. *
  4775. * and the pair of corresponding 2-by-2 blocks in S and T will have a
  4776. * complex conjugate pair of generalized eigenvalues.
  4777. *
  4778. *
  4779. * Arguments
  4780. * =========
  4781. *
  4782. * JOBVSL (input) CHARACTER*1
  4783. * = 'N': do not compute the left Schur vectors;
  4784. * = 'V': compute the left Schur vectors.
  4785. *
  4786. * JOBVSR (input) CHARACTER*1
  4787. * = 'N': do not compute the right Schur vectors;
  4788. * = 'V': compute the right Schur vectors.
  4789. *
  4790. * SORT (input) CHARACTER*1
  4791. * Specifies whether or not to order the eigenvalues on the
  4792. * diagonal of the generalized Schur form.
  4793. * = 'N': Eigenvalues are not ordered;
  4794. * = 'S': Eigenvalues are ordered (see SELCTG);
  4795. *
  4796. * SELCTG (external procedure) LOGICAL FUNCTION of three DOUBLE PRECISION arguments
  4797. * SELCTG must be declared EXTERNAL in the calling subroutine.
  4798. * If SORT = 'N', SELCTG is not referenced.
  4799. * If SORT = 'S', SELCTG is used to select eigenvalues to sort
  4800. * to the top left of the Schur form.
  4801. * An eigenvalue (ALPHAR(j)+ALPHAI(j))/BETA(j) is selected if
  4802. * SELCTG(ALPHAR(j),ALPHAI(j),BETA(j)) is true; i.e. if either
  4803. * one of a complex conjugate pair of eigenvalues is selected,
  4804. * then both complex eigenvalues are selected.
  4805. *
  4806. * Note that in the ill-conditioned case, a selected complex
  4807. * eigenvalue may no longer satisfy SELCTG(ALPHAR(j),ALPHAI(j),
  4808. * BETA(j)) = .TRUE. after ordering. INFO is to be set to N+2
  4809. * in this case.
  4810. *
  4811. * N (input) INTEGER
  4812. * The order of the matrices A, B, VSL, and VSR. N >= 0.
  4813. *
  4814. * A (input/output) DOUBLE PRECISION array, dimension (LDA, N)
  4815. * On entry, the first of the pair of matrices.
  4816. * On exit, A has been overwritten by its generalized Schur
  4817. * form S.
  4818. *
  4819. * LDA (input) INTEGER
  4820. * The leading dimension of A. LDA >= max(1,N).
  4821. *
  4822. * B (input/output) DOUBLE PRECISION array, dimension (LDB, N)
  4823. * On entry, the second of the pair of matrices.
  4824. * On exit, B has been overwritten by its generalized Schur
  4825. * form T.
  4826. *
  4827. * LDB (input) INTEGER
  4828. * The leading dimension of B. LDB >= max(1,N).
  4829. *
  4830. * SDIM (output) INTEGER
  4831. * If SORT = 'N', SDIM = 0.
  4832. * If SORT = 'S', SDIM = number of eigenvalues (after sorting)
  4833. * for which SELCTG is true. (Complex conjugate pairs for which
  4834. * SELCTG is true for either eigenvalue count as 2.)
  4835. *
  4836. * ALPHAR (output) DOUBLE PRECISION array, dimension (N)
  4837. * ALPHAI (output) DOUBLE PRECISION array, dimension (N)
  4838. * BETA (output) DOUBLE PRECISION array, dimension (N)
  4839. * On exit, (ALPHAR(j) + ALPHAI(j)*i)/BETA(j), j=1,...,N, will
  4840. * be the generalized eigenvalues. ALPHAR(j) + ALPHAI(j)*i,
  4841. * and BETA(j),j=1,...,N are the diagonals of the complex Schur
  4842. * form (S,T) that would result if the 2-by-2 diagonal blocks of
  4843. * the real Schur form of (A,B) were further reduced to
  4844. * triangular form using 2-by-2 complex unitary transformations.
  4845. * If ALPHAI(j) is zero, then the j-th eigenvalue is real; if
  4846. * positive, then the j-th and (j+1)-st eigenvalues are a
  4847. * complex conjugate pair, with ALPHAI(j+1) negative.
  4848. *
  4849. * Note: the quotients ALPHAR(j)/BETA(j) and ALPHAI(j)/BETA(j)
  4850. * may easily over- or underflow, and BETA(j) may even be zero.
  4851. * Thus, the user should avoid naively computing the ratio.
  4852. * However, ALPHAR and ALPHAI will be always less than and
  4853. * usually comparable with norm(A) in magnitude, and BETA always
  4854. * less than and usually comparable with norm(B).
  4855. *
  4856. * VSL (output) DOUBLE PRECISION array, dimension (LDVSL,N)
  4857. * If JOBVSL = 'V', VSL will contain the left Schur vectors.
  4858. * Not referenced if JOBVSL = 'N'.
  4859. *
  4860. * LDVSL (input) INTEGER
  4861. * The leading dimension of the matrix VSL. LDVSL >=1, and
  4862. * if JOBVSL = 'V', LDVSL >= N.
  4863. *
  4864. * VSR (output) DOUBLE PRECISION array, dimension (LDVSR,N)
  4865. * If JOBVSR = 'V', VSR will contain the right Schur vectors.
  4866. * Not referenced if JOBVSR = 'N'.
  4867. *
  4868. * LDVSR (input) INTEGER
  4869. * The leading dimension of the matrix VSR. LDVSR >= 1, and
  4870. * if JOBVSR = 'V', LDVSR >= N.
  4871. *
  4872. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  4873. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  4874. *
  4875. * LWORK (input) INTEGER
  4876. * The dimension of the array WORK.
  4877. * If N = 0, LWORK >= 1, else LWORK >= 8*N+16.
  4878. * For good performance , LWORK must generally be larger.
  4879. *
  4880. * If LWORK = -1, then a workspace query is assumed; the routine
  4881. * only calculates the optimal size of the WORK array, returns
  4882. * this value as the first entry of the WORK array, and no error
  4883. * message related to LWORK is issued by XERBLA.
  4884. *
  4885. * BWORK (workspace) LOGICAL array, dimension (N)
  4886. * Not referenced if SORT = 'N'.
  4887. *
  4888. * C++ Return value: INFO (output) INTEGER
  4889. * = 0: successful exit
  4890. * < 0: if INFO = -i, the i-th argument had an illegal value.
  4891. * = 1,...,N:
  4892. * The QZ iteration failed. (A,B) are not in Schur
  4893. * form, but ALPHAR(j), ALPHAI(j), and BETA(j) should
  4894. * be correct for j=INFO+1,...,N.
  4895. * > N: =N+1: other than QZ iteration failed in DHGEQZ.
  4896. * =N+2: after reordering, roundoff changed values of
  4897. * some complex eigenvalues so that leading
  4898. * eigenvalues in the Generalized Schur form no
  4899. * longer satisfy SELCTG=.TRUE. This could also
  4900. * be caused due to scaling.
  4901. * =N+3: reordering failed in DTGSEN.
  4902. *
  4903. * =====================================================================
  4904. *
  4905. * .. Parameters ..
  4906. **/
  4907. int C_DGGES(char jobvsl, char jobvsr, char sort, int n, double* a, int lda, double* b, int ldb, int* sdim, double* alphar, double* alphai, double* beta, double* vsl, int ldvsl, double* vsr, int ldvsr, double* work, int lwork)
  4908. {
  4909. int info;
  4910. ::F_DGGES(&jobvsl, &jobvsr, &sort, &n, a, &lda, b, &ldb, sdim, alphar, alphai, beta, vsl, &ldvsl, vsr, &ldvsr, work, &lwork, &info);
  4911. return info;
  4912. }
  4913. /**
  4914. * Purpose
  4915. * =======
  4916. *
  4917. * DGGESX computes for a pair of N-by-N real nonsymmetric matrices
  4918. * (A,B), the generalized eigenvalues, the real Schur form (S,T), and,
  4919. * optionally, the left and/or right matrices of Schur vectors (VSL and
  4920. * VSR). This gives the generalized Schur factorization
  4921. *
  4922. * (A,B) = ( (VSL) S (VSR)**T, (VSL) T (VSR)**T )
  4923. *
  4924. * Optionally, it also orders the eigenvalues so that a selected cluster
  4925. * of eigenvalues appears in the leading diagonal blocks of the upper
  4926. * quasi-triangular matrix S and the upper triangular matrix T; computes
  4927. * a reciprocal condition number for the average of the selected
  4928. * eigenvalues (RCONDE); and computes a reciprocal condition number for
  4929. * the right and left deflating subspaces corresponding to the selected
  4930. * eigenvalues (RCONDV). The leading columns of VSL and VSR then form
  4931. * an orthonormal basis for the corresponding left and right eigenspaces
  4932. * (deflating subspaces).
  4933. *
  4934. * A generalized eigenvalue for a pair of matrices (A,B) is a scalar w
  4935. * or a ratio alpha/beta = w, such that A - w*B is singular. It is
  4936. * usually represented as the pair (alpha,beta), as there is a
  4937. * reasonable interpretation for beta=0 or for both being zero.
  4938. *
  4939. * A pair of matrices (S,T) is in generalized real Schur form if T is
  4940. * upper triangular with non-negative diagonal and S is block upper
  4941. * triangular with 1-by-1 and 2-by-2 blocks. 1-by-1 blocks correspond
  4942. * to real generalized eigenvalues, while 2-by-2 blocks of S will be
  4943. * "standardized" by making the corresponding elements of T have the
  4944. * form:
  4945. * [ a 0 ]
  4946. * [ 0 b ]
  4947. *
  4948. * and the pair of corresponding 2-by-2 blocks in S and T will have a
  4949. * complex conjugate pair of generalized eigenvalues.
  4950. *
  4951. *
  4952. * Arguments
  4953. * =========
  4954. *
  4955. * JOBVSL (input) CHARACTER*1
  4956. * = 'N': do not compute the left Schur vectors;
  4957. * = 'V': compute the left Schur vectors.
  4958. *
  4959. * JOBVSR (input) CHARACTER*1
  4960. * = 'N': do not compute the right Schur vectors;
  4961. * = 'V': compute the right Schur vectors.
  4962. *
  4963. * SORT (input) CHARACTER*1
  4964. * Specifies whether or not to order the eigenvalues on the
  4965. * diagonal of the generalized Schur form.
  4966. * = 'N': Eigenvalues are not ordered;
  4967. * = 'S': Eigenvalues are ordered (see SELCTG).
  4968. *
  4969. * SELCTG (external procedure) LOGICAL FUNCTION of three DOUBLE PRECISION arguments
  4970. * SELCTG must be declared EXTERNAL in the calling subroutine.
  4971. * If SORT = 'N', SELCTG is not referenced.
  4972. * If SORT = 'S', SELCTG is used to select eigenvalues to sort
  4973. * to the top left of the Schur form.
  4974. * An eigenvalue (ALPHAR(j)+ALPHAI(j))/BETA(j) is selected if
  4975. * SELCTG(ALPHAR(j),ALPHAI(j),BETA(j)) is true; i.e. if either
  4976. * one of a complex conjugate pair of eigenvalues is selected,
  4977. * then both complex eigenvalues are selected.
  4978. * Note that a selected complex eigenvalue may no longer satisfy
  4979. * SELCTG(ALPHAR(j),ALPHAI(j),BETA(j)) = .TRUE. after ordering,
  4980. * since ordering may change the value of complex eigenvalues
  4981. * (especially if the eigenvalue is ill-conditioned), in this
  4982. * case INFO is set to N+3.
  4983. *
  4984. * SENSE (input) CHARACTER*1
  4985. * Determines which reciprocal condition numbers are computed.
  4986. * = 'N' : None are computed;
  4987. * = 'E' : Computed for average of selected eigenvalues only;
  4988. * = 'V' : Computed for selected deflating subspaces only;
  4989. * = 'B' : Computed for both.
  4990. * If SENSE = 'E', 'V', or 'B', SORT must equal 'S'.
  4991. *
  4992. * N (input) INTEGER
  4993. * The order of the matrices A, B, VSL, and VSR. N >= 0.
  4994. *
  4995. * A (input/output) DOUBLE PRECISION array, dimension (LDA, N)
  4996. * On entry, the first of the pair of matrices.
  4997. * On exit, A has been overwritten by its generalized Schur
  4998. * form S.
  4999. *
  5000. * LDA (input) INTEGER
  5001. * The leading dimension of A. LDA >= max(1,N).
  5002. *
  5003. * B (input/output) DOUBLE PRECISION array, dimension (LDB, N)
  5004. * On entry, the second of the pair of matrices.
  5005. * On exit, B has been overwritten by its generalized Schur
  5006. * form T.
  5007. *
  5008. * LDB (input) INTEGER
  5009. * The leading dimension of B. LDB >= max(1,N).
  5010. *
  5011. * SDIM (output) INTEGER
  5012. * If SORT = 'N', SDIM = 0.
  5013. * If SORT = 'S', SDIM = number of eigenvalues (after sorting)
  5014. * for which SELCTG is true. (Complex conjugate pairs for which
  5015. * SELCTG is true for either eigenvalue count as 2.)
  5016. *
  5017. * ALPHAR (output) DOUBLE PRECISION array, dimension (N)
  5018. * ALPHAI (output) DOUBLE PRECISION array, dimension (N)
  5019. * BETA (output) DOUBLE PRECISION array, dimension (N)
  5020. * On exit, (ALPHAR(j) + ALPHAI(j)*i)/BETA(j), j=1,...,N, will
  5021. * be the generalized eigenvalues. ALPHAR(j) + ALPHAI(j)*i
  5022. * and BETA(j),j=1,...,N are the diagonals of the complex Schur
  5023. * form (S,T) that would result if the 2-by-2 diagonal blocks of
  5024. * the real Schur form of (A,B) were further reduced to
  5025. * triangular form using 2-by-2 complex unitary transformations.
  5026. * If ALPHAI(j) is zero, then the j-th eigenvalue is real; if
  5027. * positive, then the j-th and (j+1)-st eigenvalues are a
  5028. * complex conjugate pair, with ALPHAI(j+1) negative.
  5029. *
  5030. * Note: the quotients ALPHAR(j)/BETA(j) and ALPHAI(j)/BETA(j)
  5031. * may easily over- or underflow, and BETA(j) may even be zero.
  5032. * Thus, the user should avoid naively computing the ratio.
  5033. * However, ALPHAR and ALPHAI will be always less than and
  5034. * usually comparable with norm(A) in magnitude, and BETA always
  5035. * less than and usually comparable with norm(B).
  5036. *
  5037. * VSL (output) DOUBLE PRECISION array, dimension (LDVSL,N)
  5038. * If JOBVSL = 'V', VSL will contain the left Schur vectors.
  5039. * Not referenced if JOBVSL = 'N'.
  5040. *
  5041. * LDVSL (input) INTEGER
  5042. * The leading dimension of the matrix VSL. LDVSL >=1, and
  5043. * if JOBVSL = 'V', LDVSL >= N.
  5044. *
  5045. * VSR (output) DOUBLE PRECISION array, dimension (LDVSR,N)
  5046. * If JOBVSR = 'V', VSR will contain the right Schur vectors.
  5047. * Not referenced if JOBVSR = 'N'.
  5048. *
  5049. * LDVSR (input) INTEGER
  5050. * The leading dimension of the matrix VSR. LDVSR >= 1, and
  5051. * if JOBVSR = 'V', LDVSR >= N.
  5052. *
  5053. * RCONDE (output) DOUBLE PRECISION array, dimension ( 2 )
  5054. * If SENSE = 'E' or 'B', RCONDE(1) and RCONDE(2) contain the
  5055. * reciprocal condition numbers for the average of the selected
  5056. * eigenvalues.
  5057. * Not referenced if SENSE = 'N' or 'V'.
  5058. *
  5059. * RCONDV (output) DOUBLE PRECISION array, dimension ( 2 )
  5060. * If SENSE = 'V' or 'B', RCONDV(1) and RCONDV(2) contain the
  5061. * reciprocal condition numbers for the selected deflating
  5062. * subspaces.
  5063. * Not referenced if SENSE = 'N' or 'E'.
  5064. *
  5065. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  5066. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  5067. *
  5068. * LWORK (input) INTEGER
  5069. * The dimension of the array WORK.
  5070. * If N = 0, LWORK >= 1, else if SENSE = 'E', 'V', or 'B',
  5071. * LWORK >= max( 8*N, 6*N+16, 2*SDIM*(N-SDIM) ), else
  5072. * LWORK >= max( 8*N, 6*N+16 ).
  5073. * Note that 2*SDIM*(N-SDIM) <= N*N/2.
  5074. * Note also that an error is only returned if
  5075. * LWORK < max( 8*N, 6*N+16), but if SENSE = 'E' or 'V' or 'B'
  5076. * this may not be large enough.
  5077. *
  5078. * If LWORK = -1, then a workspace query is assumed; the routine
  5079. * only calculates the bound on the optimal size of the WORK
  5080. * array and the minimum size of the IWORK array, returns these
  5081. * values as the first entries of the WORK and IWORK arrays, and
  5082. * no error message related to LWORK or LIWORK is issued by
  5083. * XERBLA.
  5084. *
  5085. * IWORK (workspace) INTEGER array, dimension (MAX(1,LIWORK))
  5086. * On exit, if INFO = 0, IWORK(1) returns the minimum LIWORK.
  5087. *
  5088. * LIWORK (input) INTEGER
  5089. * The dimension of the array IWORK.
  5090. * If SENSE = 'N' or N = 0, LIWORK >= 1, otherwise
  5091. * LIWORK >= N+6.
  5092. *
  5093. * If LIWORK = -1, then a workspace query is assumed; the
  5094. * routine only calculates the bound on the optimal size of the
  5095. * WORK array and the minimum size of the IWORK array, returns
  5096. * these values as the first entries of the WORK and IWORK
  5097. * arrays, and no error message related to LWORK or LIWORK is
  5098. * issued by XERBLA.
  5099. *
  5100. * BWORK (workspace) LOGICAL array, dimension (N)
  5101. * Not referenced if SORT = 'N'.
  5102. *
  5103. * C++ Return value: INFO (output) INTEGER
  5104. * = 0: successful exit
  5105. * < 0: if INFO = -i, the i-th argument had an illegal value.
  5106. * = 1,...,N:
  5107. * The QZ iteration failed. (A,B) are not in Schur
  5108. * form, but ALPHAR(j), ALPHAI(j), and BETA(j) should
  5109. * be correct for j=INFO+1,...,N.
  5110. * > N: =N+1: other than QZ iteration failed in DHGEQZ
  5111. * =N+2: after reordering, roundoff changed values of
  5112. * some complex eigenvalues so that leading
  5113. * eigenvalues in the Generalized Schur form no
  5114. * longer satisfy SELCTG=.TRUE. This could also
  5115. * be caused due to scaling.
  5116. * =N+3: reordering failed in DTGSEN.
  5117. *
  5118. * Further Details
  5119. * ===============
  5120. *
  5121. * An approximate (asymptotic) bound on the average absolute error of
  5122. * the selected eigenvalues is
  5123. *
  5124. * EPS * norm((A, B)) / RCONDE( 1 ).
  5125. *
  5126. * An approximate (asymptotic) bound on the maximum angular error in
  5127. * the computed deflating subspaces is
  5128. *
  5129. * EPS * norm((A, B)) / RCONDV( 2 ).
  5130. *
  5131. * See LAPACK User's Guide, section 4.11 for more information.
  5132. *
  5133. * =====================================================================
  5134. *
  5135. * .. Parameters ..
  5136. **/
  5137. int C_DGGESX(char jobvsl, char jobvsr, char sort, char sense, int n, double* a, int lda, double* b, int ldb, int* sdim, double* alphar, double* alphai, double* beta, double* vsl, int ldvsl, double* vsr, int ldvsr, double* rconde, double* rcondv, double* work, int lwork, int* iwork, int liwork)
  5138. {
  5139. int info;
  5140. ::F_DGGESX(&jobvsl, &jobvsr, &sort, &sense, &n, a, &lda, b, &ldb, sdim, alphar, alphai, beta, vsl, &ldvsl, vsr, &ldvsr, rconde, rcondv, work, &lwork, iwork, &liwork, &info);
  5141. return info;
  5142. }
  5143. /**
  5144. * Purpose
  5145. * =======
  5146. *
  5147. * DGGEV computes for a pair of N-by-N real nonsymmetric matrices (A,B)
  5148. * the generalized eigenvalues, and optionally, the left and/or right
  5149. * generalized eigenvectors.
  5150. *
  5151. * A generalized eigenvalue for a pair of matrices (A,B) is a scalar
  5152. * lambda or a ratio alpha/beta = lambda, such that A - lambda*B is
  5153. * singular. It is usually represented as the pair (alpha,beta), as
  5154. * there is a reasonable interpretation for beta=0, and even for both
  5155. * being zero.
  5156. *
  5157. * The right eigenvector v(j) corresponding to the eigenvalue lambda(j)
  5158. * of (A,B) satisfies
  5159. *
  5160. * A * v(j) = lambda(j) * B * v(j).
  5161. *
  5162. * The left eigenvector u(j) corresponding to the eigenvalue lambda(j)
  5163. * of (A,B) satisfies
  5164. *
  5165. * u(j)**H * A = lambda(j) * u(j)**H * B .
  5166. *
  5167. * where u(j)**H is the conjugate-transpose of u(j).
  5168. *
  5169. *
  5170. * Arguments
  5171. * =========
  5172. *
  5173. * JOBVL (input) CHARACTER*1
  5174. * = 'N': do not compute the left generalized eigenvectors;
  5175. * = 'V': compute the left generalized eigenvectors.
  5176. *
  5177. * JOBVR (input) CHARACTER*1
  5178. * = 'N': do not compute the right generalized eigenvectors;
  5179. * = 'V': compute the right generalized eigenvectors.
  5180. *
  5181. * N (input) INTEGER
  5182. * The order of the matrices A, B, VL, and VR. N >= 0.
  5183. *
  5184. * A (input/output) DOUBLE PRECISION array, dimension (LDA, N)
  5185. * On entry, the matrix A in the pair (A,B).
  5186. * On exit, A has been overwritten.
  5187. *
  5188. * LDA (input) INTEGER
  5189. * The leading dimension of A. LDA >= max(1,N).
  5190. *
  5191. * B (input/output) DOUBLE PRECISION array, dimension (LDB, N)
  5192. * On entry, the matrix B in the pair (A,B).
  5193. * On exit, B has been overwritten.
  5194. *
  5195. * LDB (input) INTEGER
  5196. * The leading dimension of B. LDB >= max(1,N).
  5197. *
  5198. * ALPHAR (output) DOUBLE PRECISION array, dimension (N)
  5199. * ALPHAI (output) DOUBLE PRECISION array, dimension (N)
  5200. * BETA (output) DOUBLE PRECISION array, dimension (N)
  5201. * On exit, (ALPHAR(j) + ALPHAI(j)*i)/BETA(j), j=1,...,N, will
  5202. * be the generalized eigenvalues. If ALPHAI(j) is zero, then
  5203. * the j-th eigenvalue is real; if positive, then the j-th and
  5204. * (j+1)-st eigenvalues are a complex conjugate pair, with
  5205. * ALPHAI(j+1) negative.
  5206. *
  5207. * Note: the quotients ALPHAR(j)/BETA(j) and ALPHAI(j)/BETA(j)
  5208. * may easily over- or underflow, and BETA(j) may even be zero.
  5209. * Thus, the user should avoid naively computing the ratio
  5210. * alpha/beta. However, ALPHAR and ALPHAI will be always less
  5211. * than and usually comparable with norm(A) in magnitude, and
  5212. * BETA always less than and usually comparable with norm(B).
  5213. *
  5214. * VL (output) DOUBLE PRECISION array, dimension (LDVL,N)
  5215. * If JOBVL = 'V', the left eigenvectors u(j) are stored one
  5216. * after another in the columns of VL, in the same order as
  5217. * their eigenvalues. If the j-th eigenvalue is real, then
  5218. * u(j) = VL(:,j), the j-th column of VL. If the j-th and
  5219. * (j+1)-th eigenvalues form a complex conjugate pair, then
  5220. * u(j) = VL(:,j)+i*VL(:,j+1) and u(j+1) = VL(:,j)-i*VL(:,j+1).
  5221. * Each eigenvector is scaled so the largest component has
  5222. * abs(real part)+abs(imag. part)=1.
  5223. * Not referenced if JOBVL = 'N'.
  5224. *
  5225. * LDVL (input) INTEGER
  5226. * The leading dimension of the matrix VL. LDVL >= 1, and
  5227. * if JOBVL = 'V', LDVL >= N.
  5228. *
  5229. * VR (output) DOUBLE PRECISION array, dimension (LDVR,N)
  5230. * If JOBVR = 'V', the right eigenvectors v(j) are stored one
  5231. * after another in the columns of VR, in the same order as
  5232. * their eigenvalues. If the j-th eigenvalue is real, then
  5233. * v(j) = VR(:,j), the j-th column of VR. If the j-th and
  5234. * (j+1)-th eigenvalues form a complex conjugate pair, then
  5235. * v(j) = VR(:,j)+i*VR(:,j+1) and v(j+1) = VR(:,j)-i*VR(:,j+1).
  5236. * Each eigenvector is scaled so the largest component has
  5237. * abs(real part)+abs(imag. part)=1.
  5238. * Not referenced if JOBVR = 'N'.
  5239. *
  5240. * LDVR (input) INTEGER
  5241. * The leading dimension of the matrix VR. LDVR >= 1, and
  5242. * if JOBVR = 'V', LDVR >= N.
  5243. *
  5244. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  5245. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  5246. *
  5247. * LWORK (input) INTEGER
  5248. * The dimension of the array WORK. LWORK >= max(1,8*N).
  5249. * For good performance, LWORK must generally be larger.
  5250. *
  5251. * If LWORK = -1, then a workspace query is assumed; the routine
  5252. * only calculates the optimal size of the WORK array, returns
  5253. * this value as the first entry of the WORK array, and no error
  5254. * message related to LWORK is issued by XERBLA.
  5255. *
  5256. * C++ Return value: INFO (output) INTEGER
  5257. * = 0: successful exit
  5258. * < 0: if INFO = -i, the i-th argument had an illegal value.
  5259. * = 1,...,N:
  5260. * The QZ iteration failed. No eigenvectors have been
  5261. * calculated, but ALPHAR(j), ALPHAI(j), and BETA(j)
  5262. * should be correct for j=INFO+1,...,N.
  5263. * > N: =N+1: other than QZ iteration failed in DHGEQZ.
  5264. * =N+2: error return from DTGEVC.
  5265. *
  5266. * =====================================================================
  5267. *
  5268. * .. Parameters ..
  5269. **/
  5270. int C_DGGEV(char jobvl, char jobvr, int n, double* a, int lda, double* b, int ldb, double* alphar, double* alphai, double* beta, double* vl, int ldvl, double* vr, int ldvr, double* work, int lwork)
  5271. {
  5272. int info;
  5273. ::F_DGGEV(&jobvl, &jobvr, &n, a, &lda, b, &ldb, alphar, alphai, beta, vl, &ldvl, vr, &ldvr, work, &lwork, &info);
  5274. return info;
  5275. }
  5276. /**
  5277. * Purpose
  5278. * =======
  5279. *
  5280. * DGGEVX computes for a pair of N-by-N real nonsymmetric matrices (A,B)
  5281. * the generalized eigenvalues, and optionally, the left and/or right
  5282. * generalized eigenvectors.
  5283. *
  5284. * Optionally also, it computes a balancing transformation to improve
  5285. * the conditioning of the eigenvalues and eigenvectors (ILO, IHI,
  5286. * LSCALE, RSCALE, ABNRM, and BBNRM), reciprocal condition numbers for
  5287. * the eigenvalues (RCONDE), and reciprocal condition numbers for the
  5288. * right eigenvectors (RCONDV).
  5289. *
  5290. * A generalized eigenvalue for a pair of matrices (A,B) is a scalar
  5291. * lambda or a ratio alpha/beta = lambda, such that A - lambda*B is
  5292. * singular. It is usually represented as the pair (alpha,beta), as
  5293. * there is a reasonable interpretation for beta=0, and even for both
  5294. * being zero.
  5295. *
  5296. * The right eigenvector v(j) corresponding to the eigenvalue lambda(j)
  5297. * of (A,B) satisfies
  5298. *
  5299. * A * v(j) = lambda(j) * B * v(j) .
  5300. *
  5301. * The left eigenvector u(j) corresponding to the eigenvalue lambda(j)
  5302. * of (A,B) satisfies
  5303. *
  5304. * u(j)**H * A = lambda(j) * u(j)**H * B.
  5305. *
  5306. * where u(j)**H is the conjugate-transpose of u(j).
  5307. *
  5308. *
  5309. * Arguments
  5310. * =========
  5311. *
  5312. * BALANC (input) CHARACTER*1
  5313. * Specifies the balance option to be performed.
  5314. * = 'N': do not diagonally scale or permute;
  5315. * = 'P': permute only;
  5316. * = 'S': scale only;
  5317. * = 'B': both permute and scale.
  5318. * Computed reciprocal condition numbers will be for the
  5319. * matrices after permuting and/or balancing. Permuting does
  5320. * not change condition numbers (in exact arithmetic), but
  5321. * balancing does.
  5322. *
  5323. * JOBVL (input) CHARACTER*1
  5324. * = 'N': do not compute the left generalized eigenvectors;
  5325. * = 'V': compute the left generalized eigenvectors.
  5326. *
  5327. * JOBVR (input) CHARACTER*1
  5328. * = 'N': do not compute the right generalized eigenvectors;
  5329. * = 'V': compute the right generalized eigenvectors.
  5330. *
  5331. * SENSE (input) CHARACTER*1
  5332. * Determines which reciprocal condition numbers are computed.
  5333. * = 'N': none are computed;
  5334. * = 'E': computed for eigenvalues only;
  5335. * = 'V': computed for eigenvectors only;
  5336. * = 'B': computed for eigenvalues and eigenvectors.
  5337. *
  5338. * N (input) INTEGER
  5339. * The order of the matrices A, B, VL, and VR. N >= 0.
  5340. *
  5341. * A (input/output) DOUBLE PRECISION array, dimension (LDA, N)
  5342. * On entry, the matrix A in the pair (A,B).
  5343. * On exit, A has been overwritten. If JOBVL='V' or JOBVR='V'
  5344. * or both, then A contains the first part of the real Schur
  5345. * form of the "balanced" versions of the input A and B.
  5346. *
  5347. * LDA (input) INTEGER
  5348. * The leading dimension of A. LDA >= max(1,N).
  5349. *
  5350. * B (input/output) DOUBLE PRECISION array, dimension (LDB, N)
  5351. * On entry, the matrix B in the pair (A,B).
  5352. * On exit, B has been overwritten. If JOBVL='V' or JOBVR='V'
  5353. * or both, then B contains the second part of the real Schur
  5354. * form of the "balanced" versions of the input A and B.
  5355. *
  5356. * LDB (input) INTEGER
  5357. * The leading dimension of B. LDB >= max(1,N).
  5358. *
  5359. * ALPHAR (output) DOUBLE PRECISION array, dimension (N)
  5360. * ALPHAI (output) DOUBLE PRECISION array, dimension (N)
  5361. * BETA (output) DOUBLE PRECISION array, dimension (N)
  5362. * On exit, (ALPHAR(j) + ALPHAI(j)*i)/BETA(j), j=1,...,N, will
  5363. * be the generalized eigenvalues. If ALPHAI(j) is zero, then
  5364. * the j-th eigenvalue is real; if positive, then the j-th and
  5365. * (j+1)-st eigenvalues are a complex conjugate pair, with
  5366. * ALPHAI(j+1) negative.
  5367. *
  5368. * Note: the quotients ALPHAR(j)/BETA(j) and ALPHAI(j)/BETA(j)
  5369. * may easily over- or underflow, and BETA(j) may even be zero.
  5370. * Thus, the user should avoid naively computing the ratio
  5371. * ALPHA/BETA. However, ALPHAR and ALPHAI will be always less
  5372. * than and usually comparable with norm(A) in magnitude, and
  5373. * BETA always less than and usually comparable with norm(B).
  5374. *
  5375. * VL (output) DOUBLE PRECISION array, dimension (LDVL,N)
  5376. * If JOBVL = 'V', the left eigenvectors u(j) are stored one
  5377. * after another in the columns of VL, in the same order as
  5378. * their eigenvalues. If the j-th eigenvalue is real, then
  5379. * u(j) = VL(:,j), the j-th column of VL. If the j-th and
  5380. * (j+1)-th eigenvalues form a complex conjugate pair, then
  5381. * u(j) = VL(:,j)+i*VL(:,j+1) and u(j+1) = VL(:,j)-i*VL(:,j+1).
  5382. * Each eigenvector will be scaled so the largest component have
  5383. * abs(real part) + abs(imag. part) = 1.
  5384. * Not referenced if JOBVL = 'N'.
  5385. *
  5386. * LDVL (input) INTEGER
  5387. * The leading dimension of the matrix VL. LDVL >= 1, and
  5388. * if JOBVL = 'V', LDVL >= N.
  5389. *
  5390. * VR (output) DOUBLE PRECISION array, dimension (LDVR,N)
  5391. * If JOBVR = 'V', the right eigenvectors v(j) are stored one
  5392. * after another in the columns of VR, in the same order as
  5393. * their eigenvalues. If the j-th eigenvalue is real, then
  5394. * v(j) = VR(:,j), the j-th column of VR. If the j-th and
  5395. * (j+1)-th eigenvalues form a complex conjugate pair, then
  5396. * v(j) = VR(:,j)+i*VR(:,j+1) and v(j+1) = VR(:,j)-i*VR(:,j+1).
  5397. * Each eigenvector will be scaled so the largest component have
  5398. * abs(real part) + abs(imag. part) = 1.
  5399. * Not referenced if JOBVR = 'N'.
  5400. *
  5401. * LDVR (input) INTEGER
  5402. * The leading dimension of the matrix VR. LDVR >= 1, and
  5403. * if JOBVR = 'V', LDVR >= N.
  5404. *
  5405. * ILO (output) INTEGER
  5406. * IHI (output) INTEGER
  5407. * ILO and IHI are integer values such that on exit
  5408. * A(i,j) = 0 and B(i,j) = 0 if i > j and
  5409. * j = 1,...,ILO-1 or i = IHI+1,...,N.
  5410. * If BALANC = 'N' or 'S', ILO = 1 and IHI = N.
  5411. *
  5412. * LSCALE (output) DOUBLE PRECISION array, dimension (N)
  5413. * Details of the permutations and scaling factors applied
  5414. * to the left side of A and B. If PL(j) is the index of the
  5415. * row interchanged with row j, and DL(j) is the scaling
  5416. * factor applied to row j, then
  5417. * LSCALE(j) = PL(j) for j = 1,...,ILO-1
  5418. * = DL(j) for j = ILO,...,IHI
  5419. * = PL(j) for j = IHI+1,...,N.
  5420. * The order in which the interchanges are made is N to IHI+1,
  5421. * then 1 to ILO-1.
  5422. *
  5423. * RSCALE (output) DOUBLE PRECISION array, dimension (N)
  5424. * Details of the permutations and scaling factors applied
  5425. * to the right side of A and B. If PR(j) is the index of the
  5426. * column interchanged with column j, and DR(j) is the scaling
  5427. * factor applied to column j, then
  5428. * RSCALE(j) = PR(j) for j = 1,...,ILO-1
  5429. * = DR(j) for j = ILO,...,IHI
  5430. * = PR(j) for j = IHI+1,...,N
  5431. * The order in which the interchanges are made is N to IHI+1,
  5432. * then 1 to ILO-1.
  5433. *
  5434. * ABNRM (output) DOUBLE PRECISION
  5435. * The one-norm of the balanced matrix A.
  5436. *
  5437. * BBNRM (output) DOUBLE PRECISION
  5438. * The one-norm of the balanced matrix B.
  5439. *
  5440. * RCONDE (output) DOUBLE PRECISION array, dimension (N)
  5441. * If SENSE = 'E' or 'B', the reciprocal condition numbers of
  5442. * the eigenvalues, stored in consecutive elements of the array.
  5443. * For a complex conjugate pair of eigenvalues two consecutive
  5444. * elements of RCONDE are set to the same value. Thus RCONDE(j),
  5445. * RCONDV(j), and the j-th columns of VL and VR all correspond
  5446. * to the j-th eigenpair.
  5447. * If SENSE = 'N or 'V', RCONDE is not referenced.
  5448. *
  5449. * RCONDV (output) DOUBLE PRECISION array, dimension (N)
  5450. * If SENSE = 'V' or 'B', the estimated reciprocal condition
  5451. * numbers of the eigenvectors, stored in consecutive elements
  5452. * of the array. For a complex eigenvector two consecutive
  5453. * elements of RCONDV are set to the same value. If the
  5454. * eigenvalues cannot be reordered to compute RCONDV(j),
  5455. * RCONDV(j) is set to 0; this can only occur when the true
  5456. * value would be very small anyway.
  5457. * If SENSE = 'N' or 'E', RCONDV is not referenced.
  5458. *
  5459. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  5460. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  5461. *
  5462. * LWORK (input) INTEGER
  5463. * The dimension of the array WORK. LWORK >= max(1,2*N).
  5464. * If BALANC = 'S' or 'B', or JOBVL = 'V', or JOBVR = 'V',
  5465. * LWORK >= max(1,6*N).
  5466. * If SENSE = 'E' or 'B', LWORK >= max(1,10*N).
  5467. * If SENSE = 'V' or 'B', LWORK >= 2*N*N+8*N+16.
  5468. *
  5469. * If LWORK = -1, then a workspace query is assumed; the routine
  5470. * only calculates the optimal size of the WORK array, returns
  5471. * this value as the first entry of the WORK array, and no error
  5472. * message related to LWORK is issued by XERBLA.
  5473. *
  5474. * IWORK (workspace) INTEGER array, dimension (N+6)
  5475. * If SENSE = 'E', IWORK is not referenced.
  5476. *
  5477. * BWORK (workspace) LOGICAL array, dimension (N)
  5478. * If SENSE = 'N', BWORK is not referenced.
  5479. *
  5480. * C++ Return value: INFO (output) INTEGER
  5481. * = 0: successful exit
  5482. * < 0: if INFO = -i, the i-th argument had an illegal value.
  5483. * = 1,...,N:
  5484. * The QZ iteration failed. No eigenvectors have been
  5485. * calculated, but ALPHAR(j), ALPHAI(j), and BETA(j)
  5486. * should be correct for j=INFO+1,...,N.
  5487. * > N: =N+1: other than QZ iteration failed in DHGEQZ.
  5488. * =N+2: error return from DTGEVC.
  5489. *
  5490. * Further Details
  5491. * ===============
  5492. *
  5493. * Balancing a matrix pair (A,B) includes, first, permuting rows and
  5494. * columns to isolate eigenvalues, second, applying diagonal similarity
  5495. * transformation to the rows and columns to make the rows and columns
  5496. * as close in norm as possible. The computed reciprocal condition
  5497. * numbers correspond to the balanced matrix. Permuting rows and columns
  5498. * will not change the condition numbers (in exact arithmetic) but
  5499. * diagonal scaling will. For further explanation of balancing, see
  5500. * section 4.11.1.2 of LAPACK Users' Guide.
  5501. *
  5502. * An approximate error bound on the chordal distance between the i-th
  5503. * computed generalized eigenvalue w and the corresponding exact
  5504. * eigenvalue lambda is
  5505. *
  5506. * chord(w, lambda) <= EPS * norm(ABNRM, BBNRM) / RCONDE(I)
  5507. *
  5508. * An approximate error bound for the angle between the i-th computed
  5509. * eigenvector VL(i) or VR(i) is given by
  5510. *
  5511. * EPS * norm(ABNRM, BBNRM) / DIF(i).
  5512. *
  5513. * For further explanation of the reciprocal condition numbers RCONDE
  5514. * and RCONDV, see section 4.11 of LAPACK User's Guide.
  5515. *
  5516. * =====================================================================
  5517. *
  5518. * .. Parameters ..
  5519. **/
  5520. int C_DGGEVX(char balanc, char jobvl, char jobvr, char sense, int n, double* a, int lda, double* b, int ldb, double* alphar, double* alphai, double* beta, double* vl, int ldvl, double* vr, int ldvr, int* ilo, int* ihi, double* lscale, double* rscale, double* abnrm, double* bbnrm, double* rconde, double* rcondv, double* work, int lwork, int* iwork)
  5521. {
  5522. int info;
  5523. ::F_DGGEVX(&balanc, &jobvl, &jobvr, &sense, &n, a, &lda, b, &ldb, alphar, alphai, beta, vl, &ldvl, vr, &ldvr, ilo, ihi, lscale, rscale, abnrm, bbnrm, rconde, rcondv, work, &lwork, iwork, &info);
  5524. return info;
  5525. }
  5526. /**
  5527. * Purpose
  5528. * =======
  5529. *
  5530. * DGGGLM solves a general Gauss-Markov linear model (GLM) problem:
  5531. *
  5532. * minimize || y ||_2 subject to d = A*x + B*y
  5533. * x
  5534. *
  5535. * where A is an N-by-M matrix, B is an N-by-P matrix, and d is a
  5536. * given N-vector. It is assumed that M <= N <= M+P, and
  5537. *
  5538. * rank(A) = M and rank( A B ) = N.
  5539. *
  5540. * Under these assumptions, the constrained equation is always
  5541. * consistent, and there is a unique solution x and a minimal 2-norm
  5542. * solution y, which is obtained using a generalized QR factorization
  5543. * of the matrices (A, B) given by
  5544. *
  5545. * A = Q*(R), B = Q*T*Z.
  5546. * (0)
  5547. *
  5548. * In particular, if matrix B is square nonsingular, then the problem
  5549. * GLM is equivalent to the following weighted linear least squares
  5550. * problem
  5551. *
  5552. * minimize || inv(B)*(d-A*x) ||_2
  5553. * x
  5554. *
  5555. * where inv(B) denotes the inverse of B.
  5556. *
  5557. * Arguments
  5558. * =========
  5559. *
  5560. * N (input) INTEGER
  5561. * The number of rows of the matrices A and B. N >= 0.
  5562. *
  5563. * M (input) INTEGER
  5564. * The number of columns of the matrix A. 0 <= M <= N.
  5565. *
  5566. * P (input) INTEGER
  5567. * The number of columns of the matrix B. P >= N-M.
  5568. *
  5569. * A (input/output) DOUBLE PRECISION array, dimension (LDA,M)
  5570. * On entry, the N-by-M matrix A.
  5571. * On exit, the upper triangular part of the array A contains
  5572. * the M-by-M upper triangular matrix R.
  5573. *
  5574. * LDA (input) INTEGER
  5575. * The leading dimension of the array A. LDA >= max(1,N).
  5576. *
  5577. * B (input/output) DOUBLE PRECISION array, dimension (LDB,P)
  5578. * On entry, the N-by-P matrix B.
  5579. * On exit, if N <= P, the upper triangle of the subarray
  5580. * B(1:N,P-N+1:P) contains the N-by-N upper triangular matrix T;
  5581. * if N > P, the elements on and above the (N-P)th subdiagonal
  5582. * contain the N-by-P upper trapezoidal matrix T.
  5583. *
  5584. * LDB (input) INTEGER
  5585. * The leading dimension of the array B. LDB >= max(1,N).
  5586. *
  5587. * D (input/output) DOUBLE PRECISION array, dimension (N)
  5588. * On entry, D is the left hand side of the GLM equation.
  5589. * On exit, D is destroyed.
  5590. *
  5591. * X (output) DOUBLE PRECISION array, dimension (M)
  5592. * Y (output) DOUBLE PRECISION array, dimension (P)
  5593. * On exit, X and Y are the solutions of the GLM problem.
  5594. *
  5595. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  5596. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  5597. *
  5598. * LWORK (input) INTEGER
  5599. * The dimension of the array WORK. LWORK >= max(1,N+M+P).
  5600. * For optimum performance, LWORK >= M+min(N,P)+max(N,P)*NB,
  5601. * where NB is an upper bound for the optimal blocksizes for
  5602. * DGEQRF, SGERQF, DORMQR and SORMRQ.
  5603. *
  5604. * If LWORK = -1, then a workspace query is assumed; the routine
  5605. * only calculates the optimal size of the WORK array, returns
  5606. * this value as the first entry of the WORK array, and no error
  5607. * message related to LWORK is issued by XERBLA.
  5608. *
  5609. * C++ Return value: INFO (output) INTEGER
  5610. * = 0: successful exit.
  5611. * < 0: if INFO = -i, the i-th argument had an illegal value.
  5612. * = 1: the upper triangular factor R associated with A in the
  5613. * generalized QR factorization of the pair (A, B) is
  5614. * singular, so that rank(A) < M; the least squares
  5615. * solution could not be computed.
  5616. * = 2: the bottom (N-M) by (N-M) part of the upper trapezoidal
  5617. * factor T associated with B in the generalized QR
  5618. * factorization of the pair (A, B) is singular, so that
  5619. * rank( A B ) < N; the least squares solution could not
  5620. * be computed.
  5621. *
  5622. * ===================================================================
  5623. *
  5624. * .. Parameters ..
  5625. **/
  5626. int C_DGGGLM(int n, int m, int p, double* a, int lda, double* b, int ldb, double* d, double* x, double* y, double* work, int lwork)
  5627. {
  5628. int info;
  5629. ::F_DGGGLM(&n, &m, &p, a, &lda, b, &ldb, d, x, y, work, &lwork, &info);
  5630. return info;
  5631. }
  5632. /**
  5633. * Purpose
  5634. * =======
  5635. *
  5636. * DGGHRD reduces a pair of real matrices (A,B) to generalized upper
  5637. * Hessenberg form using orthogonal transformations, where A is a
  5638. * general matrix and B is upper triangular. The form of the
  5639. * generalized eigenvalue problem is
  5640. * A*x = lambda*B*x,
  5641. * and B is typically made upper triangular by computing its QR
  5642. * factorization and moving the orthogonal matrix Q to the left side
  5643. * of the equation.
  5644. *
  5645. * This subroutine simultaneously reduces A to a Hessenberg matrix H:
  5646. * Q**T*A*Z = H
  5647. * and transforms B to another upper triangular matrix T:
  5648. * Q**T*B*Z = T
  5649. * in order to reduce the problem to its standard form
  5650. * H*y = lambda*T*y
  5651. * where y = Z**T*x.
  5652. *
  5653. * The orthogonal matrices Q and Z are determined as products of Givens
  5654. * rotations. They may either be formed explicitly, or they may be
  5655. * postmultiplied into input matrices Q1 and Z1, so that
  5656. *
  5657. * Q1 * A * Z1**T = (Q1*Q) * H * (Z1*Z)**T
  5658. *
  5659. * Q1 * B * Z1**T = (Q1*Q) * T * (Z1*Z)**T
  5660. *
  5661. * If Q1 is the orthogonal matrix from the QR factorization of B in the
  5662. * original equation A*x = lambda*B*x, then DGGHRD reduces the original
  5663. * problem to generalized Hessenberg form.
  5664. *
  5665. * Arguments
  5666. * =========
  5667. *
  5668. * COMPQ (input) CHARACTER*1
  5669. * = 'N': do not compute Q;
  5670. * = 'I': Q is initialized to the unit matrix, and the
  5671. * orthogonal matrix Q is returned;
  5672. * = 'V': Q must contain an orthogonal matrix Q1 on entry,
  5673. * and the product Q1*Q is returned.
  5674. *
  5675. * COMPZ (input) CHARACTER*1
  5676. * = 'N': do not compute Z;
  5677. * = 'I': Z is initialized to the unit matrix, and the
  5678. * orthogonal matrix Z is returned;
  5679. * = 'V': Z must contain an orthogonal matrix Z1 on entry,
  5680. * and the product Z1*Z is returned.
  5681. *
  5682. * N (input) INTEGER
  5683. * The order of the matrices A and B. N >= 0.
  5684. *
  5685. * ILO (input) INTEGER
  5686. * IHI (input) INTEGER
  5687. * ILO and IHI mark the rows and columns of A which are to be
  5688. * reduced. It is assumed that A is already upper triangular
  5689. * in rows and columns 1:ILO-1 and IHI+1:N. ILO and IHI are
  5690. * normally set by a previous call to SGGBAL; otherwise they
  5691. * should be set to 1 and N respectively.
  5692. * 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0.
  5693. *
  5694. * A (input/output) DOUBLE PRECISION array, dimension (LDA, N)
  5695. * On entry, the N-by-N general matrix to be reduced.
  5696. * On exit, the upper triangle and the first subdiagonal of A
  5697. * are overwritten with the upper Hessenberg matrix H, and the
  5698. * rest is set to zero.
  5699. *
  5700. * LDA (input) INTEGER
  5701. * The leading dimension of the array A. LDA >= max(1,N).
  5702. *
  5703. * B (input/output) DOUBLE PRECISION array, dimension (LDB, N)
  5704. * On entry, the N-by-N upper triangular matrix B.
  5705. * On exit, the upper triangular matrix T = Q**T B Z. The
  5706. * elements below the diagonal are set to zero.
  5707. *
  5708. * LDB (input) INTEGER
  5709. * The leading dimension of the array B. LDB >= max(1,N).
  5710. *
  5711. * Q (input/output) DOUBLE PRECISION array, dimension (LDQ, N)
  5712. * On entry, if COMPQ = 'V', the orthogonal matrix Q1,
  5713. * typically from the QR factorization of B.
  5714. * On exit, if COMPQ='I', the orthogonal matrix Q, and if
  5715. * COMPQ = 'V', the product Q1*Q.
  5716. * Not referenced if COMPQ='N'.
  5717. *
  5718. * LDQ (input) INTEGER
  5719. * The leading dimension of the array Q.
  5720. * LDQ >= N if COMPQ='V' or 'I'; LDQ >= 1 otherwise.
  5721. *
  5722. * Z (input/output) DOUBLE PRECISION array, dimension (LDZ, N)
  5723. * On entry, if COMPZ = 'V', the orthogonal matrix Z1.
  5724. * On exit, if COMPZ='I', the orthogonal matrix Z, and if
  5725. * COMPZ = 'V', the product Z1*Z.
  5726. * Not referenced if COMPZ='N'.
  5727. *
  5728. * LDZ (input) INTEGER
  5729. * The leading dimension of the array Z.
  5730. * LDZ >= N if COMPZ='V' or 'I'; LDZ >= 1 otherwise.
  5731. *
  5732. * C++ Return value: INFO (output) INTEGER
  5733. * = 0: successful exit.
  5734. * < 0: if INFO = -i, the i-th argument had an illegal value.
  5735. *
  5736. * Further Details
  5737. * ===============
  5738. *
  5739. * This routine reduces A to Hessenberg and B to triangular form by
  5740. * an unblocked reduction, as described in _Matrix_Computations_,
  5741. * by Golub and Van Loan (Johns Hopkins Press.)
  5742. *
  5743. * =====================================================================
  5744. *
  5745. * .. Parameters ..
  5746. **/
  5747. int C_DGGHRD(char compq, char compz, int n, int ilo, int ihi, double* a, int lda, double* b, int ldb, double* q, int ldq, double* z, int ldz)
  5748. {
  5749. int info;
  5750. ::F_DGGHRD(&compq, &compz, &n, &ilo, &ihi, a, &lda, b, &ldb, q, &ldq, z, &ldz, &info);
  5751. return info;
  5752. }
  5753. /**
  5754. * Purpose
  5755. * =======
  5756. *
  5757. * DGGLSE solves the linear equality-constrained least squares (LSE)
  5758. * problem:
  5759. *
  5760. * minimize || c - A*x ||_2 subject to B*x = d
  5761. *
  5762. * where A is an M-by-N matrix, B is a P-by-N matrix, c is a given
  5763. * M-vector, and d is a given P-vector. It is assumed that
  5764. * P <= N <= M+P, and
  5765. *
  5766. * rank(B) = P and rank( (A) ) = N.
  5767. * ( (B) )
  5768. *
  5769. * These conditions ensure that the LSE problem has a unique solution,
  5770. * which is obtained using a generalized RQ factorization of the
  5771. * matrices (B, A) given by
  5772. *
  5773. * B = (0 R)*Q, A = Z*T*Q.
  5774. *
  5775. * Arguments
  5776. * =========
  5777. *
  5778. * M (input) INTEGER
  5779. * The number of rows of the matrix A. M >= 0.
  5780. *
  5781. * N (input) INTEGER
  5782. * The number of columns of the matrices A and B. N >= 0.
  5783. *
  5784. * P (input) INTEGER
  5785. * The number of rows of the matrix B. 0 <= P <= N <= M+P.
  5786. *
  5787. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  5788. * On entry, the M-by-N matrix A.
  5789. * On exit, the elements on and above the diagonal of the array
  5790. * contain the min(M,N)-by-N upper trapezoidal matrix T.
  5791. *
  5792. * LDA (input) INTEGER
  5793. * The leading dimension of the array A. LDA >= max(1,M).
  5794. *
  5795. * B (input/output) DOUBLE PRECISION array, dimension (LDB,N)
  5796. * On entry, the P-by-N matrix B.
  5797. * On exit, the upper triangle of the subarray B(1:P,N-P+1:N)
  5798. * contains the P-by-P upper triangular matrix R.
  5799. *
  5800. * LDB (input) INTEGER
  5801. * The leading dimension of the array B. LDB >= max(1,P).
  5802. *
  5803. * C (input/output) DOUBLE PRECISION array, dimension (M)
  5804. * On entry, C contains the right hand side vector for the
  5805. * least squares part of the LSE problem.
  5806. * On exit, the residual sum of squares for the solution
  5807. * is given by the sum of squares of elements N-P+1 to M of
  5808. * vector C.
  5809. *
  5810. * D (input/output) DOUBLE PRECISION array, dimension (P)
  5811. * On entry, D contains the right hand side vector for the
  5812. * constrained equation.
  5813. * On exit, D is destroyed.
  5814. *
  5815. * X (output) DOUBLE PRECISION array, dimension (N)
  5816. * On exit, X is the solution of the LSE problem.
  5817. *
  5818. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  5819. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  5820. *
  5821. * LWORK (input) INTEGER
  5822. * The dimension of the array WORK. LWORK >= max(1,M+N+P).
  5823. * For optimum performance LWORK >= P+min(M,N)+max(M,N)*NB,
  5824. * where NB is an upper bound for the optimal blocksizes for
  5825. * DGEQRF, SGERQF, DORMQR and SORMRQ.
  5826. *
  5827. * If LWORK = -1, then a workspace query is assumed; the routine
  5828. * only calculates the optimal size of the WORK array, returns
  5829. * this value as the first entry of the WORK array, and no error
  5830. * message related to LWORK is issued by XERBLA.
  5831. *
  5832. * C++ Return value: INFO (output) INTEGER
  5833. * = 0: successful exit.
  5834. * < 0: if INFO = -i, the i-th argument had an illegal value.
  5835. * = 1: the upper triangular factor R associated with B in the
  5836. * generalized RQ factorization of the pair (B, A) is
  5837. * singular, so that rank(B) < P; the least squares
  5838. * solution could not be computed.
  5839. * = 2: the (N-P) by (N-P) part of the upper trapezoidal factor
  5840. * T associated with A in the generalized RQ factorization
  5841. * of the pair (B, A) is singular, so that
  5842. * rank( (A) ) < N; the least squares solution could not
  5843. * ( (B) )
  5844. * be computed.
  5845. *
  5846. * =====================================================================
  5847. *
  5848. * .. Parameters ..
  5849. **/
  5850. int C_DGGLSE(int m, int n, int p, double* a, int lda, double* b, int ldb, double* c, double* d, double* x, double* work, int lwork)
  5851. {
  5852. int info;
  5853. ::F_DGGLSE(&m, &n, &p, a, &lda, b, &ldb, c, d, x, work, &lwork, &info);
  5854. return info;
  5855. }
  5856. /**
  5857. * Purpose
  5858. * =======
  5859. *
  5860. * DGGQRF computes a generalized QR factorization of an N-by-M matrix A
  5861. * and an N-by-P matrix B:
  5862. *
  5863. * A = Q*R, B = Q*T*Z,
  5864. *
  5865. * where Q is an N-by-N orthogonal matrix, Z is a P-by-P orthogonal
  5866. * matrix, and R and T assume one of the forms:
  5867. *
  5868. * if N >= M, R = ( R11 ) M , or if N < M, R = ( R11 R12 ) N,
  5869. * ( 0 ) N-M N M-N
  5870. * M
  5871. *
  5872. * where R11 is upper triangular, and
  5873. *
  5874. * if N <= P, T = ( 0 T12 ) N, or if N > P, T = ( T11 ) N-P,
  5875. * P-N N ( T21 ) P
  5876. * P
  5877. *
  5878. * where T12 or T21 is upper triangular.
  5879. *
  5880. * In particular, if B is square and nonsingular, the GQR factorization
  5881. * of A and B implicitly gives the QR factorization of inv(B)*A:
  5882. *
  5883. * inv(B)*A = Z'*(inv(T)*R)
  5884. *
  5885. * where inv(B) denotes the inverse of the matrix B, and Z' denotes the
  5886. * transpose of the matrix Z.
  5887. *
  5888. * Arguments
  5889. * =========
  5890. *
  5891. * N (input) INTEGER
  5892. * The number of rows of the matrices A and B. N >= 0.
  5893. *
  5894. * M (input) INTEGER
  5895. * The number of columns of the matrix A. M >= 0.
  5896. *
  5897. * P (input) INTEGER
  5898. * The number of columns of the matrix B. P >= 0.
  5899. *
  5900. * A (input/output) DOUBLE PRECISION array, dimension (LDA,M)
  5901. * On entry, the N-by-M matrix A.
  5902. * On exit, the elements on and above the diagonal of the array
  5903. * contain the min(N,M)-by-M upper trapezoidal matrix R (R is
  5904. * upper triangular if N >= M); the elements below the diagonal,
  5905. * with the array TAUA, represent the orthogonal matrix Q as a
  5906. * product of min(N,M) elementary reflectors (see Further
  5907. * Details).
  5908. *
  5909. * LDA (input) INTEGER
  5910. * The leading dimension of the array A. LDA >= max(1,N).
  5911. *
  5912. * TAUA (output) DOUBLE PRECISION array, dimension (min(N,M))
  5913. * The scalar factors of the elementary reflectors which
  5914. * represent the orthogonal matrix Q (see Further Details).
  5915. *
  5916. * B (input/output) DOUBLE PRECISION array, dimension (LDB,P)
  5917. * On entry, the N-by-P matrix B.
  5918. * On exit, if N <= P, the upper triangle of the subarray
  5919. * B(1:N,P-N+1:P) contains the N-by-N upper triangular matrix T;
  5920. * if N > P, the elements on and above the (N-P)-th subdiagonal
  5921. * contain the N-by-P upper trapezoidal matrix T; the remaining
  5922. * elements, with the array TAUB, represent the orthogonal
  5923. * matrix Z as a product of elementary reflectors (see Further
  5924. * Details).
  5925. *
  5926. * LDB (input) INTEGER
  5927. * The leading dimension of the array B. LDB >= max(1,N).
  5928. *
  5929. * TAUB (output) DOUBLE PRECISION array, dimension (min(N,P))
  5930. * The scalar factors of the elementary reflectors which
  5931. * represent the orthogonal matrix Z (see Further Details).
  5932. *
  5933. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  5934. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  5935. *
  5936. * LWORK (input) INTEGER
  5937. * The dimension of the array WORK. LWORK >= max(1,N,M,P).
  5938. * For optimum performance LWORK >= max(N,M,P)*max(NB1,NB2,NB3),
  5939. * where NB1 is the optimal blocksize for the QR factorization
  5940. * of an N-by-M matrix, NB2 is the optimal blocksize for the
  5941. * RQ factorization of an N-by-P matrix, and NB3 is the optimal
  5942. * blocksize for a call of DORMQR.
  5943. *
  5944. * If LWORK = -1, then a workspace query is assumed; the routine
  5945. * only calculates the optimal size of the WORK array, returns
  5946. * this value as the first entry of the WORK array, and no error
  5947. * message related to LWORK is issued by XERBLA.
  5948. *
  5949. * C++ Return value: INFO (output) INTEGER
  5950. * = 0: successful exit
  5951. * < 0: if INFO = -i, the i-th argument had an illegal value.
  5952. *
  5953. * Further Details
  5954. * ===============
  5955. *
  5956. * The matrix Q is represented as a product of elementary reflectors
  5957. *
  5958. * Q = H(1) H(2) . . . H(k), where k = min(n,m).
  5959. *
  5960. * Each H(i) has the form
  5961. *
  5962. * H(i) = I - taua * v * v'
  5963. *
  5964. * where taua is a real scalar, and v is a real vector with
  5965. * v(1:i-1) = 0 and v(i) = 1; v(i+1:n) is stored on exit in A(i+1:n,i),
  5966. * and taua in TAUA(i).
  5967. * To form Q explicitly, use LAPACK subroutine DORGQR.
  5968. * To use Q to update another matrix, use LAPACK subroutine DORMQR.
  5969. *
  5970. * The matrix Z is represented as a product of elementary reflectors
  5971. *
  5972. * Z = H(1) H(2) . . . H(k), where k = min(n,p).
  5973. *
  5974. * Each H(i) has the form
  5975. *
  5976. * H(i) = I - taub * v * v'
  5977. *
  5978. * where taub is a real scalar, and v is a real vector with
  5979. * v(p-k+i+1:p) = 0 and v(p-k+i) = 1; v(1:p-k+i-1) is stored on exit in
  5980. * B(n-k+i,1:p-k+i-1), and taub in TAUB(i).
  5981. * To form Z explicitly, use LAPACK subroutine DORGRQ.
  5982. * To use Z to update another matrix, use LAPACK subroutine DORMRQ.
  5983. *
  5984. * =====================================================================
  5985. *
  5986. * .. Local Scalars ..
  5987. **/
  5988. int C_DGGQRF(int n, int m, int p, double* a, int lda, double* taua, double* b, int ldb, double* taub, double* work, int lwork)
  5989. {
  5990. int info;
  5991. ::F_DGGQRF(&n, &m, &p, a, &lda, taua, b, &ldb, taub, work, &lwork, &info);
  5992. return info;
  5993. }
  5994. /**
  5995. * Purpose
  5996. * =======
  5997. *
  5998. * DGGRQF computes a generalized RQ factorization of an M-by-N matrix A
  5999. * and a P-by-N matrix B:
  6000. *
  6001. * A = R*Q, B = Z*T*Q,
  6002. *
  6003. * where Q is an N-by-N orthogonal matrix, Z is a P-by-P orthogonal
  6004. * matrix, and R and T assume one of the forms:
  6005. *
  6006. * if M <= N, R = ( 0 R12 ) M, or if M > N, R = ( R11 ) M-N,
  6007. * N-M M ( R21 ) N
  6008. * N
  6009. *
  6010. * where R12 or R21 is upper triangular, and
  6011. *
  6012. * if P >= N, T = ( T11 ) N , or if P < N, T = ( T11 T12 ) P,
  6013. * ( 0 ) P-N P N-P
  6014. * N
  6015. *
  6016. * where T11 is upper triangular.
  6017. *
  6018. * In particular, if B is square and nonsingular, the GRQ factorization
  6019. * of A and B implicitly gives the RQ factorization of A*inv(B):
  6020. *
  6021. * A*inv(B) = (R*inv(T))*Z'
  6022. *
  6023. * where inv(B) denotes the inverse of the matrix B, and Z' denotes the
  6024. * transpose of the matrix Z.
  6025. *
  6026. * Arguments
  6027. * =========
  6028. *
  6029. * M (input) INTEGER
  6030. * The number of rows of the matrix A. M >= 0.
  6031. *
  6032. * P (input) INTEGER
  6033. * The number of rows of the matrix B. P >= 0.
  6034. *
  6035. * N (input) INTEGER
  6036. * The number of columns of the matrices A and B. N >= 0.
  6037. *
  6038. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  6039. * On entry, the M-by-N matrix A.
  6040. * On exit, if M <= N, the upper triangle of the subarray
  6041. * A(1:M,N-M+1:N) contains the M-by-M upper triangular matrix R;
  6042. * if M > N, the elements on and above the (M-N)-th subdiagonal
  6043. * contain the M-by-N upper trapezoidal matrix R; the remaining
  6044. * elements, with the array TAUA, represent the orthogonal
  6045. * matrix Q as a product of elementary reflectors (see Further
  6046. * Details).
  6047. *
  6048. * LDA (input) INTEGER
  6049. * The leading dimension of the array A. LDA >= max(1,M).
  6050. *
  6051. * TAUA (output) DOUBLE PRECISION array, dimension (min(M,N))
  6052. * The scalar factors of the elementary reflectors which
  6053. * represent the orthogonal matrix Q (see Further Details).
  6054. *
  6055. * B (input/output) DOUBLE PRECISION array, dimension (LDB,N)
  6056. * On entry, the P-by-N matrix B.
  6057. * On exit, the elements on and above the diagonal of the array
  6058. * contain the min(P,N)-by-N upper trapezoidal matrix T (T is
  6059. * upper triangular if P >= N); the elements below the diagonal,
  6060. * with the array TAUB, represent the orthogonal matrix Z as a
  6061. * product of elementary reflectors (see Further Details).
  6062. *
  6063. * LDB (input) INTEGER
  6064. * The leading dimension of the array B. LDB >= max(1,P).
  6065. *
  6066. * TAUB (output) DOUBLE PRECISION array, dimension (min(P,N))
  6067. * The scalar factors of the elementary reflectors which
  6068. * represent the orthogonal matrix Z (see Further Details).
  6069. *
  6070. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  6071. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  6072. *
  6073. * LWORK (input) INTEGER
  6074. * The dimension of the array WORK. LWORK >= max(1,N,M,P).
  6075. * For optimum performance LWORK >= max(N,M,P)*max(NB1,NB2,NB3),
  6076. * where NB1 is the optimal blocksize for the RQ factorization
  6077. * of an M-by-N matrix, NB2 is the optimal blocksize for the
  6078. * QR factorization of a P-by-N matrix, and NB3 is the optimal
  6079. * blocksize for a call of DORMRQ.
  6080. *
  6081. * If LWORK = -1, then a workspace query is assumed; the routine
  6082. * only calculates the optimal size of the WORK array, returns
  6083. * this value as the first entry of the WORK array, and no error
  6084. * message related to LWORK is issued by XERBLA.
  6085. *
  6086. * C++ Return value: INFO (output) INTEGER
  6087. * = 0: successful exit
  6088. * < 0: if INF0= -i, the i-th argument had an illegal value.
  6089. *
  6090. * Further Details
  6091. * ===============
  6092. *
  6093. * The matrix Q is represented as a product of elementary reflectors
  6094. *
  6095. * Q = H(1) H(2) . . . H(k), where k = min(m,n).
  6096. *
  6097. * Each H(i) has the form
  6098. *
  6099. * H(i) = I - taua * v * v'
  6100. *
  6101. * where taua is a real scalar, and v is a real vector with
  6102. * v(n-k+i+1:n) = 0 and v(n-k+i) = 1; v(1:n-k+i-1) is stored on exit in
  6103. * A(m-k+i,1:n-k+i-1), and taua in TAUA(i).
  6104. * To form Q explicitly, use LAPACK subroutine DORGRQ.
  6105. * To use Q to update another matrix, use LAPACK subroutine DORMRQ.
  6106. *
  6107. * The matrix Z is represented as a product of elementary reflectors
  6108. *
  6109. * Z = H(1) H(2) . . . H(k), where k = min(p,n).
  6110. *
  6111. * Each H(i) has the form
  6112. *
  6113. * H(i) = I - taub * v * v'
  6114. *
  6115. * where taub is a real scalar, and v is a real vector with
  6116. * v(1:i-1) = 0 and v(i) = 1; v(i+1:p) is stored on exit in B(i+1:p,i),
  6117. * and taub in TAUB(i).
  6118. * To form Z explicitly, use LAPACK subroutine DORGQR.
  6119. * To use Z to update another matrix, use LAPACK subroutine DORMQR.
  6120. *
  6121. * =====================================================================
  6122. *
  6123. * .. Local Scalars ..
  6124. **/
  6125. int C_DGGRQF(int m, int p, int n, double* a, int lda, double* taua, double* b, int ldb, double* taub, double* work, int lwork)
  6126. {
  6127. int info;
  6128. ::F_DGGRQF(&m, &p, &n, a, &lda, taua, b, &ldb, taub, work, &lwork, &info);
  6129. return info;
  6130. }
  6131. /**
  6132. * Purpose
  6133. * =======
  6134. *
  6135. * DGGSVD computes the generalized singular value decomposition (GSVD)
  6136. * of an M-by-N real matrix A and P-by-N real matrix B:
  6137. *
  6138. * U'*A*Q = D1*( 0 R ), V'*B*Q = D2*( 0 R )
  6139. *
  6140. * where U, V and Q are orthogonal matrices, and Z' is the transpose
  6141. * of Z. Let K+L = the effective numerical rank of the matrix (A',B')',
  6142. * then R is a K+L-by-K+L nonsingular upper triangular matrix, D1 and
  6143. * D2 are M-by-(K+L) and P-by-(K+L) "diagonal" matrices and of the
  6144. * following structures, respectively:
  6145. *
  6146. * If M-K-L >= 0,
  6147. *
  6148. * K L
  6149. * D1 = K ( I 0 )
  6150. * L ( 0 C )
  6151. * M-K-L ( 0 0 )
  6152. *
  6153. * K L
  6154. * D2 = L ( 0 S )
  6155. * P-L ( 0 0 )
  6156. *
  6157. * N-K-L K L
  6158. * ( 0 R ) = K ( 0 R11 R12 )
  6159. * L ( 0 0 R22 )
  6160. *
  6161. * where
  6162. *
  6163. * C = diag( ALPHA(K+1), ... , ALPHA(K+L) ),
  6164. * S = diag( BETA(K+1), ... , BETA(K+L) ),
  6165. * C**2 + S**2 = I.
  6166. *
  6167. * R is stored in A(1:K+L,N-K-L+1:N) on exit.
  6168. *
  6169. * If M-K-L < 0,
  6170. *
  6171. * K M-K K+L-M
  6172. * D1 = K ( I 0 0 )
  6173. * M-K ( 0 C 0 )
  6174. *
  6175. * K M-K K+L-M
  6176. * D2 = M-K ( 0 S 0 )
  6177. * K+L-M ( 0 0 I )
  6178. * P-L ( 0 0 0 )
  6179. *
  6180. * N-K-L K M-K K+L-M
  6181. * ( 0 R ) = K ( 0 R11 R12 R13 )
  6182. * M-K ( 0 0 R22 R23 )
  6183. * K+L-M ( 0 0 0 R33 )
  6184. *
  6185. * where
  6186. *
  6187. * C = diag( ALPHA(K+1), ... , ALPHA(M) ),
  6188. * S = diag( BETA(K+1), ... , BETA(M) ),
  6189. * C**2 + S**2 = I.
  6190. *
  6191. * (R11 R12 R13 ) is stored in A(1:M, N-K-L+1:N), and R33 is stored
  6192. * ( 0 R22 R23 )
  6193. * in B(M-K+1:L,N+M-K-L+1:N) on exit.
  6194. *
  6195. * The routine computes C, S, R, and optionally the orthogonal
  6196. * transformation matrices U, V and Q.
  6197. *
  6198. * In particular, if B is an N-by-N nonsingular matrix, then the GSVD of
  6199. * A and B implicitly gives the SVD of A*inv(B):
  6200. * A*inv(B) = U*(D1*inv(D2))*V'.
  6201. * If ( A',B')' has orthonormal columns, then the GSVD of A and B is
  6202. * also equal to the CS decomposition of A and B. Furthermore, the GSVD
  6203. * can be used to derive the solution of the eigenvalue problem:
  6204. * A'*A x = lambda* B'*B x.
  6205. * In some literature, the GSVD of A and B is presented in the form
  6206. * U'*A*X = ( 0 D1 ), V'*B*X = ( 0 D2 )
  6207. * where U and V are orthogonal and X is nonsingular, D1 and D2 are
  6208. * ``diagonal''. The former GSVD form can be converted to the latter
  6209. * form by taking the nonsingular matrix X as
  6210. *
  6211. * X = Q*( I 0 )
  6212. * ( 0 inv(R) ).
  6213. *
  6214. * Arguments
  6215. * =========
  6216. *
  6217. * JOBU (input) CHARACTER*1
  6218. * = 'U': Orthogonal matrix U is computed;
  6219. * = 'N': U is not computed.
  6220. *
  6221. * JOBV (input) CHARACTER*1
  6222. * = 'V': Orthogonal matrix V is computed;
  6223. * = 'N': V is not computed.
  6224. *
  6225. * JOBQ (input) CHARACTER*1
  6226. * = 'Q': Orthogonal matrix Q is computed;
  6227. * = 'N': Q is not computed.
  6228. *
  6229. * M (input) INTEGER
  6230. * The number of rows of the matrix A. M >= 0.
  6231. *
  6232. * N (input) INTEGER
  6233. * The number of columns of the matrices A and B. N >= 0.
  6234. *
  6235. * P (input) INTEGER
  6236. * The number of rows of the matrix B. P >= 0.
  6237. *
  6238. * K (output) INTEGER
  6239. * L (output) INTEGER
  6240. * On exit, K and L specify the dimension of the subblocks
  6241. * described in the Purpose section.
  6242. * K + L = effective numerical rank of (A',B')'.
  6243. *
  6244. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  6245. * On entry, the M-by-N matrix A.
  6246. * On exit, A contains the triangular matrix R, or part of R.
  6247. * See Purpose for details.
  6248. *
  6249. * LDA (input) INTEGER
  6250. * The leading dimension of the array A. LDA >= max(1,M).
  6251. *
  6252. * B (input/output) DOUBLE PRECISION array, dimension (LDB,N)
  6253. * On entry, the P-by-N matrix B.
  6254. * On exit, B contains the triangular matrix R if M-K-L < 0.
  6255. * See Purpose for details.
  6256. *
  6257. * LDB (input) INTEGER
  6258. * The leading dimension of the array B. LDB >= max(1,P).
  6259. *
  6260. * ALPHA (output) DOUBLE PRECISION array, dimension (N)
  6261. * BETA (output) DOUBLE PRECISION array, dimension (N)
  6262. * On exit, ALPHA and BETA contain the generalized singular
  6263. * value pairs of A and B;
  6264. * ALPHA(1:K) = 1,
  6265. * BETA(1:K) = 0,
  6266. * and if M-K-L >= 0,
  6267. * ALPHA(K+1:K+L) = C,
  6268. * BETA(K+1:K+L) = S,
  6269. * or if M-K-L < 0,
  6270. * ALPHA(K+1:M)=C, ALPHA(M+1:K+L)=0
  6271. * BETA(K+1:M) =S, BETA(M+1:K+L) =1
  6272. * and
  6273. * ALPHA(K+L+1:N) = 0
  6274. * BETA(K+L+1:N) = 0
  6275. *
  6276. * U (output) DOUBLE PRECISION array, dimension (LDU,M)
  6277. * If JOBU = 'U', U contains the M-by-M orthogonal matrix U.
  6278. * If JOBU = 'N', U is not referenced.
  6279. *
  6280. * LDU (input) INTEGER
  6281. * The leading dimension of the array U. LDU >= max(1,M) if
  6282. * JOBU = 'U'; LDU >= 1 otherwise.
  6283. *
  6284. * V (output) DOUBLE PRECISION array, dimension (LDV,P)
  6285. * If JOBV = 'V', V contains the P-by-P orthogonal matrix V.
  6286. * If JOBV = 'N', V is not referenced.
  6287. *
  6288. * LDV (input) INTEGER
  6289. * The leading dimension of the array V. LDV >= max(1,P) if
  6290. * JOBV = 'V'; LDV >= 1 otherwise.
  6291. *
  6292. * Q (output) DOUBLE PRECISION array, dimension (LDQ,N)
  6293. * If JOBQ = 'Q', Q contains the N-by-N orthogonal matrix Q.
  6294. * If JOBQ = 'N', Q is not referenced.
  6295. *
  6296. * LDQ (input) INTEGER
  6297. * The leading dimension of the array Q. LDQ >= max(1,N) if
  6298. * JOBQ = 'Q'; LDQ >= 1 otherwise.
  6299. *
  6300. * WORK (workspace) DOUBLE PRECISION array,
  6301. * dimension (max(3*N,M,P)+N)
  6302. *
  6303. * IWORK (workspace/output) INTEGER array, dimension (N)
  6304. * On exit, IWORK stores the sorting information. More
  6305. * precisely, the following loop will sort ALPHA
  6306. * for I = K+1, min(M,K+L)
  6307. * swap ALPHA(I) and ALPHA(IWORK(I))
  6308. * endfor
  6309. * such that ALPHA(1) >= ALPHA(2) >= ... >= ALPHA(N).
  6310. *
  6311. * C++ Return value: INFO (output) INTEGER
  6312. * = 0: successful exit
  6313. * < 0: if INFO = -i, the i-th argument had an illegal value.
  6314. * > 0: if INFO = 1, the Jacobi-type procedure failed to
  6315. * converge. For further details, see subroutine DTGSJA.
  6316. *
  6317. * Internal Parameters
  6318. * ===================
  6319. *
  6320. * TOLA DOUBLE PRECISION
  6321. * TOLB DOUBLE PRECISION
  6322. * TOLA and TOLB are the thresholds to determine the effective
  6323. * rank of (A',B')'. Generally, they are set to
  6324. * TOLA = MAX(M,N)*norm(A)*MAZHEPS,
  6325. * TOLB = MAX(P,N)*norm(B)*MAZHEPS.
  6326. * The size of TOLA and TOLB may affect the size of backward
  6327. * errors of the decomposition.
  6328. *
  6329. * Further Details
  6330. * ===============
  6331. *
  6332. * 2-96 Based on modifications by
  6333. * Ming Gu and Huan Ren, Computer Science Division, University of
  6334. * California at Berkeley, USA
  6335. *
  6336. * =====================================================================
  6337. *
  6338. * .. Local Scalars ..
  6339. **/
  6340. int C_DGGSVD(char jobu, char jobv, char jobq, int m, int n, int p, int* k, int* l, double* a, int lda, double* b, int ldb, double* alpha, double* beta, double* u, int ldu, double* v, int ldv, double* q, int ldq, double* work, int* iwork)
  6341. {
  6342. int info;
  6343. ::F_DGGSVD(&jobu, &jobv, &jobq, &m, &n, &p, k, l, a, &lda, b, &ldb, alpha, beta, u, &ldu, v, &ldv, q, &ldq, work, iwork, &info);
  6344. return info;
  6345. }
  6346. /**
  6347. * Purpose
  6348. * =======
  6349. *
  6350. * DGGSVP computes orthogonal matrices U, V and Q such that
  6351. *
  6352. * N-K-L K L
  6353. * U'*A*Q = K ( 0 A12 A13 ) if M-K-L >= 0;
  6354. * L ( 0 0 A23 )
  6355. * M-K-L ( 0 0 0 )
  6356. *
  6357. * N-K-L K L
  6358. * = K ( 0 A12 A13 ) if M-K-L < 0;
  6359. * M-K ( 0 0 A23 )
  6360. *
  6361. * N-K-L K L
  6362. * V'*B*Q = L ( 0 0 B13 )
  6363. * P-L ( 0 0 0 )
  6364. *
  6365. * where the K-by-K matrix A12 and L-by-L matrix B13 are nonsingular
  6366. * upper triangular; A23 is L-by-L upper triangular if M-K-L >= 0,
  6367. * otherwise A23 is (M-K)-by-L upper trapezoidal. K+L = the effective
  6368. * numerical rank of the (M+P)-by-N matrix (A',B')'. Z' denotes the
  6369. * transpose of Z.
  6370. *
  6371. * This decomposition is the preprocessing step for computing the
  6372. * Generalized Singular Value Decomposition (GSVD), see subroutine
  6373. * DGGSVD.
  6374. *
  6375. * Arguments
  6376. * =========
  6377. *
  6378. * JOBU (input) CHARACTER*1
  6379. * = 'U': Orthogonal matrix U is computed;
  6380. * = 'N': U is not computed.
  6381. *
  6382. * JOBV (input) CHARACTER*1
  6383. * = 'V': Orthogonal matrix V is computed;
  6384. * = 'N': V is not computed.
  6385. *
  6386. * JOBQ (input) CHARACTER*1
  6387. * = 'Q': Orthogonal matrix Q is computed;
  6388. * = 'N': Q is not computed.
  6389. *
  6390. * M (input) INTEGER
  6391. * The number of rows of the matrix A. M >= 0.
  6392. *
  6393. * P (input) INTEGER
  6394. * The number of rows of the matrix B. P >= 0.
  6395. *
  6396. * N (input) INTEGER
  6397. * The number of columns of the matrices A and B. N >= 0.
  6398. *
  6399. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  6400. * On entry, the M-by-N matrix A.
  6401. * On exit, A contains the triangular (or trapezoidal) matrix
  6402. * described in the Purpose section.
  6403. *
  6404. * LDA (input) INTEGER
  6405. * The leading dimension of the array A. LDA >= max(1,M).
  6406. *
  6407. * B (input/output) DOUBLE PRECISION array, dimension (LDB,N)
  6408. * On entry, the P-by-N matrix B.
  6409. * On exit, B contains the triangular matrix described in
  6410. * the Purpose section.
  6411. *
  6412. * LDB (input) INTEGER
  6413. * The leading dimension of the array B. LDB >= max(1,P).
  6414. *
  6415. * TOLA (input) DOUBLE PRECISION
  6416. * TOLB (input) DOUBLE PRECISION
  6417. * TOLA and TOLB are the thresholds to determine the effective
  6418. * numerical rank of matrix B and a subblock of A. Generally,
  6419. * they are set to
  6420. * TOLA = MAX(M,N)*norm(A)*MAZHEPS,
  6421. * TOLB = MAX(P,N)*norm(B)*MAZHEPS.
  6422. * The size of TOLA and TOLB may affect the size of backward
  6423. * errors of the decomposition.
  6424. *
  6425. * K (output) INTEGER
  6426. * L (output) INTEGER
  6427. * On exit, K and L specify the dimension of the subblocks
  6428. * described in Purpose.
  6429. * K + L = effective numerical rank of (A',B')'.
  6430. *
  6431. * U (output) DOUBLE PRECISION array, dimension (LDU,M)
  6432. * If JOBU = 'U', U contains the orthogonal matrix U.
  6433. * If JOBU = 'N', U is not referenced.
  6434. *
  6435. * LDU (input) INTEGER
  6436. * The leading dimension of the array U. LDU >= max(1,M) if
  6437. * JOBU = 'U'; LDU >= 1 otherwise.
  6438. *
  6439. * V (output) DOUBLE PRECISION array, dimension (LDV,P)
  6440. * If JOBV = 'V', V contains the orthogonal matrix V.
  6441. * If JOBV = 'N', V is not referenced.
  6442. *
  6443. * LDV (input) INTEGER
  6444. * The leading dimension of the array V. LDV >= max(1,P) if
  6445. * JOBV = 'V'; LDV >= 1 otherwise.
  6446. *
  6447. * Q (output) DOUBLE PRECISION array, dimension (LDQ,N)
  6448. * If JOBQ = 'Q', Q contains the orthogonal matrix Q.
  6449. * If JOBQ = 'N', Q is not referenced.
  6450. *
  6451. * LDQ (input) INTEGER
  6452. * The leading dimension of the array Q. LDQ >= max(1,N) if
  6453. * JOBQ = 'Q'; LDQ >= 1 otherwise.
  6454. *
  6455. * IWORK (workspace) INTEGER array, dimension (N)
  6456. *
  6457. * TAU (workspace) DOUBLE PRECISION array, dimension (N)
  6458. *
  6459. * WORK (workspace) DOUBLE PRECISION array, dimension (max(3*N,M,P))
  6460. *
  6461. * C++ Return value: INFO (output) INTEGER
  6462. * = 0: successful exit
  6463. * < 0: if INFO = -i, the i-th argument had an illegal value.
  6464. *
  6465. *
  6466. * Further Details
  6467. * ===============
  6468. *
  6469. * The subroutine uses LAPACK subroutine DGEQPF for the QR factorization
  6470. * with column pivoting to detect the effective numerical rank of the
  6471. * a matrix. It may be replaced by a better rank determination strategy.
  6472. *
  6473. * =====================================================================
  6474. *
  6475. * .. Parameters ..
  6476. **/
  6477. int C_DGGSVP(char jobu, char jobv, char jobq, int m, int p, int n, double* a, int lda, double* b, int ldb, double tola, double tolb, int* k, int* l, double* u, int ldu, double* v, int ldv, double* q, int ldq, int* iwork, double* tau, double* work)
  6478. {
  6479. int info;
  6480. ::F_DGGSVP(&jobu, &jobv, &jobq, &m, &p, &n, a, &lda, b, &ldb, &tola, &tolb, k, l, u, &ldu, v, &ldv, q, &ldq, iwork, tau, work, &info);
  6481. return info;
  6482. }
  6483. /**
  6484. * Purpose
  6485. * =======
  6486. *
  6487. * DGTCON estimates the reciprocal of the condition number of a real
  6488. * tridiagonal matrix A using the LU factorization as computed by
  6489. * DGTTRF.
  6490. *
  6491. * An estimate is obtained for norm(inv(A)), and the reciprocal of the
  6492. * condition number is computed as RCOND = 1 / (ANORM * norm(inv(A))).
  6493. *
  6494. * Arguments
  6495. * =========
  6496. *
  6497. * NORM (input) CHARACTER*1
  6498. * Specifies whether the 1-norm condition number or the
  6499. * infinity-norm condition number is required:
  6500. * = '1' or 'O': 1-norm;
  6501. * = 'I': Infinity-norm.
  6502. *
  6503. * N (input) INTEGER
  6504. * The order of the matrix A. N >= 0.
  6505. *
  6506. * DL (input) DOUBLE PRECISION array, dimension (N-1)
  6507. * The (n-1) multipliers that define the matrix L from the
  6508. * LU factorization of A as computed by DGTTRF.
  6509. *
  6510. * D (input) DOUBLE PRECISION array, dimension (N)
  6511. * The n diagonal elements of the upper triangular matrix U from
  6512. * the LU factorization of A.
  6513. *
  6514. * DU (input) DOUBLE PRECISION array, dimension (N-1)
  6515. * The (n-1) elements of the first superdiagonal of U.
  6516. *
  6517. * DU2 (input) DOUBLE PRECISION array, dimension (N-2)
  6518. * The (n-2) elements of the second superdiagonal of U.
  6519. *
  6520. * IPIV (input) INTEGER array, dimension (N)
  6521. * The pivot indices; for 1 <= i <= n, row i of the matrix was
  6522. * interchanged with row IPIV(i). IPIV(i) will always be either
  6523. * i or i+1; IPIV(i) = i indicates a row interchange was not
  6524. * required.
  6525. *
  6526. * ANORM (input) DOUBLE PRECISION
  6527. * If NORM = '1' or 'O', the 1-norm of the original matrix A.
  6528. * If NORM = 'I', the infinity-norm of the original matrix A.
  6529. *
  6530. * RCOND (output) DOUBLE PRECISION
  6531. * The reciprocal of the condition number of the matrix A,
  6532. * computed as RCOND = 1/(ANORM * AINVNM), where AINVNM is an
  6533. * estimate of the 1-norm of inv(A) computed in this routine.
  6534. *
  6535. * WORK (workspace) DOUBLE PRECISION array, dimension (2*N)
  6536. *
  6537. * IWORK (workspace) INTEGER array, dimension (N)
  6538. *
  6539. * C++ Return value: INFO (output) INTEGER
  6540. * = 0: successful exit
  6541. * < 0: if INFO = -i, the i-th argument had an illegal value
  6542. *
  6543. * =====================================================================
  6544. *
  6545. * .. Parameters ..
  6546. **/
  6547. int C_DGTCON(char norm, int n, double* dl, double* d, double* du, double* du2, int* ipiv, double anorm, double* rcond, double* work, int* iwork)
  6548. {
  6549. int info;
  6550. ::F_DGTCON(&norm, &n, dl, d, du, du2, ipiv, &anorm, rcond, work, iwork, &info);
  6551. return info;
  6552. }
  6553. /**
  6554. * Purpose
  6555. * =======
  6556. *
  6557. * DGTRFS improves the computed solution to a system of linear
  6558. * equations when the coefficient matrix is tridiagonal, and provides
  6559. * error bounds and backward error estimates for the solution.
  6560. *
  6561. * Arguments
  6562. * =========
  6563. *
  6564. * TRANS (input) CHARACTER*1
  6565. * Specifies the form of the system of equations:
  6566. * = 'N': A * X = B (No transpose)
  6567. * = 'T': A**T * X = B (Transpose)
  6568. * = 'C': A**H * X = B (Conjugate transpose = Transpose)
  6569. *
  6570. * N (input) INTEGER
  6571. * The order of the matrix A. N >= 0.
  6572. *
  6573. * NRHS (input) INTEGER
  6574. * The number of right hand sides, i.e., the number of columns
  6575. * of the matrix B. NRHS >= 0.
  6576. *
  6577. * DL (input) DOUBLE PRECISION array, dimension (N-1)
  6578. * The (n-1) subdiagonal elements of A.
  6579. *
  6580. * D (input) DOUBLE PRECISION array, dimension (N)
  6581. * The diagonal elements of A.
  6582. *
  6583. * DU (input) DOUBLE PRECISION array, dimension (N-1)
  6584. * The (n-1) superdiagonal elements of A.
  6585. *
  6586. * DLF (input) DOUBLE PRECISION array, dimension (N-1)
  6587. * The (n-1) multipliers that define the matrix L from the
  6588. * LU factorization of A as computed by DGTTRF.
  6589. *
  6590. * DF (input) DOUBLE PRECISION array, dimension (N)
  6591. * The n diagonal elements of the upper triangular matrix U from
  6592. * the LU factorization of A.
  6593. *
  6594. * DUF (input) DOUBLE PRECISION array, dimension (N-1)
  6595. * The (n-1) elements of the first superdiagonal of U.
  6596. *
  6597. * DU2 (input) DOUBLE PRECISION array, dimension (N-2)
  6598. * The (n-2) elements of the second superdiagonal of U.
  6599. *
  6600. * IPIV (input) INTEGER array, dimension (N)
  6601. * The pivot indices; for 1 <= i <= n, row i of the matrix was
  6602. * interchanged with row IPIV(i). IPIV(i) will always be either
  6603. * i or i+1; IPIV(i) = i indicates a row interchange was not
  6604. * required.
  6605. *
  6606. * B (input) DOUBLE PRECISION array, dimension (LDB,NRHS)
  6607. * The right hand side matrix B.
  6608. *
  6609. * LDB (input) INTEGER
  6610. * The leading dimension of the array B. LDB >= max(1,N).
  6611. *
  6612. * X (input/output) DOUBLE PRECISION array, dimension (LDX,NRHS)
  6613. * On entry, the solution matrix X, as computed by DGTTRS.
  6614. * On exit, the improved solution matrix X.
  6615. *
  6616. * LDX (input) INTEGER
  6617. * The leading dimension of the array X. LDX >= max(1,N).
  6618. *
  6619. * FERR (output) DOUBLE PRECISION array, dimension (NRHS)
  6620. * The estimated forward error bound for each solution vector
  6621. * X(j) (the j-th column of the solution matrix X).
  6622. * If XTRUE is the true solution corresponding to X(j), FERR(j)
  6623. * is an estimated upper bound for the magnitude of the largest
  6624. * element in (X(j) - XTRUE) divided by the magnitude of the
  6625. * largest element in X(j). The estimate is as reliable as
  6626. * the estimate for RCOND, and is almost always a slight
  6627. * overestimate of the true error.
  6628. *
  6629. * BERR (output) DOUBLE PRECISION array, dimension (NRHS)
  6630. * The componentwise relative backward error of each solution
  6631. * vector X(j) (i.e., the smallest relative change in
  6632. * any element of A or B that makes X(j) an exact solution).
  6633. *
  6634. * WORK (workspace) DOUBLE PRECISION array, dimension (3*N)
  6635. *
  6636. * IWORK (workspace) INTEGER array, dimension (N)
  6637. *
  6638. * C++ Return value: INFO (output) INTEGER
  6639. * = 0: successful exit
  6640. * < 0: if INFO = -i, the i-th argument had an illegal value
  6641. *
  6642. * Internal Parameters
  6643. * ===================
  6644. *
  6645. * ITMAX is the maximum number of steps of iterative refinement.
  6646. *
  6647. * =====================================================================
  6648. *
  6649. * .. Parameters ..
  6650. **/
  6651. int C_DGTRFS(char trans, int n, int nrhs, double* dl, double* d, double* du, double* dlf, double* df, double* duf, double* du2, int* ipiv, double* b, int ldb, double* x, int ldx, double* ferr, double* berr, double* work, int* iwork)
  6652. {
  6653. int info;
  6654. ::F_DGTRFS(&trans, &n, &nrhs, dl, d, du, dlf, df, duf, du2, ipiv, b, &ldb, x, &ldx, ferr, berr, work, iwork, &info);
  6655. return info;
  6656. }
  6657. /**
  6658. * Purpose
  6659. * =======
  6660. *
  6661. * DGTSV solves the equation
  6662. *
  6663. * A*X = B,
  6664. *
  6665. * where A is an n by n tridiagonal matrix, by Gaussian elimination with
  6666. * partial pivoting.
  6667. *
  6668. * Note that the equation A'*X = B may be solved by interchanging the
  6669. * order of the arguments DU and DL.
  6670. *
  6671. * Arguments
  6672. * =========
  6673. *
  6674. * N (input) INTEGER
  6675. * The order of the matrix A. N >= 0.
  6676. *
  6677. * NRHS (input) INTEGER
  6678. * The number of right hand sides, i.e., the number of columns
  6679. * of the matrix B. NRHS >= 0.
  6680. *
  6681. * DL (input/output) DOUBLE PRECISION array, dimension (N-1)
  6682. * On entry, DL must contain the (n-1) sub-diagonal elements of
  6683. * A.
  6684. *
  6685. * On exit, DL is overwritten by the (n-2) elements of the
  6686. * second super-diagonal of the upper triangular matrix U from
  6687. * the LU factorization of A, in DL(1), ..., DL(n-2).
  6688. *
  6689. * D (input/output) DOUBLE PRECISION array, dimension (N)
  6690. * On entry, D must contain the diagonal elements of A.
  6691. *
  6692. * On exit, D is overwritten by the n diagonal elements of U.
  6693. *
  6694. * DU (input/output) DOUBLE PRECISION array, dimension (N-1)
  6695. * On entry, DU must contain the (n-1) super-diagonal elements
  6696. * of A.
  6697. *
  6698. * On exit, DU is overwritten by the (n-1) elements of the first
  6699. * super-diagonal of U.
  6700. *
  6701. * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
  6702. * On entry, the N by NRHS matrix of right hand side matrix B.
  6703. * On exit, if INFO = 0, the N by NRHS solution matrix X.
  6704. *
  6705. * LDB (input) INTEGER
  6706. * The leading dimension of the array B. LDB >= max(1,N).
  6707. *
  6708. * C++ Return value: INFO (output) INTEGER
  6709. * = 0: successful exit
  6710. * < 0: if INFO = -i, the i-th argument had an illegal value
  6711. * > 0: if INFO = i, U(i,i) is exactly zero, and the solution
  6712. * has not been computed. The factorization has not been
  6713. * completed unless i = N.
  6714. *
  6715. * =====================================================================
  6716. *
  6717. * .. Parameters ..
  6718. **/
  6719. int C_DGTSV(int n, int nrhs, double* dl, double* d, double* du, double* b, int ldb)
  6720. {
  6721. int info;
  6722. ::F_DGTSV(&n, &nrhs, dl, d, du, b, &ldb, &info);
  6723. return info;
  6724. }
  6725. /**
  6726. * Purpose
  6727. * =======
  6728. *
  6729. * DGTSVX uses the LU factorization to compute the solution to a real
  6730. * system of linear equations A * X = B or A**T * X = B,
  6731. * where A is a tridiagonal matrix of order N and X and B are N-by-NRHS
  6732. * matrices.
  6733. *
  6734. * Error bounds on the solution and a condition estimate are also
  6735. * provided.
  6736. *
  6737. * Description
  6738. * ===========
  6739. *
  6740. * The following steps are performed:
  6741. *
  6742. * 1. If FACT = 'N', the LU decomposition is used to factor the matrix A
  6743. * as A = L * U, where L is a product of permutation and unit lower
  6744. * bidiagonal matrices and U is upper triangular with nonzeros in
  6745. * only the main diagonal and first two superdiagonals.
  6746. *
  6747. * 2. If some U(i,i)=0, so that U is exactly singular, then the routine
  6748. * returns with INFO = i. Otherwise, the factored form of A is used
  6749. * to estimate the condition number of the matrix A. If the
  6750. * reciprocal of the condition number is less than machine precision,
  6751. * C++ Return value: INFO (output) INTEGER
  6752. * to solve for X and compute error bounds as described below.
  6753. *
  6754. * 3. The system of equations is solved for X using the factored form
  6755. * of A.
  6756. *
  6757. * 4. Iterative refinement is applied to improve the computed solution
  6758. * matrix and calculate error bounds and backward error estimates
  6759. * for it.
  6760. *
  6761. * Arguments
  6762. * =========
  6763. *
  6764. * FACT (input) CHARACTER*1
  6765. * Specifies whether or not the factored form of A has been
  6766. * supplied on entry.
  6767. * = 'F': DLF, DF, DUF, DU2, and IPIV contain the factored
  6768. * form of A; DL, D, DU, DLF, DF, DUF, DU2 and IPIV
  6769. * will not be modified.
  6770. * = 'N': The matrix will be copied to DLF, DF, and DUF
  6771. * and factored.
  6772. *
  6773. * TRANS (input) CHARACTER*1
  6774. * Specifies the form of the system of equations:
  6775. * = 'N': A * X = B (No transpose)
  6776. * = 'T': A**T * X = B (Transpose)
  6777. * = 'C': A**H * X = B (Conjugate transpose = Transpose)
  6778. *
  6779. * N (input) INTEGER
  6780. * The order of the matrix A. N >= 0.
  6781. *
  6782. * NRHS (input) INTEGER
  6783. * The number of right hand sides, i.e., the number of columns
  6784. * of the matrix B. NRHS >= 0.
  6785. *
  6786. * DL (input) DOUBLE PRECISION array, dimension (N-1)
  6787. * The (n-1) subdiagonal elements of A.
  6788. *
  6789. * D (input) DOUBLE PRECISION array, dimension (N)
  6790. * The n diagonal elements of A.
  6791. *
  6792. * DU (input) DOUBLE PRECISION array, dimension (N-1)
  6793. * The (n-1) superdiagonal elements of A.
  6794. *
  6795. * DLF (input or output) DOUBLE PRECISION array, dimension (N-1)
  6796. * If FACT = 'F', then DLF is an input argument and on entry
  6797. * contains the (n-1) multipliers that define the matrix L from
  6798. * the LU factorization of A as computed by DGTTRF.
  6799. *
  6800. * If FACT = 'N', then DLF is an output argument and on exit
  6801. * contains the (n-1) multipliers that define the matrix L from
  6802. * the LU factorization of A.
  6803. *
  6804. * DF (input or output) DOUBLE PRECISION array, dimension (N)
  6805. * If FACT = 'F', then DF is an input argument and on entry
  6806. * contains the n diagonal elements of the upper triangular
  6807. * matrix U from the LU factorization of A.
  6808. *
  6809. * If FACT = 'N', then DF is an output argument and on exit
  6810. * contains the n diagonal elements of the upper triangular
  6811. * matrix U from the LU factorization of A.
  6812. *
  6813. * DUF (input or output) DOUBLE PRECISION array, dimension (N-1)
  6814. * If FACT = 'F', then DUF is an input argument and on entry
  6815. * contains the (n-1) elements of the first superdiagonal of U.
  6816. *
  6817. * If FACT = 'N', then DUF is an output argument and on exit
  6818. * contains the (n-1) elements of the first superdiagonal of U.
  6819. *
  6820. * DU2 (input or output) DOUBLE PRECISION array, dimension (N-2)
  6821. * If FACT = 'F', then DU2 is an input argument and on entry
  6822. * contains the (n-2) elements of the second superdiagonal of
  6823. * U.
  6824. *
  6825. * If FACT = 'N', then DU2 is an output argument and on exit
  6826. * contains the (n-2) elements of the second superdiagonal of
  6827. * U.
  6828. *
  6829. * IPIV (input or output) INTEGER array, dimension (N)
  6830. * If FACT = 'F', then IPIV is an input argument and on entry
  6831. * contains the pivot indices from the LU factorization of A as
  6832. * computed by DGTTRF.
  6833. *
  6834. * If FACT = 'N', then IPIV is an output argument and on exit
  6835. * contains the pivot indices from the LU factorization of A;
  6836. * row i of the matrix was interchanged with row IPIV(i).
  6837. * IPIV(i) will always be either i or i+1; IPIV(i) = i indicates
  6838. * a row interchange was not required.
  6839. *
  6840. * B (input) DOUBLE PRECISION array, dimension (LDB,NRHS)
  6841. * The N-by-NRHS right hand side matrix B.
  6842. *
  6843. * LDB (input) INTEGER
  6844. * The leading dimension of the array B. LDB >= max(1,N).
  6845. *
  6846. * X (output) DOUBLE PRECISION array, dimension (LDX,NRHS)
  6847. * If INFO = 0 or INFO = N+1, the N-by-NRHS solution matrix X.
  6848. *
  6849. * LDX (input) INTEGER
  6850. * The leading dimension of the array X. LDX >= max(1,N).
  6851. *
  6852. * RCOND (output) DOUBLE PRECISION
  6853. * The estimate of the reciprocal condition number of the matrix
  6854. * A. If RCOND is less than the machine precision (in
  6855. * particular, if RCOND = 0), the matrix is singular to working
  6856. * precision. This condition is indicated by a return code of
  6857. * C++ Return value: INFO (output) INTEGER
  6858. *
  6859. * FERR (output) DOUBLE PRECISION array, dimension (NRHS)
  6860. * The estimated forward error bound for each solution vector
  6861. * X(j) (the j-th column of the solution matrix X).
  6862. * If XTRUE is the true solution corresponding to X(j), FERR(j)
  6863. * is an estimated upper bound for the magnitude of the largest
  6864. * element in (X(j) - XTRUE) divided by the magnitude of the
  6865. * largest element in X(j). The estimate is as reliable as
  6866. * the estimate for RCOND, and is almost always a slight
  6867. * overestimate of the true error.
  6868. *
  6869. * BERR (output) DOUBLE PRECISION array, dimension (NRHS)
  6870. * The componentwise relative backward error of each solution
  6871. * vector X(j) (i.e., the smallest relative change in
  6872. * any element of A or B that makes X(j) an exact solution).
  6873. *
  6874. * WORK (workspace) DOUBLE PRECISION array, dimension (3*N)
  6875. *
  6876. * IWORK (workspace) INTEGER array, dimension (N)
  6877. *
  6878. * C++ Return value: INFO (output) INTEGER
  6879. * = 0: successful exit
  6880. * < 0: if INFO = -i, the i-th argument had an illegal value
  6881. * > 0: if INFO = i, and i is
  6882. * <= N: U(i,i) is exactly zero. The factorization
  6883. * has not been completed unless i = N, but the
  6884. * factor U is exactly singular, so the solution
  6885. * and error bounds could not be computed.
  6886. * RCOND = 0 is returned.
  6887. * = N+1: U is nonsingular, but RCOND is less than machine
  6888. * precision, meaning that the matrix is singular
  6889. * to working precision. Nevertheless, the
  6890. * solution and error bounds are computed because
  6891. * there are a number of situations where the
  6892. * computed solution can be more accurate than the
  6893. * value of RCOND would suggest.
  6894. *
  6895. * =====================================================================
  6896. *
  6897. * .. Parameters ..
  6898. **/
  6899. int C_DGTSVX(char fact, char trans, int n, int nrhs, double* dl, double* d, double* du, double* dlf, double* df, double* duf, double* du2, int* ipiv, double* b, int ldb, double* x, int ldx, double* rcond)
  6900. {
  6901. int info;
  6902. ::F_DGTSVX(&fact, &trans, &n, &nrhs, dl, d, du, dlf, df, duf, du2, ipiv, b, &ldb, x, &ldx, rcond, &info);
  6903. return info;
  6904. }
  6905. /**
  6906. * Purpose
  6907. * =======
  6908. *
  6909. * DGTTRF computes an LU factorization of a real tridiagonal matrix A
  6910. * using elimination with partial pivoting and row interchanges.
  6911. *
  6912. * The factorization has the form
  6913. * A = L * U
  6914. * where L is a product of permutation and unit lower bidiagonal
  6915. * matrices and U is upper triangular with nonzeros in only the main
  6916. * diagonal and first two superdiagonals.
  6917. *
  6918. * Arguments
  6919. * =========
  6920. *
  6921. * N (input) INTEGER
  6922. * The order of the matrix A.
  6923. *
  6924. * DL (input/output) DOUBLE PRECISION array, dimension (N-1)
  6925. * On entry, DL must contain the (n-1) sub-diagonal elements of
  6926. * A.
  6927. *
  6928. * On exit, DL is overwritten by the (n-1) multipliers that
  6929. * define the matrix L from the LU factorization of A.
  6930. *
  6931. * D (input/output) DOUBLE PRECISION array, dimension (N)
  6932. * On entry, D must contain the diagonal elements of A.
  6933. *
  6934. * On exit, D is overwritten by the n diagonal elements of the
  6935. * upper triangular matrix U from the LU factorization of A.
  6936. *
  6937. * DU (input/output) DOUBLE PRECISION array, dimension (N-1)
  6938. * On entry, DU must contain the (n-1) super-diagonal elements
  6939. * of A.
  6940. *
  6941. * On exit, DU is overwritten by the (n-1) elements of the first
  6942. * super-diagonal of U.
  6943. *
  6944. * DU2 (output) DOUBLE PRECISION array, dimension (N-2)
  6945. * On exit, DU2 is overwritten by the (n-2) elements of the
  6946. * second super-diagonal of U.
  6947. *
  6948. * IPIV (output) INTEGER array, dimension (N)
  6949. * The pivot indices; for 1 <= i <= n, row i of the matrix was
  6950. * interchanged with row IPIV(i). IPIV(i) will always be either
  6951. * i or i+1; IPIV(i) = i indicates a row interchange was not
  6952. * required.
  6953. *
  6954. * C++ Return value: INFO (output) INTEGER
  6955. * = 0: successful exit
  6956. * < 0: if INFO = -k, the k-th argument had an illegal value
  6957. * > 0: if INFO = k, U(k,k) is exactly zero. The factorization
  6958. * has been completed, but the factor U is exactly
  6959. * singular, and division by zero will occur if it is used
  6960. * to solve a system of equations.
  6961. *
  6962. * =====================================================================
  6963. *
  6964. * .. Parameters ..
  6965. **/
  6966. int C_DGTTRF(int n, double* dl, double* d, double* du, double* du2, int* ipiv)
  6967. {
  6968. int info;
  6969. ::F_DGTTRF(&n, dl, d, du, du2, ipiv, &info);
  6970. return info;
  6971. }
  6972. /**
  6973. * Purpose
  6974. * =======
  6975. *
  6976. * DGTTRS solves one of the systems of equations
  6977. * A*X = B or A'*X = B,
  6978. * with a tridiagonal matrix A using the LU factorization computed
  6979. * by DGTTRF.
  6980. *
  6981. * Arguments
  6982. * =========
  6983. *
  6984. * TRANS (input) CHARACTER*1
  6985. * Specifies the form of the system of equations.
  6986. * = 'N': A * X = B (No transpose)
  6987. * = 'T': A'* X = B (Transpose)
  6988. * = 'C': A'* X = B (Conjugate transpose = Transpose)
  6989. *
  6990. * N (input) INTEGER
  6991. * The order of the matrix A.
  6992. *
  6993. * NRHS (input) INTEGER
  6994. * The number of right hand sides, i.e., the number of columns
  6995. * of the matrix B. NRHS >= 0.
  6996. *
  6997. * DL (input) DOUBLE PRECISION array, dimension (N-1)
  6998. * The (n-1) multipliers that define the matrix L from the
  6999. * LU factorization of A.
  7000. *
  7001. * D (input) DOUBLE PRECISION array, dimension (N)
  7002. * The n diagonal elements of the upper triangular matrix U from
  7003. * the LU factorization of A.
  7004. *
  7005. * DU (input) DOUBLE PRECISION array, dimension (N-1)
  7006. * The (n-1) elements of the first super-diagonal of U.
  7007. *
  7008. * DU2 (input) DOUBLE PRECISION array, dimension (N-2)
  7009. * The (n-2) elements of the second super-diagonal of U.
  7010. *
  7011. * IPIV (input) INTEGER array, dimension (N)
  7012. * The pivot indices; for 1 <= i <= n, row i of the matrix was
  7013. * interchanged with row IPIV(i). IPIV(i) will always be either
  7014. * i or i+1; IPIV(i) = i indicates a row interchange was not
  7015. * required.
  7016. *
  7017. * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
  7018. * On entry, the matrix of right hand side vectors B.
  7019. * On exit, B is overwritten by the solution vectors X.
  7020. *
  7021. * LDB (input) INTEGER
  7022. * The leading dimension of the array B. LDB >= max(1,N).
  7023. *
  7024. * C++ Return value: INFO (output) INTEGER
  7025. * = 0: successful exit
  7026. * < 0: if INFO = -i, the i-th argument had an illegal value
  7027. *
  7028. * =====================================================================
  7029. *
  7030. * .. Local Scalars ..
  7031. **/
  7032. int C_DGTTRS(char trans, int n, int nrhs, double* dl, double* d, double* du, double* du2, int* ipiv, double* b, int ldb)
  7033. {
  7034. int info;
  7035. ::F_DGTTRS(&trans, &n, &nrhs, dl, d, du, du2, ipiv, b, &ldb, &info);
  7036. return info;
  7037. }
  7038. /**
  7039. * Purpose
  7040. * =======
  7041. *
  7042. * DHGEQZ computes the eigenvalues of a real matrix pair (H,T),
  7043. * where H is an upper Hessenberg matrix and T is upper triangular,
  7044. * using the double-shift QZ method.
  7045. * Matrix pairs of this type are produced by the reduction to
  7046. * generalized upper Hessenberg form of a real matrix pair (A,B):
  7047. *
  7048. * A = Q1*H*Z1**T, B = Q1*T*Z1**T,
  7049. *
  7050. * as computed by DGGHRD.
  7051. *
  7052. * If JOB='S', then the Hessenberg-triangular pair (H,T) is
  7053. * also reduced to generalized Schur form,
  7054. *
  7055. * H = Q*S*Z**T, T = Q*P*Z**T,
  7056. *
  7057. * where Q and Z are orthogonal matrices, P is an upper triangular
  7058. * matrix, and S is a quasi-triangular matrix with 1-by-1 and 2-by-2
  7059. * diagonal blocks.
  7060. *
  7061. * The 1-by-1 blocks correspond to real eigenvalues of the matrix pair
  7062. * (H,T) and the 2-by-2 blocks correspond to complex conjugate pairs of
  7063. * eigenvalues.
  7064. *
  7065. * Additionally, the 2-by-2 upper triangular diagonal blocks of P
  7066. * corresponding to 2-by-2 blocks of S are reduced to positive diagonal
  7067. * form, i.e., if S(j+1,j) is non-zero, then P(j+1,j) = P(j,j+1) = 0,
  7068. * P(j,j) > 0, and P(j+1,j+1) > 0.
  7069. *
  7070. * Optionally, the orthogonal matrix Q from the generalized Schur
  7071. * factorization may be postmultiplied into an input matrix Q1, and the
  7072. * orthogonal matrix Z may be postmultiplied into an input matrix Z1.
  7073. * If Q1 and Z1 are the orthogonal matrices from DGGHRD that reduced
  7074. * the matrix pair (A,B) to generalized upper Hessenberg form, then the
  7075. * output matrices Q1*Q and Z1*Z are the orthogonal factors from the
  7076. * generalized Schur factorization of (A,B):
  7077. *
  7078. * A = (Q1*Q)*S*(Z1*Z)**T, B = (Q1*Q)*P*(Z1*Z)**T.
  7079. *
  7080. * To avoid overflow, eigenvalues of the matrix pair (H,T) (equivalently,
  7081. * of (A,B)) are computed as a pair of values (alpha,beta), where alpha is
  7082. * complex and beta real.
  7083. * If beta is nonzero, lambda = alpha / beta is an eigenvalue of the
  7084. * generalized nonsymmetric eigenvalue problem (GNEP)
  7085. * A*x = lambda*B*x
  7086. * and if alpha is nonzero, mu = beta / alpha is an eigenvalue of the
  7087. * alternate form of the GNEP
  7088. * mu*A*y = B*y.
  7089. * Real eigenvalues can be read directly from the generalized Schur
  7090. * form:
  7091. * alpha = S(i,i), beta = P(i,i).
  7092. *
  7093. * Ref: C.B. Moler & G.W. Stewart, "An Algorithm for Generalized Matrix
  7094. * Eigenvalue Problems", SIAM J. Numer. Anal., 10(1973),
  7095. * pp. 241--256.
  7096. *
  7097. * Arguments
  7098. * =========
  7099. *
  7100. * JOB (input) CHARACTER*1
  7101. * = 'E': Compute eigenvalues only;
  7102. * = 'S': Compute eigenvalues and the Schur form.
  7103. *
  7104. * COMPQ (input) CHARACTER*1
  7105. * = 'N': Left Schur vectors (Q) are not computed;
  7106. * = 'I': Q is initialized to the unit matrix and the matrix Q
  7107. * of left Schur vectors of (H,T) is returned;
  7108. * = 'V': Q must contain an orthogonal matrix Q1 on entry and
  7109. * the product Q1*Q is returned.
  7110. *
  7111. * COMPZ (input) CHARACTER*1
  7112. * = 'N': Right Schur vectors (Z) are not computed;
  7113. * = 'I': Z is initialized to the unit matrix and the matrix Z
  7114. * of right Schur vectors of (H,T) is returned;
  7115. * = 'V': Z must contain an orthogonal matrix Z1 on entry and
  7116. * the product Z1*Z is returned.
  7117. *
  7118. * N (input) INTEGER
  7119. * The order of the matrices H, T, Q, and Z. N >= 0.
  7120. *
  7121. * ILO (input) INTEGER
  7122. * IHI (input) INTEGER
  7123. * ILO and IHI mark the rows and columns of H which are in
  7124. * Hessenberg form. It is assumed that A is already upper
  7125. * triangular in rows and columns 1:ILO-1 and IHI+1:N.
  7126. * If N > 0, 1 <= ILO <= IHI <= N; if N = 0, ILO=1 and IHI=0.
  7127. *
  7128. * H (input/output) DOUBLE PRECISION array, dimension (LDH, N)
  7129. * On entry, the N-by-N upper Hessenberg matrix H.
  7130. * On exit, if JOB = 'S', H contains the upper quasi-triangular
  7131. * matrix S from the generalized Schur factorization;
  7132. * 2-by-2 diagonal blocks (corresponding to complex conjugate
  7133. * pairs of eigenvalues) are returned in standard form, with
  7134. * H(i,i) = H(i+1,i+1) and H(i+1,i)*H(i,i+1) < 0.
  7135. * If JOB = 'E', the diagonal blocks of H match those of S, but
  7136. * the rest of H is unspecified.
  7137. *
  7138. * LDH (input) INTEGER
  7139. * The leading dimension of the array H. LDH >= max( 1, N ).
  7140. *
  7141. * T (input/output) DOUBLE PRECISION array, dimension (LDT, N)
  7142. * On entry, the N-by-N upper triangular matrix T.
  7143. * On exit, if JOB = 'S', T contains the upper triangular
  7144. * matrix P from the generalized Schur factorization;
  7145. * 2-by-2 diagonal blocks of P corresponding to 2-by-2 blocks of S
  7146. * are reduced to positive diagonal form, i.e., if H(j+1,j) is
  7147. * non-zero, then T(j+1,j) = T(j,j+1) = 0, T(j,j) > 0, and
  7148. * T(j+1,j+1) > 0.
  7149. * If JOB = 'E', the diagonal blocks of T match those of P, but
  7150. * the rest of T is unspecified.
  7151. *
  7152. * LDT (input) INTEGER
  7153. * The leading dimension of the array T. LDT >= max( 1, N ).
  7154. *
  7155. * ALPHAR (output) DOUBLE PRECISION array, dimension (N)
  7156. * The real parts of each scalar alpha defining an eigenvalue
  7157. * of GNEP.
  7158. *
  7159. * ALPHAI (output) DOUBLE PRECISION array, dimension (N)
  7160. * The imaginary parts of each scalar alpha defining an
  7161. * eigenvalue of GNEP.
  7162. * If ALPHAI(j) is zero, then the j-th eigenvalue is real; if
  7163. * positive, then the j-th and (j+1)-st eigenvalues are a
  7164. * complex conjugate pair, with ALPHAI(j+1) = -ALPHAI(j).
  7165. *
  7166. * BETA (output) DOUBLE PRECISION array, dimension (N)
  7167. * The scalars beta that define the eigenvalues of GNEP.
  7168. * Together, the quantities alpha = (ALPHAR(j),ALPHAI(j)) and
  7169. * beta = BETA(j) represent the j-th eigenvalue of the matrix
  7170. * pair (A,B), in one of the forms lambda = alpha/beta or
  7171. * mu = beta/alpha. Since either lambda or mu may overflow,
  7172. * they should not, in general, be computed.
  7173. *
  7174. * Q (input/output) DOUBLE PRECISION array, dimension (LDQ, N)
  7175. * On entry, if COMPZ = 'V', the orthogonal matrix Q1 used in
  7176. * the reduction of (A,B) to generalized Hessenberg form.
  7177. * On exit, if COMPZ = 'I', the orthogonal matrix of left Schur
  7178. * vectors of (H,T), and if COMPZ = 'V', the orthogonal matrix
  7179. * of left Schur vectors of (A,B).
  7180. * Not referenced if COMPZ = 'N'.
  7181. *
  7182. * LDQ (input) INTEGER
  7183. * The leading dimension of the array Q. LDQ >= 1.
  7184. * If COMPQ='V' or 'I', then LDQ >= N.
  7185. *
  7186. * Z (input/output) DOUBLE PRECISION array, dimension (LDZ, N)
  7187. * On entry, if COMPZ = 'V', the orthogonal matrix Z1 used in
  7188. * the reduction of (A,B) to generalized Hessenberg form.
  7189. * On exit, if COMPZ = 'I', the orthogonal matrix of
  7190. * right Schur vectors of (H,T), and if COMPZ = 'V', the
  7191. * orthogonal matrix of right Schur vectors of (A,B).
  7192. * Not referenced if COMPZ = 'N'.
  7193. *
  7194. * LDZ (input) INTEGER
  7195. * The leading dimension of the array Z. LDZ >= 1.
  7196. * If COMPZ='V' or 'I', then LDZ >= N.
  7197. *
  7198. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  7199. * On exit, if INFO >= 0, WORK(1) returns the optimal LWORK.
  7200. *
  7201. * LWORK (input) INTEGER
  7202. * The dimension of the array WORK. LWORK >= max(1,N).
  7203. *
  7204. * If LWORK = -1, then a workspace query is assumed; the routine
  7205. * only calculates the optimal size of the WORK array, returns
  7206. * this value as the first entry of the WORK array, and no error
  7207. * message related to LWORK is issued by XERBLA.
  7208. *
  7209. * C++ Return value: INFO (output) INTEGER
  7210. * = 0: successful exit
  7211. * < 0: if INFO = -i, the i-th argument had an illegal value
  7212. * = 1,...,N: the QZ iteration did not converge. (H,T) is not
  7213. * in Schur form, but ALPHAR(i), ALPHAI(i), and
  7214. * BETA(i), i=INFO+1,...,N should be correct.
  7215. * = N+1,...,2*N: the shift calculation failed. (H,T) is not
  7216. * in Schur form, but ALPHAR(i), ALPHAI(i), and
  7217. * BETA(i), i=INFO-N+1,...,N should be correct.
  7218. *
  7219. * Further Details
  7220. * ===============
  7221. *
  7222. * Iteration counters:
  7223. *
  7224. * JITER -- counts iterations.
  7225. * IITER -- counts iterations run since ILAST was last
  7226. * changed. This is therefore reset only when a 1-by-1 or
  7227. * 2-by-2 block deflates off the bottom.
  7228. *
  7229. * =====================================================================
  7230. *
  7231. * .. Parameters ..
  7232. * $ SAFETY = 1.0E+0 )
  7233. **/
  7234. int C_DHGEQZ(char job, char compq, char compz, int n, int ilo, int ihi, double* h, int ldh, double* t, int ldt, double* alphar, double* alphai, double* beta, double* q, int ldq, double* z, int ldz, double* work, int lwork)
  7235. {
  7236. int info;
  7237. ::F_DHGEQZ(&job, &compq, &compz, &n, &ilo, &ihi, h, &ldh, t, &ldt, alphar, alphai, beta, q, &ldq, z, &ldz, work, &lwork, &info);
  7238. return info;
  7239. }
  7240. /**
  7241. * Purpose
  7242. * =======
  7243. *
  7244. * DHSEIN uses inverse iteration to find specified right and/or left
  7245. * eigenvectors of a real upper Hessenberg matrix H.
  7246. *
  7247. * The right eigenvector x and the left eigenvector y of the matrix H
  7248. * corresponding to an eigenvalue w are defined by:
  7249. *
  7250. * H * x = w * x, y**h * H = w * y**h
  7251. *
  7252. * where y**h denotes the conjugate transpose of the vector y.
  7253. *
  7254. * Arguments
  7255. * =========
  7256. *
  7257. * SIDE (input) CHARACTER*1
  7258. * = 'R': compute right eigenvectors only;
  7259. * = 'L': compute left eigenvectors only;
  7260. * = 'B': compute both right and left eigenvectors.
  7261. *
  7262. * EIGSRC (input) CHARACTER*1
  7263. * Specifies the source of eigenvalues supplied in (WR,WI):
  7264. * = 'Q': the eigenvalues were found using DHSEQR; thus, if
  7265. * H has zero subdiagonal elements, and so is
  7266. * block-triangular, then the j-th eigenvalue can be
  7267. * assumed to be an eigenvalue of the block containing
  7268. * the j-th row/column. This property allows DHSEIN to
  7269. * perform inverse iteration on just one diagonal block.
  7270. * = 'N': no assumptions are made on the correspondence
  7271. * between eigenvalues and diagonal blocks. In this
  7272. * case, DHSEIN must always perform inverse iteration
  7273. * using the whole matrix H.
  7274. *
  7275. * INITV (input) CHARACTER*1
  7276. * = 'N': no initial vectors are supplied;
  7277. * = 'U': user-supplied initial vectors are stored in the arrays
  7278. * VL and/or VR.
  7279. *
  7280. * SELECT (input/output) LOGICAL array, dimension (N)
  7281. * Specifies the eigenvectors to be computed. To select the
  7282. * real eigenvector corresponding to a real eigenvalue WR(j),
  7283. * SELECT(j) must be set to .TRUE.. To select the complex
  7284. * eigenvector corresponding to a complex eigenvalue
  7285. * (WR(j),WI(j)), with complex conjugate (WR(j+1),WI(j+1)),
  7286. * either SELECT(j) or SELECT(j+1) or both must be set to
  7287. * .TRUE.; then on exit SELECT(j) is .TRUE. and SELECT(j+1) is
  7288. * .FALSE..
  7289. *
  7290. * N (input) INTEGER
  7291. * The order of the matrix H. N >= 0.
  7292. *
  7293. * H (input) DOUBLE PRECISION array, dimension (LDH,N)
  7294. * The upper Hessenberg matrix H.
  7295. *
  7296. * LDH (input) INTEGER
  7297. * The leading dimension of the array H. LDH >= max(1,N).
  7298. *
  7299. * WR (input/output) DOUBLE PRECISION array, dimension (N)
  7300. * WI (input) DOUBLE PRECISION array, dimension (N)
  7301. * On entry, the real and imaginary parts of the eigenvalues of
  7302. * H; a complex conjugate pair of eigenvalues must be stored in
  7303. * consecutive elements of WR and WI.
  7304. * On exit, WR may have been altered since close eigenvalues
  7305. * are perturbed slightly in searching for independent
  7306. * eigenvectors.
  7307. *
  7308. * VL (input/output) DOUBLE PRECISION array, dimension (LDVL,MM)
  7309. * On entry, if INITV = 'U' and SIDE = 'L' or 'B', VL must
  7310. * contain starting vectors for the inverse iteration for the
  7311. * left eigenvectors; the starting vector for each eigenvector
  7312. * must be in the same column(s) in which the eigenvector will
  7313. * be stored.
  7314. * On exit, if SIDE = 'L' or 'B', the left eigenvectors
  7315. * specified by SELECT will be stored consecutively in the
  7316. * columns of VL, in the same order as their eigenvalues. A
  7317. * complex eigenvector corresponding to a complex eigenvalue is
  7318. * stored in two consecutive columns, the first holding the real
  7319. * part and the second the imaginary part.
  7320. * If SIDE = 'R', VL is not referenced.
  7321. *
  7322. * LDVL (input) INTEGER
  7323. * The leading dimension of the array VL.
  7324. * LDVL >= max(1,N) if SIDE = 'L' or 'B'; LDVL >= 1 otherwise.
  7325. *
  7326. * VR (input/output) DOUBLE PRECISION array, dimension (LDVR,MM)
  7327. * On entry, if INITV = 'U' and SIDE = 'R' or 'B', VR must
  7328. * contain starting vectors for the inverse iteration for the
  7329. * right eigenvectors; the starting vector for each eigenvector
  7330. * must be in the same column(s) in which the eigenvector will
  7331. * be stored.
  7332. * On exit, if SIDE = 'R' or 'B', the right eigenvectors
  7333. * specified by SELECT will be stored consecutively in the
  7334. * columns of VR, in the same order as their eigenvalues. A
  7335. * complex eigenvector corresponding to a complex eigenvalue is
  7336. * stored in two consecutive columns, the first holding the real
  7337. * part and the second the imaginary part.
  7338. * If SIDE = 'L', VR is not referenced.
  7339. *
  7340. * LDVR (input) INTEGER
  7341. * The leading dimension of the array VR.
  7342. * LDVR >= max(1,N) if SIDE = 'R' or 'B'; LDVR >= 1 otherwise.
  7343. *
  7344. * MM (input) INTEGER
  7345. * The number of columns in the arrays VL and/or VR. MM >= M.
  7346. *
  7347. * M (output) INTEGER
  7348. * The number of columns in the arrays VL and/or VR required to
  7349. * store the eigenvectors; each selected real eigenvector
  7350. * occupies one column and each selected complex eigenvector
  7351. * occupies two columns.
  7352. *
  7353. * WORK (workspace) DOUBLE PRECISION array, dimension ((N+2)*N)
  7354. *
  7355. * IFAILL (output) INTEGER array, dimension (MM)
  7356. * If SIDE = 'L' or 'B', IFAILL(i) = j > 0 if the left
  7357. * eigenvector in the i-th column of VL (corresponding to the
  7358. * eigenvalue w(j)) failed to converge; IFAILL(i) = 0 if the
  7359. * eigenvector converged satisfactorily. If the i-th and (i+1)th
  7360. * columns of VL hold a complex eigenvector, then IFAILL(i) and
  7361. * IFAILL(i+1) are set to the same value.
  7362. * If SIDE = 'R', IFAILL is not referenced.
  7363. *
  7364. * IFAILR (output) INTEGER array, dimension (MM)
  7365. * If SIDE = 'R' or 'B', IFAILR(i) = j > 0 if the right
  7366. * eigenvector in the i-th column of VR (corresponding to the
  7367. * eigenvalue w(j)) failed to converge; IFAILR(i) = 0 if the
  7368. * eigenvector converged satisfactorily. If the i-th and (i+1)th
  7369. * columns of VR hold a complex eigenvector, then IFAILR(i) and
  7370. * IFAILR(i+1) are set to the same value.
  7371. * If SIDE = 'L', IFAILR is not referenced.
  7372. *
  7373. * C++ Return value: INFO (output) INTEGER
  7374. * = 0: successful exit
  7375. * < 0: if INFO = -i, the i-th argument had an illegal value
  7376. * > 0: if INFO = i, i is the number of eigenvectors which
  7377. * failed to converge; see IFAILL and IFAILR for further
  7378. * details.
  7379. *
  7380. * Further Details
  7381. * ===============
  7382. *
  7383. * Each eigenvector is normalized so that the element of largest
  7384. * magnitude has magnitude 1; here the magnitude of a complex number
  7385. * (x,y) is taken to be |x|+|y|.
  7386. *
  7387. * =====================================================================
  7388. *
  7389. * .. Parameters ..
  7390. **/
  7391. int C_DHSEIN(char side, char eigsrc, char initv, int n, double* h, int ldh, double* wr, double* wi, double* vl, int ldvl, double* vr, int ldvr, int mm, int* m, double* work, int* ifaill, int* ifailr)
  7392. {
  7393. int info;
  7394. ::F_DHSEIN(&side, &eigsrc, &initv, &n, h, &ldh, wr, wi, vl, &ldvl, vr, &ldvr, &mm, m, work, ifaill, ifailr, &info);
  7395. return info;
  7396. }
  7397. /**
  7398. * Purpose
  7399. * =======
  7400. *
  7401. * DHSEQR computes the eigenvalues of a Hessenberg matrix H
  7402. * and, optionally, the matrices T and Z from the Schur decomposition
  7403. * H = Z T Z**T, where T is an upper quasi-triangular matrix (the
  7404. * Schur form), and Z is the orthogonal matrix of Schur vectors.
  7405. *
  7406. * Optionally Z may be postmultiplied into an input orthogonal
  7407. * matrix Q so that this routine can give the Schur factorization
  7408. * of a matrix A which has been reduced to the Hessenberg form H
  7409. * by the orthogonal matrix Q: A = Q*H*Q**T = (QZ)*T*(QZ)**T.
  7410. *
  7411. * Arguments
  7412. * =========
  7413. *
  7414. * JOB (input) CHARACTER*1
  7415. * = 'E': compute eigenvalues only;
  7416. * = 'S': compute eigenvalues and the Schur form T.
  7417. *
  7418. * COMPZ (input) CHARACTER*1
  7419. * = 'N': no Schur vectors are computed;
  7420. * = 'I': Z is initialized to the unit matrix and the matrix Z
  7421. * of Schur vectors of H is returned;
  7422. * = 'V': Z must contain an orthogonal matrix Q on entry, and
  7423. * the product Q*Z is returned.
  7424. *
  7425. * N (input) INTEGER
  7426. * The order of the matrix H. N .GE. 0.
  7427. *
  7428. * ILO (input) INTEGER
  7429. * IHI (input) INTEGER
  7430. * It is assumed that H is already upper triangular in rows
  7431. * and columns 1:ILO-1 and IHI+1:N. ILO and IHI are normally
  7432. * set by a previous call to DGEBAL, and then passed to DGEHRD
  7433. * when the matrix output by DGEBAL is reduced to Hessenberg
  7434. * form. Otherwise ILO and IHI should be set to 1 and N
  7435. * respectively. If N.GT.0, then 1.LE.ILO.LE.IHI.LE.N.
  7436. * If N = 0, then ILO = 1 and IHI = 0.
  7437. *
  7438. * H (input/output) DOUBLE PRECISION array, dimension (LDH,N)
  7439. * On entry, the upper Hessenberg matrix H.
  7440. * On exit, if INFO = 0 and JOB = 'S', then H contains the
  7441. * upper quasi-triangular matrix T from the Schur decomposition
  7442. * (the Schur form); 2-by-2 diagonal blocks (corresponding to
  7443. * complex conjugate pairs of eigenvalues) are returned in
  7444. * standard form, with H(i,i) = H(i+1,i+1) and
  7445. * H(i+1,i)*H(i,i+1).LT.0. If INFO = 0 and JOB = 'E', the
  7446. * contents of H are unspecified on exit. (The output value of
  7447. * H when INFO.GT.0 is given under the description of INFO
  7448. * below.)
  7449. *
  7450. * Unlike earlier versions of DHSEQR, this subroutine may
  7451. * explicitly H(i,j) = 0 for i.GT.j and j = 1, 2, ... ILO-1
  7452. * or j = IHI+1, IHI+2, ... N.
  7453. *
  7454. * LDH (input) INTEGER
  7455. * The leading dimension of the array H. LDH .GE. max(1,N).
  7456. *
  7457. * WR (output) DOUBLE PRECISION array, dimension (N)
  7458. * WI (output) DOUBLE PRECISION array, dimension (N)
  7459. * The real and imaginary parts, respectively, of the computed
  7460. * eigenvalues. If two eigenvalues are computed as a complex
  7461. * conjugate pair, they are stored in consecutive elements of
  7462. * WR and WI, say the i-th and (i+1)th, with WI(i) .GT. 0 and
  7463. * WI(i+1) .LT. 0. If JOB = 'S', the eigenvalues are stored in
  7464. * the same order as on the diagonal of the Schur form returned
  7465. * in H, with WR(i) = H(i,i) and, if H(i:i+1,i:i+1) is a 2-by-2
  7466. * diagonal block, WI(i) = sqrt(-H(i+1,i)*H(i,i+1)) and
  7467. * WI(i+1) = -WI(i).
  7468. *
  7469. * Z (input/output) DOUBLE PRECISION array, dimension (LDZ,N)
  7470. * If COMPZ = 'N', Z is not referenced.
  7471. * If COMPZ = 'I', on entry Z need not be set and on exit,
  7472. * if INFO = 0, Z contains the orthogonal matrix Z of the Schur
  7473. * vectors of H. If COMPZ = 'V', on entry Z must contain an
  7474. * N-by-N matrix Q, which is assumed to be equal to the unit
  7475. * matrix except for the submatrix Z(ILO:IHI,ILO:IHI). On exit,
  7476. * if INFO = 0, Z contains Q*Z.
  7477. * Normally Q is the orthogonal matrix generated by DORGHR
  7478. * after the call to DGEHRD which formed the Hessenberg matrix
  7479. * H. (The output value of Z when INFO.GT.0 is given under
  7480. * the description of INFO below.)
  7481. *
  7482. * LDZ (input) INTEGER
  7483. * The leading dimension of the array Z. if COMPZ = 'I' or
  7484. * COMPZ = 'V', then LDZ.GE.MAX(1,N). Otherwize, LDZ.GE.1.
  7485. *
  7486. * WORK (workspace/output) DOUBLE PRECISION array, dimension (LWORK)
  7487. * On exit, if INFO = 0, WORK(1) returns an estimate of
  7488. * the optimal value for LWORK.
  7489. *
  7490. * LWORK (input) INTEGER
  7491. * The dimension of the array WORK. LWORK .GE. max(1,N)
  7492. * is sufficient and delivers very good and sometimes
  7493. * optimal performance. However, LWORK as large as 11*N
  7494. * may be required for optimal performance. A workspace
  7495. * query is recommended to determine the optimal workspace
  7496. * size.
  7497. *
  7498. * If LWORK = -1, then DHSEQR does a workspace query.
  7499. * In this case, DHSEQR checks the input parameters and
  7500. * estimates the optimal workspace size for the given
  7501. * values of N, ILO and IHI. The estimate is returned
  7502. * in WORK(1). No error message related to LWORK is
  7503. * issued by XERBLA. Neither H nor Z are accessed.
  7504. *
  7505. *
  7506. * C++ Return value: INFO (output) INTEGER
  7507. * = 0: successful exit
  7508. * .LT. 0: if INFO = -i, the i-th argument had an illegal
  7509. * value
  7510. * .GT. 0: if INFO = i, DHSEQR failed to compute all of
  7511. * the eigenvalues. Elements 1:ilo-1 and i+1:n of WR
  7512. * and WI contain those eigenvalues which have been
  7513. * successfully computed. (Failures are rare.)
  7514. *
  7515. * If INFO .GT. 0 and JOB = 'E', then on exit, the
  7516. * remaining unconverged eigenvalues are the eigen-
  7517. * values of the upper Hessenberg matrix rows and
  7518. * columns ILO through INFO of the final, output
  7519. * value of H.
  7520. *
  7521. * If INFO .GT. 0 and JOB = 'S', then on exit
  7522. *
  7523. * (*) (initial value of H)*U = U*(final value of H)
  7524. *
  7525. * where U is an orthogonal matrix. The final
  7526. * value of H is upper Hessenberg and quasi-triangular
  7527. * in rows and columns INFO+1 through IHI.
  7528. *
  7529. * If INFO .GT. 0 and COMPZ = 'V', then on exit
  7530. *
  7531. * (final value of Z) = (initial value of Z)*U
  7532. *
  7533. * where U is the orthogonal matrix in (*) (regard-
  7534. * less of the value of JOB.)
  7535. *
  7536. * If INFO .GT. 0 and COMPZ = 'I', then on exit
  7537. * (final value of Z) = U
  7538. * where U is the orthogonal matrix in (*) (regard-
  7539. * less of the value of JOB.)
  7540. *
  7541. * If INFO .GT. 0 and COMPZ = 'N', then Z is not
  7542. * accessed.
  7543. *
  7544. * ================================================================
  7545. * Default values supplied by
  7546. * ILAENV(ISPEC,'DHSEQR',JOB(:1)//COMPZ(:1),N,ILO,IHI,LWORK).
  7547. * It is suggested that these defaults be adjusted in order
  7548. * to attain best performance in each particular
  7549. * computational environment.
  7550. *
  7551. * ISPEC=12: The DLAHQR vs DLAQR0 crossover point.
  7552. * Default: 75. (Must be at least 11.)
  7553. *
  7554. * ISPEC=13: Recommended deflation window size.
  7555. * This depends on ILO, IHI and NS. NS is the
  7556. * number of simultaneous shifts returned
  7557. * by ILAENV(ISPEC=15). (See ISPEC=15 below.)
  7558. * The default for (IHI-ILO+1).LE.500 is NS.
  7559. * The default for (IHI-ILO+1).GT.500 is 3*NS/2.
  7560. *
  7561. * ISPEC=14: Nibble crossover point. (See IPARMQ for
  7562. * details.) Default: 14% of deflation window
  7563. * size.
  7564. *
  7565. * ISPEC=15: Number of simultaneous shifts in a multishift
  7566. * QR iteration.
  7567. *
  7568. * If IHI-ILO+1 is ...
  7569. *
  7570. * greater than ...but less ... the
  7571. * or equal to ... than default is
  7572. *
  7573. * 1 30 NS = 2(+)
  7574. * 30 60 NS = 4(+)
  7575. * 60 150 NS = 10(+)
  7576. * 150 590 NS = **
  7577. * 590 3000 NS = 64
  7578. * 3000 6000 NS = 128
  7579. * 6000 infinity NS = 256
  7580. *
  7581. * (+) By default some or all matrices of this order
  7582. * are passed to the implicit double shift routine
  7583. * DLAHQR and this parameter is ignored. See
  7584. * ISPEC=12 above and comments in IPARMQ for
  7585. * details.
  7586. *
  7587. * (**) The asterisks (**) indicate an ad-hoc
  7588. * function of N increasing from 10 to 64.
  7589. *
  7590. * ISPEC=16: Select structured matrix multiply.
  7591. * If the number of simultaneous shifts (specified
  7592. * by ISPEC=15) is less than 14, then the default
  7593. * for ISPEC=16 is 0. Otherwise the default for
  7594. * ISPEC=16 is 2.
  7595. *
  7596. * ================================================================
  7597. * Based on contributions by
  7598. * Karen Braman and Ralph Byers, Department of Mathematics,
  7599. * University of Kansas, USA
  7600. *
  7601. * ================================================================
  7602. * References:
  7603. * K. Braman, R. Byers and R. Mathias, The Multi-Shift QR
  7604. * Algorithm Part I: Maintaining Well Focused Shifts, and Level 3
  7605. * Performance, SIAM Journal of Matrix Analysis, volume 23, pages
  7606. * 929--947, 2002.
  7607. *
  7608. * K. Braman, R. Byers and R. Mathias, The Multi-Shift QR
  7609. * Algorithm Part II: Aggressive Early Deflation, SIAM Journal
  7610. * of Matrix Analysis, volume 23, pages 948--973, 2002.
  7611. *
  7612. * ================================================================
  7613. * .. Parameters ..
  7614. *
  7615. * ==== Matrices of order NTINY or smaller must be processed by
  7616. * . DLAHQR because of insufficient subdiagonal scratch space.
  7617. * . (This is a hard limit.) ====
  7618. **/
  7619. int C_DHSEQR(char job, char compz, int n, int ilo, int ihi, double* h, int ldh, double* wr, double* wi, double* z, int ldz, double* work, int lwork)
  7620. {
  7621. int info;
  7622. ::F_DHSEQR(&job, &compz, &n, &ilo, &ihi, h, &ldh, wr, wi, z, &ldz, work, &lwork, &info);
  7623. return info;
  7624. }
  7625. /**
  7626. * Purpose
  7627. * =======
  7628. *
  7629. * DOPGTR generates a real orthogonal matrix Q which is defined as the
  7630. * product of n-1 elementary reflectors H(i) of order n, as returned by
  7631. * DSPTRD using packed storage:
  7632. *
  7633. * if UPLO = 'U', Q = H(n-1) . . . H(2) H(1),
  7634. *
  7635. * if UPLO = 'L', Q = H(1) H(2) . . . H(n-1).
  7636. *
  7637. * Arguments
  7638. * =========
  7639. *
  7640. * UPLO (input) CHARACTER*1
  7641. * = 'U': Upper triangular packed storage used in previous
  7642. * call to DSPTRD;
  7643. * = 'L': Lower triangular packed storage used in previous
  7644. * call to DSPTRD.
  7645. *
  7646. * N (input) INTEGER
  7647. * The order of the matrix Q. N >= 0.
  7648. *
  7649. * AP (input) DOUBLE PRECISION array, dimension (N*(N+1)/2)
  7650. * The vectors which define the elementary reflectors, as
  7651. * returned by DSPTRD.
  7652. *
  7653. * TAU (input) DOUBLE PRECISION array, dimension (N-1)
  7654. * TAU(i) must contain the scalar factor of the elementary
  7655. * reflector H(i), as returned by DSPTRD.
  7656. *
  7657. * Q (output) DOUBLE PRECISION array, dimension (LDQ,N)
  7658. * The N-by-N orthogonal matrix Q.
  7659. *
  7660. * LDQ (input) INTEGER
  7661. * The leading dimension of the array Q. LDQ >= max(1,N).
  7662. *
  7663. * WORK (workspace) DOUBLE PRECISION array, dimension (N-1)
  7664. *
  7665. * C++ Return value: INFO (output) INTEGER
  7666. * = 0: successful exit
  7667. * < 0: if INFO = -i, the i-th argument had an illegal value
  7668. *
  7669. * =====================================================================
  7670. *
  7671. * .. Parameters ..
  7672. **/
  7673. int C_DOPGTR(char uplo, int n, double* ap, double* tau, double* q, int ldq, double* work)
  7674. {
  7675. int info;
  7676. ::F_DOPGTR(&uplo, &n, ap, tau, q, &ldq, work, &info);
  7677. return info;
  7678. }
  7679. /**
  7680. * Purpose
  7681. * =======
  7682. *
  7683. * DOPMTR overwrites the general real M-by-N matrix C with
  7684. *
  7685. * SIDE = 'L' SIDE = 'R'
  7686. * TRANS = 'N': Q * C C * Q
  7687. * TRANS = 'T': Q**T * C C * Q**T
  7688. *
  7689. * where Q is a real orthogonal matrix of order nq, with nq = m if
  7690. * SIDE = 'L' and nq = n if SIDE = 'R'. Q is defined as the product of
  7691. * nq-1 elementary reflectors, as returned by DSPTRD using packed
  7692. * storage:
  7693. *
  7694. * if UPLO = 'U', Q = H(nq-1) . . . H(2) H(1);
  7695. *
  7696. * if UPLO = 'L', Q = H(1) H(2) . . . H(nq-1).
  7697. *
  7698. * Arguments
  7699. * =========
  7700. *
  7701. * SIDE (input) CHARACTER*1
  7702. * = 'L': apply Q or Q**T from the Left;
  7703. * = 'R': apply Q or Q**T from the Right.
  7704. *
  7705. * UPLO (input) CHARACTER*1
  7706. * = 'U': Upper triangular packed storage used in previous
  7707. * call to DSPTRD;
  7708. * = 'L': Lower triangular packed storage used in previous
  7709. * call to DSPTRD.
  7710. *
  7711. * TRANS (input) CHARACTER*1
  7712. * = 'N': No transpose, apply Q;
  7713. * = 'T': Transpose, apply Q**T.
  7714. *
  7715. * M (input) INTEGER
  7716. * The number of rows of the matrix C. M >= 0.
  7717. *
  7718. * N (input) INTEGER
  7719. * The number of columns of the matrix C. N >= 0.
  7720. *
  7721. * AP (input) DOUBLE PRECISION array, dimension
  7722. * (M*(M+1)/2) if SIDE = 'L'
  7723. * (N*(N+1)/2) if SIDE = 'R'
  7724. * The vectors which define the elementary reflectors, as
  7725. * returned by DSPTRD. AP is modified by the routine but
  7726. * restored on exit.
  7727. *
  7728. * TAU (input) DOUBLE PRECISION array, dimension (M-1) if SIDE = 'L'
  7729. * or (N-1) if SIDE = 'R'
  7730. * TAU(i) must contain the scalar factor of the elementary
  7731. * reflector H(i), as returned by DSPTRD.
  7732. *
  7733. * C (input/output) DOUBLE PRECISION array, dimension (LDC,N)
  7734. * On entry, the M-by-N matrix C.
  7735. * On exit, C is overwritten by Q*C or Q**T*C or C*Q**T or C*Q.
  7736. *
  7737. * LDC (input) INTEGER
  7738. * The leading dimension of the array C. LDC >= max(1,M).
  7739. *
  7740. * WORK (workspace) DOUBLE PRECISION array, dimension
  7741. * (N) if SIDE = 'L'
  7742. * (M) if SIDE = 'R'
  7743. *
  7744. * C++ Return value: INFO (output) INTEGER
  7745. * = 0: successful exit
  7746. * < 0: if INFO = -i, the i-th argument had an illegal value
  7747. *
  7748. * =====================================================================
  7749. *
  7750. * .. Parameters ..
  7751. **/
  7752. int C_DOPMTR(char side, char uplo, char trans, int m, int n, double* ap, double* tau, double* c, int ldc, double* work)
  7753. {
  7754. int info;
  7755. ::F_DOPMTR(&side, &uplo, &trans, &m, &n, ap, tau, c, &ldc, work, &info);
  7756. return info;
  7757. }
  7758. /**
  7759. * Purpose
  7760. * =======
  7761. *
  7762. * DORGBR generates one of the real orthogonal matrices Q or P**T
  7763. * determined by DGEBRD when reducing a real matrix A to bidiagonal
  7764. * form: A = Q * B * P**T. Q and P**T are defined as products of
  7765. * elementary reflectors H(i) or G(i) respectively.
  7766. *
  7767. * If VECT = 'Q', A is assumed to have been an M-by-K matrix, and Q
  7768. * is of order M:
  7769. * if m >= k, Q = H(1) H(2) . . . H(k) and DORGBR returns the first n
  7770. * columns of Q, where m >= n >= k;
  7771. * if m < k, Q = H(1) H(2) . . . H(m-1) and DORGBR returns Q as an
  7772. * M-by-M matrix.
  7773. *
  7774. * If VECT = 'P', A is assumed to have been a K-by-N matrix, and P**T
  7775. * is of order N:
  7776. * if k < n, P**T = G(k) . . . G(2) G(1) and DORGBR returns the first m
  7777. * rows of P**T, where n >= m >= k;
  7778. * if k >= n, P**T = G(n-1) . . . G(2) G(1) and DORGBR returns P**T as
  7779. * an N-by-N matrix.
  7780. *
  7781. * Arguments
  7782. * =========
  7783. *
  7784. * VECT (input) CHARACTER*1
  7785. * Specifies whether the matrix Q or the matrix P**T is
  7786. * required, as defined in the transformation applied by DGEBRD:
  7787. * = 'Q': generate Q;
  7788. * = 'P': generate P**T.
  7789. *
  7790. * M (input) INTEGER
  7791. * The number of rows of the matrix Q or P**T to be returned.
  7792. * M >= 0.
  7793. *
  7794. * N (input) INTEGER
  7795. * The number of columns of the matrix Q or P**T to be returned.
  7796. * N >= 0.
  7797. * If VECT = 'Q', M >= N >= min(M,K);
  7798. * if VECT = 'P', N >= M >= min(N,K).
  7799. *
  7800. * K (input) INTEGER
  7801. * If VECT = 'Q', the number of columns in the original M-by-K
  7802. * matrix reduced by DGEBRD.
  7803. * If VECT = 'P', the number of rows in the original K-by-N
  7804. * matrix reduced by DGEBRD.
  7805. * K >= 0.
  7806. *
  7807. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  7808. * On entry, the vectors which define the elementary reflectors,
  7809. * as returned by DGEBRD.
  7810. * On exit, the M-by-N matrix Q or P**T.
  7811. *
  7812. * LDA (input) INTEGER
  7813. * The leading dimension of the array A. LDA >= max(1,M).
  7814. *
  7815. * TAU (input) DOUBLE PRECISION array, dimension
  7816. * (min(M,K)) if VECT = 'Q'
  7817. * (min(N,K)) if VECT = 'P'
  7818. * TAU(i) must contain the scalar factor of the elementary
  7819. * reflector H(i) or G(i), which determines Q or P**T, as
  7820. * returned by DGEBRD in its array argument TAUQ or TAUP.
  7821. *
  7822. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  7823. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  7824. *
  7825. * LWORK (input) INTEGER
  7826. * The dimension of the array WORK. LWORK >= max(1,min(M,N)).
  7827. * For optimum performance LWORK >= min(M,N)*NB, where NB
  7828. * is the optimal blocksize.
  7829. *
  7830. * If LWORK = -1, then a workspace query is assumed; the routine
  7831. * only calculates the optimal size of the WORK array, returns
  7832. * this value as the first entry of the WORK array, and no error
  7833. * message related to LWORK is issued by XERBLA.
  7834. *
  7835. * C++ Return value: INFO (output) INTEGER
  7836. * = 0: successful exit
  7837. * < 0: if INFO = -i, the i-th argument had an illegal value
  7838. *
  7839. * =====================================================================
  7840. *
  7841. * .. Parameters ..
  7842. **/
  7843. int C_DORGBR(char vect, int m, int n, int k, double* a, int lda, double* tau, double* work, int lwork)
  7844. {
  7845. int info;
  7846. ::F_DORGBR(&vect, &m, &n, &k, a, &lda, tau, work, &lwork, &info);
  7847. return info;
  7848. }
  7849. /**
  7850. * Purpose
  7851. * =======
  7852. *
  7853. * DORGHR generates a real orthogonal matrix Q which is defined as the
  7854. * product of IHI-ILO elementary reflectors of order N, as returned by
  7855. * DGEHRD:
  7856. *
  7857. * Q = H(ilo) H(ilo+1) . . . H(ihi-1).
  7858. *
  7859. * Arguments
  7860. * =========
  7861. *
  7862. * N (input) INTEGER
  7863. * The order of the matrix Q. N >= 0.
  7864. *
  7865. * ILO (input) INTEGER
  7866. * IHI (input) INTEGER
  7867. * ILO and IHI must have the same values as in the previous call
  7868. * of DGEHRD. Q is equal to the unit matrix except in the
  7869. * submatrix Q(ilo+1:ihi,ilo+1:ihi).
  7870. * 1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0.
  7871. *
  7872. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  7873. * On entry, the vectors which define the elementary reflectors,
  7874. * as returned by DGEHRD.
  7875. * On exit, the N-by-N orthogonal matrix Q.
  7876. *
  7877. * LDA (input) INTEGER
  7878. * The leading dimension of the array A. LDA >= max(1,N).
  7879. *
  7880. * TAU (input) DOUBLE PRECISION array, dimension (N-1)
  7881. * TAU(i) must contain the scalar factor of the elementary
  7882. * reflector H(i), as returned by DGEHRD.
  7883. *
  7884. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  7885. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  7886. *
  7887. * LWORK (input) INTEGER
  7888. * The dimension of the array WORK. LWORK >= IHI-ILO.
  7889. * For optimum performance LWORK >= (IHI-ILO)*NB, where NB is
  7890. * the optimal blocksize.
  7891. *
  7892. * If LWORK = -1, then a workspace query is assumed; the routine
  7893. * only calculates the optimal size of the WORK array, returns
  7894. * this value as the first entry of the WORK array, and no error
  7895. * message related to LWORK is issued by XERBLA.
  7896. *
  7897. * C++ Return value: INFO (output) INTEGER
  7898. * = 0: successful exit
  7899. * < 0: if INFO = -i, the i-th argument had an illegal value
  7900. *
  7901. * =====================================================================
  7902. *
  7903. * .. Parameters ..
  7904. **/
  7905. int C_DORGHR(int n, int ilo, int ihi, double* a, int lda, double* tau, double* work, int lwork)
  7906. {
  7907. int info;
  7908. ::F_DORGHR(&n, &ilo, &ihi, a, &lda, tau, work, &lwork, &info);
  7909. return info;
  7910. }
  7911. /**
  7912. * Purpose
  7913. * =======
  7914. *
  7915. * DORGLQ generates an M-by-N real matrix Q with orthonormal rows,
  7916. * which is defined as the first M rows of a product of K elementary
  7917. * reflectors of order N
  7918. *
  7919. * Q = H(k) . . . H(2) H(1)
  7920. *
  7921. * as returned by DGELQF.
  7922. *
  7923. * Arguments
  7924. * =========
  7925. *
  7926. * M (input) INTEGER
  7927. * The number of rows of the matrix Q. M >= 0.
  7928. *
  7929. * N (input) INTEGER
  7930. * The number of columns of the matrix Q. N >= M.
  7931. *
  7932. * K (input) INTEGER
  7933. * The number of elementary reflectors whose product defines the
  7934. * matrix Q. M >= K >= 0.
  7935. *
  7936. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  7937. * On entry, the i-th row must contain the vector which defines
  7938. * the elementary reflector H(i), for i = 1,2,...,k, as returned
  7939. * by DGELQF in the first k rows of its array argument A.
  7940. * On exit, the M-by-N matrix Q.
  7941. *
  7942. * LDA (input) INTEGER
  7943. * The first dimension of the array A. LDA >= max(1,M).
  7944. *
  7945. * TAU (input) DOUBLE PRECISION array, dimension (K)
  7946. * TAU(i) must contain the scalar factor of the elementary
  7947. * reflector H(i), as returned by DGELQF.
  7948. *
  7949. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  7950. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  7951. *
  7952. * LWORK (input) INTEGER
  7953. * The dimension of the array WORK. LWORK >= max(1,M).
  7954. * For optimum performance LWORK >= M*NB, where NB is
  7955. * the optimal blocksize.
  7956. *
  7957. * If LWORK = -1, then a workspace query is assumed; the routine
  7958. * only calculates the optimal size of the WORK array, returns
  7959. * this value as the first entry of the WORK array, and no error
  7960. * message related to LWORK is issued by XERBLA.
  7961. *
  7962. * C++ Return value: INFO (output) INTEGER
  7963. * = 0: successful exit
  7964. * < 0: if INFO = -i, the i-th argument has an illegal value
  7965. *
  7966. * =====================================================================
  7967. *
  7968. * .. Parameters ..
  7969. **/
  7970. int C_DORGLQ(int m, int n, int k, double* a, int lda, double* tau, double* work, int lwork)
  7971. {
  7972. int info;
  7973. ::F_DORGLQ(&m, &n, &k, a, &lda, tau, work, &lwork, &info);
  7974. return info;
  7975. }
  7976. /**
  7977. * Purpose
  7978. * =======
  7979. *
  7980. * DORGQL generates an M-by-N real matrix Q with orthonormal columns,
  7981. * which is defined as the last N columns of a product of K elementary
  7982. * reflectors of order M
  7983. *
  7984. * Q = H(k) . . . H(2) H(1)
  7985. *
  7986. * as returned by DGEQLF.
  7987. *
  7988. * Arguments
  7989. * =========
  7990. *
  7991. * M (input) INTEGER
  7992. * The number of rows of the matrix Q. M >= 0.
  7993. *
  7994. * N (input) INTEGER
  7995. * The number of columns of the matrix Q. M >= N >= 0.
  7996. *
  7997. * K (input) INTEGER
  7998. * The number of elementary reflectors whose product defines the
  7999. * matrix Q. N >= K >= 0.
  8000. *
  8001. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  8002. * On entry, the (n-k+i)-th column must contain the vector which
  8003. * defines the elementary reflector H(i), for i = 1,2,...,k, as
  8004. * returned by DGEQLF in the last k columns of its array
  8005. * argument A.
  8006. * On exit, the M-by-N matrix Q.
  8007. *
  8008. * LDA (input) INTEGER
  8009. * The first dimension of the array A. LDA >= max(1,M).
  8010. *
  8011. * TAU (input) DOUBLE PRECISION array, dimension (K)
  8012. * TAU(i) must contain the scalar factor of the elementary
  8013. * reflector H(i), as returned by DGEQLF.
  8014. *
  8015. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  8016. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  8017. *
  8018. * LWORK (input) INTEGER
  8019. * The dimension of the array WORK. LWORK >= max(1,N).
  8020. * For optimum performance LWORK >= N*NB, where NB is the
  8021. * optimal blocksize.
  8022. *
  8023. * If LWORK = -1, then a workspace query is assumed; the routine
  8024. * only calculates the optimal size of the WORK array, returns
  8025. * this value as the first entry of the WORK array, and no error
  8026. * message related to LWORK is issued by XERBLA.
  8027. *
  8028. * C++ Return value: INFO (output) INTEGER
  8029. * = 0: successful exit
  8030. * < 0: if INFO = -i, the i-th argument has an illegal value
  8031. *
  8032. * =====================================================================
  8033. *
  8034. * .. Parameters ..
  8035. **/
  8036. int C_DORGQL(int m, int n, int k, double* a, int lda, double* tau, double* work, int lwork)
  8037. {
  8038. int info;
  8039. ::F_DORGQL(&m, &n, &k, a, &lda, tau, work, &lwork, &info);
  8040. return info;
  8041. }
  8042. /**
  8043. * Purpose
  8044. * =======
  8045. *
  8046. * DORGQR generates an M-by-N real matrix Q with orthonormal columns,
  8047. * which is defined as the first N columns of a product of K elementary
  8048. * reflectors of order M
  8049. *
  8050. * Q = H(1) H(2) . . . H(k)
  8051. *
  8052. * as returned by DGEQRF.
  8053. *
  8054. * Arguments
  8055. * =========
  8056. *
  8057. * M (input) INTEGER
  8058. * The number of rows of the matrix Q. M >= 0.
  8059. *
  8060. * N (input) INTEGER
  8061. * The number of columns of the matrix Q. M >= N >= 0.
  8062. *
  8063. * K (input) INTEGER
  8064. * The number of elementary reflectors whose product defines the
  8065. * matrix Q. N >= K >= 0.
  8066. *
  8067. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  8068. * On entry, the i-th column must contain the vector which
  8069. * defines the elementary reflector H(i), for i = 1,2,...,k, as
  8070. * returned by DGEQRF in the first k columns of its array
  8071. * argument A.
  8072. * On exit, the M-by-N matrix Q.
  8073. *
  8074. * LDA (input) INTEGER
  8075. * The first dimension of the array A. LDA >= max(1,M).
  8076. *
  8077. * TAU (input) DOUBLE PRECISION array, dimension (K)
  8078. * TAU(i) must contain the scalar factor of the elementary
  8079. * reflector H(i), as returned by DGEQRF.
  8080. *
  8081. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  8082. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  8083. *
  8084. * LWORK (input) INTEGER
  8085. * The dimension of the array WORK. LWORK >= max(1,N).
  8086. * For optimum performance LWORK >= N*NB, where NB is the
  8087. * optimal blocksize.
  8088. *
  8089. * If LWORK = -1, then a workspace query is assumed; the routine
  8090. * only calculates the optimal size of the WORK array, returns
  8091. * this value as the first entry of the WORK array, and no error
  8092. * message related to LWORK is issued by XERBLA.
  8093. *
  8094. * C++ Return value: INFO (output) INTEGER
  8095. * = 0: successful exit
  8096. * < 0: if INFO = -i, the i-th argument has an illegal value
  8097. *
  8098. * =====================================================================
  8099. *
  8100. * .. Parameters ..
  8101. **/
  8102. int C_DORGQR(int m, int n, int k, double* a, int lda, double* tau, double* work, int lwork)
  8103. {
  8104. int info;
  8105. ::F_DORGQR(&m, &n, &k, a, &lda, tau, work, &lwork, &info);
  8106. return info;
  8107. }
  8108. /**
  8109. * Purpose
  8110. * =======
  8111. *
  8112. * DORGRQ generates an M-by-N real matrix Q with orthonormal rows,
  8113. * which is defined as the last M rows of a product of K elementary
  8114. * reflectors of order N
  8115. *
  8116. * Q = H(1) H(2) . . . H(k)
  8117. *
  8118. * as returned by DGERQF.
  8119. *
  8120. * Arguments
  8121. * =========
  8122. *
  8123. * M (input) INTEGER
  8124. * The number of rows of the matrix Q. M >= 0.
  8125. *
  8126. * N (input) INTEGER
  8127. * The number of columns of the matrix Q. N >= M.
  8128. *
  8129. * K (input) INTEGER
  8130. * The number of elementary reflectors whose product defines the
  8131. * matrix Q. M >= K >= 0.
  8132. *
  8133. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  8134. * On entry, the (m-k+i)-th row must contain the vector which
  8135. * defines the elementary reflector H(i), for i = 1,2,...,k, as
  8136. * returned by DGERQF in the last k rows of its array argument
  8137. * A.
  8138. * On exit, the M-by-N matrix Q.
  8139. *
  8140. * LDA (input) INTEGER
  8141. * The first dimension of the array A. LDA >= max(1,M).
  8142. *
  8143. * TAU (input) DOUBLE PRECISION array, dimension (K)
  8144. * TAU(i) must contain the scalar factor of the elementary
  8145. * reflector H(i), as returned by DGERQF.
  8146. *
  8147. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  8148. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  8149. *
  8150. * LWORK (input) INTEGER
  8151. * The dimension of the array WORK. LWORK >= max(1,M).
  8152. * For optimum performance LWORK >= M*NB, where NB is the
  8153. * optimal blocksize.
  8154. *
  8155. * If LWORK = -1, then a workspace query is assumed; the routine
  8156. * only calculates the optimal size of the WORK array, returns
  8157. * this value as the first entry of the WORK array, and no error
  8158. * message related to LWORK is issued by XERBLA.
  8159. *
  8160. * C++ Return value: INFO (output) INTEGER
  8161. * = 0: successful exit
  8162. * < 0: if INFO = -i, the i-th argument has an illegal value
  8163. *
  8164. * =====================================================================
  8165. *
  8166. * .. Parameters ..
  8167. **/
  8168. int C_DORGRQ(int m, int n, int k, double* a, int lda, double* tau, double* work, int lwork)
  8169. {
  8170. int info;
  8171. ::F_DORGRQ(&m, &n, &k, a, &lda, tau, work, &lwork, &info);
  8172. return info;
  8173. }
  8174. /**
  8175. * Purpose
  8176. * =======
  8177. *
  8178. * DORGTR generates a real orthogonal matrix Q which is defined as the
  8179. * product of n-1 elementary reflectors of order N, as returned by
  8180. * DSYTRD:
  8181. *
  8182. * if UPLO = 'U', Q = H(n-1) . . . H(2) H(1),
  8183. *
  8184. * if UPLO = 'L', Q = H(1) H(2) . . . H(n-1).
  8185. *
  8186. * Arguments
  8187. * =========
  8188. *
  8189. * UPLO (input) CHARACTER*1
  8190. * = 'U': Upper triangle of A contains elementary reflectors
  8191. * from DSYTRD;
  8192. * = 'L': Lower triangle of A contains elementary reflectors
  8193. * from DSYTRD.
  8194. *
  8195. * N (input) INTEGER
  8196. * The order of the matrix Q. N >= 0.
  8197. *
  8198. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  8199. * On entry, the vectors which define the elementary reflectors,
  8200. * as returned by DSYTRD.
  8201. * On exit, the N-by-N orthogonal matrix Q.
  8202. *
  8203. * LDA (input) INTEGER
  8204. * The leading dimension of the array A. LDA >= max(1,N).
  8205. *
  8206. * TAU (input) DOUBLE PRECISION array, dimension (N-1)
  8207. * TAU(i) must contain the scalar factor of the elementary
  8208. * reflector H(i), as returned by DSYTRD.
  8209. *
  8210. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  8211. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  8212. *
  8213. * LWORK (input) INTEGER
  8214. * The dimension of the array WORK. LWORK >= max(1,N-1).
  8215. * For optimum performance LWORK >= (N-1)*NB, where NB is
  8216. * the optimal blocksize.
  8217. *
  8218. * If LWORK = -1, then a workspace query is assumed; the routine
  8219. * only calculates the optimal size of the WORK array, returns
  8220. * this value as the first entry of the WORK array, and no error
  8221. * message related to LWORK is issued by XERBLA.
  8222. *
  8223. * C++ Return value: INFO (output) INTEGER
  8224. * = 0: successful exit
  8225. * < 0: if INFO = -i, the i-th argument had an illegal value
  8226. *
  8227. * =====================================================================
  8228. *
  8229. * .. Parameters ..
  8230. **/
  8231. int C_DORGTR(char uplo, int n, double* a, int lda, double* tau, double* work, int lwork)
  8232. {
  8233. int info;
  8234. ::F_DORGTR(&uplo, &n, a, &lda, tau, work, &lwork, &info);
  8235. return info;
  8236. }
  8237. /**
  8238. * Purpose
  8239. * =======
  8240. *
  8241. * If VECT = 'Q', DORMBR overwrites the general real M-by-N matrix C
  8242. * with
  8243. * SIDE = 'L' SIDE = 'R'
  8244. * TRANS = 'N': Q * C C * Q
  8245. * TRANS = 'T': Q**T * C C * Q**T
  8246. *
  8247. * If VECT = 'P', DORMBR overwrites the general real M-by-N matrix C
  8248. * with
  8249. * SIDE = 'L' SIDE = 'R'
  8250. * TRANS = 'N': P * C C * P
  8251. * TRANS = 'T': P**T * C C * P**T
  8252. *
  8253. * Here Q and P**T are the orthogonal matrices determined by DGEBRD when
  8254. * reducing a real matrix A to bidiagonal form: A = Q * B * P**T. Q and
  8255. * P**T are defined as products of elementary reflectors H(i) and G(i)
  8256. * respectively.
  8257. *
  8258. * Let nq = m if SIDE = 'L' and nq = n if SIDE = 'R'. Thus nq is the
  8259. * order of the orthogonal matrix Q or P**T that is applied.
  8260. *
  8261. * If VECT = 'Q', A is assumed to have been an NQ-by-K matrix:
  8262. * if nq >= k, Q = H(1) H(2) . . . H(k);
  8263. * if nq < k, Q = H(1) H(2) . . . H(nq-1).
  8264. *
  8265. * If VECT = 'P', A is assumed to have been a K-by-NQ matrix:
  8266. * if k < nq, P = G(1) G(2) . . . G(k);
  8267. * if k >= nq, P = G(1) G(2) . . . G(nq-1).
  8268. *
  8269. * Arguments
  8270. * =========
  8271. *
  8272. * VECT (input) CHARACTER*1
  8273. * = 'Q': apply Q or Q**T;
  8274. * = 'P': apply P or P**T.
  8275. *
  8276. * SIDE (input) CHARACTER*1
  8277. * = 'L': apply Q, Q**T, P or P**T from the Left;
  8278. * = 'R': apply Q, Q**T, P or P**T from the Right.
  8279. *
  8280. * TRANS (input) CHARACTER*1
  8281. * = 'N': No transpose, apply Q or P;
  8282. * = 'T': Transpose, apply Q**T or P**T.
  8283. *
  8284. * M (input) INTEGER
  8285. * The number of rows of the matrix C. M >= 0.
  8286. *
  8287. * N (input) INTEGER
  8288. * The number of columns of the matrix C. N >= 0.
  8289. *
  8290. * K (input) INTEGER
  8291. * If VECT = 'Q', the number of columns in the original
  8292. * matrix reduced by DGEBRD.
  8293. * If VECT = 'P', the number of rows in the original
  8294. * matrix reduced by DGEBRD.
  8295. * K >= 0.
  8296. *
  8297. * A (input) DOUBLE PRECISION array, dimension
  8298. * (LDA,min(nq,K)) if VECT = 'Q'
  8299. * (LDA,nq) if VECT = 'P'
  8300. * The vectors which define the elementary reflectors H(i) and
  8301. * G(i), whose products determine the matrices Q and P, as
  8302. * returned by DGEBRD.
  8303. *
  8304. * LDA (input) INTEGER
  8305. * The leading dimension of the array A.
  8306. * If VECT = 'Q', LDA >= max(1,nq);
  8307. * if VECT = 'P', LDA >= max(1,min(nq,K)).
  8308. *
  8309. * TAU (input) DOUBLE PRECISION array, dimension (min(nq,K))
  8310. * TAU(i) must contain the scalar factor of the elementary
  8311. * reflector H(i) or G(i) which determines Q or P, as returned
  8312. * by DGEBRD in the array argument TAUQ or TAUP.
  8313. *
  8314. * C (input/output) DOUBLE PRECISION array, dimension (LDC,N)
  8315. * On entry, the M-by-N matrix C.
  8316. * On exit, C is overwritten by Q*C or Q**T*C or C*Q**T or C*Q
  8317. * or P*C or P**T*C or C*P or C*P**T.
  8318. *
  8319. * LDC (input) INTEGER
  8320. * The leading dimension of the array C. LDC >= max(1,M).
  8321. *
  8322. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  8323. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  8324. *
  8325. * LWORK (input) INTEGER
  8326. * The dimension of the array WORK.
  8327. * If SIDE = 'L', LWORK >= max(1,N);
  8328. * if SIDE = 'R', LWORK >= max(1,M).
  8329. * For optimum performance LWORK >= N*NB if SIDE = 'L', and
  8330. * LWORK >= M*NB if SIDE = 'R', where NB is the optimal
  8331. * blocksize.
  8332. *
  8333. * If LWORK = -1, then a workspace query is assumed; the routine
  8334. * only calculates the optimal size of the WORK array, returns
  8335. * this value as the first entry of the WORK array, and no error
  8336. * message related to LWORK is issued by XERBLA.
  8337. *
  8338. * C++ Return value: INFO (output) INTEGER
  8339. * = 0: successful exit
  8340. * < 0: if INFO = -i, the i-th argument had an illegal value
  8341. *
  8342. * =====================================================================
  8343. *
  8344. * .. Local Scalars ..
  8345. **/
  8346. int C_DORMBR(char vect, char side, char trans, int m, int n, int k, double* a, int lda, double* tau, double* c, int ldc, double* work, int lwork)
  8347. {
  8348. int info;
  8349. ::F_DORMBR(&vect, &side, &trans, &m, &n, &k, a, &lda, tau, c, &ldc, work, &lwork, &info);
  8350. return info;
  8351. }
  8352. /**
  8353. * Purpose
  8354. * =======
  8355. *
  8356. * DORMHR overwrites the general real M-by-N matrix C with
  8357. *
  8358. * SIDE = 'L' SIDE = 'R'
  8359. * TRANS = 'N': Q * C C * Q
  8360. * TRANS = 'T': Q**T * C C * Q**T
  8361. *
  8362. * where Q is a real orthogonal matrix of order nq, with nq = m if
  8363. * SIDE = 'L' and nq = n if SIDE = 'R'. Q is defined as the product of
  8364. * IHI-ILO elementary reflectors, as returned by DGEHRD:
  8365. *
  8366. * Q = H(ilo) H(ilo+1) . . . H(ihi-1).
  8367. *
  8368. * Arguments
  8369. * =========
  8370. *
  8371. * SIDE (input) CHARACTER*1
  8372. * = 'L': apply Q or Q**T from the Left;
  8373. * = 'R': apply Q or Q**T from the Right.
  8374. *
  8375. * TRANS (input) CHARACTER*1
  8376. * = 'N': No transpose, apply Q;
  8377. * = 'T': Transpose, apply Q**T.
  8378. *
  8379. * M (input) INTEGER
  8380. * The number of rows of the matrix C. M >= 0.
  8381. *
  8382. * N (input) INTEGER
  8383. * The number of columns of the matrix C. N >= 0.
  8384. *
  8385. * ILO (input) INTEGER
  8386. * IHI (input) INTEGER
  8387. * ILO and IHI must have the same values as in the previous call
  8388. * of DGEHRD. Q is equal to the unit matrix except in the
  8389. * submatrix Q(ilo+1:ihi,ilo+1:ihi).
  8390. * If SIDE = 'L', then 1 <= ILO <= IHI <= M, if M > 0, and
  8391. * ILO = 1 and IHI = 0, if M = 0;
  8392. * if SIDE = 'R', then 1 <= ILO <= IHI <= N, if N > 0, and
  8393. * ILO = 1 and IHI = 0, if N = 0.
  8394. *
  8395. * A (input) DOUBLE PRECISION array, dimension
  8396. * (LDA,M) if SIDE = 'L'
  8397. * (LDA,N) if SIDE = 'R'
  8398. * The vectors which define the elementary reflectors, as
  8399. * returned by DGEHRD.
  8400. *
  8401. * LDA (input) INTEGER
  8402. * The leading dimension of the array A.
  8403. * LDA >= max(1,M) if SIDE = 'L'; LDA >= max(1,N) if SIDE = 'R'.
  8404. *
  8405. * TAU (input) DOUBLE PRECISION array, dimension
  8406. * (M-1) if SIDE = 'L'
  8407. * (N-1) if SIDE = 'R'
  8408. * TAU(i) must contain the scalar factor of the elementary
  8409. * reflector H(i), as returned by DGEHRD.
  8410. *
  8411. * C (input/output) DOUBLE PRECISION array, dimension (LDC,N)
  8412. * On entry, the M-by-N matrix C.
  8413. * On exit, C is overwritten by Q*C or Q**T*C or C*Q**T or C*Q.
  8414. *
  8415. * LDC (input) INTEGER
  8416. * The leading dimension of the array C. LDC >= max(1,M).
  8417. *
  8418. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  8419. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  8420. *
  8421. * LWORK (input) INTEGER
  8422. * The dimension of the array WORK.
  8423. * If SIDE = 'L', LWORK >= max(1,N);
  8424. * if SIDE = 'R', LWORK >= max(1,M).
  8425. * For optimum performance LWORK >= N*NB if SIDE = 'L', and
  8426. * LWORK >= M*NB if SIDE = 'R', where NB is the optimal
  8427. * blocksize.
  8428. *
  8429. * If LWORK = -1, then a workspace query is assumed; the routine
  8430. * only calculates the optimal size of the WORK array, returns
  8431. * this value as the first entry of the WORK array, and no error
  8432. * message related to LWORK is issued by XERBLA.
  8433. *
  8434. * C++ Return value: INFO (output) INTEGER
  8435. * = 0: successful exit
  8436. * < 0: if INFO = -i, the i-th argument had an illegal value
  8437. *
  8438. * =====================================================================
  8439. *
  8440. * .. Local Scalars ..
  8441. **/
  8442. int C_DORMHR(char side, char trans, int m, int n, int ilo, int ihi, double* a, int lda, double* tau, double* c, int ldc, double* work, int lwork)
  8443. {
  8444. int info;
  8445. ::F_DORMHR(&side, &trans, &m, &n, &ilo, &ihi, a, &lda, tau, c, &ldc, work, &lwork, &info);
  8446. return info;
  8447. }
  8448. /**
  8449. * Purpose
  8450. * =======
  8451. *
  8452. * DORMLQ overwrites the general real M-by-N matrix C with
  8453. *
  8454. * SIDE = 'L' SIDE = 'R'
  8455. * TRANS = 'N': Q * C C * Q
  8456. * TRANS = 'T': Q**T * C C * Q**T
  8457. *
  8458. * where Q is a real orthogonal matrix defined as the product of k
  8459. * elementary reflectors
  8460. *
  8461. * Q = H(k) . . . H(2) H(1)
  8462. *
  8463. * as returned by DGELQF. Q is of order M if SIDE = 'L' and of order N
  8464. * if SIDE = 'R'.
  8465. *
  8466. * Arguments
  8467. * =========
  8468. *
  8469. * SIDE (input) CHARACTER*1
  8470. * = 'L': apply Q or Q**T from the Left;
  8471. * = 'R': apply Q or Q**T from the Right.
  8472. *
  8473. * TRANS (input) CHARACTER*1
  8474. * = 'N': No transpose, apply Q;
  8475. * = 'T': Transpose, apply Q**T.
  8476. *
  8477. * M (input) INTEGER
  8478. * The number of rows of the matrix C. M >= 0.
  8479. *
  8480. * N (input) INTEGER
  8481. * The number of columns of the matrix C. N >= 0.
  8482. *
  8483. * K (input) INTEGER
  8484. * The number of elementary reflectors whose product defines
  8485. * the matrix Q.
  8486. * If SIDE = 'L', M >= K >= 0;
  8487. * if SIDE = 'R', N >= K >= 0.
  8488. *
  8489. * A (input) DOUBLE PRECISION array, dimension
  8490. * (LDA,M) if SIDE = 'L',
  8491. * (LDA,N) if SIDE = 'R'
  8492. * The i-th row must contain the vector which defines the
  8493. * elementary reflector H(i), for i = 1,2,...,k, as returned by
  8494. * DGELQF in the first k rows of its array argument A.
  8495. * A is modified by the routine but restored on exit.
  8496. *
  8497. * LDA (input) INTEGER
  8498. * The leading dimension of the array A. LDA >= max(1,K).
  8499. *
  8500. * TAU (input) DOUBLE PRECISION array, dimension (K)
  8501. * TAU(i) must contain the scalar factor of the elementary
  8502. * reflector H(i), as returned by DGELQF.
  8503. *
  8504. * C (input/output) DOUBLE PRECISION array, dimension (LDC,N)
  8505. * On entry, the M-by-N matrix C.
  8506. * On exit, C is overwritten by Q*C or Q**T*C or C*Q**T or C*Q.
  8507. *
  8508. * LDC (input) INTEGER
  8509. * The leading dimension of the array C. LDC >= max(1,M).
  8510. *
  8511. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  8512. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  8513. *
  8514. * LWORK (input) INTEGER
  8515. * The dimension of the array WORK.
  8516. * If SIDE = 'L', LWORK >= max(1,N);
  8517. * if SIDE = 'R', LWORK >= max(1,M).
  8518. * For optimum performance LWORK >= N*NB if SIDE = 'L', and
  8519. * LWORK >= M*NB if SIDE = 'R', where NB is the optimal
  8520. * blocksize.
  8521. *
  8522. * If LWORK = -1, then a workspace query is assumed; the routine
  8523. * only calculates the optimal size of the WORK array, returns
  8524. * this value as the first entry of the WORK array, and no error
  8525. * message related to LWORK is issued by XERBLA.
  8526. *
  8527. * C++ Return value: INFO (output) INTEGER
  8528. * = 0: successful exit
  8529. * < 0: if INFO = -i, the i-th argument had an illegal value
  8530. *
  8531. * =====================================================================
  8532. *
  8533. * .. Parameters ..
  8534. **/
  8535. int C_DORMLQ(char side, char trans, int m, int n, int k, double* a, int lda, double* tau, double* c, int ldc, double* work, int lwork)
  8536. {
  8537. int info;
  8538. ::F_DORMLQ(&side, &trans, &m, &n, &k, a, &lda, tau, c, &ldc, work, &lwork, &info);
  8539. return info;
  8540. }
  8541. /**
  8542. * Purpose
  8543. * =======
  8544. *
  8545. * DORMQL overwrites the general real M-by-N matrix C with
  8546. *
  8547. * SIDE = 'L' SIDE = 'R'
  8548. * TRANS = 'N': Q * C C * Q
  8549. * TRANS = 'T': Q**T * C C * Q**T
  8550. *
  8551. * where Q is a real orthogonal matrix defined as the product of k
  8552. * elementary reflectors
  8553. *
  8554. * Q = H(k) . . . H(2) H(1)
  8555. *
  8556. * as returned by DGEQLF. Q is of order M if SIDE = 'L' and of order N
  8557. * if SIDE = 'R'.
  8558. *
  8559. * Arguments
  8560. * =========
  8561. *
  8562. * SIDE (input) CHARACTER*1
  8563. * = 'L': apply Q or Q**T from the Left;
  8564. * = 'R': apply Q or Q**T from the Right.
  8565. *
  8566. * TRANS (input) CHARACTER*1
  8567. * = 'N': No transpose, apply Q;
  8568. * = 'T': Transpose, apply Q**T.
  8569. *
  8570. * M (input) INTEGER
  8571. * The number of rows of the matrix C. M >= 0.
  8572. *
  8573. * N (input) INTEGER
  8574. * The number of columns of the matrix C. N >= 0.
  8575. *
  8576. * K (input) INTEGER
  8577. * The number of elementary reflectors whose product defines
  8578. * the matrix Q.
  8579. * If SIDE = 'L', M >= K >= 0;
  8580. * if SIDE = 'R', N >= K >= 0.
  8581. *
  8582. * A (input) DOUBLE PRECISION array, dimension (LDA,K)
  8583. * The i-th column must contain the vector which defines the
  8584. * elementary reflector H(i), for i = 1,2,...,k, as returned by
  8585. * DGEQLF in the last k columns of its array argument A.
  8586. * A is modified by the routine but restored on exit.
  8587. *
  8588. * LDA (input) INTEGER
  8589. * The leading dimension of the array A.
  8590. * If SIDE = 'L', LDA >= max(1,M);
  8591. * if SIDE = 'R', LDA >= max(1,N).
  8592. *
  8593. * TAU (input) DOUBLE PRECISION array, dimension (K)
  8594. * TAU(i) must contain the scalar factor of the elementary
  8595. * reflector H(i), as returned by DGEQLF.
  8596. *
  8597. * C (input/output) DOUBLE PRECISION array, dimension (LDC,N)
  8598. * On entry, the M-by-N matrix C.
  8599. * On exit, C is overwritten by Q*C or Q**T*C or C*Q**T or C*Q.
  8600. *
  8601. * LDC (input) INTEGER
  8602. * The leading dimension of the array C. LDC >= max(1,M).
  8603. *
  8604. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  8605. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  8606. *
  8607. * LWORK (input) INTEGER
  8608. * The dimension of the array WORK.
  8609. * If SIDE = 'L', LWORK >= max(1,N);
  8610. * if SIDE = 'R', LWORK >= max(1,M).
  8611. * For optimum performance LWORK >= N*NB if SIDE = 'L', and
  8612. * LWORK >= M*NB if SIDE = 'R', where NB is the optimal
  8613. * blocksize.
  8614. *
  8615. * If LWORK = -1, then a workspace query is assumed; the routine
  8616. * only calculates the optimal size of the WORK array, returns
  8617. * this value as the first entry of the WORK array, and no error
  8618. * message related to LWORK is issued by XERBLA.
  8619. *
  8620. * C++ Return value: INFO (output) INTEGER
  8621. * = 0: successful exit
  8622. * < 0: if INFO = -i, the i-th argument had an illegal value
  8623. *
  8624. * =====================================================================
  8625. *
  8626. * .. Parameters ..
  8627. **/
  8628. int C_DORMQL(char side, char trans, int m, int n, int k, double* a, int lda, double* tau, double* c, int ldc, double* work, int lwork)
  8629. {
  8630. int info;
  8631. ::F_DORMQL(&side, &trans, &m, &n, &k, a, &lda, tau, c, &ldc, work, &lwork, &info);
  8632. return info;
  8633. }
  8634. /**
  8635. * Purpose
  8636. * =======
  8637. *
  8638. * DORMQR overwrites the general real M-by-N matrix C with
  8639. *
  8640. * SIDE = 'L' SIDE = 'R'
  8641. * TRANS = 'N': Q * C C * Q
  8642. * TRANS = 'T': Q**T * C C * Q**T
  8643. *
  8644. * where Q is a real orthogonal matrix defined as the product of k
  8645. * elementary reflectors
  8646. *
  8647. * Q = H(1) H(2) . . . H(k)
  8648. *
  8649. * as returned by DGEQRF. Q is of order M if SIDE = 'L' and of order N
  8650. * if SIDE = 'R'.
  8651. *
  8652. * Arguments
  8653. * =========
  8654. *
  8655. * SIDE (input) CHARACTER*1
  8656. * = 'L': apply Q or Q**T from the Left;
  8657. * = 'R': apply Q or Q**T from the Right.
  8658. *
  8659. * TRANS (input) CHARACTER*1
  8660. * = 'N': No transpose, apply Q;
  8661. * = 'T': Transpose, apply Q**T.
  8662. *
  8663. * M (input) INTEGER
  8664. * The number of rows of the matrix C. M >= 0.
  8665. *
  8666. * N (input) INTEGER
  8667. * The number of columns of the matrix C. N >= 0.
  8668. *
  8669. * K (input) INTEGER
  8670. * The number of elementary reflectors whose product defines
  8671. * the matrix Q.
  8672. * If SIDE = 'L', M >= K >= 0;
  8673. * if SIDE = 'R', N >= K >= 0.
  8674. *
  8675. * A (input) DOUBLE PRECISION array, dimension (LDA,K)
  8676. * The i-th column must contain the vector which defines the
  8677. * elementary reflector H(i), for i = 1,2,...,k, as returned by
  8678. * DGEQRF in the first k columns of its array argument A.
  8679. * A is modified by the routine but restored on exit.
  8680. *
  8681. * LDA (input) INTEGER
  8682. * The leading dimension of the array A.
  8683. * If SIDE = 'L', LDA >= max(1,M);
  8684. * if SIDE = 'R', LDA >= max(1,N).
  8685. *
  8686. * TAU (input) DOUBLE PRECISION array, dimension (K)
  8687. * TAU(i) must contain the scalar factor of the elementary
  8688. * reflector H(i), as returned by DGEQRF.
  8689. *
  8690. * C (input/output) DOUBLE PRECISION array, dimension (LDC,N)
  8691. * On entry, the M-by-N matrix C.
  8692. * On exit, C is overwritten by Q*C or Q**T*C or C*Q**T or C*Q.
  8693. *
  8694. * LDC (input) INTEGER
  8695. * The leading dimension of the array C. LDC >= max(1,M).
  8696. *
  8697. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  8698. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  8699. *
  8700. * LWORK (input) INTEGER
  8701. * The dimension of the array WORK.
  8702. * If SIDE = 'L', LWORK >= max(1,N);
  8703. * if SIDE = 'R', LWORK >= max(1,M).
  8704. * For optimum performance LWORK >= N*NB if SIDE = 'L', and
  8705. * LWORK >= M*NB if SIDE = 'R', where NB is the optimal
  8706. * blocksize.
  8707. *
  8708. * If LWORK = -1, then a workspace query is assumed; the routine
  8709. * only calculates the optimal size of the WORK array, returns
  8710. * this value as the first entry of the WORK array, and no error
  8711. * message related to LWORK is issued by XERBLA.
  8712. *
  8713. * C++ Return value: INFO (output) INTEGER
  8714. * = 0: successful exit
  8715. * < 0: if INFO = -i, the i-th argument had an illegal value
  8716. *
  8717. * =====================================================================
  8718. *
  8719. * .. Parameters ..
  8720. **/
  8721. int C_DORMQR(char side, char trans, int m, int n, int k, double* a, int lda, double* tau, double* c, int ldc, double* work, int lwork)
  8722. {
  8723. int info;
  8724. ::F_DORMQR(&side, &trans, &m, &n, &k, a, &lda, tau, c, &ldc, work, &lwork, &info);
  8725. return info;
  8726. }
  8727. /**
  8728. * Purpose
  8729. * =======
  8730. *
  8731. * DORMR3 overwrites the general real m by n matrix C with
  8732. *
  8733. * Q * C if SIDE = 'L' and TRANS = 'N', or
  8734. *
  8735. * Q'* C if SIDE = 'L' and TRANS = 'T', or
  8736. *
  8737. * C * Q if SIDE = 'R' and TRANS = 'N', or
  8738. *
  8739. * C * Q' if SIDE = 'R' and TRANS = 'T',
  8740. *
  8741. * where Q is a real orthogonal matrix defined as the product of k
  8742. * elementary reflectors
  8743. *
  8744. * Q = H(1) H(2) . . . H(k)
  8745. *
  8746. * as returned by DTZRZF. Q is of order m if SIDE = 'L' and of order n
  8747. * if SIDE = 'R'.
  8748. *
  8749. * Arguments
  8750. * =========
  8751. *
  8752. * SIDE (input) CHARACTER*1
  8753. * = 'L': apply Q or Q' from the Left
  8754. * = 'R': apply Q or Q' from the Right
  8755. *
  8756. * TRANS (input) CHARACTER*1
  8757. * = 'N': apply Q (No transpose)
  8758. * = 'T': apply Q' (Transpose)
  8759. *
  8760. * M (input) INTEGER
  8761. * The number of rows of the matrix C. M >= 0.
  8762. *
  8763. * N (input) INTEGER
  8764. * The number of columns of the matrix C. N >= 0.
  8765. *
  8766. * K (input) INTEGER
  8767. * The number of elementary reflectors whose product defines
  8768. * the matrix Q.
  8769. * If SIDE = 'L', M >= K >= 0;
  8770. * if SIDE = 'R', N >= K >= 0.
  8771. *
  8772. * L (input) INTEGER
  8773. * The number of columns of the matrix A containing
  8774. * the meaningful part of the Householder reflectors.
  8775. * If SIDE = 'L', M >= L >= 0, if SIDE = 'R', N >= L >= 0.
  8776. *
  8777. * A (input) DOUBLE PRECISION array, dimension
  8778. * (LDA,M) if SIDE = 'L',
  8779. * (LDA,N) if SIDE = 'R'
  8780. * The i-th row must contain the vector which defines the
  8781. * elementary reflector H(i), for i = 1,2,...,k, as returned by
  8782. * DTZRZF in the last k rows of its array argument A.
  8783. * A is modified by the routine but restored on exit.
  8784. *
  8785. * LDA (input) INTEGER
  8786. * The leading dimension of the array A. LDA >= max(1,K).
  8787. *
  8788. * TAU (input) DOUBLE PRECISION array, dimension (K)
  8789. * TAU(i) must contain the scalar factor of the elementary
  8790. * reflector H(i), as returned by DTZRZF.
  8791. *
  8792. * C (input/output) DOUBLE PRECISION array, dimension (LDC,N)
  8793. * On entry, the m-by-n matrix C.
  8794. * On exit, C is overwritten by Q*C or Q'*C or C*Q' or C*Q.
  8795. *
  8796. * LDC (input) INTEGER
  8797. * The leading dimension of the array C. LDC >= max(1,M).
  8798. *
  8799. * WORK (workspace) DOUBLE PRECISION array, dimension
  8800. * (N) if SIDE = 'L',
  8801. * (M) if SIDE = 'R'
  8802. *
  8803. * C++ Return value: INFO (output) INTEGER
  8804. * = 0: successful exit
  8805. * < 0: if INFO = -i, the i-th argument had an illegal value
  8806. *
  8807. * Further Details
  8808. * ===============
  8809. *
  8810. * Based on contributions by
  8811. * A. Petitet, Computer Science Dept., Univ. of Tenn., Knoxville, USA
  8812. *
  8813. * =====================================================================
  8814. *
  8815. * .. Local Scalars ..
  8816. **/
  8817. int C_DORMR3(char side, char trans, int m, int n, int k, int l, double* a, int lda, double* tau, double* c, int ldc, double* work)
  8818. {
  8819. int info;
  8820. ::F_DORMR3(&side, &trans, &m, &n, &k, &l, a, &lda, tau, c, &ldc, work, &info);
  8821. return info;
  8822. }
  8823. /**
  8824. * Purpose
  8825. * =======
  8826. *
  8827. * DORMRQ overwrites the general real M-by-N matrix C with
  8828. *
  8829. * SIDE = 'L' SIDE = 'R'
  8830. * TRANS = 'N': Q * C C * Q
  8831. * TRANS = 'T': Q**T * C C * Q**T
  8832. *
  8833. * where Q is a real orthogonal matrix defined as the product of k
  8834. * elementary reflectors
  8835. *
  8836. * Q = H(1) H(2) . . . H(k)
  8837. *
  8838. * as returned by DGERQF. Q is of order M if SIDE = 'L' and of order N
  8839. * if SIDE = 'R'.
  8840. *
  8841. * Arguments
  8842. * =========
  8843. *
  8844. * SIDE (input) CHARACTER*1
  8845. * = 'L': apply Q or Q**T from the Left;
  8846. * = 'R': apply Q or Q**T from the Right.
  8847. *
  8848. * TRANS (input) CHARACTER*1
  8849. * = 'N': No transpose, apply Q;
  8850. * = 'T': Transpose, apply Q**T.
  8851. *
  8852. * M (input) INTEGER
  8853. * The number of rows of the matrix C. M >= 0.
  8854. *
  8855. * N (input) INTEGER
  8856. * The number of columns of the matrix C. N >= 0.
  8857. *
  8858. * K (input) INTEGER
  8859. * The number of elementary reflectors whose product defines
  8860. * the matrix Q.
  8861. * If SIDE = 'L', M >= K >= 0;
  8862. * if SIDE = 'R', N >= K >= 0.
  8863. *
  8864. * A (input) DOUBLE PRECISION array, dimension
  8865. * (LDA,M) if SIDE = 'L',
  8866. * (LDA,N) if SIDE = 'R'
  8867. * The i-th row must contain the vector which defines the
  8868. * elementary reflector H(i), for i = 1,2,...,k, as returned by
  8869. * DGERQF in the last k rows of its array argument A.
  8870. * A is modified by the routine but restored on exit.
  8871. *
  8872. * LDA (input) INTEGER
  8873. * The leading dimension of the array A. LDA >= max(1,K).
  8874. *
  8875. * TAU (input) DOUBLE PRECISION array, dimension (K)
  8876. * TAU(i) must contain the scalar factor of the elementary
  8877. * reflector H(i), as returned by DGERQF.
  8878. *
  8879. * C (input/output) DOUBLE PRECISION array, dimension (LDC,N)
  8880. * On entry, the M-by-N matrix C.
  8881. * On exit, C is overwritten by Q*C or Q**T*C or C*Q**T or C*Q.
  8882. *
  8883. * LDC (input) INTEGER
  8884. * The leading dimension of the array C. LDC >= max(1,M).
  8885. *
  8886. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  8887. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  8888. *
  8889. * LWORK (input) INTEGER
  8890. * The dimension of the array WORK.
  8891. * If SIDE = 'L', LWORK >= max(1,N);
  8892. * if SIDE = 'R', LWORK >= max(1,M).
  8893. * For optimum performance LWORK >= N*NB if SIDE = 'L', and
  8894. * LWORK >= M*NB if SIDE = 'R', where NB is the optimal
  8895. * blocksize.
  8896. *
  8897. * If LWORK = -1, then a workspace query is assumed; the routine
  8898. * only calculates the optimal size of the WORK array, returns
  8899. * this value as the first entry of the WORK array, and no error
  8900. * message related to LWORK is issued by XERBLA.
  8901. *
  8902. * C++ Return value: INFO (output) INTEGER
  8903. * = 0: successful exit
  8904. * < 0: if INFO = -i, the i-th argument had an illegal value
  8905. *
  8906. * =====================================================================
  8907. *
  8908. * .. Parameters ..
  8909. **/
  8910. int C_DORMRQ(char side, char trans, int m, int n, int k, double* a, int lda, double* tau, double* c, int ldc, double* work, int lwork)
  8911. {
  8912. int info;
  8913. ::F_DORMRQ(&side, &trans, &m, &n, &k, a, &lda, tau, c, &ldc, work, &lwork, &info);
  8914. return info;
  8915. }
  8916. /**
  8917. * Purpose
  8918. * =======
  8919. *
  8920. * DORMRZ overwrites the general real M-by-N matrix C with
  8921. *
  8922. * SIDE = 'L' SIDE = 'R'
  8923. * TRANS = 'N': Q * C C * Q
  8924. * TRANS = 'T': Q**T * C C * Q**T
  8925. *
  8926. * where Q is a real orthogonal matrix defined as the product of k
  8927. * elementary reflectors
  8928. *
  8929. * Q = H(1) H(2) . . . H(k)
  8930. *
  8931. * as returned by DTZRZF. Q is of order M if SIDE = 'L' and of order N
  8932. * if SIDE = 'R'.
  8933. *
  8934. * Arguments
  8935. * =========
  8936. *
  8937. * SIDE (input) CHARACTER*1
  8938. * = 'L': apply Q or Q**T from the Left;
  8939. * = 'R': apply Q or Q**T from the Right.
  8940. *
  8941. * TRANS (input) CHARACTER*1
  8942. * = 'N': No transpose, apply Q;
  8943. * = 'T': Transpose, apply Q**T.
  8944. *
  8945. * M (input) INTEGER
  8946. * The number of rows of the matrix C. M >= 0.
  8947. *
  8948. * N (input) INTEGER
  8949. * The number of columns of the matrix C. N >= 0.
  8950. *
  8951. * K (input) INTEGER
  8952. * The number of elementary reflectors whose product defines
  8953. * the matrix Q.
  8954. * If SIDE = 'L', M >= K >= 0;
  8955. * if SIDE = 'R', N >= K >= 0.
  8956. *
  8957. * L (input) INTEGER
  8958. * The number of columns of the matrix A containing
  8959. * the meaningful part of the Householder reflectors.
  8960. * If SIDE = 'L', M >= L >= 0, if SIDE = 'R', N >= L >= 0.
  8961. *
  8962. * A (input) DOUBLE PRECISION array, dimension
  8963. * (LDA,M) if SIDE = 'L',
  8964. * (LDA,N) if SIDE = 'R'
  8965. * The i-th row must contain the vector which defines the
  8966. * elementary reflector H(i), for i = 1,2,...,k, as returned by
  8967. * DTZRZF in the last k rows of its array argument A.
  8968. * A is modified by the routine but restored on exit.
  8969. *
  8970. * LDA (input) INTEGER
  8971. * The leading dimension of the array A. LDA >= max(1,K).
  8972. *
  8973. * TAU (input) DOUBLE PRECISION array, dimension (K)
  8974. * TAU(i) must contain the scalar factor of the elementary
  8975. * reflector H(i), as returned by DTZRZF.
  8976. *
  8977. * C (input/output) DOUBLE PRECISION array, dimension (LDC,N)
  8978. * On entry, the M-by-N matrix C.
  8979. * On exit, C is overwritten by Q*C or Q**H*C or C*Q**H or C*Q.
  8980. *
  8981. * LDC (input) INTEGER
  8982. * The leading dimension of the array C. LDC >= max(1,M).
  8983. *
  8984. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  8985. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  8986. *
  8987. * LWORK (input) INTEGER
  8988. * The dimension of the array WORK.
  8989. * If SIDE = 'L', LWORK >= max(1,N);
  8990. * if SIDE = 'R', LWORK >= max(1,M).
  8991. * For optimum performance LWORK >= N*NB if SIDE = 'L', and
  8992. * LWORK >= M*NB if SIDE = 'R', where NB is the optimal
  8993. * blocksize.
  8994. *
  8995. * If LWORK = -1, then a workspace query is assumed; the routine
  8996. * only calculates the optimal size of the WORK array, returns
  8997. * this value as the first entry of the WORK array, and no error
  8998. * message related to LWORK is issued by XERBLA.
  8999. *
  9000. * C++ Return value: INFO (output) INTEGER
  9001. * = 0: successful exit
  9002. * < 0: if INFO = -i, the i-th argument had an illegal value
  9003. *
  9004. * Further Details
  9005. * ===============
  9006. *
  9007. * Based on contributions by
  9008. * A. Petitet, Computer Science Dept., Univ. of Tenn., Knoxville, USA
  9009. *
  9010. * =====================================================================
  9011. *
  9012. * .. Parameters ..
  9013. **/
  9014. int C_DORMRZ(char side, char trans, int m, int n, int k, int l, double* a, int lda, double* tau, double* c, int ldc, double* work, int lwork)
  9015. {
  9016. int info;
  9017. ::F_DORMRZ(&side, &trans, &m, &n, &k, &l, a, &lda, tau, c, &ldc, work, &lwork, &info);
  9018. return info;
  9019. }
  9020. /**
  9021. * Purpose
  9022. * =======
  9023. *
  9024. * DORMTR overwrites the general real M-by-N matrix C with
  9025. *
  9026. * SIDE = 'L' SIDE = 'R'
  9027. * TRANS = 'N': Q * C C * Q
  9028. * TRANS = 'T': Q**T * C C * Q**T
  9029. *
  9030. * where Q is a real orthogonal matrix of order nq, with nq = m if
  9031. * SIDE = 'L' and nq = n if SIDE = 'R'. Q is defined as the product of
  9032. * nq-1 elementary reflectors, as returned by DSYTRD:
  9033. *
  9034. * if UPLO = 'U', Q = H(nq-1) . . . H(2) H(1);
  9035. *
  9036. * if UPLO = 'L', Q = H(1) H(2) . . . H(nq-1).
  9037. *
  9038. * Arguments
  9039. * =========
  9040. *
  9041. * SIDE (input) CHARACTER*1
  9042. * = 'L': apply Q or Q**T from the Left;
  9043. * = 'R': apply Q or Q**T from the Right.
  9044. *
  9045. * UPLO (input) CHARACTER*1
  9046. * = 'U': Upper triangle of A contains elementary reflectors
  9047. * from DSYTRD;
  9048. * = 'L': Lower triangle of A contains elementary reflectors
  9049. * from DSYTRD.
  9050. *
  9051. * TRANS (input) CHARACTER*1
  9052. * = 'N': No transpose, apply Q;
  9053. * = 'T': Transpose, apply Q**T.
  9054. *
  9055. * M (input) INTEGER
  9056. * The number of rows of the matrix C. M >= 0.
  9057. *
  9058. * N (input) INTEGER
  9059. * The number of columns of the matrix C. N >= 0.
  9060. *
  9061. * A (input) DOUBLE PRECISION array, dimension
  9062. * (LDA,M) if SIDE = 'L'
  9063. * (LDA,N) if SIDE = 'R'
  9064. * The vectors which define the elementary reflectors, as
  9065. * returned by DSYTRD.
  9066. *
  9067. * LDA (input) INTEGER
  9068. * The leading dimension of the array A.
  9069. * LDA >= max(1,M) if SIDE = 'L'; LDA >= max(1,N) if SIDE = 'R'.
  9070. *
  9071. * TAU (input) DOUBLE PRECISION array, dimension
  9072. * (M-1) if SIDE = 'L'
  9073. * (N-1) if SIDE = 'R'
  9074. * TAU(i) must contain the scalar factor of the elementary
  9075. * reflector H(i), as returned by DSYTRD.
  9076. *
  9077. * C (input/output) DOUBLE PRECISION array, dimension (LDC,N)
  9078. * On entry, the M-by-N matrix C.
  9079. * On exit, C is overwritten by Q*C or Q**T*C or C*Q**T or C*Q.
  9080. *
  9081. * LDC (input) INTEGER
  9082. * The leading dimension of the array C. LDC >= max(1,M).
  9083. *
  9084. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  9085. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  9086. *
  9087. * LWORK (input) INTEGER
  9088. * The dimension of the array WORK.
  9089. * If SIDE = 'L', LWORK >= max(1,N);
  9090. * if SIDE = 'R', LWORK >= max(1,M).
  9091. * For optimum performance LWORK >= N*NB if SIDE = 'L', and
  9092. * LWORK >= M*NB if SIDE = 'R', where NB is the optimal
  9093. * blocksize.
  9094. *
  9095. * If LWORK = -1, then a workspace query is assumed; the routine
  9096. * only calculates the optimal size of the WORK array, returns
  9097. * this value as the first entry of the WORK array, and no error
  9098. * message related to LWORK is issued by XERBLA.
  9099. *
  9100. * C++ Return value: INFO (output) INTEGER
  9101. * = 0: successful exit
  9102. * < 0: if INFO = -i, the i-th argument had an illegal value
  9103. *
  9104. * =====================================================================
  9105. *
  9106. * .. Local Scalars ..
  9107. **/
  9108. int C_DORMTR(char side, char uplo, char trans, int m, int n, double* a, int lda, double* tau, double* c, int ldc, double* work, int lwork)
  9109. {
  9110. int info;
  9111. ::F_DORMTR(&side, &uplo, &trans, &m, &n, a, &lda, tau, c, &ldc, work, &lwork, &info);
  9112. return info;
  9113. }
  9114. /**
  9115. * Purpose
  9116. * =======
  9117. *
  9118. * DPBCON estimates the reciprocal of the condition number (in the
  9119. * 1-norm) of a real symmetric positive definite band matrix using the
  9120. * Cholesky factorization A = U**T*U or A = L*L**T computed by DPBTRF.
  9121. *
  9122. * An estimate is obtained for norm(inv(A)), and the reciprocal of the
  9123. * condition number is computed as RCOND = 1 / (ANORM * norm(inv(A))).
  9124. *
  9125. * Arguments
  9126. * =========
  9127. *
  9128. * UPLO (input) CHARACTER*1
  9129. * = 'U': Upper triangular factor stored in AB;
  9130. * = 'L': Lower triangular factor stored in AB.
  9131. *
  9132. * N (input) INTEGER
  9133. * The order of the matrix A. N >= 0.
  9134. *
  9135. * KD (input) INTEGER
  9136. * The number of superdiagonals of the matrix A if UPLO = 'U',
  9137. * or the number of subdiagonals if UPLO = 'L'. KD >= 0.
  9138. *
  9139. * AB (input) DOUBLE PRECISION array, dimension (LDAB,N)
  9140. * The triangular factor U or L from the Cholesky factorization
  9141. * A = U**T*U or A = L*L**T of the band matrix A, stored in the
  9142. * first KD+1 rows of the array. The j-th column of U or L is
  9143. * stored in the j-th column of the array AB as follows:
  9144. * if UPLO ='U', AB(kd+1+i-j,j) = U(i,j) for max(1,j-kd)<=i<=j;
  9145. * if UPLO ='L', AB(1+i-j,j) = L(i,j) for j<=i<=min(n,j+kd).
  9146. *
  9147. * LDAB (input) INTEGER
  9148. * The leading dimension of the array AB. LDAB >= KD+1.
  9149. *
  9150. * ANORM (input) DOUBLE PRECISION
  9151. * The 1-norm (or infinity-norm) of the symmetric band matrix A.
  9152. *
  9153. * RCOND (output) DOUBLE PRECISION
  9154. * The reciprocal of the condition number of the matrix A,
  9155. * computed as RCOND = 1/(ANORM * AINVNM), where AINVNM is an
  9156. * estimate of the 1-norm of inv(A) computed in this routine.
  9157. *
  9158. * WORK (workspace) DOUBLE PRECISION array, dimension (3*N)
  9159. *
  9160. * IWORK (workspace) INTEGER array, dimension (N)
  9161. *
  9162. * C++ Return value: INFO (output) INTEGER
  9163. * = 0: successful exit
  9164. * < 0: if INFO = -i, the i-th argument had an illegal value
  9165. *
  9166. * =====================================================================
  9167. *
  9168. * .. Parameters ..
  9169. **/
  9170. int C_DPBCON(char uplo, int n, int kd, double* ab, int ldab, double anorm, double* rcond, double* work, int* iwork)
  9171. {
  9172. int info;
  9173. ::F_DPBCON(&uplo, &n, &kd, ab, &ldab, &anorm, rcond, work, iwork, &info);
  9174. return info;
  9175. }
  9176. /**
  9177. * Purpose
  9178. * =======
  9179. *
  9180. * DPBEQU computes row and column scalings intended to equilibrate a
  9181. * symmetric positive definite band matrix A and reduce its condition
  9182. * number (with respect to the two-norm). S contains the scale factors,
  9183. * S(i) = 1/sqrt(A(i,i)), chosen so that the scaled matrix B with
  9184. * elements B(i,j) = S(i)*A(i,j)*S(j) has ones on the diagonal. This
  9185. * choice of S puts the condition number of B within a factor N of the
  9186. * smallest possible condition number over all possible diagonal
  9187. * scalings.
  9188. *
  9189. * Arguments
  9190. * =========
  9191. *
  9192. * UPLO (input) CHARACTER*1
  9193. * = 'U': Upper triangular of A is stored;
  9194. * = 'L': Lower triangular of A is stored.
  9195. *
  9196. * N (input) INTEGER
  9197. * The order of the matrix A. N >= 0.
  9198. *
  9199. * KD (input) INTEGER
  9200. * The number of superdiagonals of the matrix A if UPLO = 'U',
  9201. * or the number of subdiagonals if UPLO = 'L'. KD >= 0.
  9202. *
  9203. * AB (input) DOUBLE PRECISION array, dimension (LDAB,N)
  9204. * The upper or lower triangle of the symmetric band matrix A,
  9205. * stored in the first KD+1 rows of the array. The j-th column
  9206. * of A is stored in the j-th column of the array AB as follows:
  9207. * if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
  9208. * if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd).
  9209. *
  9210. * LDAB (input) INTEGER
  9211. * The leading dimension of the array A. LDAB >= KD+1.
  9212. *
  9213. * S (output) DOUBLE PRECISION array, dimension (N)
  9214. * If INFO = 0, S contains the scale factors for A.
  9215. *
  9216. * SCOND (output) DOUBLE PRECISION
  9217. * If INFO = 0, S contains the ratio of the smallest S(i) to
  9218. * the largest S(i). If SCOND >= 0.1 and AMAX is neither too
  9219. * large nor too small, it is not worth scaling by S.
  9220. *
  9221. * AMAX (output) DOUBLE PRECISION
  9222. * Absolute value of largest matrix element. If AMAX is very
  9223. * close to overflow or very close to underflow, the matrix
  9224. * should be scaled.
  9225. *
  9226. * C++ Return value: INFO (output) INTEGER
  9227. * = 0: successful exit
  9228. * < 0: if INFO = -i, the i-th argument had an illegal value.
  9229. * > 0: if INFO = i, the i-th diagonal element is nonpositive.
  9230. *
  9231. * =====================================================================
  9232. *
  9233. * .. Parameters ..
  9234. **/
  9235. int C_DPBEQU(char uplo, int n, int kd, double* ab, int ldab, double* s, double* scond, double* amax)
  9236. {
  9237. int info;
  9238. ::F_DPBEQU(&uplo, &n, &kd, ab, &ldab, s, scond, amax, &info);
  9239. return info;
  9240. }
  9241. /**
  9242. * Purpose
  9243. * =======
  9244. *
  9245. * DPBRFS improves the computed solution to a system of linear
  9246. * equations when the coefficient matrix is symmetric positive definite
  9247. * and banded, and provides error bounds and backward error estimates
  9248. * for the solution.
  9249. *
  9250. * Arguments
  9251. * =========
  9252. *
  9253. * UPLO (input) CHARACTER*1
  9254. * = 'U': Upper triangle of A is stored;
  9255. * = 'L': Lower triangle of A is stored.
  9256. *
  9257. * N (input) INTEGER
  9258. * The order of the matrix A. N >= 0.
  9259. *
  9260. * KD (input) INTEGER
  9261. * The number of superdiagonals of the matrix A if UPLO = 'U',
  9262. * or the number of subdiagonals if UPLO = 'L'. KD >= 0.
  9263. *
  9264. * NRHS (input) INTEGER
  9265. * The number of right hand sides, i.e., the number of columns
  9266. * of the matrices B and X. NRHS >= 0.
  9267. *
  9268. * AB (input) DOUBLE PRECISION array, dimension (LDAB,N)
  9269. * The upper or lower triangle of the symmetric band matrix A,
  9270. * stored in the first KD+1 rows of the array. The j-th column
  9271. * of A is stored in the j-th column of the array AB as follows:
  9272. * if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
  9273. * if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd).
  9274. *
  9275. * LDAB (input) INTEGER
  9276. * The leading dimension of the array AB. LDAB >= KD+1.
  9277. *
  9278. * AFB (input) DOUBLE PRECISION array, dimension (LDAFB,N)
  9279. * The triangular factor U or L from the Cholesky factorization
  9280. * A = U**T*U or A = L*L**T of the band matrix A as computed by
  9281. * DPBTRF, in the same storage format as A (see AB).
  9282. *
  9283. * LDAFB (input) INTEGER
  9284. * The leading dimension of the array AFB. LDAFB >= KD+1.
  9285. *
  9286. * B (input) DOUBLE PRECISION array, dimension (LDB,NRHS)
  9287. * The right hand side matrix B.
  9288. *
  9289. * LDB (input) INTEGER
  9290. * The leading dimension of the array B. LDB >= max(1,N).
  9291. *
  9292. * X (input/output) DOUBLE PRECISION array, dimension (LDX,NRHS)
  9293. * On entry, the solution matrix X, as computed by DPBTRS.
  9294. * On exit, the improved solution matrix X.
  9295. *
  9296. * LDX (input) INTEGER
  9297. * The leading dimension of the array X. LDX >= max(1,N).
  9298. *
  9299. * FERR (output) DOUBLE PRECISION array, dimension (NRHS)
  9300. * The estimated forward error bound for each solution vector
  9301. * X(j) (the j-th column of the solution matrix X).
  9302. * If XTRUE is the true solution corresponding to X(j), FERR(j)
  9303. * is an estimated upper bound for the magnitude of the largest
  9304. * element in (X(j) - XTRUE) divided by the magnitude of the
  9305. * largest element in X(j). The estimate is as reliable as
  9306. * the estimate for RCOND, and is almost always a slight
  9307. * overestimate of the true error.
  9308. *
  9309. * BERR (output) DOUBLE PRECISION array, dimension (NRHS)
  9310. * The componentwise relative backward error of each solution
  9311. * vector X(j) (i.e., the smallest relative change in
  9312. * any element of A or B that makes X(j) an exact solution).
  9313. *
  9314. * WORK (workspace) DOUBLE PRECISION array, dimension (3*N)
  9315. *
  9316. * IWORK (workspace) INTEGER array, dimension (N)
  9317. *
  9318. * C++ Return value: INFO (output) INTEGER
  9319. * = 0: successful exit
  9320. * < 0: if INFO = -i, the i-th argument had an illegal value
  9321. *
  9322. * Internal Parameters
  9323. * ===================
  9324. *
  9325. * ITMAX is the maximum number of steps of iterative refinement.
  9326. *
  9327. * =====================================================================
  9328. *
  9329. * .. Parameters ..
  9330. **/
  9331. int C_DPBRFS(char uplo, int n, int kd, int nrhs, double* ab, int ldab, double* afb, int ldafb, double* b, int ldb, double* x, int ldx, double* ferr, double* berr, double* work, int* iwork)
  9332. {
  9333. int info;
  9334. ::F_DPBRFS(&uplo, &n, &kd, &nrhs, ab, &ldab, afb, &ldafb, b, &ldb, x, &ldx, ferr, berr, work, iwork, &info);
  9335. return info;
  9336. }
  9337. /**
  9338. * Purpose
  9339. * =======
  9340. *
  9341. * DPBSTF computes a split Cholesky factorization of a real
  9342. * symmetric positive definite band matrix A.
  9343. *
  9344. * This routine is designed to be used in conjunction with DSBGST.
  9345. *
  9346. * The factorization has the form A = S**T*S where S is a band matrix
  9347. * of the same bandwidth as A and the following structure:
  9348. *
  9349. * S = ( U )
  9350. * ( M L )
  9351. *
  9352. * where U is upper triangular of order m = (n+kd)/2, and L is lower
  9353. * triangular of order n-m.
  9354. *
  9355. * Arguments
  9356. * =========
  9357. *
  9358. * UPLO (input) CHARACTER*1
  9359. * = 'U': Upper triangle of A is stored;
  9360. * = 'L': Lower triangle of A is stored.
  9361. *
  9362. * N (input) INTEGER
  9363. * The order of the matrix A. N >= 0.
  9364. *
  9365. * KD (input) INTEGER
  9366. * The number of superdiagonals of the matrix A if UPLO = 'U',
  9367. * or the number of subdiagonals if UPLO = 'L'. KD >= 0.
  9368. *
  9369. * AB (input/output) DOUBLE PRECISION array, dimension (LDAB,N)
  9370. * On entry, the upper or lower triangle of the symmetric band
  9371. * matrix A, stored in the first kd+1 rows of the array. The
  9372. * j-th column of A is stored in the j-th column of the array AB
  9373. * as follows:
  9374. * if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
  9375. * if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd).
  9376. *
  9377. * On exit, if INFO = 0, the factor S from the split Cholesky
  9378. * factorization A = S**T*S. See Further Details.
  9379. *
  9380. * LDAB (input) INTEGER
  9381. * The leading dimension of the array AB. LDAB >= KD+1.
  9382. *
  9383. * C++ Return value: INFO (output) INTEGER
  9384. * = 0: successful exit
  9385. * < 0: if INFO = -i, the i-th argument had an illegal value
  9386. * > 0: if INFO = i, the factorization could not be completed,
  9387. * because the updated element a(i,i) was negative; the
  9388. * matrix A is not positive definite.
  9389. *
  9390. * Further Details
  9391. * ===============
  9392. *
  9393. * The band storage scheme is illustrated by the following example, when
  9394. * N = 7, KD = 2:
  9395. *
  9396. * S = ( s11 s12 s13 )
  9397. * ( s22 s23 s24 )
  9398. * ( s33 s34 )
  9399. * ( s44 )
  9400. * ( s53 s54 s55 )
  9401. * ( s64 s65 s66 )
  9402. * ( s75 s76 s77 )
  9403. *
  9404. * If UPLO = 'U', the array AB holds:
  9405. *
  9406. * on entry: on exit:
  9407. *
  9408. * * * a13 a24 a35 a46 a57 * * s13 s24 s53 s64 s75
  9409. * * a12 a23 a34 a45 a56 a67 * s12 s23 s34 s54 s65 s76
  9410. * a11 a22 a33 a44 a55 a66 a77 s11 s22 s33 s44 s55 s66 s77
  9411. *
  9412. * If UPLO = 'L', the array AB holds:
  9413. *
  9414. * on entry: on exit:
  9415. *
  9416. * a11 a22 a33 a44 a55 a66 a77 s11 s22 s33 s44 s55 s66 s77
  9417. * a21 a32 a43 a54 a65 a76 * s12 s23 s34 s54 s65 s76 *
  9418. * a31 a42 a53 a64 a64 * * s13 s24 s53 s64 s75 * *
  9419. *
  9420. * Array elements marked * are not used by the routine.
  9421. *
  9422. * =====================================================================
  9423. *
  9424. * .. Parameters ..
  9425. **/
  9426. int C_DPBSTF(char uplo, int n, int kd, double* ab, int ldab)
  9427. {
  9428. int info;
  9429. ::F_DPBSTF(&uplo, &n, &kd, ab, &ldab, &info);
  9430. return info;
  9431. }
  9432. /**
  9433. * Purpose
  9434. * =======
  9435. *
  9436. * DPBSV computes the solution to a real system of linear equations
  9437. * A * X = B,
  9438. * where A is an N-by-N symmetric positive definite band matrix and X
  9439. * and B are N-by-NRHS matrices.
  9440. *
  9441. * The Cholesky decomposition is used to factor A as
  9442. * A = U**T * U, if UPLO = 'U', or
  9443. * A = L * L**T, if UPLO = 'L',
  9444. * where U is an upper triangular band matrix, and L is a lower
  9445. * triangular band matrix, with the same number of superdiagonals or
  9446. * subdiagonals as A. The factored form of A is then used to solve the
  9447. * system of equations A * X = B.
  9448. *
  9449. * Arguments
  9450. * =========
  9451. *
  9452. * UPLO (input) CHARACTER*1
  9453. * = 'U': Upper triangle of A is stored;
  9454. * = 'L': Lower triangle of A is stored.
  9455. *
  9456. * N (input) INTEGER
  9457. * The number of linear equations, i.e., the order of the
  9458. * matrix A. N >= 0.
  9459. *
  9460. * KD (input) INTEGER
  9461. * The number of superdiagonals of the matrix A if UPLO = 'U',
  9462. * or the number of subdiagonals if UPLO = 'L'. KD >= 0.
  9463. *
  9464. * NRHS (input) INTEGER
  9465. * The number of right hand sides, i.e., the number of columns
  9466. * of the matrix B. NRHS >= 0.
  9467. *
  9468. * AB (input/output) DOUBLE PRECISION array, dimension (LDAB,N)
  9469. * On entry, the upper or lower triangle of the symmetric band
  9470. * matrix A, stored in the first KD+1 rows of the array. The
  9471. * j-th column of A is stored in the j-th column of the array AB
  9472. * as follows:
  9473. * if UPLO = 'U', AB(KD+1+i-j,j) = A(i,j) for max(1,j-KD)<=i<=j;
  9474. * if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(N,j+KD).
  9475. * See below for further details.
  9476. *
  9477. * On exit, if INFO = 0, the triangular factor U or L from the
  9478. * Cholesky factorization A = U**T*U or A = L*L**T of the band
  9479. * matrix A, in the same storage format as A.
  9480. *
  9481. * LDAB (input) INTEGER
  9482. * The leading dimension of the array AB. LDAB >= KD+1.
  9483. *
  9484. * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
  9485. * On entry, the N-by-NRHS right hand side matrix B.
  9486. * On exit, if INFO = 0, the N-by-NRHS solution matrix X.
  9487. *
  9488. * LDB (input) INTEGER
  9489. * The leading dimension of the array B. LDB >= max(1,N).
  9490. *
  9491. * C++ Return value: INFO (output) INTEGER
  9492. * = 0: successful exit
  9493. * < 0: if INFO = -i, the i-th argument had an illegal value
  9494. * > 0: if INFO = i, the leading minor of order i of A is not
  9495. * positive definite, so the factorization could not be
  9496. * completed, and the solution has not been computed.
  9497. *
  9498. * Further Details
  9499. * ===============
  9500. *
  9501. * The band storage scheme is illustrated by the following example, when
  9502. * N = 6, KD = 2, and UPLO = 'U':
  9503. *
  9504. * On entry: On exit:
  9505. *
  9506. * * * a13 a24 a35 a46 * * u13 u24 u35 u46
  9507. * * a12 a23 a34 a45 a56 * u12 u23 u34 u45 u56
  9508. * a11 a22 a33 a44 a55 a66 u11 u22 u33 u44 u55 u66
  9509. *
  9510. * Similarly, if UPLO = 'L' the format of A is as follows:
  9511. *
  9512. * On entry: On exit:
  9513. *
  9514. * a11 a22 a33 a44 a55 a66 l11 l22 l33 l44 l55 l66
  9515. * a21 a32 a43 a54 a65 * l21 l32 l43 l54 l65 *
  9516. * a31 a42 a53 a64 * * l31 l42 l53 l64 * *
  9517. *
  9518. * Array elements marked * are not used by the routine.
  9519. *
  9520. * =====================================================================
  9521. *
  9522. * .. External Functions ..
  9523. **/
  9524. int C_DPBSV(char uplo, int n, int kd, int nrhs, double* ab, int ldab, double* b, int ldb)
  9525. {
  9526. int info;
  9527. ::F_DPBSV(&uplo, &n, &kd, &nrhs, ab, &ldab, b, &ldb, &info);
  9528. return info;
  9529. }
  9530. /**
  9531. * Purpose
  9532. * =======
  9533. *
  9534. * DPBSVX uses the Cholesky factorization A = U**T*U or A = L*L**T to
  9535. * compute the solution to a real system of linear equations
  9536. * A * X = B,
  9537. * where A is an N-by-N symmetric positive definite band matrix and X
  9538. * and B are N-by-NRHS matrices.
  9539. *
  9540. * Error bounds on the solution and a condition estimate are also
  9541. * provided.
  9542. *
  9543. * Description
  9544. * ===========
  9545. *
  9546. * The following steps are performed:
  9547. *
  9548. * 1. If FACT = 'E', real scaling factors are computed to equilibrate
  9549. * the system:
  9550. * diag(S) * A * diag(S) * inv(diag(S)) * X = diag(S) * B
  9551. * Whether or not the system will be equilibrated depends on the
  9552. * scaling of the matrix A, but if equilibration is used, A is
  9553. * overwritten by diag(S)*A*diag(S) and B by diag(S)*B.
  9554. *
  9555. * 2. If FACT = 'N' or 'E', the Cholesky decomposition is used to
  9556. * factor the matrix A (after equilibration if FACT = 'E') as
  9557. * A = U**T * U, if UPLO = 'U', or
  9558. * A = L * L**T, if UPLO = 'L',
  9559. * where U is an upper triangular band matrix, and L is a lower
  9560. * triangular band matrix.
  9561. *
  9562. * 3. If the leading i-by-i principal minor is not positive definite,
  9563. * then the routine returns with INFO = i. Otherwise, the factored
  9564. * form of A is used to estimate the condition number of the matrix
  9565. * A. If the reciprocal of the condition number is less than machine
  9566. * precision, INFO = N+1 is returned as a warning, but the routine
  9567. * still goes on to solve for X and compute error bounds as
  9568. * described below.
  9569. *
  9570. * 4. The system of equations is solved for X using the factored form
  9571. * of A.
  9572. *
  9573. * 5. Iterative refinement is applied to improve the computed solution
  9574. * matrix and calculate error bounds and backward error estimates
  9575. * for it.
  9576. *
  9577. * 6. If equilibration was used, the matrix X is premultiplied by
  9578. * diag(S) so that it solves the original system before
  9579. * equilibration.
  9580. *
  9581. * Arguments
  9582. * =========
  9583. *
  9584. * FACT (input) CHARACTER*1
  9585. * Specifies whether or not the factored form of the matrix A is
  9586. * supplied on entry, and if not, whether the matrix A should be
  9587. * equilibrated before it is factored.
  9588. * = 'F': On entry, AFB contains the factored form of A.
  9589. * If EQUED = 'Y', the matrix A has been equilibrated
  9590. * with scaling factors given by S. AB and AFB will not
  9591. * be modified.
  9592. * = 'N': The matrix A will be copied to AFB and factored.
  9593. * = 'E': The matrix A will be equilibrated if necessary, then
  9594. * copied to AFB and factored.
  9595. *
  9596. * UPLO (input) CHARACTER*1
  9597. * = 'U': Upper triangle of A is stored;
  9598. * = 'L': Lower triangle of A is stored.
  9599. *
  9600. * N (input) INTEGER
  9601. * The number of linear equations, i.e., the order of the
  9602. * matrix A. N >= 0.
  9603. *
  9604. * KD (input) INTEGER
  9605. * The number of superdiagonals of the matrix A if UPLO = 'U',
  9606. * or the number of subdiagonals if UPLO = 'L'. KD >= 0.
  9607. *
  9608. * NRHS (input) INTEGER
  9609. * The number of right-hand sides, i.e., the number of columns
  9610. * of the matrices B and X. NRHS >= 0.
  9611. *
  9612. * AB (input/output) DOUBLE PRECISION array, dimension (LDAB,N)
  9613. * On entry, the upper or lower triangle of the symmetric band
  9614. * matrix A, stored in the first KD+1 rows of the array, except
  9615. * if FACT = 'F' and EQUED = 'Y', then A must contain the
  9616. * equilibrated matrix diag(S)*A*diag(S). The j-th column of A
  9617. * is stored in the j-th column of the array AB as follows:
  9618. * if UPLO = 'U', AB(KD+1+i-j,j) = A(i,j) for max(1,j-KD)<=i<=j;
  9619. * if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(N,j+KD).
  9620. * See below for further details.
  9621. *
  9622. * On exit, if FACT = 'E' and EQUED = 'Y', A is overwritten by
  9623. * diag(S)*A*diag(S).
  9624. *
  9625. * LDAB (input) INTEGER
  9626. * The leading dimension of the array A. LDAB >= KD+1.
  9627. *
  9628. * AFB (input or output) DOUBLE PRECISION array, dimension (LDAFB,N)
  9629. * If FACT = 'F', then AFB is an input argument and on entry
  9630. * contains the triangular factor U or L from the Cholesky
  9631. * factorization A = U**T*U or A = L*L**T of the band matrix
  9632. * A, in the same storage format as A (see AB). If EQUED = 'Y',
  9633. * then AFB is the factored form of the equilibrated matrix A.
  9634. *
  9635. * If FACT = 'N', then AFB is an output argument and on exit
  9636. * returns the triangular factor U or L from the Cholesky
  9637. * factorization A = U**T*U or A = L*L**T.
  9638. *
  9639. * If FACT = 'E', then AFB is an output argument and on exit
  9640. * returns the triangular factor U or L from the Cholesky
  9641. * factorization A = U**T*U or A = L*L**T of the equilibrated
  9642. * matrix A (see the description of A for the form of the
  9643. * equilibrated matrix).
  9644. *
  9645. * LDAFB (input) INTEGER
  9646. * The leading dimension of the array AFB. LDAFB >= KD+1.
  9647. *
  9648. * EQUED (input or output) CHARACTER*1
  9649. * Specifies the form of equilibration that was done.
  9650. * = 'N': No equilibration (always true if FACT = 'N').
  9651. * = 'Y': Equilibration was done, i.e., A has been replaced by
  9652. * diag(S) * A * diag(S).
  9653. * EQUED is an input argument if FACT = 'F'; otherwise, it is an
  9654. * output argument.
  9655. *
  9656. * S (input or output) DOUBLE PRECISION array, dimension (N)
  9657. * The scale factors for A; not accessed if EQUED = 'N'. S is
  9658. * an input argument if FACT = 'F'; otherwise, S is an output
  9659. * argument. If FACT = 'F' and EQUED = 'Y', each element of S
  9660. * must be positive.
  9661. *
  9662. * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
  9663. * On entry, the N-by-NRHS right hand side matrix B.
  9664. * On exit, if EQUED = 'N', B is not modified; if EQUED = 'Y',
  9665. * B is overwritten by diag(S) * B.
  9666. *
  9667. * LDB (input) INTEGER
  9668. * The leading dimension of the array B. LDB >= max(1,N).
  9669. *
  9670. * X (output) DOUBLE PRECISION array, dimension (LDX,NRHS)
  9671. * If INFO = 0 or INFO = N+1, the N-by-NRHS solution matrix X to
  9672. * the original system of equations. Note that if EQUED = 'Y',
  9673. * A and B are modified on exit, and the solution to the
  9674. * equilibrated system is inv(diag(S))*X.
  9675. *
  9676. * LDX (input) INTEGER
  9677. * The leading dimension of the array X. LDX >= max(1,N).
  9678. *
  9679. * RCOND (output) DOUBLE PRECISION
  9680. * The estimate of the reciprocal condition number of the matrix
  9681. * A after equilibration (if done). If RCOND is less than the
  9682. * machine precision (in particular, if RCOND = 0), the matrix
  9683. * is singular to working precision. This condition is
  9684. * indicated by a return code of INFO > 0.
  9685. *
  9686. * FERR (output) DOUBLE PRECISION array, dimension (NRHS)
  9687. * The estimated forward error bound for each solution vector
  9688. * X(j) (the j-th column of the solution matrix X).
  9689. * If XTRUE is the true solution corresponding to X(j), FERR(j)
  9690. * is an estimated upper bound for the magnitude of the largest
  9691. * element in (X(j) - XTRUE) divided by the magnitude of the
  9692. * largest element in X(j). The estimate is as reliable as
  9693. * the estimate for RCOND, and is almost always a slight
  9694. * overestimate of the true error.
  9695. *
  9696. * BERR (output) DOUBLE PRECISION array, dimension (NRHS)
  9697. * The componentwise relative backward error of each solution
  9698. * vector X(j) (i.e., the smallest relative change in
  9699. * any element of A or B that makes X(j) an exact solution).
  9700. *
  9701. * WORK (workspace) DOUBLE PRECISION array, dimension (3*N)
  9702. *
  9703. * IWORK (workspace) INTEGER array, dimension (N)
  9704. *
  9705. * C++ Return value: INFO (output) INTEGER
  9706. * = 0: successful exit
  9707. * < 0: if INFO = -i, the i-th argument had an illegal value
  9708. * > 0: if INFO = i, and i is
  9709. * <= N: the leading minor of order i of A is
  9710. * not positive definite, so the factorization
  9711. * could not be completed, and the solution has not
  9712. * been computed. RCOND = 0 is returned.
  9713. * = N+1: U is nonsingular, but RCOND is less than machine
  9714. * precision, meaning that the matrix is singular
  9715. * to working precision. Nevertheless, the
  9716. * solution and error bounds are computed because
  9717. * there are a number of situations where the
  9718. * computed solution can be more accurate than the
  9719. * value of RCOND would suggest.
  9720. *
  9721. * Further Details
  9722. * ===============
  9723. *
  9724. * The band storage scheme is illustrated by the following example, when
  9725. * N = 6, KD = 2, and UPLO = 'U':
  9726. *
  9727. * Two-dimensional storage of the symmetric matrix A:
  9728. *
  9729. * a11 a12 a13
  9730. * a22 a23 a24
  9731. * a33 a34 a35
  9732. * a44 a45 a46
  9733. * a55 a56
  9734. * (aij=conjg(aji)) a66
  9735. *
  9736. * Band storage of the upper triangle of A:
  9737. *
  9738. * * * a13 a24 a35 a46
  9739. * * a12 a23 a34 a45 a56
  9740. * a11 a22 a33 a44 a55 a66
  9741. *
  9742. * Similarly, if UPLO = 'L' the format of A is as follows:
  9743. *
  9744. * a11 a22 a33 a44 a55 a66
  9745. * a21 a32 a43 a54 a65 *
  9746. * a31 a42 a53 a64 * *
  9747. *
  9748. * Array elements marked * are not used by the routine.
  9749. *
  9750. * =====================================================================
  9751. *
  9752. * .. Parameters ..
  9753. **/
  9754. int C_DPBSVX(char fact, char uplo, int n, int kd, int nrhs, double* ab, int ldab, double* afb, int ldafb, char equed, double* s, double* b, int ldb, double* x, int ldx, double* rcond, double* ferr, double* berr, double* work, int* iwork)
  9755. {
  9756. int info;
  9757. ::F_DPBSVX(&fact, &uplo, &n, &kd, &nrhs, ab, &ldab, afb, &ldafb, &equed, s, b, &ldb, x, &ldx, rcond, ferr, berr, work, iwork, &info);
  9758. return info;
  9759. }
  9760. /**
  9761. * Purpose
  9762. * =======
  9763. *
  9764. * DPBTRF computes the Cholesky factorization of a real symmetric
  9765. * positive definite band matrix A.
  9766. *
  9767. * The factorization has the form
  9768. * A = U**T * U, if UPLO = 'U', or
  9769. * A = L * L**T, if UPLO = 'L',
  9770. * where U is an upper triangular matrix and L is lower triangular.
  9771. *
  9772. * Arguments
  9773. * =========
  9774. *
  9775. * UPLO (input) CHARACTER*1
  9776. * = 'U': Upper triangle of A is stored;
  9777. * = 'L': Lower triangle of A is stored.
  9778. *
  9779. * N (input) INTEGER
  9780. * The order of the matrix A. N >= 0.
  9781. *
  9782. * KD (input) INTEGER
  9783. * The number of superdiagonals of the matrix A if UPLO = 'U',
  9784. * or the number of subdiagonals if UPLO = 'L'. KD >= 0.
  9785. *
  9786. * AB (input/output) DOUBLE PRECISION array, dimension (LDAB,N)
  9787. * On entry, the upper or lower triangle of the symmetric band
  9788. * matrix A, stored in the first KD+1 rows of the array. The
  9789. * j-th column of A is stored in the j-th column of the array AB
  9790. * as follows:
  9791. * if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
  9792. * if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd).
  9793. *
  9794. * On exit, if INFO = 0, the triangular factor U or L from the
  9795. * Cholesky factorization A = U**T*U or A = L*L**T of the band
  9796. * matrix A, in the same storage format as A.
  9797. *
  9798. * LDAB (input) INTEGER
  9799. * The leading dimension of the array AB. LDAB >= KD+1.
  9800. *
  9801. * C++ Return value: INFO (output) INTEGER
  9802. * = 0: successful exit
  9803. * < 0: if INFO = -i, the i-th argument had an illegal value
  9804. * > 0: if INFO = i, the leading minor of order i is not
  9805. * positive definite, and the factorization could not be
  9806. * completed.
  9807. *
  9808. * Further Details
  9809. * ===============
  9810. *
  9811. * The band storage scheme is illustrated by the following example, when
  9812. * N = 6, KD = 2, and UPLO = 'U':
  9813. *
  9814. * On entry: On exit:
  9815. *
  9816. * * * a13 a24 a35 a46 * * u13 u24 u35 u46
  9817. * * a12 a23 a34 a45 a56 * u12 u23 u34 u45 u56
  9818. * a11 a22 a33 a44 a55 a66 u11 u22 u33 u44 u55 u66
  9819. *
  9820. * Similarly, if UPLO = 'L' the format of A is as follows:
  9821. *
  9822. * On entry: On exit:
  9823. *
  9824. * a11 a22 a33 a44 a55 a66 l11 l22 l33 l44 l55 l66
  9825. * a21 a32 a43 a54 a65 * l21 l32 l43 l54 l65 *
  9826. * a31 a42 a53 a64 * * l31 l42 l53 l64 * *
  9827. *
  9828. * Array elements marked * are not used by the routine.
  9829. *
  9830. * Contributed by
  9831. * Peter Mayes and Giuseppe Radicati, IBM ECSEC, Rome, March 23, 1989
  9832. *
  9833. * =====================================================================
  9834. *
  9835. * .. Parameters ..
  9836. **/
  9837. int C_DPBTRF(char uplo, int n, int kd, double* ab, int ldab)
  9838. {
  9839. int info;
  9840. ::F_DPBTRF(&uplo, &n, &kd, ab, &ldab, &info);
  9841. return info;
  9842. }
  9843. /**
  9844. * Purpose
  9845. * =======
  9846. *
  9847. * DPBTRS solves a system of linear equations A*X = B with a symmetric
  9848. * positive definite band matrix A using the Cholesky factorization
  9849. * A = U**T*U or A = L*L**T computed by DPBTRF.
  9850. *
  9851. * Arguments
  9852. * =========
  9853. *
  9854. * UPLO (input) CHARACTER*1
  9855. * = 'U': Upper triangular factor stored in AB;
  9856. * = 'L': Lower triangular factor stored in AB.
  9857. *
  9858. * N (input) INTEGER
  9859. * The order of the matrix A. N >= 0.
  9860. *
  9861. * KD (input) INTEGER
  9862. * The number of superdiagonals of the matrix A if UPLO = 'U',
  9863. * or the number of subdiagonals if UPLO = 'L'. KD >= 0.
  9864. *
  9865. * NRHS (input) INTEGER
  9866. * The number of right hand sides, i.e., the number of columns
  9867. * of the matrix B. NRHS >= 0.
  9868. *
  9869. * AB (input) DOUBLE PRECISION array, dimension (LDAB,N)
  9870. * The triangular factor U or L from the Cholesky factorization
  9871. * A = U**T*U or A = L*L**T of the band matrix A, stored in the
  9872. * first KD+1 rows of the array. The j-th column of U or L is
  9873. * stored in the j-th column of the array AB as follows:
  9874. * if UPLO ='U', AB(kd+1+i-j,j) = U(i,j) for max(1,j-kd)<=i<=j;
  9875. * if UPLO ='L', AB(1+i-j,j) = L(i,j) for j<=i<=min(n,j+kd).
  9876. *
  9877. * LDAB (input) INTEGER
  9878. * The leading dimension of the array AB. LDAB >= KD+1.
  9879. *
  9880. * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
  9881. * On entry, the right hand side matrix B.
  9882. * On exit, the solution matrix X.
  9883. *
  9884. * LDB (input) INTEGER
  9885. * The leading dimension of the array B. LDB >= max(1,N).
  9886. *
  9887. * C++ Return value: INFO (output) INTEGER
  9888. * = 0: successful exit
  9889. * < 0: if INFO = -i, the i-th argument had an illegal value
  9890. *
  9891. * =====================================================================
  9892. *
  9893. * .. Local Scalars ..
  9894. **/
  9895. int C_DPBTRS(char uplo, int n, int kd, int nrhs, double* ab, int ldab, double* b, int ldb)
  9896. {
  9897. int info;
  9898. ::F_DPBTRS(&uplo, &n, &kd, &nrhs, ab, &ldab, b, &ldb, &info);
  9899. return info;
  9900. }
  9901. /**
  9902. * Purpose
  9903. * =======
  9904. *
  9905. * DPOCON estimates the reciprocal of the condition number (in the
  9906. * 1-norm) of a real symmetric positive definite matrix using the
  9907. * Cholesky factorization A = U**T*U or A = L*L**T computed by DPOTRF.
  9908. *
  9909. * An estimate is obtained for norm(inv(A)), and the reciprocal of the
  9910. * condition number is computed as RCOND = 1 / (ANORM * norm(inv(A))).
  9911. *
  9912. * Arguments
  9913. * =========
  9914. *
  9915. * UPLO (input) CHARACTER*1
  9916. * = 'U': Upper triangle of A is stored;
  9917. * = 'L': Lower triangle of A is stored.
  9918. *
  9919. * N (input) INTEGER
  9920. * The order of the matrix A. N >= 0.
  9921. *
  9922. * A (input) DOUBLE PRECISION array, dimension (LDA,N)
  9923. * The triangular factor U or L from the Cholesky factorization
  9924. * A = U**T*U or A = L*L**T, as computed by DPOTRF.
  9925. *
  9926. * LDA (input) INTEGER
  9927. * The leading dimension of the array A. LDA >= max(1,N).
  9928. *
  9929. * ANORM (input) DOUBLE PRECISION
  9930. * The 1-norm (or infinity-norm) of the symmetric matrix A.
  9931. *
  9932. * RCOND (output) DOUBLE PRECISION
  9933. * The reciprocal of the condition number of the matrix A,
  9934. * computed as RCOND = 1/(ANORM * AINVNM), where AINVNM is an
  9935. * estimate of the 1-norm of inv(A) computed in this routine.
  9936. *
  9937. * WORK (workspace) DOUBLE PRECISION array, dimension (3*N)
  9938. *
  9939. * IWORK (workspace) INTEGER array, dimension (N)
  9940. *
  9941. * C++ Return value: INFO (output) INTEGER
  9942. * = 0: successful exit
  9943. * < 0: if INFO = -i, the i-th argument had an illegal value
  9944. *
  9945. * =====================================================================
  9946. *
  9947. * .. Parameters ..
  9948. **/
  9949. int C_DPOCON(char uplo, int n, double* a, int lda, double anorm, double* rcond, double* work, int* iwork)
  9950. {
  9951. int info;
  9952. ::F_DPOCON(&uplo, &n, a, &lda, &anorm, rcond, work, iwork, &info);
  9953. return info;
  9954. }
  9955. /**
  9956. * Purpose
  9957. * =======
  9958. *
  9959. * DPOEQU computes row and column scalings intended to equilibrate a
  9960. * symmetric positive definite matrix A and reduce its condition number
  9961. * (with respect to the two-norm). S contains the scale factors,
  9962. * S(i) = 1/sqrt(A(i,i)), chosen so that the scaled matrix B with
  9963. * elements B(i,j) = S(i)*A(i,j)*S(j) has ones on the diagonal. This
  9964. * choice of S puts the condition number of B within a factor N of the
  9965. * smallest possible condition number over all possible diagonal
  9966. * scalings.
  9967. *
  9968. * Arguments
  9969. * =========
  9970. *
  9971. * N (input) INTEGER
  9972. * The order of the matrix A. N >= 0.
  9973. *
  9974. * A (input) DOUBLE PRECISION array, dimension (LDA,N)
  9975. * The N-by-N symmetric positive definite matrix whose scaling
  9976. * factors are to be computed. Only the diagonal elements of A
  9977. * are referenced.
  9978. *
  9979. * LDA (input) INTEGER
  9980. * The leading dimension of the array A. LDA >= max(1,N).
  9981. *
  9982. * S (output) DOUBLE PRECISION array, dimension (N)
  9983. * If INFO = 0, S contains the scale factors for A.
  9984. *
  9985. * SCOND (output) DOUBLE PRECISION
  9986. * If INFO = 0, S contains the ratio of the smallest S(i) to
  9987. * the largest S(i). If SCOND >= 0.1 and AMAX is neither too
  9988. * large nor too small, it is not worth scaling by S.
  9989. *
  9990. * AMAX (output) DOUBLE PRECISION
  9991. * Absolute value of largest matrix element. If AMAX is very
  9992. * close to overflow or very close to underflow, the matrix
  9993. * should be scaled.
  9994. *
  9995. * C++ Return value: INFO (output) INTEGER
  9996. * = 0: successful exit
  9997. * < 0: if INFO = -i, the i-th argument had an illegal value
  9998. * > 0: if INFO = i, the i-th diagonal element is nonpositive.
  9999. *
  10000. * =====================================================================
  10001. *
  10002. * .. Parameters ..
  10003. **/
  10004. int C_DPOEQU(int n, double* a, int lda, double* s, double* scond, double* amax)
  10005. {
  10006. int info;
  10007. ::F_DPOEQU(&n, a, &lda, s, scond, amax, &info);
  10008. return info;
  10009. }
  10010. /**
  10011. * Purpose
  10012. * =======
  10013. *
  10014. * DPORFS improves the computed solution to a system of linear
  10015. * equations when the coefficient matrix is symmetric positive definite,
  10016. * and provides error bounds and backward error estimates for the
  10017. * solution.
  10018. *
  10019. * Arguments
  10020. * =========
  10021. *
  10022. * UPLO (input) CHARACTER*1
  10023. * = 'U': Upper triangle of A is stored;
  10024. * = 'L': Lower triangle of A is stored.
  10025. *
  10026. * N (input) INTEGER
  10027. * The order of the matrix A. N >= 0.
  10028. *
  10029. * NRHS (input) INTEGER
  10030. * The number of right hand sides, i.e., the number of columns
  10031. * of the matrices B and X. NRHS >= 0.
  10032. *
  10033. * A (input) DOUBLE PRECISION array, dimension (LDA,N)
  10034. * The symmetric matrix A. If UPLO = 'U', the leading N-by-N
  10035. * upper triangular part of A contains the upper triangular part
  10036. * of the matrix A, and the strictly lower triangular part of A
  10037. * is not referenced. If UPLO = 'L', the leading N-by-N lower
  10038. * triangular part of A contains the lower triangular part of
  10039. * the matrix A, and the strictly upper triangular part of A is
  10040. * not referenced.
  10041. *
  10042. * LDA (input) INTEGER
  10043. * The leading dimension of the array A. LDA >= max(1,N).
  10044. *
  10045. * AF (input) DOUBLE PRECISION array, dimension (LDAF,N)
  10046. * The triangular factor U or L from the Cholesky factorization
  10047. * A = U**T*U or A = L*L**T, as computed by DPOTRF.
  10048. *
  10049. * LDAF (input) INTEGER
  10050. * The leading dimension of the array AF. LDAF >= max(1,N).
  10051. *
  10052. * B (input) DOUBLE PRECISION array, dimension (LDB,NRHS)
  10053. * The right hand side matrix B.
  10054. *
  10055. * LDB (input) INTEGER
  10056. * The leading dimension of the array B. LDB >= max(1,N).
  10057. *
  10058. * X (input/output) DOUBLE PRECISION array, dimension (LDX,NRHS)
  10059. * On entry, the solution matrix X, as computed by DPOTRS.
  10060. * On exit, the improved solution matrix X.
  10061. *
  10062. * LDX (input) INTEGER
  10063. * The leading dimension of the array X. LDX >= max(1,N).
  10064. *
  10065. * FERR (output) DOUBLE PRECISION array, dimension (NRHS)
  10066. * The estimated forward error bound for each solution vector
  10067. * X(j) (the j-th column of the solution matrix X).
  10068. * If XTRUE is the true solution corresponding to X(j), FERR(j)
  10069. * is an estimated upper bound for the magnitude of the largest
  10070. * element in (X(j) - XTRUE) divided by the magnitude of the
  10071. * largest element in X(j). The estimate is as reliable as
  10072. * the estimate for RCOND, and is almost always a slight
  10073. * overestimate of the true error.
  10074. *
  10075. * BERR (output) DOUBLE PRECISION array, dimension (NRHS)
  10076. * The componentwise relative backward error of each solution
  10077. * vector X(j) (i.e., the smallest relative change in
  10078. * any element of A or B that makes X(j) an exact solution).
  10079. *
  10080. * WORK (workspace) DOUBLE PRECISION array, dimension (3*N)
  10081. *
  10082. * IWORK (workspace) INTEGER array, dimension (N)
  10083. *
  10084. * C++ Return value: INFO (output) INTEGER
  10085. * = 0: successful exit
  10086. * < 0: if INFO = -i, the i-th argument had an illegal value
  10087. *
  10088. * Internal Parameters
  10089. * ===================
  10090. *
  10091. * ITMAX is the maximum number of steps of iterative refinement.
  10092. *
  10093. * =====================================================================
  10094. *
  10095. * .. Parameters ..
  10096. **/
  10097. int C_DPORFS(char uplo, int n, int nrhs, double* a, int lda, double* af, int ldaf, double* b, int ldb, double* x, int ldx, double* ferr, double* berr, double* work, int* iwork)
  10098. {
  10099. int info;
  10100. ::F_DPORFS(&uplo, &n, &nrhs, a, &lda, af, &ldaf, b, &ldb, x, &ldx, ferr, berr, work, iwork, &info);
  10101. return info;
  10102. }
  10103. /**
  10104. * Purpose
  10105. * =======
  10106. *
  10107. * DPOSV computes the solution to a real system of linear equations
  10108. * A * X = B,
  10109. * where A is an N-by-N symmetric positive definite matrix and X and B
  10110. * are N-by-NRHS matrices.
  10111. *
  10112. * The Cholesky decomposition is used to factor A as
  10113. * A = U**T* U, if UPLO = 'U', or
  10114. * A = L * L**T, if UPLO = 'L',
  10115. * where U is an upper triangular matrix and L is a lower triangular
  10116. * matrix. The factored form of A is then used to solve the system of
  10117. * equations A * X = B.
  10118. *
  10119. * Arguments
  10120. * =========
  10121. *
  10122. * UPLO (input) CHARACTER*1
  10123. * = 'U': Upper triangle of A is stored;
  10124. * = 'L': Lower triangle of A is stored.
  10125. *
  10126. * N (input) INTEGER
  10127. * The number of linear equations, i.e., the order of the
  10128. * matrix A. N >= 0.
  10129. *
  10130. * NRHS (input) INTEGER
  10131. * The number of right hand sides, i.e., the number of columns
  10132. * of the matrix B. NRHS >= 0.
  10133. *
  10134. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  10135. * On entry, the symmetric matrix A. If UPLO = 'U', the leading
  10136. * N-by-N upper triangular part of A contains the upper
  10137. * triangular part of the matrix A, and the strictly lower
  10138. * triangular part of A is not referenced. If UPLO = 'L', the
  10139. * leading N-by-N lower triangular part of A contains the lower
  10140. * triangular part of the matrix A, and the strictly upper
  10141. * triangular part of A is not referenced.
  10142. *
  10143. * On exit, if INFO = 0, the factor U or L from the Cholesky
  10144. * factorization A = U**T*U or A = L*L**T.
  10145. *
  10146. * LDA (input) INTEGER
  10147. * The leading dimension of the array A. LDA >= max(1,N).
  10148. *
  10149. * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
  10150. * On entry, the N-by-NRHS right hand side matrix B.
  10151. * On exit, if INFO = 0, the N-by-NRHS solution matrix X.
  10152. *
  10153. * LDB (input) INTEGER
  10154. * The leading dimension of the array B. LDB >= max(1,N).
  10155. *
  10156. * C++ Return value: INFO (output) INTEGER
  10157. * = 0: successful exit
  10158. * < 0: if INFO = -i, the i-th argument had an illegal value
  10159. * > 0: if INFO = i, the leading minor of order i of A is not
  10160. * positive definite, so the factorization could not be
  10161. * completed, and the solution has not been computed.
  10162. *
  10163. * =====================================================================
  10164. *
  10165. * .. External Functions ..
  10166. **/
  10167. int C_DPOSV(char uplo, int n, int nrhs, double* a, int lda, double* b, int ldb)
  10168. {
  10169. int info;
  10170. ::F_DPOSV(&uplo, &n, &nrhs, a, &lda, b, &ldb, &info);
  10171. return info;
  10172. }
  10173. /**
  10174. * Purpose
  10175. * =======
  10176. *
  10177. * DPOSVX uses the Cholesky factorization A = U**T*U or A = L*L**T to
  10178. * compute the solution to a real system of linear equations
  10179. * A * X = B,
  10180. * where A is an N-by-N symmetric positive definite matrix and X and B
  10181. * are N-by-NRHS matrices.
  10182. *
  10183. * Error bounds on the solution and a condition estimate are also
  10184. * provided.
  10185. *
  10186. * Description
  10187. * ===========
  10188. *
  10189. * The following steps are performed:
  10190. *
  10191. * 1. If FACT = 'E', real scaling factors are computed to equilibrate
  10192. * the system:
  10193. * diag(S) * A * diag(S) * inv(diag(S)) * X = diag(S) * B
  10194. * Whether or not the system will be equilibrated depends on the
  10195. * scaling of the matrix A, but if equilibration is used, A is
  10196. * overwritten by diag(S)*A*diag(S) and B by diag(S)*B.
  10197. *
  10198. * 2. If FACT = 'N' or 'E', the Cholesky decomposition is used to
  10199. * factor the matrix A (after equilibration if FACT = 'E') as
  10200. * A = U**T* U, if UPLO = 'U', or
  10201. * A = L * L**T, if UPLO = 'L',
  10202. * where U is an upper triangular matrix and L is a lower triangular
  10203. * matrix.
  10204. *
  10205. * 3. If the leading i-by-i principal minor is not positive definite,
  10206. * then the routine returns with INFO = i. Otherwise, the factored
  10207. * form of A is used to estimate the condition number of the matrix
  10208. * A. If the reciprocal of the condition number is less than machine
  10209. * precision, INFO = N+1 is returned as a warning, but the routine
  10210. * still goes on to solve for X and compute error bounds as
  10211. * described below.
  10212. *
  10213. * 4. The system of equations is solved for X using the factored form
  10214. * of A.
  10215. *
  10216. * 5. Iterative refinement is applied to improve the computed solution
  10217. * matrix and calculate error bounds and backward error estimates
  10218. * for it.
  10219. *
  10220. * 6. If equilibration was used, the matrix X is premultiplied by
  10221. * diag(S) so that it solves the original system before
  10222. * equilibration.
  10223. *
  10224. * Arguments
  10225. * =========
  10226. *
  10227. * FACT (input) CHARACTER*1
  10228. * Specifies whether or not the factored form of the matrix A is
  10229. * supplied on entry, and if not, whether the matrix A should be
  10230. * equilibrated before it is factored.
  10231. * = 'F': On entry, AF contains the factored form of A.
  10232. * If EQUED = 'Y', the matrix A has been equilibrated
  10233. * with scaling factors given by S. A and AF will not
  10234. * be modified.
  10235. * = 'N': The matrix A will be copied to AF and factored.
  10236. * = 'E': The matrix A will be equilibrated if necessary, then
  10237. * copied to AF and factored.
  10238. *
  10239. * UPLO (input) CHARACTER*1
  10240. * = 'U': Upper triangle of A is stored;
  10241. * = 'L': Lower triangle of A is stored.
  10242. *
  10243. * N (input) INTEGER
  10244. * The number of linear equations, i.e., the order of the
  10245. * matrix A. N >= 0.
  10246. *
  10247. * NRHS (input) INTEGER
  10248. * The number of right hand sides, i.e., the number of columns
  10249. * of the matrices B and X. NRHS >= 0.
  10250. *
  10251. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  10252. * On entry, the symmetric matrix A, except if FACT = 'F' and
  10253. * EQUED = 'Y', then A must contain the equilibrated matrix
  10254. * diag(S)*A*diag(S). If UPLO = 'U', the leading
  10255. * N-by-N upper triangular part of A contains the upper
  10256. * triangular part of the matrix A, and the strictly lower
  10257. * triangular part of A is not referenced. If UPLO = 'L', the
  10258. * leading N-by-N lower triangular part of A contains the lower
  10259. * triangular part of the matrix A, and the strictly upper
  10260. * triangular part of A is not referenced. A is not modified if
  10261. * FACT = 'F' or 'N', or if FACT = 'E' and EQUED = 'N' on exit.
  10262. *
  10263. * On exit, if FACT = 'E' and EQUED = 'Y', A is overwritten by
  10264. * diag(S)*A*diag(S).
  10265. *
  10266. * LDA (input) INTEGER
  10267. * The leading dimension of the array A. LDA >= max(1,N).
  10268. *
  10269. * AF (input or output) DOUBLE PRECISION array, dimension (LDAF,N)
  10270. * If FACT = 'F', then AF is an input argument and on entry
  10271. * contains the triangular factor U or L from the Cholesky
  10272. * factorization A = U**T*U or A = L*L**T, in the same storage
  10273. * format as A. If EQUED .ne. 'N', then AF is the factored form
  10274. * of the equilibrated matrix diag(S)*A*diag(S).
  10275. *
  10276. * If FACT = 'N', then AF is an output argument and on exit
  10277. * returns the triangular factor U or L from the Cholesky
  10278. * factorization A = U**T*U or A = L*L**T of the original
  10279. * matrix A.
  10280. *
  10281. * If FACT = 'E', then AF is an output argument and on exit
  10282. * returns the triangular factor U or L from the Cholesky
  10283. * factorization A = U**T*U or A = L*L**T of the equilibrated
  10284. * matrix A (see the description of A for the form of the
  10285. * equilibrated matrix).
  10286. *
  10287. * LDAF (input) INTEGER
  10288. * The leading dimension of the array AF. LDAF >= max(1,N).
  10289. *
  10290. * EQUED (input or output) CHARACTER*1
  10291. * Specifies the form of equilibration that was done.
  10292. * = 'N': No equilibration (always true if FACT = 'N').
  10293. * = 'Y': Equilibration was done, i.e., A has been replaced by
  10294. * diag(S) * A * diag(S).
  10295. * EQUED is an input argument if FACT = 'F'; otherwise, it is an
  10296. * output argument.
  10297. *
  10298. * S (input or output) DOUBLE PRECISION array, dimension (N)
  10299. * The scale factors for A; not accessed if EQUED = 'N'. S is
  10300. * an input argument if FACT = 'F'; otherwise, S is an output
  10301. * argument. If FACT = 'F' and EQUED = 'Y', each element of S
  10302. * must be positive.
  10303. *
  10304. * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
  10305. * On entry, the N-by-NRHS right hand side matrix B.
  10306. * On exit, if EQUED = 'N', B is not modified; if EQUED = 'Y',
  10307. * B is overwritten by diag(S) * B.
  10308. *
  10309. * LDB (input) INTEGER
  10310. * The leading dimension of the array B. LDB >= max(1,N).
  10311. *
  10312. * X (output) DOUBLE PRECISION array, dimension (LDX,NRHS)
  10313. * If INFO = 0 or INFO = N+1, the N-by-NRHS solution matrix X to
  10314. * the original system of equations. Note that if EQUED = 'Y',
  10315. * A and B are modified on exit, and the solution to the
  10316. * equilibrated system is inv(diag(S))*X.
  10317. *
  10318. * LDX (input) INTEGER
  10319. * The leading dimension of the array X. LDX >= max(1,N).
  10320. *
  10321. * RCOND (output) DOUBLE PRECISION
  10322. * The estimate of the reciprocal condition number of the matrix
  10323. * A after equilibration (if done). If RCOND is less than the
  10324. * machine precision (in particular, if RCOND = 0), the matrix
  10325. * is singular to working precision. This condition is
  10326. * indicated by a return code of INFO > 0.
  10327. *
  10328. * FERR (output) DOUBLE PRECISION array, dimension (NRHS)
  10329. * The estimated forward error bound for each solution vector
  10330. * X(j) (the j-th column of the solution matrix X).
  10331. * If XTRUE is the true solution corresponding to X(j), FERR(j)
  10332. * is an estimated upper bound for the magnitude of the largest
  10333. * element in (X(j) - XTRUE) divided by the magnitude of the
  10334. * largest element in X(j). The estimate is as reliable as
  10335. * the estimate for RCOND, and is almost always a slight
  10336. * overestimate of the true error.
  10337. *
  10338. * BERR (output) DOUBLE PRECISION array, dimension (NRHS)
  10339. * The componentwise relative backward error of each solution
  10340. * vector X(j) (i.e., the smallest relative change in
  10341. * any element of A or B that makes X(j) an exact solution).
  10342. *
  10343. * WORK (workspace) DOUBLE PRECISION array, dimension (3*N)
  10344. *
  10345. * IWORK (workspace) INTEGER array, dimension (N)
  10346. *
  10347. * C++ Return value: INFO (output) INTEGER
  10348. * = 0: successful exit
  10349. * < 0: if INFO = -i, the i-th argument had an illegal value
  10350. * > 0: if INFO = i, and i is
  10351. * <= N: the leading minor of order i of A is
  10352. * not positive definite, so the factorization
  10353. * could not be completed, and the solution has not
  10354. * been computed. RCOND = 0 is returned.
  10355. * = N+1: U is nonsingular, but RCOND is less than machine
  10356. * precision, meaning that the matrix is singular
  10357. * to working precision. Nevertheless, the
  10358. * solution and error bounds are computed because
  10359. * there are a number of situations where the
  10360. * computed solution can be more accurate than the
  10361. * value of RCOND would suggest.
  10362. *
  10363. * =====================================================================
  10364. *
  10365. * .. Parameters ..
  10366. **/
  10367. int C_DPOSVX(char fact, char uplo, int n, int nrhs, double* a, int lda, double* af, int ldaf, char equed, double* s, double* b, int ldb, double* x, int ldx, double* rcond, double* ferr, double* berr, double* work, int* iwork)
  10368. {
  10369. int info;
  10370. ::F_DPOSVX(&fact, &uplo, &n, &nrhs, a, &lda, af, &ldaf, &equed, s, b, &ldb, x, &ldx, rcond, ferr, berr, work, iwork, &info);
  10371. return info;
  10372. }
  10373. /**
  10374. * Purpose
  10375. * =======
  10376. *
  10377. * DPOTRF computes the Cholesky factorization of a real symmetric
  10378. * positive definite matrix A.
  10379. *
  10380. * The factorization has the form
  10381. * A = U**T * U, if UPLO = 'U', or
  10382. * A = L * L**T, if UPLO = 'L',
  10383. * where U is an upper triangular matrix and L is lower triangular.
  10384. *
  10385. * This is the block version of the algorithm, calling Level 3 BLAS.
  10386. *
  10387. * Arguments
  10388. * =========
  10389. *
  10390. * UPLO (input) CHARACTER*1
  10391. * = 'U': Upper triangle of A is stored;
  10392. * = 'L': Lower triangle of A is stored.
  10393. *
  10394. * N (input) INTEGER
  10395. * The order of the matrix A. N >= 0.
  10396. *
  10397. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  10398. * On entry, the symmetric matrix A. If UPLO = 'U', the leading
  10399. * N-by-N upper triangular part of A contains the upper
  10400. * triangular part of the matrix A, and the strictly lower
  10401. * triangular part of A is not referenced. If UPLO = 'L', the
  10402. * leading N-by-N lower triangular part of A contains the lower
  10403. * triangular part of the matrix A, and the strictly upper
  10404. * triangular part of A is not referenced.
  10405. *
  10406. * On exit, if INFO = 0, the factor U or L from the Cholesky
  10407. * factorization A = U**T*U or A = L*L**T.
  10408. *
  10409. * LDA (input) INTEGER
  10410. * The leading dimension of the array A. LDA >= max(1,N).
  10411. *
  10412. * C++ Return value: INFO (output) INTEGER
  10413. * = 0: successful exit
  10414. * < 0: if INFO = -i, the i-th argument had an illegal value
  10415. * > 0: if INFO = i, the leading minor of order i is not
  10416. * positive definite, and the factorization could not be
  10417. * completed.
  10418. *
  10419. * =====================================================================
  10420. *
  10421. * .. Parameters ..
  10422. **/
  10423. int C_DPOTRF(char uplo, int n, double* a, int lda)
  10424. {
  10425. int info;
  10426. ::F_DPOTRF(&uplo, &n, a, &lda, &info);
  10427. return info;
  10428. }
  10429. /**
  10430. * Purpose
  10431. * =======
  10432. *
  10433. * DPOTRI computes the inverse of a real symmetric positive definite
  10434. * matrix A using the Cholesky factorization A = U**T*U or A = L*L**T
  10435. * computed by DPOTRF.
  10436. *
  10437. * Arguments
  10438. * =========
  10439. *
  10440. * UPLO (input) CHARACTER*1
  10441. * = 'U': Upper triangle of A is stored;
  10442. * = 'L': Lower triangle of A is stored.
  10443. *
  10444. * N (input) INTEGER
  10445. * The order of the matrix A. N >= 0.
  10446. *
  10447. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  10448. * On entry, the triangular factor U or L from the Cholesky
  10449. * factorization A = U**T*U or A = L*L**T, as computed by
  10450. * DPOTRF.
  10451. * On exit, the upper or lower triangle of the (symmetric)
  10452. * inverse of A, overwriting the input factor U or L.
  10453. *
  10454. * LDA (input) INTEGER
  10455. * The leading dimension of the array A. LDA >= max(1,N).
  10456. *
  10457. * C++ Return value: INFO (output) INTEGER
  10458. * = 0: successful exit
  10459. * < 0: if INFO = -i, the i-th argument had an illegal value
  10460. * > 0: if INFO = i, the (i,i) element of the factor U or L is
  10461. * zero, and the inverse could not be computed.
  10462. *
  10463. * =====================================================================
  10464. *
  10465. * .. External Functions ..
  10466. **/
  10467. int C_DPOTRI(char uplo, int n, double* a, int lda)
  10468. {
  10469. int info;
  10470. ::F_DPOTRI(&uplo, &n, a, &lda, &info);
  10471. return info;
  10472. }
  10473. /**
  10474. * Purpose
  10475. * =======
  10476. *
  10477. * DPOTRS solves a system of linear equations A*X = B with a symmetric
  10478. * positive definite matrix A using the Cholesky factorization
  10479. * A = U**T*U or A = L*L**T computed by DPOTRF.
  10480. *
  10481. * Arguments
  10482. * =========
  10483. *
  10484. * UPLO (input) CHARACTER*1
  10485. * = 'U': Upper triangle of A is stored;
  10486. * = 'L': Lower triangle of A is stored.
  10487. *
  10488. * N (input) INTEGER
  10489. * The order of the matrix A. N >= 0.
  10490. *
  10491. * NRHS (input) INTEGER
  10492. * The number of right hand sides, i.e., the number of columns
  10493. * of the matrix B. NRHS >= 0.
  10494. *
  10495. * A (input) DOUBLE PRECISION array, dimension (LDA,N)
  10496. * The triangular factor U or L from the Cholesky factorization
  10497. * A = U**T*U or A = L*L**T, as computed by DPOTRF.
  10498. *
  10499. * LDA (input) INTEGER
  10500. * The leading dimension of the array A. LDA >= max(1,N).
  10501. *
  10502. * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
  10503. * On entry, the right hand side matrix B.
  10504. * On exit, the solution matrix X.
  10505. *
  10506. * LDB (input) INTEGER
  10507. * The leading dimension of the array B. LDB >= max(1,N).
  10508. *
  10509. * C++ Return value: INFO (output) INTEGER
  10510. * = 0: successful exit
  10511. * < 0: if INFO = -i, the i-th argument had an illegal value
  10512. *
  10513. * =====================================================================
  10514. *
  10515. * .. Parameters ..
  10516. **/
  10517. int C_DPOTRS(char uplo, int n, int nrhs, double* a, int lda, double* b, int ldb)
  10518. {
  10519. int info;
  10520. ::F_DPOTRS(&uplo, &n, &nrhs, a, &lda, b, &ldb, &info);
  10521. return info;
  10522. }
  10523. /**
  10524. * Purpose
  10525. * =======
  10526. *
  10527. * DPPCON estimates the reciprocal of the condition number (in the
  10528. * 1-norm) of a real symmetric positive definite packed matrix using
  10529. * the Cholesky factorization A = U**T*U or A = L*L**T computed by
  10530. * DPPTRF.
  10531. *
  10532. * An estimate is obtained for norm(inv(A)), and the reciprocal of the
  10533. * condition number is computed as RCOND = 1 / (ANORM * norm(inv(A))).
  10534. *
  10535. * Arguments
  10536. * =========
  10537. *
  10538. * UPLO (input) CHARACTER*1
  10539. * = 'U': Upper triangle of A is stored;
  10540. * = 'L': Lower triangle of A is stored.
  10541. *
  10542. * N (input) INTEGER
  10543. * The order of the matrix A. N >= 0.
  10544. *
  10545. * AP (input) DOUBLE PRECISION array, dimension (N*(N+1)/2)
  10546. * The triangular factor U or L from the Cholesky factorization
  10547. * A = U**T*U or A = L*L**T, packed columnwise in a linear
  10548. * array. The j-th column of U or L is stored in the array AP
  10549. * as follows:
  10550. * if UPLO = 'U', AP(i + (j-1)*j/2) = U(i,j) for 1<=i<=j;
  10551. * if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = L(i,j) for j<=i<=n.
  10552. *
  10553. * ANORM (input) DOUBLE PRECISION
  10554. * The 1-norm (or infinity-norm) of the symmetric matrix A.
  10555. *
  10556. * RCOND (output) DOUBLE PRECISION
  10557. * The reciprocal of the condition number of the matrix A,
  10558. * computed as RCOND = 1/(ANORM * AINVNM), where AINVNM is an
  10559. * estimate of the 1-norm of inv(A) computed in this routine.
  10560. *
  10561. * WORK (workspace) DOUBLE PRECISION array, dimension (3*N)
  10562. *
  10563. * IWORK (workspace) INTEGER array, dimension (N)
  10564. *
  10565. * C++ Return value: INFO (output) INTEGER
  10566. * = 0: successful exit
  10567. * < 0: if INFO = -i, the i-th argument had an illegal value
  10568. *
  10569. * =====================================================================
  10570. *
  10571. * .. Parameters ..
  10572. **/
  10573. int C_DPPCON(char uplo, int n, double* ap, double anorm, double* rcond, double* work, int* iwork)
  10574. {
  10575. int info;
  10576. ::F_DPPCON(&uplo, &n, ap, &anorm, rcond, work, iwork, &info);
  10577. return info;
  10578. }
  10579. /**
  10580. * Purpose
  10581. * =======
  10582. *
  10583. * DPPEQU computes row and column scalings intended to equilibrate a
  10584. * symmetric positive definite matrix A in packed storage and reduce
  10585. * its condition number (with respect to the two-norm). S contains the
  10586. * scale factors, S(i)=1/sqrt(A(i,i)), chosen so that the scaled matrix
  10587. * B with elements B(i,j)=S(i)*A(i,j)*S(j) has ones on the diagonal.
  10588. * This choice of S puts the condition number of B within a factor N of
  10589. * the smallest possible condition number over all possible diagonal
  10590. * scalings.
  10591. *
  10592. * Arguments
  10593. * =========
  10594. *
  10595. * UPLO (input) CHARACTER*1
  10596. * = 'U': Upper triangle of A is stored;
  10597. * = 'L': Lower triangle of A is stored.
  10598. *
  10599. * N (input) INTEGER
  10600. * The order of the matrix A. N >= 0.
  10601. *
  10602. * AP (input) DOUBLE PRECISION array, dimension (N*(N+1)/2)
  10603. * The upper or lower triangle of the symmetric matrix A, packed
  10604. * columnwise in a linear array. The j-th column of A is stored
  10605. * in the array AP as follows:
  10606. * if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
  10607. * if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n.
  10608. *
  10609. * S (output) DOUBLE PRECISION array, dimension (N)
  10610. * If INFO = 0, S contains the scale factors for A.
  10611. *
  10612. * SCOND (output) DOUBLE PRECISION
  10613. * If INFO = 0, S contains the ratio of the smallest S(i) to
  10614. * the largest S(i). If SCOND >= 0.1 and AMAX is neither too
  10615. * large nor too small, it is not worth scaling by S.
  10616. *
  10617. * AMAX (output) DOUBLE PRECISION
  10618. * Absolute value of largest matrix element. If AMAX is very
  10619. * close to overflow or very close to underflow, the matrix
  10620. * should be scaled.
  10621. *
  10622. * C++ Return value: INFO (output) INTEGER
  10623. * = 0: successful exit
  10624. * < 0: if INFO = -i, the i-th argument had an illegal value
  10625. * > 0: if INFO = i, the i-th diagonal element is nonpositive.
  10626. *
  10627. * =====================================================================
  10628. *
  10629. * .. Parameters ..
  10630. **/
  10631. int C_DPPEQU(char uplo, int n, double* ap, double* s, double* scond, double* amax)
  10632. {
  10633. int info;
  10634. ::F_DPPEQU(&uplo, &n, ap, s, scond, amax, &info);
  10635. return info;
  10636. }
  10637. /**
  10638. * Purpose
  10639. * =======
  10640. *
  10641. * DPPRFS improves the computed solution to a system of linear
  10642. * equations when the coefficient matrix is symmetric positive definite
  10643. * and packed, and provides error bounds and backward error estimates
  10644. * for the solution.
  10645. *
  10646. * Arguments
  10647. * =========
  10648. *
  10649. * UPLO (input) CHARACTER*1
  10650. * = 'U': Upper triangle of A is stored;
  10651. * = 'L': Lower triangle of A is stored.
  10652. *
  10653. * N (input) INTEGER
  10654. * The order of the matrix A. N >= 0.
  10655. *
  10656. * NRHS (input) INTEGER
  10657. * The number of right hand sides, i.e., the number of columns
  10658. * of the matrices B and X. NRHS >= 0.
  10659. *
  10660. * AP (input) DOUBLE PRECISION array, dimension (N*(N+1)/2)
  10661. * The upper or lower triangle of the symmetric matrix A, packed
  10662. * columnwise in a linear array. The j-th column of A is stored
  10663. * in the array AP as follows:
  10664. * if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
  10665. * if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n.
  10666. *
  10667. * AFP (input) DOUBLE PRECISION array, dimension (N*(N+1)/2)
  10668. * The triangular factor U or L from the Cholesky factorization
  10669. * A = U**T*U or A = L*L**T, as computed by DPPTRF/ZPPTRF,
  10670. * packed columnwise in a linear array in the same format as A
  10671. * (see AP).
  10672. *
  10673. * B (input) DOUBLE PRECISION array, dimension (LDB,NRHS)
  10674. * The right hand side matrix B.
  10675. *
  10676. * LDB (input) INTEGER
  10677. * The leading dimension of the array B. LDB >= max(1,N).
  10678. *
  10679. * X (input/output) DOUBLE PRECISION array, dimension (LDX,NRHS)
  10680. * On entry, the solution matrix X, as computed by DPPTRS.
  10681. * On exit, the improved solution matrix X.
  10682. *
  10683. * LDX (input) INTEGER
  10684. * The leading dimension of the array X. LDX >= max(1,N).
  10685. *
  10686. * FERR (output) DOUBLE PRECISION array, dimension (NRHS)
  10687. * The estimated forward error bound for each solution vector
  10688. * X(j) (the j-th column of the solution matrix X).
  10689. * If XTRUE is the true solution corresponding to X(j), FERR(j)
  10690. * is an estimated upper bound for the magnitude of the largest
  10691. * element in (X(j) - XTRUE) divided by the magnitude of the
  10692. * largest element in X(j). The estimate is as reliable as
  10693. * the estimate for RCOND, and is almost always a slight
  10694. * overestimate of the true error.
  10695. *
  10696. * BERR (output) DOUBLE PRECISION array, dimension (NRHS)
  10697. * The componentwise relative backward error of each solution
  10698. * vector X(j) (i.e., the smallest relative change in
  10699. * any element of A or B that makes X(j) an exact solution).
  10700. *
  10701. * WORK (workspace) DOUBLE PRECISION array, dimension (3*N)
  10702. *
  10703. * IWORK (workspace) INTEGER array, dimension (N)
  10704. *
  10705. * C++ Return value: INFO (output) INTEGER
  10706. * = 0: successful exit
  10707. * < 0: if INFO = -i, the i-th argument had an illegal value
  10708. *
  10709. * Internal Parameters
  10710. * ===================
  10711. *
  10712. * ITMAX is the maximum number of steps of iterative refinement.
  10713. *
  10714. * =====================================================================
  10715. *
  10716. * .. Parameters ..
  10717. **/
  10718. int C_DPPRFS(char uplo, int n, int nrhs, double* ap, double* afp, double* b, int ldb, double* x, int ldx, double* ferr, double* berr, double* work, int* iwork)
  10719. {
  10720. int info;
  10721. ::F_DPPRFS(&uplo, &n, &nrhs, ap, afp, b, &ldb, x, &ldx, ferr, berr, work, iwork, &info);
  10722. return info;
  10723. }
  10724. /**
  10725. * Purpose
  10726. * =======
  10727. *
  10728. * DPPSV computes the solution to a real system of linear equations
  10729. * A * X = B,
  10730. * where A is an N-by-N symmetric positive definite matrix stored in
  10731. * packed format and X and B are N-by-NRHS matrices.
  10732. *
  10733. * The Cholesky decomposition is used to factor A as
  10734. * A = U**T* U, if UPLO = 'U', or
  10735. * A = L * L**T, if UPLO = 'L',
  10736. * where U is an upper triangular matrix and L is a lower triangular
  10737. * matrix. The factored form of A is then used to solve the system of
  10738. * equations A * X = B.
  10739. *
  10740. * Arguments
  10741. * =========
  10742. *
  10743. * UPLO (input) CHARACTER*1
  10744. * = 'U': Upper triangle of A is stored;
  10745. * = 'L': Lower triangle of A is stored.
  10746. *
  10747. * N (input) INTEGER
  10748. * The number of linear equations, i.e., the order of the
  10749. * matrix A. N >= 0.
  10750. *
  10751. * NRHS (input) INTEGER
  10752. * The number of right hand sides, i.e., the number of columns
  10753. * of the matrix B. NRHS >= 0.
  10754. *
  10755. * AP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2)
  10756. * On entry, the upper or lower triangle of the symmetric matrix
  10757. * A, packed columnwise in a linear array. The j-th column of A
  10758. * is stored in the array AP as follows:
  10759. * if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
  10760. * if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n.
  10761. * See below for further details.
  10762. *
  10763. * On exit, if INFO = 0, the factor U or L from the Cholesky
  10764. * factorization A = U**T*U or A = L*L**T, in the same storage
  10765. * format as A.
  10766. *
  10767. * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
  10768. * On entry, the N-by-NRHS right hand side matrix B.
  10769. * On exit, if INFO = 0, the N-by-NRHS solution matrix X.
  10770. *
  10771. * LDB (input) INTEGER
  10772. * The leading dimension of the array B. LDB >= max(1,N).
  10773. *
  10774. * C++ Return value: INFO (output) INTEGER
  10775. * = 0: successful exit
  10776. * < 0: if INFO = -i, the i-th argument had an illegal value
  10777. * > 0: if INFO = i, the leading minor of order i of A is not
  10778. * positive definite, so the factorization could not be
  10779. * completed, and the solution has not been computed.
  10780. *
  10781. * Further Details
  10782. * ===============
  10783. *
  10784. * The packed storage scheme is illustrated by the following example
  10785. * when N = 4, UPLO = 'U':
  10786. *
  10787. * Two-dimensional storage of the symmetric matrix A:
  10788. *
  10789. * a11 a12 a13 a14
  10790. * a22 a23 a24
  10791. * a33 a34 (aij = conjg(aji))
  10792. * a44
  10793. *
  10794. * Packed storage of the upper triangle of A:
  10795. *
  10796. * AP = [ a11, a12, a22, a13, a23, a33, a14, a24, a34, a44 ]
  10797. *
  10798. * =====================================================================
  10799. *
  10800. * .. External Functions ..
  10801. **/
  10802. int C_DPPSV(char uplo, int n, int nrhs, double* ap, double* b, int ldb)
  10803. {
  10804. int info;
  10805. ::F_DPPSV(&uplo, &n, &nrhs, ap, b, &ldb, &info);
  10806. return info;
  10807. }
  10808. /**
  10809. * Purpose
  10810. * =======
  10811. *
  10812. * DPPSVX uses the Cholesky factorization A = U**T*U or A = L*L**T to
  10813. * compute the solution to a real system of linear equations
  10814. * A * X = B,
  10815. * where A is an N-by-N symmetric positive definite matrix stored in
  10816. * packed format and X and B are N-by-NRHS matrices.
  10817. *
  10818. * Error bounds on the solution and a condition estimate are also
  10819. * provided.
  10820. *
  10821. * Description
  10822. * ===========
  10823. *
  10824. * The following steps are performed:
  10825. *
  10826. * 1. If FACT = 'E', real scaling factors are computed to equilibrate
  10827. * the system:
  10828. * diag(S) * A * diag(S) * inv(diag(S)) * X = diag(S) * B
  10829. * Whether or not the system will be equilibrated depends on the
  10830. * scaling of the matrix A, but if equilibration is used, A is
  10831. * overwritten by diag(S)*A*diag(S) and B by diag(S)*B.
  10832. *
  10833. * 2. If FACT = 'N' or 'E', the Cholesky decomposition is used to
  10834. * factor the matrix A (after equilibration if FACT = 'E') as
  10835. * A = U**T* U, if UPLO = 'U', or
  10836. * A = L * L**T, if UPLO = 'L',
  10837. * where U is an upper triangular matrix and L is a lower triangular
  10838. * matrix.
  10839. *
  10840. * 3. If the leading i-by-i principal minor is not positive definite,
  10841. * then the routine returns with INFO = i. Otherwise, the factored
  10842. * form of A is used to estimate the condition number of the matrix
  10843. * A. If the reciprocal of the condition number is less than machine
  10844. * precision, INFO = N+1 is returned as a warning, but the routine
  10845. * still goes on to solve for X and compute error bounds as
  10846. * described below.
  10847. *
  10848. * 4. The system of equations is solved for X using the factored form
  10849. * of A.
  10850. *
  10851. * 5. Iterative refinement is applied to improve the computed solution
  10852. * matrix and calculate error bounds and backward error estimates
  10853. * for it.
  10854. *
  10855. * 6. If equilibration was used, the matrix X is premultiplied by
  10856. * diag(S) so that it solves the original system before
  10857. * equilibration.
  10858. *
  10859. * Arguments
  10860. * =========
  10861. *
  10862. * FACT (input) CHARACTER*1
  10863. * Specifies whether or not the factored form of the matrix A is
  10864. * supplied on entry, and if not, whether the matrix A should be
  10865. * equilibrated before it is factored.
  10866. * = 'F': On entry, AFP contains the factored form of A.
  10867. * If EQUED = 'Y', the matrix A has been equilibrated
  10868. * with scaling factors given by S. AP and AFP will not
  10869. * be modified.
  10870. * = 'N': The matrix A will be copied to AFP and factored.
  10871. * = 'E': The matrix A will be equilibrated if necessary, then
  10872. * copied to AFP and factored.
  10873. *
  10874. * UPLO (input) CHARACTER*1
  10875. * = 'U': Upper triangle of A is stored;
  10876. * = 'L': Lower triangle of A is stored.
  10877. *
  10878. * N (input) INTEGER
  10879. * The number of linear equations, i.e., the order of the
  10880. * matrix A. N >= 0.
  10881. *
  10882. * NRHS (input) INTEGER
  10883. * The number of right hand sides, i.e., the number of columns
  10884. * of the matrices B and X. NRHS >= 0.
  10885. *
  10886. * AP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2)
  10887. * On entry, the upper or lower triangle of the symmetric matrix
  10888. * A, packed columnwise in a linear array, except if FACT = 'F'
  10889. * and EQUED = 'Y', then A must contain the equilibrated matrix
  10890. * diag(S)*A*diag(S). The j-th column of A is stored in the
  10891. * array AP as follows:
  10892. * if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
  10893. * if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n.
  10894. * See below for further details. A is not modified if
  10895. * FACT = 'F' or 'N', or if FACT = 'E' and EQUED = 'N' on exit.
  10896. *
  10897. * On exit, if FACT = 'E' and EQUED = 'Y', A is overwritten by
  10898. * diag(S)*A*diag(S).
  10899. *
  10900. * AFP (input or output) DOUBLE PRECISION array, dimension
  10901. * (N*(N+1)/2)
  10902. * If FACT = 'F', then AFP is an input argument and on entry
  10903. * contains the triangular factor U or L from the Cholesky
  10904. * factorization A = U'*U or A = L*L', in the same storage
  10905. * format as A. If EQUED .ne. 'N', then AFP is the factored
  10906. * form of the equilibrated matrix A.
  10907. *
  10908. * If FACT = 'N', then AFP is an output argument and on exit
  10909. * returns the triangular factor U or L from the Cholesky
  10910. * factorization A = U'*U or A = L*L' of the original matrix A.
  10911. *
  10912. * If FACT = 'E', then AFP is an output argument and on exit
  10913. * returns the triangular factor U or L from the Cholesky
  10914. * factorization A = U'*U or A = L*L' of the equilibrated
  10915. * matrix A (see the description of AP for the form of the
  10916. * equilibrated matrix).
  10917. *
  10918. * EQUED (input or output) CHARACTER*1
  10919. * Specifies the form of equilibration that was done.
  10920. * = 'N': No equilibration (always true if FACT = 'N').
  10921. * = 'Y': Equilibration was done, i.e., A has been replaced by
  10922. * diag(S) * A * diag(S).
  10923. * EQUED is an input argument if FACT = 'F'; otherwise, it is an
  10924. * output argument.
  10925. *
  10926. * S (input or output) DOUBLE PRECISION array, dimension (N)
  10927. * The scale factors for A; not accessed if EQUED = 'N'. S is
  10928. * an input argument if FACT = 'F'; otherwise, S is an output
  10929. * argument. If FACT = 'F' and EQUED = 'Y', each element of S
  10930. * must be positive.
  10931. *
  10932. * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
  10933. * On entry, the N-by-NRHS right hand side matrix B.
  10934. * On exit, if EQUED = 'N', B is not modified; if EQUED = 'Y',
  10935. * B is overwritten by diag(S) * B.
  10936. *
  10937. * LDB (input) INTEGER
  10938. * The leading dimension of the array B. LDB >= max(1,N).
  10939. *
  10940. * X (output) DOUBLE PRECISION array, dimension (LDX,NRHS)
  10941. * If INFO = 0 or INFO = N+1, the N-by-NRHS solution matrix X to
  10942. * the original system of equations. Note that if EQUED = 'Y',
  10943. * A and B are modified on exit, and the solution to the
  10944. * equilibrated system is inv(diag(S))*X.
  10945. *
  10946. * LDX (input) INTEGER
  10947. * The leading dimension of the array X. LDX >= max(1,N).
  10948. *
  10949. * RCOND (output) DOUBLE PRECISION
  10950. * The estimate of the reciprocal condition number of the matrix
  10951. * A after equilibration (if done). If RCOND is less than the
  10952. * machine precision (in particular, if RCOND = 0), the matrix
  10953. * is singular to working precision. This condition is
  10954. * indicated by a return code of INFO > 0.
  10955. *
  10956. * FERR (output) DOUBLE PRECISION array, dimension (NRHS)
  10957. * The estimated forward error bound for each solution vector
  10958. * X(j) (the j-th column of the solution matrix X).
  10959. * If XTRUE is the true solution corresponding to X(j), FERR(j)
  10960. * is an estimated upper bound for the magnitude of the largest
  10961. * element in (X(j) - XTRUE) divided by the magnitude of the
  10962. * largest element in X(j). The estimate is as reliable as
  10963. * the estimate for RCOND, and is almost always a slight
  10964. * overestimate of the true error.
  10965. *
  10966. * BERR (output) DOUBLE PRECISION array, dimension (NRHS)
  10967. * The componentwise relative backward error of each solution
  10968. * vector X(j) (i.e., the smallest relative change in
  10969. * any element of A or B that makes X(j) an exact solution).
  10970. *
  10971. * WORK (workspace) DOUBLE PRECISION array, dimension (3*N)
  10972. *
  10973. * IWORK (workspace) INTEGER array, dimension (N)
  10974. *
  10975. * C++ Return value: INFO (output) INTEGER
  10976. * = 0: successful exit
  10977. * < 0: if INFO = -i, the i-th argument had an illegal value
  10978. * > 0: if INFO = i, and i is
  10979. * <= N: the leading minor of order i of A is
  10980. * not positive definite, so the factorization
  10981. * could not be completed, and the solution has not
  10982. * been computed. RCOND = 0 is returned.
  10983. * = N+1: U is nonsingular, but RCOND is less than machine
  10984. * precision, meaning that the matrix is singular
  10985. * to working precision. Nevertheless, the
  10986. * solution and error bounds are computed because
  10987. * there are a number of situations where the
  10988. * computed solution can be more accurate than the
  10989. * value of RCOND would suggest.
  10990. *
  10991. * Further Details
  10992. * ===============
  10993. *
  10994. * The packed storage scheme is illustrated by the following example
  10995. * when N = 4, UPLO = 'U':
  10996. *
  10997. * Two-dimensional storage of the symmetric matrix A:
  10998. *
  10999. * a11 a12 a13 a14
  11000. * a22 a23 a24
  11001. * a33 a34 (aij = conjg(aji))
  11002. * a44
  11003. *
  11004. * Packed storage of the upper triangle of A:
  11005. *
  11006. * AP = [ a11, a12, a22, a13, a23, a33, a14, a24, a34, a44 ]
  11007. *
  11008. * =====================================================================
  11009. *
  11010. * .. Parameters ..
  11011. **/
  11012. int C_DPPSVX(char fact, char uplo, int n, int nrhs, double* ap, double* afp, char equed, double* s, double* b, int ldb, double* x, int ldx, double* rcond, double* ferr, double* berr, double* work, int* iwork)
  11013. {
  11014. int info;
  11015. ::F_DPPSVX(&fact, &uplo, &n, &nrhs, ap, afp, &equed, s, b, &ldb, x, &ldx, rcond, ferr, berr, work, iwork, &info);
  11016. return info;
  11017. }
  11018. /**
  11019. * Purpose
  11020. * =======
  11021. *
  11022. * DPPTRF computes the Cholesky factorization of a real symmetric
  11023. * positive definite matrix A stored in packed format.
  11024. *
  11025. * The factorization has the form
  11026. * A = U**T * U, if UPLO = 'U', or
  11027. * A = L * L**T, if UPLO = 'L',
  11028. * where U is an upper triangular matrix and L is lower triangular.
  11029. *
  11030. * Arguments
  11031. * =========
  11032. *
  11033. * UPLO (input) CHARACTER*1
  11034. * = 'U': Upper triangle of A is stored;
  11035. * = 'L': Lower triangle of A is stored.
  11036. *
  11037. * N (input) INTEGER
  11038. * The order of the matrix A. N >= 0.
  11039. *
  11040. * AP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2)
  11041. * On entry, the upper or lower triangle of the symmetric matrix
  11042. * A, packed columnwise in a linear array. The j-th column of A
  11043. * is stored in the array AP as follows:
  11044. * if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
  11045. * if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n.
  11046. * See below for further details.
  11047. *
  11048. * On exit, if INFO = 0, the triangular factor U or L from the
  11049. * Cholesky factorization A = U**T*U or A = L*L**T, in the same
  11050. * storage format as A.
  11051. *
  11052. * C++ Return value: INFO (output) INTEGER
  11053. * = 0: successful exit
  11054. * < 0: if INFO = -i, the i-th argument had an illegal value
  11055. * > 0: if INFO = i, the leading minor of order i is not
  11056. * positive definite, and the factorization could not be
  11057. * completed.
  11058. *
  11059. * Further Details
  11060. * ======= =======
  11061. *
  11062. * The packed storage scheme is illustrated by the following example
  11063. * when N = 4, UPLO = 'U':
  11064. *
  11065. * Two-dimensional storage of the symmetric matrix A:
  11066. *
  11067. * a11 a12 a13 a14
  11068. * a22 a23 a24
  11069. * a33 a34 (aij = aji)
  11070. * a44
  11071. *
  11072. * Packed storage of the upper triangle of A:
  11073. *
  11074. * AP = [ a11, a12, a22, a13, a23, a33, a14, a24, a34, a44 ]
  11075. *
  11076. * =====================================================================
  11077. *
  11078. * .. Parameters ..
  11079. **/
  11080. int C_DPPTRF(char uplo, int n, double* ap)
  11081. {
  11082. int info;
  11083. ::F_DPPTRF(&uplo, &n, ap, &info);
  11084. return info;
  11085. }
  11086. /**
  11087. * Purpose
  11088. * =======
  11089. *
  11090. * DPPTRI computes the inverse of a real symmetric positive definite
  11091. * matrix A using the Cholesky factorization A = U**T*U or A = L*L**T
  11092. * computed by DPPTRF.
  11093. *
  11094. * Arguments
  11095. * =========
  11096. *
  11097. * UPLO (input) CHARACTER*1
  11098. * = 'U': Upper triangular factor is stored in AP;
  11099. * = 'L': Lower triangular factor is stored in AP.
  11100. *
  11101. * N (input) INTEGER
  11102. * The order of the matrix A. N >= 0.
  11103. *
  11104. * AP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2)
  11105. * On entry, the triangular factor U or L from the Cholesky
  11106. * factorization A = U**T*U or A = L*L**T, packed columnwise as
  11107. * a linear array. The j-th column of U or L is stored in the
  11108. * array AP as follows:
  11109. * if UPLO = 'U', AP(i + (j-1)*j/2) = U(i,j) for 1<=i<=j;
  11110. * if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = L(i,j) for j<=i<=n.
  11111. *
  11112. * On exit, the upper or lower triangle of the (symmetric)
  11113. * inverse of A, overwriting the input factor U or L.
  11114. *
  11115. * C++ Return value: INFO (output) INTEGER
  11116. * = 0: successful exit
  11117. * < 0: if INFO = -i, the i-th argument had an illegal value
  11118. * > 0: if INFO = i, the (i,i) element of the factor U or L is
  11119. * zero, and the inverse could not be computed.
  11120. *
  11121. * =====================================================================
  11122. *
  11123. * .. Parameters ..
  11124. **/
  11125. int C_DPPTRI(char uplo, int n, double* ap)
  11126. {
  11127. int info;
  11128. ::F_DPPTRI(&uplo, &n, ap, &info);
  11129. return info;
  11130. }
  11131. /**
  11132. * Purpose
  11133. * =======
  11134. *
  11135. * DPPTRS solves a system of linear equations A*X = B with a symmetric
  11136. * positive definite matrix A in packed storage using the Cholesky
  11137. * factorization A = U**T*U or A = L*L**T computed by DPPTRF.
  11138. *
  11139. * Arguments
  11140. * =========
  11141. *
  11142. * UPLO (input) CHARACTER*1
  11143. * = 'U': Upper triangle of A is stored;
  11144. * = 'L': Lower triangle of A is stored.
  11145. *
  11146. * N (input) INTEGER
  11147. * The order of the matrix A. N >= 0.
  11148. *
  11149. * NRHS (input) INTEGER
  11150. * The number of right hand sides, i.e., the number of columns
  11151. * of the matrix B. NRHS >= 0.
  11152. *
  11153. * AP (input) DOUBLE PRECISION array, dimension (N*(N+1)/2)
  11154. * The triangular factor U or L from the Cholesky factorization
  11155. * A = U**T*U or A = L*L**T, packed columnwise in a linear
  11156. * array. The j-th column of U or L is stored in the array AP
  11157. * as follows:
  11158. * if UPLO = 'U', AP(i + (j-1)*j/2) = U(i,j) for 1<=i<=j;
  11159. * if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = L(i,j) for j<=i<=n.
  11160. *
  11161. * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
  11162. * On entry, the right hand side matrix B.
  11163. * On exit, the solution matrix X.
  11164. *
  11165. * LDB (input) INTEGER
  11166. * The leading dimension of the array B. LDB >= max(1,N).
  11167. *
  11168. * C++ Return value: INFO (output) INTEGER
  11169. * = 0: successful exit
  11170. * < 0: if INFO = -i, the i-th argument had an illegal value
  11171. *
  11172. * =====================================================================
  11173. *
  11174. * .. Local Scalars ..
  11175. **/
  11176. int C_DPPTRS(char uplo, int n, int nrhs, double* ap, double* b, int ldb)
  11177. {
  11178. int info;
  11179. ::F_DPPTRS(&uplo, &n, &nrhs, ap, b, &ldb, &info);
  11180. return info;
  11181. }
  11182. /**
  11183. * Purpose
  11184. * =======
  11185. *
  11186. * DPTCON computes the reciprocal of the condition number (in the
  11187. * 1-norm) of a real symmetric positive definite tridiagonal matrix
  11188. * using the factorization A = L*D*L**T or A = U**T*D*U computed by
  11189. * DPTTRF.
  11190. *
  11191. * Norm(inv(A)) is computed by a direct method, and the reciprocal of
  11192. * the condition number is computed as
  11193. * RCOND = 1 / (ANORM * norm(inv(A))).
  11194. *
  11195. * Arguments
  11196. * =========
  11197. *
  11198. * N (input) INTEGER
  11199. * The order of the matrix A. N >= 0.
  11200. *
  11201. * D (input) DOUBLE PRECISION array, dimension (N)
  11202. * The n diagonal elements of the diagonal matrix D from the
  11203. * factorization of A, as computed by DPTTRF.
  11204. *
  11205. * E (input) DOUBLE PRECISION array, dimension (N-1)
  11206. * The (n-1) off-diagonal elements of the unit bidiagonal factor
  11207. * U or L from the factorization of A, as computed by DPTTRF.
  11208. *
  11209. * ANORM (input) DOUBLE PRECISION
  11210. * The 1-norm of the original matrix A.
  11211. *
  11212. * RCOND (output) DOUBLE PRECISION
  11213. * The reciprocal of the condition number of the matrix A,
  11214. * computed as RCOND = 1/(ANORM * AINVNM), where AINVNM is the
  11215. * 1-norm of inv(A) computed in this routine.
  11216. *
  11217. * WORK (workspace) DOUBLE PRECISION array, dimension (N)
  11218. *
  11219. * C++ Return value: INFO (output) INTEGER
  11220. * = 0: successful exit
  11221. * < 0: if INFO = -i, the i-th argument had an illegal value
  11222. *
  11223. * Further Details
  11224. * ===============
  11225. *
  11226. * The method used is described in Nicholas J. Higham, "Efficient
  11227. * Algorithms for Computing the Condition Number of a Tridiagonal
  11228. * Matrix", SIAM J. Sci. Stat. Comput., Vol. 7, No. 1, January 1986.
  11229. *
  11230. * =====================================================================
  11231. *
  11232. * .. Parameters ..
  11233. **/
  11234. int C_DPTCON(int n, double* d, double* e, double anorm, double* rcond, double* work)
  11235. {
  11236. int info;
  11237. ::F_DPTCON(&n, d, e, &anorm, rcond, work, &info);
  11238. return info;
  11239. }
  11240. /**
  11241. * Purpose
  11242. * =======
  11243. *
  11244. * DPTEQR computes all eigenvalues and, optionally, eigenvectors of a
  11245. * symmetric positive definite tridiagonal matrix by first factoring the
  11246. * matrix using DPTTRF, and then calling DBDSQR to compute the singular
  11247. * values of the bidiagonal factor.
  11248. *
  11249. * This routine computes the eigenvalues of the positive definite
  11250. * tridiagonal matrix to high relative accuracy. This means that if the
  11251. * eigenvalues range over many orders of magnitude in size, then the
  11252. * small eigenvalues and corresponding eigenvectors will be computed
  11253. * more accurately than, for example, with the standard QR method.
  11254. *
  11255. * The eigenvectors of a full or band symmetric positive definite matrix
  11256. * can also be found if DSYTRD, DSPTRD, or DSBTRD has been used to
  11257. * reduce this matrix to tridiagonal form. (The reduction to tridiagonal
  11258. * form, however, may preclude the possibility of obtaining high
  11259. * relative accuracy in the small eigenvalues of the original matrix, if
  11260. * these eigenvalues range over many orders of magnitude.)
  11261. *
  11262. * Arguments
  11263. * =========
  11264. *
  11265. * COMPZ (input) CHARACTER*1
  11266. * = 'N': Compute eigenvalues only.
  11267. * = 'V': Compute eigenvectors of original symmetric
  11268. * matrix also. Array Z contains the orthogonal
  11269. * matrix used to reduce the original matrix to
  11270. * tridiagonal form.
  11271. * = 'I': Compute eigenvectors of tridiagonal matrix also.
  11272. *
  11273. * N (input) INTEGER
  11274. * The order of the matrix. N >= 0.
  11275. *
  11276. * D (input/output) DOUBLE PRECISION array, dimension (N)
  11277. * On entry, the n diagonal elements of the tridiagonal
  11278. * matrix.
  11279. * On normal exit, D contains the eigenvalues, in descending
  11280. * order.
  11281. *
  11282. * E (input/output) DOUBLE PRECISION array, dimension (N-1)
  11283. * On entry, the (n-1) subdiagonal elements of the tridiagonal
  11284. * matrix.
  11285. * On exit, E has been destroyed.
  11286. *
  11287. * Z (input/output) DOUBLE PRECISION array, dimension (LDZ, N)
  11288. * On entry, if COMPZ = 'V', the orthogonal matrix used in the
  11289. * reduction to tridiagonal form.
  11290. * On exit, if COMPZ = 'V', the orthonormal eigenvectors of the
  11291. * original symmetric matrix;
  11292. * if COMPZ = 'I', the orthonormal eigenvectors of the
  11293. * tridiagonal matrix.
  11294. * If INFO > 0 on exit, Z contains the eigenvectors associated
  11295. * with only the stored eigenvalues.
  11296. * If COMPZ = 'N', then Z is not referenced.
  11297. *
  11298. * LDZ (input) INTEGER
  11299. * The leading dimension of the array Z. LDZ >= 1, and if
  11300. * COMPZ = 'V' or 'I', LDZ >= max(1,N).
  11301. *
  11302. * WORK (workspace) DOUBLE PRECISION array, dimension (4*N)
  11303. *
  11304. * C++ Return value: INFO (output) INTEGER
  11305. * = 0: successful exit.
  11306. * < 0: if INFO = -i, the i-th argument had an illegal value.
  11307. * > 0: if INFO = i, and i is:
  11308. * <= N the Cholesky factorization of the matrix could
  11309. * not be performed because the i-th principal minor
  11310. * was not positive definite.
  11311. * > N the SVD algorithm failed to converge;
  11312. * if INFO = N+i, i off-diagonal elements of the
  11313. * bidiagonal factor did not converge to zero.
  11314. *
  11315. * =====================================================================
  11316. *
  11317. * .. Parameters ..
  11318. **/
  11319. int C_DPTEQR(char compz, int n, double* d, double* e, double* z, int ldz, double* work)
  11320. {
  11321. int info;
  11322. ::F_DPTEQR(&compz, &n, d, e, z, &ldz, work, &info);
  11323. return info;
  11324. }
  11325. /**
  11326. * Purpose
  11327. * =======
  11328. *
  11329. * DPTRFS improves the computed solution to a system of linear
  11330. * equations when the coefficient matrix is symmetric positive definite
  11331. * and tridiagonal, and provides error bounds and backward error
  11332. * estimates for the solution.
  11333. *
  11334. * Arguments
  11335. * =========
  11336. *
  11337. * N (input) INTEGER
  11338. * The order of the matrix A. N >= 0.
  11339. *
  11340. * NRHS (input) INTEGER
  11341. * The number of right hand sides, i.e., the number of columns
  11342. * of the matrix B. NRHS >= 0.
  11343. *
  11344. * D (input) DOUBLE PRECISION array, dimension (N)
  11345. * The n diagonal elements of the tridiagonal matrix A.
  11346. *
  11347. * E (input) DOUBLE PRECISION array, dimension (N-1)
  11348. * The (n-1) subdiagonal elements of the tridiagonal matrix A.
  11349. *
  11350. * DF (input) DOUBLE PRECISION array, dimension (N)
  11351. * The n diagonal elements of the diagonal matrix D from the
  11352. * factorization computed by DPTTRF.
  11353. *
  11354. * EF (input) DOUBLE PRECISION array, dimension (N-1)
  11355. * The (n-1) subdiagonal elements of the unit bidiagonal factor
  11356. * L from the factorization computed by DPTTRF.
  11357. *
  11358. * B (input) DOUBLE PRECISION array, dimension (LDB,NRHS)
  11359. * The right hand side matrix B.
  11360. *
  11361. * LDB (input) INTEGER
  11362. * The leading dimension of the array B. LDB >= max(1,N).
  11363. *
  11364. * X (input/output) DOUBLE PRECISION array, dimension (LDX,NRHS)
  11365. * On entry, the solution matrix X, as computed by DPTTRS.
  11366. * On exit, the improved solution matrix X.
  11367. *
  11368. * LDX (input) INTEGER
  11369. * The leading dimension of the array X. LDX >= max(1,N).
  11370. *
  11371. * FERR (output) DOUBLE PRECISION array, dimension (NRHS)
  11372. * The forward error bound for each solution vector
  11373. * X(j) (the j-th column of the solution matrix X).
  11374. * If XTRUE is the true solution corresponding to X(j), FERR(j)
  11375. * is an estimated upper bound for the magnitude of the largest
  11376. * element in (X(j) - XTRUE) divided by the magnitude of the
  11377. * largest element in X(j).
  11378. *
  11379. * BERR (output) DOUBLE PRECISION array, dimension (NRHS)
  11380. * The componentwise relative backward error of each solution
  11381. * vector X(j) (i.e., the smallest relative change in
  11382. * any element of A or B that makes X(j) an exact solution).
  11383. *
  11384. * WORK (workspace) DOUBLE PRECISION array, dimension (2*N)
  11385. *
  11386. * C++ Return value: INFO (output) INTEGER
  11387. * = 0: successful exit
  11388. * < 0: if INFO = -i, the i-th argument had an illegal value
  11389. *
  11390. * Internal Parameters
  11391. * ===================
  11392. *
  11393. * ITMAX is the maximum number of steps of iterative refinement.
  11394. *
  11395. * =====================================================================
  11396. *
  11397. * .. Parameters ..
  11398. **/
  11399. int C_DPTRFS(int n, int nrhs, double* d, double* e, double* df, double* ef, double* b, int ldb, double* x, int ldx, double* ferr, double* berr, double* work)
  11400. {
  11401. int info;
  11402. ::F_DPTRFS(&n, &nrhs, d, e, df, ef, b, &ldb, x, &ldx, ferr, berr, work, &info);
  11403. return info;
  11404. }
  11405. /**
  11406. * Purpose
  11407. * =======
  11408. *
  11409. * DPTSV computes the solution to a real system of linear equations
  11410. * A*X = B, where A is an N-by-N symmetric positive definite tridiagonal
  11411. * matrix, and X and B are N-by-NRHS matrices.
  11412. *
  11413. * A is factored as A = L*D*L**T, and the factored form of A is then
  11414. * used to solve the system of equations.
  11415. *
  11416. * Arguments
  11417. * =========
  11418. *
  11419. * N (input) INTEGER
  11420. * The order of the matrix A. N >= 0.
  11421. *
  11422. * NRHS (input) INTEGER
  11423. * The number of right hand sides, i.e., the number of columns
  11424. * of the matrix B. NRHS >= 0.
  11425. *
  11426. * D (input/output) DOUBLE PRECISION array, dimension (N)
  11427. * On entry, the n diagonal elements of the tridiagonal matrix
  11428. * A. On exit, the n diagonal elements of the diagonal matrix
  11429. * D from the factorization A = L*D*L**T.
  11430. *
  11431. * E (input/output) DOUBLE PRECISION array, dimension (N-1)
  11432. * On entry, the (n-1) subdiagonal elements of the tridiagonal
  11433. * matrix A. On exit, the (n-1) subdiagonal elements of the
  11434. * unit bidiagonal factor L from the L*D*L**T factorization of
  11435. * A. (E can also be regarded as the superdiagonal of the unit
  11436. * bidiagonal factor U from the U**T*D*U factorization of A.)
  11437. *
  11438. * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
  11439. * On entry, the N-by-NRHS right hand side matrix B.
  11440. * On exit, if INFO = 0, the N-by-NRHS solution matrix X.
  11441. *
  11442. * LDB (input) INTEGER
  11443. * The leading dimension of the array B. LDB >= max(1,N).
  11444. *
  11445. * C++ Return value: INFO (output) INTEGER
  11446. * = 0: successful exit
  11447. * < 0: if INFO = -i, the i-th argument had an illegal value
  11448. * > 0: if INFO = i, the leading minor of order i is not
  11449. * positive definite, and the solution has not been
  11450. * computed. The factorization has not been completed
  11451. * unless i = N.
  11452. *
  11453. * =====================================================================
  11454. *
  11455. * .. External Subroutines ..
  11456. **/
  11457. int C_DPTSV(int n, int nrhs, double* d, double* e, double* b, int ldb)
  11458. {
  11459. int info;
  11460. ::F_DPTSV(&n, &nrhs, d, e, b, &ldb, &info);
  11461. return info;
  11462. }
  11463. /**
  11464. * Purpose
  11465. * =======
  11466. *
  11467. * DPTSVX uses the factorization A = L*D*L**T to compute the solution
  11468. * to a real system of linear equations A*X = B, where A is an N-by-N
  11469. * symmetric positive definite tridiagonal matrix and X and B are
  11470. * N-by-NRHS matrices.
  11471. *
  11472. * Error bounds on the solution and a condition estimate are also
  11473. * provided.
  11474. *
  11475. * Description
  11476. * ===========
  11477. *
  11478. * The following steps are performed:
  11479. *
  11480. * 1. If FACT = 'N', the matrix A is factored as A = L*D*L**T, where L
  11481. * is a unit lower bidiagonal matrix and D is diagonal. The
  11482. * factorization can also be regarded as having the form
  11483. * A = U**T*D*U.
  11484. *
  11485. * 2. If the leading i-by-i principal minor is not positive definite,
  11486. * then the routine returns with INFO = i. Otherwise, the factored
  11487. * form of A is used to estimate the condition number of the matrix
  11488. * A. If the reciprocal of the condition number is less than machine
  11489. * precision, INFO = N+1 is returned as a warning, but the routine
  11490. * still goes on to solve for X and compute error bounds as
  11491. * described below.
  11492. *
  11493. * 3. The system of equations is solved for X using the factored form
  11494. * of A.
  11495. *
  11496. * 4. Iterative refinement is applied to improve the computed solution
  11497. * matrix and calculate error bounds and backward error estimates
  11498. * for it.
  11499. *
  11500. * Arguments
  11501. * =========
  11502. *
  11503. * FACT (input) CHARACTER*1
  11504. * Specifies whether or not the factored form of A has been
  11505. * supplied on entry.
  11506. * = 'F': On entry, DF and EF contain the factored form of A.
  11507. * D, E, DF, and EF will not be modified.
  11508. * = 'N': The matrix A will be copied to DF and EF and
  11509. * factored.
  11510. *
  11511. * N (input) INTEGER
  11512. * The order of the matrix A. N >= 0.
  11513. *
  11514. * NRHS (input) INTEGER
  11515. * The number of right hand sides, i.e., the number of columns
  11516. * of the matrices B and X. NRHS >= 0.
  11517. *
  11518. * D (input) DOUBLE PRECISION array, dimension (N)
  11519. * The n diagonal elements of the tridiagonal matrix A.
  11520. *
  11521. * E (input) DOUBLE PRECISION array, dimension (N-1)
  11522. * The (n-1) subdiagonal elements of the tridiagonal matrix A.
  11523. *
  11524. * DF (input or output) DOUBLE PRECISION array, dimension (N)
  11525. * If FACT = 'F', then DF is an input argument and on entry
  11526. * contains the n diagonal elements of the diagonal matrix D
  11527. * from the L*D*L**T factorization of A.
  11528. * If FACT = 'N', then DF is an output argument and on exit
  11529. * contains the n diagonal elements of the diagonal matrix D
  11530. * from the L*D*L**T factorization of A.
  11531. *
  11532. * EF (input or output) DOUBLE PRECISION array, dimension (N-1)
  11533. * If FACT = 'F', then EF is an input argument and on entry
  11534. * contains the (n-1) subdiagonal elements of the unit
  11535. * bidiagonal factor L from the L*D*L**T factorization of A.
  11536. * If FACT = 'N', then EF is an output argument and on exit
  11537. * contains the (n-1) subdiagonal elements of the unit
  11538. * bidiagonal factor L from the L*D*L**T factorization of A.
  11539. *
  11540. * B (input) DOUBLE PRECISION array, dimension (LDB,NRHS)
  11541. * The N-by-NRHS right hand side matrix B.
  11542. *
  11543. * LDB (input) INTEGER
  11544. * The leading dimension of the array B. LDB >= max(1,N).
  11545. *
  11546. * X (output) DOUBLE PRECISION array, dimension (LDX,NRHS)
  11547. * If INFO = 0 of INFO = N+1, the N-by-NRHS solution matrix X.
  11548. *
  11549. * LDX (input) INTEGER
  11550. * The leading dimension of the array X. LDX >= max(1,N).
  11551. *
  11552. * RCOND (output) DOUBLE PRECISION
  11553. * The reciprocal condition number of the matrix A. If RCOND
  11554. * is less than the machine precision (in particular, if
  11555. * RCOND = 0), the matrix is singular to working precision.
  11556. * This condition is indicated by a return code of INFO > 0.
  11557. *
  11558. * FERR (output) DOUBLE PRECISION array, dimension (NRHS)
  11559. * The forward error bound for each solution vector
  11560. * X(j) (the j-th column of the solution matrix X).
  11561. * If XTRUE is the true solution corresponding to X(j), FERR(j)
  11562. * is an estimated upper bound for the magnitude of the largest
  11563. * element in (X(j) - XTRUE) divided by the magnitude of the
  11564. * largest element in X(j).
  11565. *
  11566. * BERR (output) DOUBLE PRECISION array, dimension (NRHS)
  11567. * The componentwise relative backward error of each solution
  11568. * vector X(j) (i.e., the smallest relative change in any
  11569. * element of A or B that makes X(j) an exact solution).
  11570. *
  11571. * WORK (workspace) DOUBLE PRECISION array, dimension (2*N)
  11572. *
  11573. * C++ Return value: INFO (output) INTEGER
  11574. * = 0: successful exit
  11575. * < 0: if INFO = -i, the i-th argument had an illegal value
  11576. * > 0: if INFO = i, and i is
  11577. * <= N: the leading minor of order i of A is
  11578. * not positive definite, so the factorization
  11579. * could not be completed, and the solution has not
  11580. * been computed. RCOND = 0 is returned.
  11581. * = N+1: U is nonsingular, but RCOND is less than machine
  11582. * precision, meaning that the matrix is singular
  11583. * to working precision. Nevertheless, the
  11584. * solution and error bounds are computed because
  11585. * there are a number of situations where the
  11586. * computed solution can be more accurate than the
  11587. * value of RCOND would suggest.
  11588. *
  11589. * =====================================================================
  11590. *
  11591. * .. Parameters ..
  11592. **/
  11593. int C_DPTSVX(char fact, int n, int nrhs, double* d, double* e, double* df, double* ef, double* b, int ldb, double* x, int ldx, double* rcond, double* ferr, double* berr, double* work)
  11594. {
  11595. int info;
  11596. ::F_DPTSVX(&fact, &n, &nrhs, d, e, df, ef, b, &ldb, x, &ldx, rcond, ferr, berr, work, &info);
  11597. return info;
  11598. }
  11599. /**
  11600. * Purpose
  11601. * =======
  11602. *
  11603. * DPTTRF computes the L*D*L' factorization of a real symmetric
  11604. * positive definite tridiagonal matrix A. The factorization may also
  11605. * be regarded as having the form A = U'*D*U.
  11606. *
  11607. * Arguments
  11608. * =========
  11609. *
  11610. * N (input) INTEGER
  11611. * The order of the matrix A. N >= 0.
  11612. *
  11613. * D (input/output) DOUBLE PRECISION array, dimension (N)
  11614. * On entry, the n diagonal elements of the tridiagonal matrix
  11615. * A. On exit, the n diagonal elements of the diagonal matrix
  11616. * D from the L*D*L' factorization of A.
  11617. *
  11618. * E (input/output) DOUBLE PRECISION array, dimension (N-1)
  11619. * On entry, the (n-1) subdiagonal elements of the tridiagonal
  11620. * matrix A. On exit, the (n-1) subdiagonal elements of the
  11621. * unit bidiagonal factor L from the L*D*L' factorization of A.
  11622. * E can also be regarded as the superdiagonal of the unit
  11623. * bidiagonal factor U from the U'*D*U factorization of A.
  11624. *
  11625. * C++ Return value: INFO (output) INTEGER
  11626. * = 0: successful exit
  11627. * < 0: if INFO = -k, the k-th argument had an illegal value
  11628. * > 0: if INFO = k, the leading minor of order k is not
  11629. * positive definite; if k < N, the factorization could not
  11630. * be completed, while if k = N, the factorization was
  11631. * completed, but D(N) <= 0.
  11632. *
  11633. * =====================================================================
  11634. *
  11635. * .. Parameters ..
  11636. **/
  11637. int C_DPTTRF(int n, double* d, double* e)
  11638. {
  11639. int info;
  11640. ::F_DPTTRF(&n, d, e, &info);
  11641. return info;
  11642. }
  11643. /**
  11644. * Purpose
  11645. * =======
  11646. *
  11647. * DPTTRS solves a tridiagonal system of the form
  11648. * A * X = B
  11649. * using the L*D*L' factorization of A computed by DPTTRF. D is a
  11650. * diagonal matrix specified in the vector D, L is a unit bidiagonal
  11651. * matrix whose subdiagonal is specified in the vector E, and X and B
  11652. * are N by NRHS matrices.
  11653. *
  11654. * Arguments
  11655. * =========
  11656. *
  11657. * N (input) INTEGER
  11658. * The order of the tridiagonal matrix A. N >= 0.
  11659. *
  11660. * NRHS (input) INTEGER
  11661. * The number of right hand sides, i.e., the number of columns
  11662. * of the matrix B. NRHS >= 0.
  11663. *
  11664. * D (input) DOUBLE PRECISION array, dimension (N)
  11665. * The n diagonal elements of the diagonal matrix D from the
  11666. * L*D*L' factorization of A.
  11667. *
  11668. * E (input) DOUBLE PRECISION array, dimension (N-1)
  11669. * The (n-1) subdiagonal elements of the unit bidiagonal factor
  11670. * L from the L*D*L' factorization of A. E can also be regarded
  11671. * as the superdiagonal of the unit bidiagonal factor U from the
  11672. * factorization A = U'*D*U.
  11673. *
  11674. * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
  11675. * On entry, the right hand side vectors B for the system of
  11676. * linear equations.
  11677. * On exit, the solution vectors, X.
  11678. *
  11679. * LDB (input) INTEGER
  11680. * The leading dimension of the array B. LDB >= max(1,N).
  11681. *
  11682. * C++ Return value: INFO (output) INTEGER
  11683. * = 0: successful exit
  11684. * < 0: if INFO = -k, the k-th argument had an illegal value
  11685. *
  11686. * =====================================================================
  11687. *
  11688. * .. Local Scalars ..
  11689. **/
  11690. int C_DPTTRS(int n, int nrhs, double* d, double* e, double* b, int ldb)
  11691. {
  11692. int info;
  11693. ::F_DPTTRS(&n, &nrhs, d, e, b, &ldb, &info);
  11694. return info;
  11695. }
  11696. /**
  11697. * Purpose
  11698. * =======
  11699. *
  11700. * DSBEV computes all the eigenvalues and, optionally, eigenvectors of
  11701. * a real symmetric band matrix A.
  11702. *
  11703. * Arguments
  11704. * =========
  11705. *
  11706. * JOBZ (input) CHARACTER*1
  11707. * = 'N': Compute eigenvalues only;
  11708. * = 'V': Compute eigenvalues and eigenvectors.
  11709. *
  11710. * UPLO (input) CHARACTER*1
  11711. * = 'U': Upper triangle of A is stored;
  11712. * = 'L': Lower triangle of A is stored.
  11713. *
  11714. * N (input) INTEGER
  11715. * The order of the matrix A. N >= 0.
  11716. *
  11717. * KD (input) INTEGER
  11718. * The number of superdiagonals of the matrix A if UPLO = 'U',
  11719. * or the number of subdiagonals if UPLO = 'L'. KD >= 0.
  11720. *
  11721. * AB (input/output) DOUBLE PRECISION array, dimension (LDAB, N)
  11722. * On entry, the upper or lower triangle of the symmetric band
  11723. * matrix A, stored in the first KD+1 rows of the array. The
  11724. * j-th column of A is stored in the j-th column of the array AB
  11725. * as follows:
  11726. * if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
  11727. * if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd).
  11728. *
  11729. * On exit, AB is overwritten by values generated during the
  11730. * reduction to tridiagonal form. If UPLO = 'U', the first
  11731. * superdiagonal and the diagonal of the tridiagonal matrix T
  11732. * are returned in rows KD and KD+1 of AB, and if UPLO = 'L',
  11733. * the diagonal and first subdiagonal of T are returned in the
  11734. * first two rows of AB.
  11735. *
  11736. * LDAB (input) INTEGER
  11737. * The leading dimension of the array AB. LDAB >= KD + 1.
  11738. *
  11739. * W (output) DOUBLE PRECISION array, dimension (N)
  11740. * If INFO = 0, the eigenvalues in ascending order.
  11741. *
  11742. * Z (output) DOUBLE PRECISION array, dimension (LDZ, N)
  11743. * If JOBZ = 'V', then if INFO = 0, Z contains the orthonormal
  11744. * eigenvectors of the matrix A, with the i-th column of Z
  11745. * holding the eigenvector associated with W(i).
  11746. * If JOBZ = 'N', then Z is not referenced.
  11747. *
  11748. * LDZ (input) INTEGER
  11749. * The leading dimension of the array Z. LDZ >= 1, and if
  11750. * JOBZ = 'V', LDZ >= max(1,N).
  11751. *
  11752. * WORK (workspace) DOUBLE PRECISION array, dimension (max(1,3*N-2))
  11753. *
  11754. * C++ Return value: INFO (output) INTEGER
  11755. * = 0: successful exit
  11756. * < 0: if INFO = -i, the i-th argument had an illegal value
  11757. * > 0: if INFO = i, the algorithm failed to converge; i
  11758. * off-diagonal elements of an intermediate tridiagonal
  11759. * form did not converge to zero.
  11760. *
  11761. * =====================================================================
  11762. *
  11763. * .. Parameters ..
  11764. **/
  11765. int C_DSBEV(char jobz, char uplo, int n, int kd, double* ab, int ldab, double* w, double* z, int ldz, double* work)
  11766. {
  11767. int info;
  11768. ::F_DSBEV(&jobz, &uplo, &n, &kd, ab, &ldab, w, z, &ldz, work, &info);
  11769. return info;
  11770. }
  11771. /**
  11772. * Purpose
  11773. * =======
  11774. *
  11775. * DSBEVD computes all the eigenvalues and, optionally, eigenvectors of
  11776. * a real symmetric band matrix A. If eigenvectors are desired, it uses
  11777. * a divide and conquer algorithm.
  11778. *
  11779. * The divide and conquer algorithm makes very mild assumptions about
  11780. * floating point arithmetic. It will work on machines with a guard
  11781. * digit in add/subtract, or on those binary machines without guard
  11782. * digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or
  11783. * Cray-2. It could conceivably fail on hexadecimal or decimal machines
  11784. * without guard digits, but we know of none.
  11785. *
  11786. * Arguments
  11787. * =========
  11788. *
  11789. * JOBZ (input) CHARACTER*1
  11790. * = 'N': Compute eigenvalues only;
  11791. * = 'V': Compute eigenvalues and eigenvectors.
  11792. *
  11793. * UPLO (input) CHARACTER*1
  11794. * = 'U': Upper triangle of A is stored;
  11795. * = 'L': Lower triangle of A is stored.
  11796. *
  11797. * N (input) INTEGER
  11798. * The order of the matrix A. N >= 0.
  11799. *
  11800. * KD (input) INTEGER
  11801. * The number of superdiagonals of the matrix A if UPLO = 'U',
  11802. * or the number of subdiagonals if UPLO = 'L'. KD >= 0.
  11803. *
  11804. * AB (input/output) DOUBLE PRECISION array, dimension (LDAB, N)
  11805. * On entry, the upper or lower triangle of the symmetric band
  11806. * matrix A, stored in the first KD+1 rows of the array. The
  11807. * j-th column of A is stored in the j-th column of the array AB
  11808. * as follows:
  11809. * if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
  11810. * if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd).
  11811. *
  11812. * On exit, AB is overwritten by values generated during the
  11813. * reduction to tridiagonal form. If UPLO = 'U', the first
  11814. * superdiagonal and the diagonal of the tridiagonal matrix T
  11815. * are returned in rows KD and KD+1 of AB, and if UPLO = 'L',
  11816. * the diagonal and first subdiagonal of T are returned in the
  11817. * first two rows of AB.
  11818. *
  11819. * LDAB (input) INTEGER
  11820. * The leading dimension of the array AB. LDAB >= KD + 1.
  11821. *
  11822. * W (output) DOUBLE PRECISION array, dimension (N)
  11823. * If INFO = 0, the eigenvalues in ascending order.
  11824. *
  11825. * Z (output) DOUBLE PRECISION array, dimension (LDZ, N)
  11826. * If JOBZ = 'V', then if INFO = 0, Z contains the orthonormal
  11827. * eigenvectors of the matrix A, with the i-th column of Z
  11828. * holding the eigenvector associated with W(i).
  11829. * If JOBZ = 'N', then Z is not referenced.
  11830. *
  11831. * LDZ (input) INTEGER
  11832. * The leading dimension of the array Z. LDZ >= 1, and if
  11833. * JOBZ = 'V', LDZ >= max(1,N).
  11834. *
  11835. * WORK (workspace/output) DOUBLE PRECISION array,
  11836. * dimension (LWORK)
  11837. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  11838. *
  11839. * LWORK (input) INTEGER
  11840. * The dimension of the array WORK.
  11841. * IF N <= 1, LWORK must be at least 1.
  11842. * If JOBZ = 'N' and N > 2, LWORK must be at least 2*N.
  11843. * If JOBZ = 'V' and N > 2, LWORK must be at least
  11844. * ( 1 + 5*N + 2*N**2 ).
  11845. *
  11846. * If LWORK = -1, then a workspace query is assumed; the routine
  11847. * only calculates the optimal sizes of the WORK and IWORK
  11848. * arrays, returns these values as the first entries of the WORK
  11849. * and IWORK arrays, and no error message related to LWORK or
  11850. * LIWORK is issued by XERBLA.
  11851. *
  11852. * IWORK (workspace/output) INTEGER array, dimension (MAX(1,LIWORK))
  11853. * On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK.
  11854. *
  11855. * LIWORK (input) INTEGER
  11856. * The dimension of the array LIWORK.
  11857. * If JOBZ = 'N' or N <= 1, LIWORK must be at least 1.
  11858. * If JOBZ = 'V' and N > 2, LIWORK must be at least 3 + 5*N.
  11859. *
  11860. * If LIWORK = -1, then a workspace query is assumed; the
  11861. * routine only calculates the optimal sizes of the WORK and
  11862. * IWORK arrays, returns these values as the first entries of
  11863. * the WORK and IWORK arrays, and no error message related to
  11864. * LWORK or LIWORK is issued by XERBLA.
  11865. *
  11866. * C++ Return value: INFO (output) INTEGER
  11867. * = 0: successful exit
  11868. * < 0: if INFO = -i, the i-th argument had an illegal value
  11869. * > 0: if INFO = i, the algorithm failed to converge; i
  11870. * off-diagonal elements of an intermediate tridiagonal
  11871. * form did not converge to zero.
  11872. *
  11873. * =====================================================================
  11874. *
  11875. * .. Parameters ..
  11876. **/
  11877. int C_DSBEVD(char jobz, char uplo, int n, int kd, double* ab, int ldab, double* w, double* z, int ldz, double* work, int lwork, int* iwork, int liwork)
  11878. {
  11879. int info;
  11880. ::F_DSBEVD(&jobz, &uplo, &n, &kd, ab, &ldab, w, z, &ldz, work, &lwork, iwork, &liwork, &info);
  11881. return info;
  11882. }
  11883. /**
  11884. * Purpose
  11885. * =======
  11886. *
  11887. * DSBEVX computes selected eigenvalues and, optionally, eigenvectors
  11888. * of a real symmetric band matrix A. Eigenvalues and eigenvectors can
  11889. * be selected by specifying either a range of values or a range of
  11890. * indices for the desired eigenvalues.
  11891. *
  11892. * Arguments
  11893. * =========
  11894. *
  11895. * JOBZ (input) CHARACTER*1
  11896. * = 'N': Compute eigenvalues only;
  11897. * = 'V': Compute eigenvalues and eigenvectors.
  11898. *
  11899. * RANGE (input) CHARACTER*1
  11900. * = 'A': all eigenvalues will be found;
  11901. * = 'V': all eigenvalues in the half-open interval (VL,VU]
  11902. * will be found;
  11903. * = 'I': the IL-th through IU-th eigenvalues will be found.
  11904. *
  11905. * UPLO (input) CHARACTER*1
  11906. * = 'U': Upper triangle of A is stored;
  11907. * = 'L': Lower triangle of A is stored.
  11908. *
  11909. * N (input) INTEGER
  11910. * The order of the matrix A. N >= 0.
  11911. *
  11912. * KD (input) INTEGER
  11913. * The number of superdiagonals of the matrix A if UPLO = 'U',
  11914. * or the number of subdiagonals if UPLO = 'L'. KD >= 0.
  11915. *
  11916. * AB (input/output) DOUBLE PRECISION array, dimension (LDAB, N)
  11917. * On entry, the upper or lower triangle of the symmetric band
  11918. * matrix A, stored in the first KD+1 rows of the array. The
  11919. * j-th column of A is stored in the j-th column of the array AB
  11920. * as follows:
  11921. * if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
  11922. * if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd).
  11923. *
  11924. * On exit, AB is overwritten by values generated during the
  11925. * reduction to tridiagonal form. If UPLO = 'U', the first
  11926. * superdiagonal and the diagonal of the tridiagonal matrix T
  11927. * are returned in rows KD and KD+1 of AB, and if UPLO = 'L',
  11928. * the diagonal and first subdiagonal of T are returned in the
  11929. * first two rows of AB.
  11930. *
  11931. * LDAB (input) INTEGER
  11932. * The leading dimension of the array AB. LDAB >= KD + 1.
  11933. *
  11934. * Q (output) DOUBLE PRECISION array, dimension (LDQ, N)
  11935. * If JOBZ = 'V', the N-by-N orthogonal matrix used in the
  11936. * reduction to tridiagonal form.
  11937. * If JOBZ = 'N', the array Q is not referenced.
  11938. *
  11939. * LDQ (input) INTEGER
  11940. * The leading dimension of the array Q. If JOBZ = 'V', then
  11941. * LDQ >= max(1,N).
  11942. *
  11943. * VL (input) DOUBLE PRECISION
  11944. * VU (input) DOUBLE PRECISION
  11945. * If RANGE='V', the lower and upper bounds of the interval to
  11946. * be searched for eigenvalues. VL < VU.
  11947. * Not referenced if RANGE = 'A' or 'I'.
  11948. *
  11949. * IL (input) INTEGER
  11950. * IU (input) INTEGER
  11951. * If RANGE='I', the indices (in ascending order) of the
  11952. * smallest and largest eigenvalues to be returned.
  11953. * 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
  11954. * Not referenced if RANGE = 'A' or 'V'.
  11955. *
  11956. * ABSTOL (input) DOUBLE PRECISION
  11957. * The absolute error tolerance for the eigenvalues.
  11958. * An approximate eigenvalue is accepted as converged
  11959. * when it is determined to lie in an interval [a,b]
  11960. * of width less than or equal to
  11961. *
  11962. * ABSTOL + EPS * max( |a|,|b| ) ,
  11963. *
  11964. * where EPS is the machine precision. If ABSTOL is less than
  11965. * or equal to zero, then EPS*|T| will be used in its place,
  11966. * where |T| is the 1-norm of the tridiagonal matrix obtained
  11967. * by reducing AB to tridiagonal form.
  11968. *
  11969. * Eigenvalues will be computed most accurately when ABSTOL is
  11970. * set to twice the underflow threshold 2*DLAMCH('S'), not zero.
  11971. * If this routine returns with INFO>0, indicating that some
  11972. * eigenvectors did not converge, try setting ABSTOL to
  11973. * 2*DLAMCH('S').
  11974. *
  11975. * See "Computing Small Singular Values of Bidiagonal Matrices
  11976. * with Guaranteed High Relative Accuracy," by Demmel and
  11977. * Kahan, LAPACK Working Note #3.
  11978. *
  11979. * M (output) INTEGER
  11980. * The total number of eigenvalues found. 0 <= M <= N.
  11981. * If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
  11982. *
  11983. * W (output) DOUBLE PRECISION array, dimension (N)
  11984. * The first M elements contain the selected eigenvalues in
  11985. * ascending order.
  11986. *
  11987. * Z (output) DOUBLE PRECISION array, dimension (LDZ, max(1,M))
  11988. * If JOBZ = 'V', then if INFO = 0, the first M columns of Z
  11989. * contain the orthonormal eigenvectors of the matrix A
  11990. * corresponding to the selected eigenvalues, with the i-th
  11991. * column of Z holding the eigenvector associated with W(i).
  11992. * If an eigenvector fails to converge, then that column of Z
  11993. * contains the latest approximation to the eigenvector, and the
  11994. * index of the eigenvector is returned in IFAIL.
  11995. * If JOBZ = 'N', then Z is not referenced.
  11996. * Note: the user must ensure that at least max(1,M) columns are
  11997. * supplied in the array Z; if RANGE = 'V', the exact value of M
  11998. * is not known in advance and an upper bound must be used.
  11999. *
  12000. * LDZ (input) INTEGER
  12001. * The leading dimension of the array Z. LDZ >= 1, and if
  12002. * JOBZ = 'V', LDZ >= max(1,N).
  12003. *
  12004. * WORK (workspace) DOUBLE PRECISION array, dimension (7*N)
  12005. *
  12006. * IWORK (workspace) INTEGER array, dimension (5*N)
  12007. *
  12008. * IFAIL (output) INTEGER array, dimension (N)
  12009. * If JOBZ = 'V', then if INFO = 0, the first M elements of
  12010. * IFAIL are zero. If INFO > 0, then IFAIL contains the
  12011. * indices of the eigenvectors that failed to converge.
  12012. * If JOBZ = 'N', then IFAIL is not referenced.
  12013. *
  12014. * C++ Return value: INFO (output) INTEGER
  12015. * = 0: successful exit.
  12016. * < 0: if INFO = -i, the i-th argument had an illegal value.
  12017. * > 0: if INFO = i, then i eigenvectors failed to converge.
  12018. * Their indices are stored in array IFAIL.
  12019. *
  12020. * =====================================================================
  12021. *
  12022. * .. Parameters ..
  12023. **/
  12024. int C_DSBEVX(char jobz, char range, char uplo, int n, int kd, double* ab, int ldab, double* q, int ldq, double vl, double vu, int il, int iu, double abstol, int* m, double* w, double* z, int ldz, double* work, int* iwork, int* ifail)
  12025. {
  12026. int info;
  12027. ::F_DSBEVX(&jobz, &range, &uplo, &n, &kd, ab, &ldab, q, &ldq, &vl, &vu, &il, &iu, &abstol, m, w, z, &ldz, work, iwork, ifail, &info);
  12028. return info;
  12029. }
  12030. /**
  12031. * Purpose
  12032. * =======
  12033. *
  12034. * DSBGST reduces a real symmetric-definite banded generalized
  12035. * eigenproblem A*x = lambda*B*x to standard form C*y = lambda*y,
  12036. * such that C has the same bandwidth as A.
  12037. *
  12038. * B must have been previously factorized as S**T*S by DPBSTF, using a
  12039. * split Cholesky factorization. A is overwritten by C = X**T*A*X, where
  12040. * X = S**(-1)*Q and Q is an orthogonal matrix chosen to preserve the
  12041. * bandwidth of A.
  12042. *
  12043. * Arguments
  12044. * =========
  12045. *
  12046. * VECT (input) CHARACTER*1
  12047. * = 'N': do not form the transformation matrix X;
  12048. * = 'V': form X.
  12049. *
  12050. * UPLO (input) CHARACTER*1
  12051. * = 'U': Upper triangle of A is stored;
  12052. * = 'L': Lower triangle of A is stored.
  12053. *
  12054. * N (input) INTEGER
  12055. * The order of the matrices A and B. N >= 0.
  12056. *
  12057. * KA (input) INTEGER
  12058. * The number of superdiagonals of the matrix A if UPLO = 'U',
  12059. * or the number of subdiagonals if UPLO = 'L'. KA >= 0.
  12060. *
  12061. * KB (input) INTEGER
  12062. * The number of superdiagonals of the matrix B if UPLO = 'U',
  12063. * or the number of subdiagonals if UPLO = 'L'. KA >= KB >= 0.
  12064. *
  12065. * AB (input/output) DOUBLE PRECISION array, dimension (LDAB,N)
  12066. * On entry, the upper or lower triangle of the symmetric band
  12067. * matrix A, stored in the first ka+1 rows of the array. The
  12068. * j-th column of A is stored in the j-th column of the array AB
  12069. * as follows:
  12070. * if UPLO = 'U', AB(ka+1+i-j,j) = A(i,j) for max(1,j-ka)<=i<=j;
  12071. * if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+ka).
  12072. *
  12073. * On exit, the transformed matrix X**T*A*X, stored in the same
  12074. * format as A.
  12075. *
  12076. * LDAB (input) INTEGER
  12077. * The leading dimension of the array AB. LDAB >= KA+1.
  12078. *
  12079. * BB (input) DOUBLE PRECISION array, dimension (LDBB,N)
  12080. * The banded factor S from the split Cholesky factorization of
  12081. * B, as returned by DPBSTF, stored in the first KB+1 rows of
  12082. * the array.
  12083. *
  12084. * LDBB (input) INTEGER
  12085. * The leading dimension of the array BB. LDBB >= KB+1.
  12086. *
  12087. * X (output) DOUBLE PRECISION array, dimension (LDX,N)
  12088. * If VECT = 'V', the n-by-n matrix X.
  12089. * If VECT = 'N', the array X is not referenced.
  12090. *
  12091. * LDX (input) INTEGER
  12092. * The leading dimension of the array X.
  12093. * LDX >= max(1,N) if VECT = 'V'; LDX >= 1 otherwise.
  12094. *
  12095. * WORK (workspace) DOUBLE PRECISION array, dimension (2*N)
  12096. *
  12097. * C++ Return value: INFO (output) INTEGER
  12098. * = 0: successful exit
  12099. * < 0: if INFO = -i, the i-th argument had an illegal value.
  12100. *
  12101. * =====================================================================
  12102. *
  12103. * .. Parameters ..
  12104. **/
  12105. int C_DSBGST(char vect, char uplo, int n, int ka, int kb, double* ab, int ldab, double* bb, int ldbb, double* x, int ldx, double* work)
  12106. {
  12107. int info;
  12108. ::F_DSBGST(&vect, &uplo, &n, &ka, &kb, ab, &ldab, bb, &ldbb, x, &ldx, work, &info);
  12109. return info;
  12110. }
  12111. /**
  12112. * Purpose
  12113. * =======
  12114. *
  12115. * DSBGV computes all the eigenvalues, and optionally, the eigenvectors
  12116. * of a real generalized symmetric-definite banded eigenproblem, of
  12117. * the form A*x=(lambda)*B*x. Here A and B are assumed to be symmetric
  12118. * and banded, and B is also positive definite.
  12119. *
  12120. * Arguments
  12121. * =========
  12122. *
  12123. * JOBZ (input) CHARACTER*1
  12124. * = 'N': Compute eigenvalues only;
  12125. * = 'V': Compute eigenvalues and eigenvectors.
  12126. *
  12127. * UPLO (input) CHARACTER*1
  12128. * = 'U': Upper triangles of A and B are stored;
  12129. * = 'L': Lower triangles of A and B are stored.
  12130. *
  12131. * N (input) INTEGER
  12132. * The order of the matrices A and B. N >= 0.
  12133. *
  12134. * KA (input) INTEGER
  12135. * The number of superdiagonals of the matrix A if UPLO = 'U',
  12136. * or the number of subdiagonals if UPLO = 'L'. KA >= 0.
  12137. *
  12138. * KB (input) INTEGER
  12139. * The number of superdiagonals of the matrix B if UPLO = 'U',
  12140. * or the number of subdiagonals if UPLO = 'L'. KB >= 0.
  12141. *
  12142. * AB (input/output) DOUBLE PRECISION array, dimension (LDAB, N)
  12143. * On entry, the upper or lower triangle of the symmetric band
  12144. * matrix A, stored in the first ka+1 rows of the array. The
  12145. * j-th column of A is stored in the j-th column of the array AB
  12146. * as follows:
  12147. * if UPLO = 'U', AB(ka+1+i-j,j) = A(i,j) for max(1,j-ka)<=i<=j;
  12148. * if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+ka).
  12149. *
  12150. * On exit, the contents of AB are destroyed.
  12151. *
  12152. * LDAB (input) INTEGER
  12153. * The leading dimension of the array AB. LDAB >= KA+1.
  12154. *
  12155. * BB (input/output) DOUBLE PRECISION array, dimension (LDBB, N)
  12156. * On entry, the upper or lower triangle of the symmetric band
  12157. * matrix B, stored in the first kb+1 rows of the array. The
  12158. * j-th column of B is stored in the j-th column of the array BB
  12159. * as follows:
  12160. * if UPLO = 'U', BB(kb+1+i-j,j) = B(i,j) for max(1,j-kb)<=i<=j;
  12161. * if UPLO = 'L', BB(1+i-j,j) = B(i,j) for j<=i<=min(n,j+kb).
  12162. *
  12163. * On exit, the factor S from the split Cholesky factorization
  12164. * B = S**T*S, as returned by DPBSTF.
  12165. *
  12166. * LDBB (input) INTEGER
  12167. * The leading dimension of the array BB. LDBB >= KB+1.
  12168. *
  12169. * W (output) DOUBLE PRECISION array, dimension (N)
  12170. * If INFO = 0, the eigenvalues in ascending order.
  12171. *
  12172. * Z (output) DOUBLE PRECISION array, dimension (LDZ, N)
  12173. * If JOBZ = 'V', then if INFO = 0, Z contains the matrix Z of
  12174. * eigenvectors, with the i-th column of Z holding the
  12175. * eigenvector associated with W(i). The eigenvectors are
  12176. * normalized so that Z**T*B*Z = I.
  12177. * If JOBZ = 'N', then Z is not referenced.
  12178. *
  12179. * LDZ (input) INTEGER
  12180. * The leading dimension of the array Z. LDZ >= 1, and if
  12181. * JOBZ = 'V', LDZ >= N.
  12182. *
  12183. * WORK (workspace) DOUBLE PRECISION array, dimension (3*N)
  12184. *
  12185. * C++ Return value: INFO (output) INTEGER
  12186. * = 0: successful exit
  12187. * < 0: if INFO = -i, the i-th argument had an illegal value
  12188. * > 0: if INFO = i, and i is:
  12189. * <= N: the algorithm failed to converge:
  12190. * i off-diagonal elements of an intermediate
  12191. * tridiagonal form did not converge to zero;
  12192. * > N: if INFO = N + i, for 1 <= i <= N, then DPBSTF
  12193. * returned INFO = i: B is not positive definite.
  12194. * The factorization of B could not be completed and
  12195. * no eigenvalues or eigenvectors were computed.
  12196. *
  12197. * =====================================================================
  12198. *
  12199. * .. Local Scalars ..
  12200. **/
  12201. int C_DSBGV(char jobz, char uplo, int n, int ka, int kb, double* ab, int ldab, double* bb, int ldbb, double* w, double* z, int ldz, double* work)
  12202. {
  12203. int info;
  12204. ::F_DSBGV(&jobz, &uplo, &n, &ka, &kb, ab, &ldab, bb, &ldbb, w, z, &ldz, work, &info);
  12205. return info;
  12206. }
  12207. /**
  12208. * Purpose
  12209. * =======
  12210. *
  12211. * DSBGVD computes all the eigenvalues, and optionally, the eigenvectors
  12212. * of a real generalized symmetric-definite banded eigenproblem, of the
  12213. * form A*x=(lambda)*B*x. Here A and B are assumed to be symmetric and
  12214. * banded, and B is also positive definite. If eigenvectors are
  12215. * desired, it uses a divide and conquer algorithm.
  12216. *
  12217. * The divide and conquer algorithm makes very mild assumptions about
  12218. * floating point arithmetic. It will work on machines with a guard
  12219. * digit in add/subtract, or on those binary machines without guard
  12220. * digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or
  12221. * Cray-2. It could conceivably fail on hexadecimal or decimal machines
  12222. * without guard digits, but we know of none.
  12223. *
  12224. * Arguments
  12225. * =========
  12226. *
  12227. * JOBZ (input) CHARACTER*1
  12228. * = 'N': Compute eigenvalues only;
  12229. * = 'V': Compute eigenvalues and eigenvectors.
  12230. *
  12231. * UPLO (input) CHARACTER*1
  12232. * = 'U': Upper triangles of A and B are stored;
  12233. * = 'L': Lower triangles of A and B are stored.
  12234. *
  12235. * N (input) INTEGER
  12236. * The order of the matrices A and B. N >= 0.
  12237. *
  12238. * KA (input) INTEGER
  12239. * The number of superdiagonals of the matrix A if UPLO = 'U',
  12240. * or the number of subdiagonals if UPLO = 'L'. KA >= 0.
  12241. *
  12242. * KB (input) INTEGER
  12243. * The number of superdiagonals of the matrix B if UPLO = 'U',
  12244. * or the number of subdiagonals if UPLO = 'L'. KB >= 0.
  12245. *
  12246. * AB (input/output) DOUBLE PRECISION array, dimension (LDAB, N)
  12247. * On entry, the upper or lower triangle of the symmetric band
  12248. * matrix A, stored in the first ka+1 rows of the array. The
  12249. * j-th column of A is stored in the j-th column of the array AB
  12250. * as follows:
  12251. * if UPLO = 'U', AB(ka+1+i-j,j) = A(i,j) for max(1,j-ka)<=i<=j;
  12252. * if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+ka).
  12253. *
  12254. * On exit, the contents of AB are destroyed.
  12255. *
  12256. * LDAB (input) INTEGER
  12257. * The leading dimension of the array AB. LDAB >= KA+1.
  12258. *
  12259. * BB (input/output) DOUBLE PRECISION array, dimension (LDBB, N)
  12260. * On entry, the upper or lower triangle of the symmetric band
  12261. * matrix B, stored in the first kb+1 rows of the array. The
  12262. * j-th column of B is stored in the j-th column of the array BB
  12263. * as follows:
  12264. * if UPLO = 'U', BB(ka+1+i-j,j) = B(i,j) for max(1,j-kb)<=i<=j;
  12265. * if UPLO = 'L', BB(1+i-j,j) = B(i,j) for j<=i<=min(n,j+kb).
  12266. *
  12267. * On exit, the factor S from the split Cholesky factorization
  12268. * B = S**T*S, as returned by DPBSTF.
  12269. *
  12270. * LDBB (input) INTEGER
  12271. * The leading dimension of the array BB. LDBB >= KB+1.
  12272. *
  12273. * W (output) DOUBLE PRECISION array, dimension (N)
  12274. * If INFO = 0, the eigenvalues in ascending order.
  12275. *
  12276. * Z (output) DOUBLE PRECISION array, dimension (LDZ, N)
  12277. * If JOBZ = 'V', then if INFO = 0, Z contains the matrix Z of
  12278. * eigenvectors, with the i-th column of Z holding the
  12279. * eigenvector associated with W(i). The eigenvectors are
  12280. * normalized so Z**T*B*Z = I.
  12281. * If JOBZ = 'N', then Z is not referenced.
  12282. *
  12283. * LDZ (input) INTEGER
  12284. * The leading dimension of the array Z. LDZ >= 1, and if
  12285. * JOBZ = 'V', LDZ >= max(1,N).
  12286. *
  12287. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  12288. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  12289. *
  12290. * LWORK (input) INTEGER
  12291. * The dimension of the array WORK.
  12292. * If N <= 1, LWORK >= 1.
  12293. * If JOBZ = 'N' and N > 1, LWORK >= 3*N.
  12294. * If JOBZ = 'V' and N > 1, LWORK >= 1 + 5*N + 2*N**2.
  12295. *
  12296. * If LWORK = -1, then a workspace query is assumed; the routine
  12297. * only calculates the optimal sizes of the WORK and IWORK
  12298. * arrays, returns these values as the first entries of the WORK
  12299. * and IWORK arrays, and no error message related to LWORK or
  12300. * LIWORK is issued by XERBLA.
  12301. *
  12302. * IWORK (workspace/output) INTEGER array, dimension (MAX(1,LIWORK))
  12303. * On exit, if LIWORK > 0, IWORK(1) returns the optimal LIWORK.
  12304. *
  12305. * LIWORK (input) INTEGER
  12306. * The dimension of the array IWORK.
  12307. * If JOBZ = 'N' or N <= 1, LIWORK >= 1.
  12308. * If JOBZ = 'V' and N > 1, LIWORK >= 3 + 5*N.
  12309. *
  12310. * If LIWORK = -1, then a workspace query is assumed; the
  12311. * routine only calculates the optimal sizes of the WORK and
  12312. * IWORK arrays, returns these values as the first entries of
  12313. * the WORK and IWORK arrays, and no error message related to
  12314. * LWORK or LIWORK is issued by XERBLA.
  12315. *
  12316. * C++ Return value: INFO (output) INTEGER
  12317. * = 0: successful exit
  12318. * < 0: if INFO = -i, the i-th argument had an illegal value
  12319. * > 0: if INFO = i, and i is:
  12320. * <= N: the algorithm failed to converge:
  12321. * i off-diagonal elements of an intermediate
  12322. * tridiagonal form did not converge to zero;
  12323. * > N: if INFO = N + i, for 1 <= i <= N, then DPBSTF
  12324. * returned INFO = i: B is not positive definite.
  12325. * The factorization of B could not be completed and
  12326. * no eigenvalues or eigenvectors were computed.
  12327. *
  12328. * Further Details
  12329. * ===============
  12330. *
  12331. * Based on contributions by
  12332. * Mark Fahey, Department of Mathematics, Univ. of Kentucky, USA
  12333. *
  12334. * =====================================================================
  12335. *
  12336. * .. Parameters ..
  12337. **/
  12338. int C_DSBGVD(char jobz, char uplo, int n, int ka, int kb, double* ab, int ldab, double* bb, int ldbb, double* w, double* z, int ldz, double* work, int lwork, int* iwork, int liwork)
  12339. {
  12340. int info;
  12341. ::F_DSBGVD(&jobz, &uplo, &n, &ka, &kb, ab, &ldab, bb, &ldbb, w, z, &ldz, work, &lwork, iwork, &liwork, &info);
  12342. return info;
  12343. }
  12344. /**
  12345. * Purpose
  12346. * =======
  12347. *
  12348. * DSBGVX computes selected eigenvalues, and optionally, eigenvectors
  12349. * of a real generalized symmetric-definite banded eigenproblem, of
  12350. * the form A*x=(lambda)*B*x. Here A and B are assumed to be symmetric
  12351. * and banded, and B is also positive definite. Eigenvalues and
  12352. * eigenvectors can be selected by specifying either all eigenvalues,
  12353. * a range of values or a range of indices for the desired eigenvalues.
  12354. *
  12355. * Arguments
  12356. * =========
  12357. *
  12358. * JOBZ (input) CHARACTER*1
  12359. * = 'N': Compute eigenvalues only;
  12360. * = 'V': Compute eigenvalues and eigenvectors.
  12361. *
  12362. * RANGE (input) CHARACTER*1
  12363. * = 'A': all eigenvalues will be found.
  12364. * = 'V': all eigenvalues in the half-open interval (VL,VU]
  12365. * will be found.
  12366. * = 'I': the IL-th through IU-th eigenvalues will be found.
  12367. *
  12368. * UPLO (input) CHARACTER*1
  12369. * = 'U': Upper triangles of A and B are stored;
  12370. * = 'L': Lower triangles of A and B are stored.
  12371. *
  12372. * N (input) INTEGER
  12373. * The order of the matrices A and B. N >= 0.
  12374. *
  12375. * KA (input) INTEGER
  12376. * The number of superdiagonals of the matrix A if UPLO = 'U',
  12377. * or the number of subdiagonals if UPLO = 'L'. KA >= 0.
  12378. *
  12379. * KB (input) INTEGER
  12380. * The number of superdiagonals of the matrix B if UPLO = 'U',
  12381. * or the number of subdiagonals if UPLO = 'L'. KB >= 0.
  12382. *
  12383. * AB (input/output) DOUBLE PRECISION array, dimension (LDAB, N)
  12384. * On entry, the upper or lower triangle of the symmetric band
  12385. * matrix A, stored in the first ka+1 rows of the array. The
  12386. * j-th column of A is stored in the j-th column of the array AB
  12387. * as follows:
  12388. * if UPLO = 'U', AB(ka+1+i-j,j) = A(i,j) for max(1,j-ka)<=i<=j;
  12389. * if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+ka).
  12390. *
  12391. * On exit, the contents of AB are destroyed.
  12392. *
  12393. * LDAB (input) INTEGER
  12394. * The leading dimension of the array AB. LDAB >= KA+1.
  12395. *
  12396. * BB (input/output) DOUBLE PRECISION array, dimension (LDBB, N)
  12397. * On entry, the upper or lower triangle of the symmetric band
  12398. * matrix B, stored in the first kb+1 rows of the array. The
  12399. * j-th column of B is stored in the j-th column of the array BB
  12400. * as follows:
  12401. * if UPLO = 'U', BB(ka+1+i-j,j) = B(i,j) for max(1,j-kb)<=i<=j;
  12402. * if UPLO = 'L', BB(1+i-j,j) = B(i,j) for j<=i<=min(n,j+kb).
  12403. *
  12404. * On exit, the factor S from the split Cholesky factorization
  12405. * B = S**T*S, as returned by DPBSTF.
  12406. *
  12407. * LDBB (input) INTEGER
  12408. * The leading dimension of the array BB. LDBB >= KB+1.
  12409. *
  12410. * Q (output) DOUBLE PRECISION array, dimension (LDQ, N)
  12411. * If JOBZ = 'V', the n-by-n matrix used in the reduction of
  12412. * A*x = (lambda)*B*x to standard form, i.e. C*x = (lambda)*x,
  12413. * and consequently C to tridiagonal form.
  12414. * If JOBZ = 'N', the array Q is not referenced.
  12415. *
  12416. * LDQ (input) INTEGER
  12417. * The leading dimension of the array Q. If JOBZ = 'N',
  12418. * LDQ >= 1. If JOBZ = 'V', LDQ >= max(1,N).
  12419. *
  12420. * VL (input) DOUBLE PRECISION
  12421. * VU (input) DOUBLE PRECISION
  12422. * If RANGE='V', the lower and upper bounds of the interval to
  12423. * be searched for eigenvalues. VL < VU.
  12424. * Not referenced if RANGE = 'A' or 'I'.
  12425. *
  12426. * IL (input) INTEGER
  12427. * IU (input) INTEGER
  12428. * If RANGE='I', the indices (in ascending order) of the
  12429. * smallest and largest eigenvalues to be returned.
  12430. * 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
  12431. * Not referenced if RANGE = 'A' or 'V'.
  12432. *
  12433. * ABSTOL (input) DOUBLE PRECISION
  12434. * The absolute error tolerance for the eigenvalues.
  12435. * An approximate eigenvalue is accepted as converged
  12436. * when it is determined to lie in an interval [a,b]
  12437. * of width less than or equal to
  12438. *
  12439. * ABSTOL + EPS * max( |a|,|b| ) ,
  12440. *
  12441. * where EPS is the machine precision. If ABSTOL is less than
  12442. * or equal to zero, then EPS*|T| will be used in its place,
  12443. * where |T| is the 1-norm of the tridiagonal matrix obtained
  12444. * by reducing A to tridiagonal form.
  12445. *
  12446. * Eigenvalues will be computed most accurately when ABSTOL is
  12447. * set to twice the underflow threshold 2*DLAMCH('S'), not zero.
  12448. * If this routine returns with INFO>0, indicating that some
  12449. * eigenvectors did not converge, try setting ABSTOL to
  12450. * 2*DLAMCH('S').
  12451. *
  12452. * M (output) INTEGER
  12453. * The total number of eigenvalues found. 0 <= M <= N.
  12454. * If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
  12455. *
  12456. * W (output) DOUBLE PRECISION array, dimension (N)
  12457. * If INFO = 0, the eigenvalues in ascending order.
  12458. *
  12459. * Z (output) DOUBLE PRECISION array, dimension (LDZ, N)
  12460. * If JOBZ = 'V', then if INFO = 0, Z contains the matrix Z of
  12461. * eigenvectors, with the i-th column of Z holding the
  12462. * eigenvector associated with W(i). The eigenvectors are
  12463. * normalized so Z**T*B*Z = I.
  12464. * If JOBZ = 'N', then Z is not referenced.
  12465. *
  12466. * LDZ (input) INTEGER
  12467. * The leading dimension of the array Z. LDZ >= 1, and if
  12468. * JOBZ = 'V', LDZ >= max(1,N).
  12469. *
  12470. * WORK (workspace/output) DOUBLE PRECISION array, dimension (7*N)
  12471. *
  12472. * IWORK (workspace/output) INTEGER array, dimension (5*N)
  12473. *
  12474. * IFAIL (output) INTEGER array, dimension (M)
  12475. * If JOBZ = 'V', then if INFO = 0, the first M elements of
  12476. * IFAIL are zero. If INFO > 0, then IFAIL contains the
  12477. * indices of the eigenvalues that failed to converge.
  12478. * If JOBZ = 'N', then IFAIL is not referenced.
  12479. *
  12480. * C++ Return value: INFO (output) INTEGER
  12481. * = 0 : successful exit
  12482. * < 0 : if INFO = -i, the i-th argument had an illegal value
  12483. * <= N: if INFO = i, then i eigenvectors failed to converge.
  12484. * Their indices are stored in IFAIL.
  12485. * > N : DPBSTF returned an error code; i.e.,
  12486. * if INFO = N + i, for 1 <= i <= N, then the leading
  12487. * minor of order i of B is not positive definite.
  12488. * The factorization of B could not be completed and
  12489. * no eigenvalues or eigenvectors were computed.
  12490. *
  12491. * Further Details
  12492. * ===============
  12493. *
  12494. * Based on contributions by
  12495. * Mark Fahey, Department of Mathematics, Univ. of Kentucky, USA
  12496. *
  12497. * =====================================================================
  12498. *
  12499. * .. Parameters ..
  12500. **/
  12501. int C_DSBGVX(char jobz, char range, char uplo, int n, int ka, int kb, double* ab, int ldab, double* bb, int ldbb, double* q, int ldq, double vl, double vu, int il, int iu, double abstol, int* m, double* w, double* z, int ldz, double* work, int* iwork, int* ifail)
  12502. {
  12503. int info;
  12504. ::F_DSBGVX(&jobz, &range, &uplo, &n, &ka, &kb, ab, &ldab, bb, &ldbb, q, &ldq, &vl, &vu, &il, &iu, &abstol, m, w, z, &ldz, work, iwork, ifail, &info);
  12505. return info;
  12506. }
  12507. /**
  12508. * Purpose
  12509. * =======
  12510. *
  12511. * DSBTRD reduces a real symmetric band matrix A to symmetric
  12512. * tridiagonal form T by an orthogonal similarity transformation:
  12513. * Q**T * A * Q = T.
  12514. *
  12515. * Arguments
  12516. * =========
  12517. *
  12518. * VECT (input) CHARACTER*1
  12519. * = 'N': do not form Q;
  12520. * = 'V': form Q;
  12521. * = 'U': update a matrix X, by forming X*Q.
  12522. *
  12523. * UPLO (input) CHARACTER*1
  12524. * = 'U': Upper triangle of A is stored;
  12525. * = 'L': Lower triangle of A is stored.
  12526. *
  12527. * N (input) INTEGER
  12528. * The order of the matrix A. N >= 0.
  12529. *
  12530. * KD (input) INTEGER
  12531. * The number of superdiagonals of the matrix A if UPLO = 'U',
  12532. * or the number of subdiagonals if UPLO = 'L'. KD >= 0.
  12533. *
  12534. * AB (input/output) DOUBLE PRECISION array, dimension (LDAB,N)
  12535. * On entry, the upper or lower triangle of the symmetric band
  12536. * matrix A, stored in the first KD+1 rows of the array. The
  12537. * j-th column of A is stored in the j-th column of the array AB
  12538. * as follows:
  12539. * if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
  12540. * if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd).
  12541. * On exit, the diagonal elements of AB are overwritten by the
  12542. * diagonal elements of the tridiagonal matrix T; if KD > 0, the
  12543. * elements on the first superdiagonal (if UPLO = 'U') or the
  12544. * first subdiagonal (if UPLO = 'L') are overwritten by the
  12545. * off-diagonal elements of T; the rest of AB is overwritten by
  12546. * values generated during the reduction.
  12547. *
  12548. * LDAB (input) INTEGER
  12549. * The leading dimension of the array AB. LDAB >= KD+1.
  12550. *
  12551. * D (output) DOUBLE PRECISION array, dimension (N)
  12552. * The diagonal elements of the tridiagonal matrix T.
  12553. *
  12554. * E (output) DOUBLE PRECISION array, dimension (N-1)
  12555. * The off-diagonal elements of the tridiagonal matrix T:
  12556. * E(i) = T(i,i+1) if UPLO = 'U'; E(i) = T(i+1,i) if UPLO = 'L'.
  12557. *
  12558. * Q (input/output) DOUBLE PRECISION array, dimension (LDQ,N)
  12559. * On entry, if VECT = 'U', then Q must contain an N-by-N
  12560. * matrix X; if VECT = 'N' or 'V', then Q need not be set.
  12561. *
  12562. * On exit:
  12563. * if VECT = 'V', Q contains the N-by-N orthogonal matrix Q;
  12564. * if VECT = 'U', Q contains the product X*Q;
  12565. * if VECT = 'N', the array Q is not referenced.
  12566. *
  12567. * LDQ (input) INTEGER
  12568. * The leading dimension of the array Q.
  12569. * LDQ >= 1, and LDQ >= N if VECT = 'V' or 'U'.
  12570. *
  12571. * WORK (workspace) DOUBLE PRECISION array, dimension (N)
  12572. *
  12573. * C++ Return value: INFO (output) INTEGER
  12574. * = 0: successful exit
  12575. * < 0: if INFO = -i, the i-th argument had an illegal value
  12576. *
  12577. * Further Details
  12578. * ===============
  12579. *
  12580. * Modified by Linda Kaufman, Bell Labs.
  12581. *
  12582. * =====================================================================
  12583. *
  12584. * .. Parameters ..
  12585. **/
  12586. int C_DSBTRD(char vect, char uplo, int n, int kd, double* ab, int ldab, double* d, double* e, double* q, int ldq, double* work)
  12587. {
  12588. int info;
  12589. ::F_DSBTRD(&vect, &uplo, &n, &kd, ab, &ldab, d, e, q, &ldq, work, &info);
  12590. return info;
  12591. }
  12592. /**
  12593. * Purpose
  12594. * =======
  12595. *
  12596. * DSGESV computes the solution to a real system of linear equations
  12597. * A * X = B,
  12598. * where A is an N-by-N matrix and X and B are N-by-NRHS matrices.
  12599. *
  12600. * DSGESV first attempts to factorize the matrix in SINGLE PRECISION
  12601. * and use this factorization within an iterative refinement procedure
  12602. * to produce a solution with DOUBLE PRECISION normwise backward error
  12603. * quality (see below). If the approach fails the method switches to a
  12604. * DOUBLE PRECISION factorization and solve.
  12605. *
  12606. * The iterative refinement is not going to be a winning strategy if
  12607. * the ratio SINGLE PRECISION performance over DOUBLE PRECISION
  12608. * performance is too small. A reasonable strategy should take the
  12609. * number of right-hand sides and the size of the matrix into account.
  12610. * This might be done with a call to ILAENV in the future. Up to now, we
  12611. * always try iterative refinement.
  12612. *
  12613. * The iterative refinement process is stopped if
  12614. * ITER > ITERMAX
  12615. * or for all the RHS we have:
  12616. * RNRM < SQRT(N)*XNRM*ANRM*EPS*BWDMAX
  12617. * where
  12618. * o ITER is the number of the current iteration in the iterative
  12619. * refinement process
  12620. * o RNRM is the infinity-norm of the residual
  12621. * o XNRM is the infinity-norm of the solution
  12622. * o ANRM is the infinity-operator-norm of the matrix A
  12623. * o EPS is the machine epsilon returned by DLAMCH('Epsilon')
  12624. * The value ITERMAX and BWDMAX are fixed to 30 and 1.0D+00
  12625. * respectively.
  12626. *
  12627. * Arguments
  12628. * =========
  12629. *
  12630. * N (input) INTEGER
  12631. * The number of linear equations, i.e., the order of the
  12632. * matrix A. N >= 0.
  12633. *
  12634. * NRHS (input) INTEGER
  12635. * The number of right hand sides, i.e., the number of columns
  12636. * of the matrix B. NRHS >= 0.
  12637. *
  12638. * A (input/output) DOUBLE PRECISION array,
  12639. * dimension (LDA,N)
  12640. * On entry, the N-by-N coefficient matrix A.
  12641. * On exit, if iterative refinement has been successfully used
  12642. * (INFO.EQ.0 and ITER.GE.0, see description below), then A is
  12643. * unchanged, if double precision factorization has been used
  12644. * (INFO.EQ.0 and ITER.LT.0, see description below), then the
  12645. * array A contains the factors L and U from the factorization
  12646. * A = P*L*U; the unit diagonal elements of L are not stored.
  12647. *
  12648. * LDA (input) INTEGER
  12649. * The leading dimension of the array A. LDA >= max(1,N).
  12650. *
  12651. * IPIV (output) INTEGER array, dimension (N)
  12652. * The pivot indices that define the permutation matrix P;
  12653. * row i of the matrix was interchanged with row IPIV(i).
  12654. * Corresponds either to the single precision factorization
  12655. * (if INFO.EQ.0 and ITER.GE.0) or the double precision
  12656. * factorization (if INFO.EQ.0 and ITER.LT.0).
  12657. *
  12658. * B (input) DOUBLE PRECISION array, dimension (LDB,NRHS)
  12659. * The N-by-NRHS right hand side matrix B.
  12660. *
  12661. * LDB (input) INTEGER
  12662. * The leading dimension of the array B. LDB >= max(1,N).
  12663. *
  12664. * X (output) DOUBLE PRECISION array, dimension (LDX,NRHS)
  12665. * If INFO = 0, the N-by-NRHS solution matrix X.
  12666. *
  12667. * LDX (input) INTEGER
  12668. * The leading dimension of the array X. LDX >= max(1,N).
  12669. *
  12670. * WORK (workspace) DOUBLE PRECISION array, dimension (N,NRHS)
  12671. * This array is used to hold the residual vectors.
  12672. *
  12673. * SWORK (workspace) REAL array, dimension (N*(N+NRHS))
  12674. * This array is used to use the single precision matrix and the
  12675. * right-hand sides or solutions in single precision.
  12676. *
  12677. * ITER (output) INTEGER
  12678. * < 0: iterative refinement has failed, double precision
  12679. * factorization has been performed
  12680. * -1 : the routine fell back to full precision for
  12681. * implementation- or machine-specific reasons
  12682. * -2 : narrowing the precision induced an overflow,
  12683. * the routine fell back to full precision
  12684. * -3 : failure of SGETRF
  12685. * -31: stop the iterative refinement after the 30th
  12686. * iterations
  12687. * > 0: iterative refinement has been sucessfully used.
  12688. * Returns the number of iterations
  12689. *
  12690. * C++ Return value: INFO (output) INTEGER
  12691. * = 0: successful exit
  12692. * < 0: if INFO = -i, the i-th argument had an illegal value
  12693. * > 0: if INFO = i, U(i,i) computed in DOUBLE PRECISION is
  12694. * exactly zero. The factorization has been completed,
  12695. * but the factor U is exactly singular, so the solution
  12696. * could not be computed.
  12697. *
  12698. * =========
  12699. *
  12700. * .. Parameters ..
  12701. **/
  12702. int C_DSGESV(int n, int nrhs, double* a, int lda, int* ipiv, double* b, int ldb, double* x, int ldx, double* work, int* iter)
  12703. {
  12704. int info;
  12705. ::F_DSGESV(&n, &nrhs, a, &lda, ipiv, b, &ldb, x, &ldx, work, iter, &info);
  12706. return info;
  12707. }
  12708. /**
  12709. * Purpose
  12710. * =======
  12711. *
  12712. * DSPCON estimates the reciprocal of the condition number (in the
  12713. * 1-norm) of a real symmetric packed matrix A using the factorization
  12714. * A = U*D*U**T or A = L*D*L**T computed by DSPTRF.
  12715. *
  12716. * An estimate is obtained for norm(inv(A)), and the reciprocal of the
  12717. * condition number is computed as RCOND = 1 / (ANORM * norm(inv(A))).
  12718. *
  12719. * Arguments
  12720. * =========
  12721. *
  12722. * UPLO (input) CHARACTER*1
  12723. * Specifies whether the details of the factorization are stored
  12724. * as an upper or lower triangular matrix.
  12725. * = 'U': Upper triangular, form is A = U*D*U**T;
  12726. * = 'L': Lower triangular, form is A = L*D*L**T.
  12727. *
  12728. * N (input) INTEGER
  12729. * The order of the matrix A. N >= 0.
  12730. *
  12731. * AP (input) DOUBLE PRECISION array, dimension (N*(N+1)/2)
  12732. * The block diagonal matrix D and the multipliers used to
  12733. * obtain the factor U or L as computed by DSPTRF, stored as a
  12734. * packed triangular matrix.
  12735. *
  12736. * IPIV (input) INTEGER array, dimension (N)
  12737. * Details of the interchanges and the block structure of D
  12738. * as determined by DSPTRF.
  12739. *
  12740. * ANORM (input) DOUBLE PRECISION
  12741. * The 1-norm of the original matrix A.
  12742. *
  12743. * RCOND (output) DOUBLE PRECISION
  12744. * The reciprocal of the condition number of the matrix A,
  12745. * computed as RCOND = 1/(ANORM * AINVNM), where AINVNM is an
  12746. * estimate of the 1-norm of inv(A) computed in this routine.
  12747. *
  12748. * WORK (workspace) DOUBLE PRECISION array, dimension (2*N)
  12749. *
  12750. * IWORK (workspace) INTEGER array, dimension (N)
  12751. *
  12752. * C++ Return value: INFO (output) INTEGER
  12753. * = 0: successful exit
  12754. * < 0: if INFO = -i, the i-th argument had an illegal value
  12755. *
  12756. * =====================================================================
  12757. *
  12758. * .. Parameters ..
  12759. **/
  12760. int C_DSPCON(char uplo, int n, double* ap, int* ipiv, double anorm, double* rcond, double* work, int* iwork)
  12761. {
  12762. int info;
  12763. ::F_DSPCON(&uplo, &n, ap, ipiv, &anorm, rcond, work, iwork, &info);
  12764. return info;
  12765. }
  12766. /**
  12767. * Purpose
  12768. * =======
  12769. *
  12770. * DSPEV computes all the eigenvalues and, optionally, eigenvectors of a
  12771. * real symmetric matrix A in packed storage.
  12772. *
  12773. * Arguments
  12774. * =========
  12775. *
  12776. * JOBZ (input) CHARACTER*1
  12777. * = 'N': Compute eigenvalues only;
  12778. * = 'V': Compute eigenvalues and eigenvectors.
  12779. *
  12780. * UPLO (input) CHARACTER*1
  12781. * = 'U': Upper triangle of A is stored;
  12782. * = 'L': Lower triangle of A is stored.
  12783. *
  12784. * N (input) INTEGER
  12785. * The order of the matrix A. N >= 0.
  12786. *
  12787. * AP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2)
  12788. * On entry, the upper or lower triangle of the symmetric matrix
  12789. * A, packed columnwise in a linear array. The j-th column of A
  12790. * is stored in the array AP as follows:
  12791. * if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
  12792. * if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n.
  12793. *
  12794. * On exit, AP is overwritten by values generated during the
  12795. * reduction to tridiagonal form. If UPLO = 'U', the diagonal
  12796. * and first superdiagonal of the tridiagonal matrix T overwrite
  12797. * the corresponding elements of A, and if UPLO = 'L', the
  12798. * diagonal and first subdiagonal of T overwrite the
  12799. * corresponding elements of A.
  12800. *
  12801. * W (output) DOUBLE PRECISION array, dimension (N)
  12802. * If INFO = 0, the eigenvalues in ascending order.
  12803. *
  12804. * Z (output) DOUBLE PRECISION array, dimension (LDZ, N)
  12805. * If JOBZ = 'V', then if INFO = 0, Z contains the orthonormal
  12806. * eigenvectors of the matrix A, with the i-th column of Z
  12807. * holding the eigenvector associated with W(i).
  12808. * If JOBZ = 'N', then Z is not referenced.
  12809. *
  12810. * LDZ (input) INTEGER
  12811. * The leading dimension of the array Z. LDZ >= 1, and if
  12812. * JOBZ = 'V', LDZ >= max(1,N).
  12813. *
  12814. * WORK (workspace) DOUBLE PRECISION array, dimension (3*N)
  12815. *
  12816. * C++ Return value: INFO (output) INTEGER
  12817. * = 0: successful exit.
  12818. * < 0: if INFO = -i, the i-th argument had an illegal value.
  12819. * > 0: if INFO = i, the algorithm failed to converge; i
  12820. * off-diagonal elements of an intermediate tridiagonal
  12821. * form did not converge to zero.
  12822. *
  12823. * =====================================================================
  12824. *
  12825. * .. Parameters ..
  12826. **/
  12827. int C_DSPEV(char jobz, char uplo, int n, double* ap, double* w, double* z, int ldz, double* work)
  12828. {
  12829. int info;
  12830. ::F_DSPEV(&jobz, &uplo, &n, ap, w, z, &ldz, work, &info);
  12831. return info;
  12832. }
  12833. /**
  12834. * Purpose
  12835. * =======
  12836. *
  12837. * DSPEVD computes all the eigenvalues and, optionally, eigenvectors
  12838. * of a real symmetric matrix A in packed storage. If eigenvectors are
  12839. * desired, it uses a divide and conquer algorithm.
  12840. *
  12841. * The divide and conquer algorithm makes very mild assumptions about
  12842. * floating point arithmetic. It will work on machines with a guard
  12843. * digit in add/subtract, or on those binary machines without guard
  12844. * digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or
  12845. * Cray-2. It could conceivably fail on hexadecimal or decimal machines
  12846. * without guard digits, but we know of none.
  12847. *
  12848. * Arguments
  12849. * =========
  12850. *
  12851. * JOBZ (input) CHARACTER*1
  12852. * = 'N': Compute eigenvalues only;
  12853. * = 'V': Compute eigenvalues and eigenvectors.
  12854. *
  12855. * UPLO (input) CHARACTER*1
  12856. * = 'U': Upper triangle of A is stored;
  12857. * = 'L': Lower triangle of A is stored.
  12858. *
  12859. * N (input) INTEGER
  12860. * The order of the matrix A. N >= 0.
  12861. *
  12862. * AP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2)
  12863. * On entry, the upper or lower triangle of the symmetric matrix
  12864. * A, packed columnwise in a linear array. The j-th column of A
  12865. * is stored in the array AP as follows:
  12866. * if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
  12867. * if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n.
  12868. *
  12869. * On exit, AP is overwritten by values generated during the
  12870. * reduction to tridiagonal form. If UPLO = 'U', the diagonal
  12871. * and first superdiagonal of the tridiagonal matrix T overwrite
  12872. * the corresponding elements of A, and if UPLO = 'L', the
  12873. * diagonal and first subdiagonal of T overwrite the
  12874. * corresponding elements of A.
  12875. *
  12876. * W (output) DOUBLE PRECISION array, dimension (N)
  12877. * If INFO = 0, the eigenvalues in ascending order.
  12878. *
  12879. * Z (output) DOUBLE PRECISION array, dimension (LDZ, N)
  12880. * If JOBZ = 'V', then if INFO = 0, Z contains the orthonormal
  12881. * eigenvectors of the matrix A, with the i-th column of Z
  12882. * holding the eigenvector associated with W(i).
  12883. * If JOBZ = 'N', then Z is not referenced.
  12884. *
  12885. * LDZ (input) INTEGER
  12886. * The leading dimension of the array Z. LDZ >= 1, and if
  12887. * JOBZ = 'V', LDZ >= max(1,N).
  12888. *
  12889. * WORK (workspace/output) DOUBLE PRECISION array,
  12890. * dimension (LWORK)
  12891. * On exit, if INFO = 0, WORK(1) returns the required LWORK.
  12892. *
  12893. * LWORK (input) INTEGER
  12894. * The dimension of the array WORK.
  12895. * If N <= 1, LWORK must be at least 1.
  12896. * If JOBZ = 'N' and N > 1, LWORK must be at least 2*N.
  12897. * If JOBZ = 'V' and N > 1, LWORK must be at least
  12898. * 1 + 6*N + N**2.
  12899. *
  12900. * If LWORK = -1, then a workspace query is assumed; the routine
  12901. * only calculates the required sizes of the WORK and IWORK
  12902. * arrays, returns these values as the first entries of the WORK
  12903. * and IWORK arrays, and no error message related to LWORK or
  12904. * LIWORK is issued by XERBLA.
  12905. *
  12906. * IWORK (workspace/output) INTEGER array, dimension (MAX(1,LIWORK))
  12907. * On exit, if INFO = 0, IWORK(1) returns the required LIWORK.
  12908. *
  12909. * LIWORK (input) INTEGER
  12910. * The dimension of the array IWORK.
  12911. * If JOBZ = 'N' or N <= 1, LIWORK must be at least 1.
  12912. * If JOBZ = 'V' and N > 1, LIWORK must be at least 3 + 5*N.
  12913. *
  12914. * If LIWORK = -1, then a workspace query is assumed; the
  12915. * routine only calculates the required sizes of the WORK and
  12916. * IWORK arrays, returns these values as the first entries of
  12917. * the WORK and IWORK arrays, and no error message related to
  12918. * LWORK or LIWORK is issued by XERBLA.
  12919. *
  12920. * C++ Return value: INFO (output) INTEGER
  12921. * = 0: successful exit
  12922. * < 0: if INFO = -i, the i-th argument had an illegal value.
  12923. * > 0: if INFO = i, the algorithm failed to converge; i
  12924. * off-diagonal elements of an intermediate tridiagonal
  12925. * form did not converge to zero.
  12926. *
  12927. * =====================================================================
  12928. *
  12929. * .. Parameters ..
  12930. **/
  12931. int C_DSPEVD(char jobz, char uplo, int n, double* ap, double* w, double* z, int ldz, double* work, int lwork, int* iwork, int liwork)
  12932. {
  12933. int info;
  12934. ::F_DSPEVD(&jobz, &uplo, &n, ap, w, z, &ldz, work, &lwork, iwork, &liwork, &info);
  12935. return info;
  12936. }
  12937. /**
  12938. * Purpose
  12939. * =======
  12940. *
  12941. * DSPEVX computes selected eigenvalues and, optionally, eigenvectors
  12942. * of a real symmetric matrix A in packed storage. Eigenvalues/vectors
  12943. * can be selected by specifying either a range of values or a range of
  12944. * indices for the desired eigenvalues.
  12945. *
  12946. * Arguments
  12947. * =========
  12948. *
  12949. * JOBZ (input) CHARACTER*1
  12950. * = 'N': Compute eigenvalues only;
  12951. * = 'V': Compute eigenvalues and eigenvectors.
  12952. *
  12953. * RANGE (input) CHARACTER*1
  12954. * = 'A': all eigenvalues will be found;
  12955. * = 'V': all eigenvalues in the half-open interval (VL,VU]
  12956. * will be found;
  12957. * = 'I': the IL-th through IU-th eigenvalues will be found.
  12958. *
  12959. * UPLO (input) CHARACTER*1
  12960. * = 'U': Upper triangle of A is stored;
  12961. * = 'L': Lower triangle of A is stored.
  12962. *
  12963. * N (input) INTEGER
  12964. * The order of the matrix A. N >= 0.
  12965. *
  12966. * AP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2)
  12967. * On entry, the upper or lower triangle of the symmetric matrix
  12968. * A, packed columnwise in a linear array. The j-th column of A
  12969. * is stored in the array AP as follows:
  12970. * if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
  12971. * if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n.
  12972. *
  12973. * On exit, AP is overwritten by values generated during the
  12974. * reduction to tridiagonal form. If UPLO = 'U', the diagonal
  12975. * and first superdiagonal of the tridiagonal matrix T overwrite
  12976. * the corresponding elements of A, and if UPLO = 'L', the
  12977. * diagonal and first subdiagonal of T overwrite the
  12978. * corresponding elements of A.
  12979. *
  12980. * VL (input) DOUBLE PRECISION
  12981. * VU (input) DOUBLE PRECISION
  12982. * If RANGE='V', the lower and upper bounds of the interval to
  12983. * be searched for eigenvalues. VL < VU.
  12984. * Not referenced if RANGE = 'A' or 'I'.
  12985. *
  12986. * IL (input) INTEGER
  12987. * IU (input) INTEGER
  12988. * If RANGE='I', the indices (in ascending order) of the
  12989. * smallest and largest eigenvalues to be returned.
  12990. * 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
  12991. * Not referenced if RANGE = 'A' or 'V'.
  12992. *
  12993. * ABSTOL (input) DOUBLE PRECISION
  12994. * The absolute error tolerance for the eigenvalues.
  12995. * An approximate eigenvalue is accepted as converged
  12996. * when it is determined to lie in an interval [a,b]
  12997. * of width less than or equal to
  12998. *
  12999. * ABSTOL + EPS * max( |a|,|b| ) ,
  13000. *
  13001. * where EPS is the machine precision. If ABSTOL is less than
  13002. * or equal to zero, then EPS*|T| will be used in its place,
  13003. * where |T| is the 1-norm of the tridiagonal matrix obtained
  13004. * by reducing AP to tridiagonal form.
  13005. *
  13006. * Eigenvalues will be computed most accurately when ABSTOL is
  13007. * set to twice the underflow threshold 2*DLAMCH('S'), not zero.
  13008. * If this routine returns with INFO>0, indicating that some
  13009. * eigenvectors did not converge, try setting ABSTOL to
  13010. * 2*DLAMCH('S').
  13011. *
  13012. * See "Computing Small Singular Values of Bidiagonal Matrices
  13013. * with Guaranteed High Relative Accuracy," by Demmel and
  13014. * Kahan, LAPACK Working Note #3.
  13015. *
  13016. * M (output) INTEGER
  13017. * The total number of eigenvalues found. 0 <= M <= N.
  13018. * If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
  13019. *
  13020. * W (output) DOUBLE PRECISION array, dimension (N)
  13021. * If INFO = 0, the selected eigenvalues in ascending order.
  13022. *
  13023. * Z (output) DOUBLE PRECISION array, dimension (LDZ, max(1,M))
  13024. * If JOBZ = 'V', then if INFO = 0, the first M columns of Z
  13025. * contain the orthonormal eigenvectors of the matrix A
  13026. * corresponding to the selected eigenvalues, with the i-th
  13027. * column of Z holding the eigenvector associated with W(i).
  13028. * If an eigenvector fails to converge, then that column of Z
  13029. * contains the latest approximation to the eigenvector, and the
  13030. * index of the eigenvector is returned in IFAIL.
  13031. * If JOBZ = 'N', then Z is not referenced.
  13032. * Note: the user must ensure that at least max(1,M) columns are
  13033. * supplied in the array Z; if RANGE = 'V', the exact value of M
  13034. * is not known in advance and an upper bound must be used.
  13035. *
  13036. * LDZ (input) INTEGER
  13037. * The leading dimension of the array Z. LDZ >= 1, and if
  13038. * JOBZ = 'V', LDZ >= max(1,N).
  13039. *
  13040. * WORK (workspace) DOUBLE PRECISION array, dimension (8*N)
  13041. *
  13042. * IWORK (workspace) INTEGER array, dimension (5*N)
  13043. *
  13044. * IFAIL (output) INTEGER array, dimension (N)
  13045. * If JOBZ = 'V', then if INFO = 0, the first M elements of
  13046. * IFAIL are zero. If INFO > 0, then IFAIL contains the
  13047. * indices of the eigenvectors that failed to converge.
  13048. * If JOBZ = 'N', then IFAIL is not referenced.
  13049. *
  13050. * C++ Return value: INFO (output) INTEGER
  13051. * = 0: successful exit
  13052. * < 0: if INFO = -i, the i-th argument had an illegal value
  13053. * > 0: if INFO = i, then i eigenvectors failed to converge.
  13054. * Their indices are stored in array IFAIL.
  13055. *
  13056. * =====================================================================
  13057. *
  13058. * .. Parameters ..
  13059. **/
  13060. int C_DSPEVX(char jobz, char range, char uplo, int n, double* ap, double vl, double vu, int il, int iu, double abstol, int* m, double* w, double* z, int ldz, double* work, int* iwork, int* ifail)
  13061. {
  13062. int info;
  13063. ::F_DSPEVX(&jobz, &range, &uplo, &n, ap, &vl, &vu, &il, &iu, &abstol, m, w, z, &ldz, work, iwork, ifail, &info);
  13064. return info;
  13065. }
  13066. /**
  13067. * Purpose
  13068. * =======
  13069. *
  13070. * DSPGST reduces a real symmetric-definite generalized eigenproblem
  13071. * to standard form, using packed storage.
  13072. *
  13073. * If ITYPE = 1, the problem is A*x = lambda*B*x,
  13074. * and A is overwritten by inv(U**T)*A*inv(U) or inv(L)*A*inv(L**T)
  13075. *
  13076. * If ITYPE = 2 or 3, the problem is A*B*x = lambda*x or
  13077. * B*A*x = lambda*x, and A is overwritten by U*A*U**T or L**T*A*L.
  13078. *
  13079. * B must have been previously factorized as U**T*U or L*L**T by DPPTRF.
  13080. *
  13081. * Arguments
  13082. * =========
  13083. *
  13084. * ITYPE (input) INTEGER
  13085. * = 1: compute inv(U**T)*A*inv(U) or inv(L)*A*inv(L**T);
  13086. * = 2 or 3: compute U*A*U**T or L**T*A*L.
  13087. *
  13088. * UPLO (input) CHARACTER*1
  13089. * = 'U': Upper triangle of A is stored and B is factored as
  13090. * U**T*U;
  13091. * = 'L': Lower triangle of A is stored and B is factored as
  13092. * L*L**T.
  13093. *
  13094. * N (input) INTEGER
  13095. * The order of the matrices A and B. N >= 0.
  13096. *
  13097. * AP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2)
  13098. * On entry, the upper or lower triangle of the symmetric matrix
  13099. * A, packed columnwise in a linear array. The j-th column of A
  13100. * is stored in the array AP as follows:
  13101. * if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
  13102. * if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n.
  13103. *
  13104. * On exit, if INFO = 0, the transformed matrix, stored in the
  13105. * same format as A.
  13106. *
  13107. * BP (input) DOUBLE PRECISION array, dimension (N*(N+1)/2)
  13108. * The triangular factor from the Cholesky factorization of B,
  13109. * stored in the same format as A, as returned by DPPTRF.
  13110. *
  13111. * C++ Return value: INFO (output) INTEGER
  13112. * = 0: successful exit
  13113. * < 0: if INFO = -i, the i-th argument had an illegal value
  13114. *
  13115. * =====================================================================
  13116. *
  13117. * .. Parameters ..
  13118. **/
  13119. int C_DSPGST(int itype, char uplo, int n, double* ap, double* bp)
  13120. {
  13121. int info;
  13122. ::F_DSPGST(&itype, &uplo, &n, ap, bp, &info);
  13123. return info;
  13124. }
  13125. /**
  13126. * Purpose
  13127. * =======
  13128. *
  13129. * DSPGV computes all the eigenvalues and, optionally, the eigenvectors
  13130. * of a real generalized symmetric-definite eigenproblem, of the form
  13131. * A*x=(lambda)*B*x, A*Bx=(lambda)*x, or B*A*x=(lambda)*x.
  13132. * Here A and B are assumed to be symmetric, stored in packed format,
  13133. * and B is also positive definite.
  13134. *
  13135. * Arguments
  13136. * =========
  13137. *
  13138. * ITYPE (input) INTEGER
  13139. * Specifies the problem type to be solved:
  13140. * = 1: A*x = (lambda)*B*x
  13141. * = 2: A*B*x = (lambda)*x
  13142. * = 3: B*A*x = (lambda)*x
  13143. *
  13144. * JOBZ (input) CHARACTER*1
  13145. * = 'N': Compute eigenvalues only;
  13146. * = 'V': Compute eigenvalues and eigenvectors.
  13147. *
  13148. * UPLO (input) CHARACTER*1
  13149. * = 'U': Upper triangles of A and B are stored;
  13150. * = 'L': Lower triangles of A and B are stored.
  13151. *
  13152. * N (input) INTEGER
  13153. * The order of the matrices A and B. N >= 0.
  13154. *
  13155. * AP (input/output) DOUBLE PRECISION array, dimension
  13156. * (N*(N+1)/2)
  13157. * On entry, the upper or lower triangle of the symmetric matrix
  13158. * A, packed columnwise in a linear array. The j-th column of A
  13159. * is stored in the array AP as follows:
  13160. * if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
  13161. * if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n.
  13162. *
  13163. * On exit, the contents of AP are destroyed.
  13164. *
  13165. * BP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2)
  13166. * On entry, the upper or lower triangle of the symmetric matrix
  13167. * B, packed columnwise in a linear array. The j-th column of B
  13168. * is stored in the array BP as follows:
  13169. * if UPLO = 'U', BP(i + (j-1)*j/2) = B(i,j) for 1<=i<=j;
  13170. * if UPLO = 'L', BP(i + (j-1)*(2*n-j)/2) = B(i,j) for j<=i<=n.
  13171. *
  13172. * On exit, the triangular factor U or L from the Cholesky
  13173. * factorization B = U**T*U or B = L*L**T, in the same storage
  13174. * format as B.
  13175. *
  13176. * W (output) DOUBLE PRECISION array, dimension (N)
  13177. * If INFO = 0, the eigenvalues in ascending order.
  13178. *
  13179. * Z (output) DOUBLE PRECISION array, dimension (LDZ, N)
  13180. * If JOBZ = 'V', then if INFO = 0, Z contains the matrix Z of
  13181. * eigenvectors. The eigenvectors are normalized as follows:
  13182. * if ITYPE = 1 or 2, Z**T*B*Z = I;
  13183. * if ITYPE = 3, Z**T*inv(B)*Z = I.
  13184. * If JOBZ = 'N', then Z is not referenced.
  13185. *
  13186. * LDZ (input) INTEGER
  13187. * The leading dimension of the array Z. LDZ >= 1, and if
  13188. * JOBZ = 'V', LDZ >= max(1,N).
  13189. *
  13190. * WORK (workspace) DOUBLE PRECISION array, dimension (3*N)
  13191. *
  13192. * C++ Return value: INFO (output) INTEGER
  13193. * = 0: successful exit
  13194. * < 0: if INFO = -i, the i-th argument had an illegal value
  13195. * > 0: DPPTRF or DSPEV returned an error code:
  13196. * <= N: if INFO = i, DSPEV failed to converge;
  13197. * i off-diagonal elements of an intermediate
  13198. * tridiagonal form did not converge to zero.
  13199. * > N: if INFO = n + i, for 1 <= i <= n, then the leading
  13200. * minor of order i of B is not positive definite.
  13201. * The factorization of B could not be completed and
  13202. * no eigenvalues or eigenvectors were computed.
  13203. *
  13204. * =====================================================================
  13205. *
  13206. * .. Local Scalars ..
  13207. **/
  13208. int C_DSPGV(int itype, char jobz, char uplo, int n, double* ap, double* bp, double* w, double* z, int ldz, double* work)
  13209. {
  13210. int info;
  13211. ::F_DSPGV(&itype, &jobz, &uplo, &n, ap, bp, w, z, &ldz, work, &info);
  13212. return info;
  13213. }
  13214. /**
  13215. * Purpose
  13216. * =======
  13217. *
  13218. * DSPGVD computes all the eigenvalues, and optionally, the eigenvectors
  13219. * of a real generalized symmetric-definite eigenproblem, of the form
  13220. * A*x=(lambda)*B*x, A*Bx=(lambda)*x, or B*A*x=(lambda)*x. Here A and
  13221. * B are assumed to be symmetric, stored in packed format, and B is also
  13222. * positive definite.
  13223. * If eigenvectors are desired, it uses a divide and conquer algorithm.
  13224. *
  13225. * The divide and conquer algorithm makes very mild assumptions about
  13226. * floating point arithmetic. It will work on machines with a guard
  13227. * digit in add/subtract, or on those binary machines without guard
  13228. * digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or
  13229. * Cray-2. It could conceivably fail on hexadecimal or decimal machines
  13230. * without guard digits, but we know of none.
  13231. *
  13232. * Arguments
  13233. * =========
  13234. *
  13235. * ITYPE (input) INTEGER
  13236. * Specifies the problem type to be solved:
  13237. * = 1: A*x = (lambda)*B*x
  13238. * = 2: A*B*x = (lambda)*x
  13239. * = 3: B*A*x = (lambda)*x
  13240. *
  13241. * JOBZ (input) CHARACTER*1
  13242. * = 'N': Compute eigenvalues only;
  13243. * = 'V': Compute eigenvalues and eigenvectors.
  13244. *
  13245. * UPLO (input) CHARACTER*1
  13246. * = 'U': Upper triangles of A and B are stored;
  13247. * = 'L': Lower triangles of A and B are stored.
  13248. *
  13249. * N (input) INTEGER
  13250. * The order of the matrices A and B. N >= 0.
  13251. *
  13252. * AP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2)
  13253. * On entry, the upper or lower triangle of the symmetric matrix
  13254. * A, packed columnwise in a linear array. The j-th column of A
  13255. * is stored in the array AP as follows:
  13256. * if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
  13257. * if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n.
  13258. *
  13259. * On exit, the contents of AP are destroyed.
  13260. *
  13261. * BP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2)
  13262. * On entry, the upper or lower triangle of the symmetric matrix
  13263. * B, packed columnwise in a linear array. The j-th column of B
  13264. * is stored in the array BP as follows:
  13265. * if UPLO = 'U', BP(i + (j-1)*j/2) = B(i,j) for 1<=i<=j;
  13266. * if UPLO = 'L', BP(i + (j-1)*(2*n-j)/2) = B(i,j) for j<=i<=n.
  13267. *
  13268. * On exit, the triangular factor U or L from the Cholesky
  13269. * factorization B = U**T*U or B = L*L**T, in the same storage
  13270. * format as B.
  13271. *
  13272. * W (output) DOUBLE PRECISION array, dimension (N)
  13273. * If INFO = 0, the eigenvalues in ascending order.
  13274. *
  13275. * Z (output) DOUBLE PRECISION array, dimension (LDZ, N)
  13276. * If JOBZ = 'V', then if INFO = 0, Z contains the matrix Z of
  13277. * eigenvectors. The eigenvectors are normalized as follows:
  13278. * if ITYPE = 1 or 2, Z**T*B*Z = I;
  13279. * if ITYPE = 3, Z**T*inv(B)*Z = I.
  13280. * If JOBZ = 'N', then Z is not referenced.
  13281. *
  13282. * LDZ (input) INTEGER
  13283. * The leading dimension of the array Z. LDZ >= 1, and if
  13284. * JOBZ = 'V', LDZ >= max(1,N).
  13285. *
  13286. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  13287. * On exit, if INFO = 0, WORK(1) returns the required LWORK.
  13288. *
  13289. * LWORK (input) INTEGER
  13290. * The dimension of the array WORK.
  13291. * If N <= 1, LWORK >= 1.
  13292. * If JOBZ = 'N' and N > 1, LWORK >= 2*N.
  13293. * If JOBZ = 'V' and N > 1, LWORK >= 1 + 6*N + 2*N**2.
  13294. *
  13295. * If LWORK = -1, then a workspace query is assumed; the routine
  13296. * only calculates the required sizes of the WORK and IWORK
  13297. * arrays, returns these values as the first entries of the WORK
  13298. * and IWORK arrays, and no error message related to LWORK or
  13299. * LIWORK is issued by XERBLA.
  13300. *
  13301. * IWORK (workspace/output) INTEGER array, dimension (MAX(1,LIWORK))
  13302. * On exit, if INFO = 0, IWORK(1) returns the required LIWORK.
  13303. *
  13304. * LIWORK (input) INTEGER
  13305. * The dimension of the array IWORK.
  13306. * If JOBZ = 'N' or N <= 1, LIWORK >= 1.
  13307. * If JOBZ = 'V' and N > 1, LIWORK >= 3 + 5*N.
  13308. *
  13309. * If LIWORK = -1, then a workspace query is assumed; the
  13310. * routine only calculates the required sizes of the WORK and
  13311. * IWORK arrays, returns these values as the first entries of
  13312. * the WORK and IWORK arrays, and no error message related to
  13313. * LWORK or LIWORK is issued by XERBLA.
  13314. *
  13315. * C++ Return value: INFO (output) INTEGER
  13316. * = 0: successful exit
  13317. * < 0: if INFO = -i, the i-th argument had an illegal value
  13318. * > 0: DPPTRF or DSPEVD returned an error code:
  13319. * <= N: if INFO = i, DSPEVD failed to converge;
  13320. * i off-diagonal elements of an intermediate
  13321. * tridiagonal form did not converge to zero;
  13322. * > N: if INFO = N + i, for 1 <= i <= N, then the leading
  13323. * minor of order i of B is not positive definite.
  13324. * The factorization of B could not be completed and
  13325. * no eigenvalues or eigenvectors were computed.
  13326. *
  13327. * Further Details
  13328. * ===============
  13329. *
  13330. * Based on contributions by
  13331. * Mark Fahey, Department of Mathematics, Univ. of Kentucky, USA
  13332. *
  13333. * =====================================================================
  13334. *
  13335. * .. Parameters ..
  13336. **/
  13337. int C_DSPGVD(int itype, char jobz, char uplo, int n, double* ap, double* bp, double* w, double* z, int ldz, double* work, int lwork, int* iwork, int liwork)
  13338. {
  13339. int info;
  13340. ::F_DSPGVD(&itype, &jobz, &uplo, &n, ap, bp, w, z, &ldz, work, &lwork, iwork, &liwork, &info);
  13341. return info;
  13342. }
  13343. /**
  13344. * Purpose
  13345. * =======
  13346. *
  13347. * DSPGVX computes selected eigenvalues, and optionally, eigenvectors
  13348. * of a real generalized symmetric-definite eigenproblem, of the form
  13349. * A*x=(lambda)*B*x, A*Bx=(lambda)*x, or B*A*x=(lambda)*x. Here A
  13350. * and B are assumed to be symmetric, stored in packed storage, and B
  13351. * is also positive definite. Eigenvalues and eigenvectors can be
  13352. * selected by specifying either a range of values or a range of indices
  13353. * for the desired eigenvalues.
  13354. *
  13355. * Arguments
  13356. * =========
  13357. *
  13358. * ITYPE (input) INTEGER
  13359. * Specifies the problem type to be solved:
  13360. * = 1: A*x = (lambda)*B*x
  13361. * = 2: A*B*x = (lambda)*x
  13362. * = 3: B*A*x = (lambda)*x
  13363. *
  13364. * JOBZ (input) CHARACTER*1
  13365. * = 'N': Compute eigenvalues only;
  13366. * = 'V': Compute eigenvalues and eigenvectors.
  13367. *
  13368. * RANGE (input) CHARACTER*1
  13369. * = 'A': all eigenvalues will be found.
  13370. * = 'V': all eigenvalues in the half-open interval (VL,VU]
  13371. * will be found.
  13372. * = 'I': the IL-th through IU-th eigenvalues will be found.
  13373. *
  13374. * UPLO (input) CHARACTER*1
  13375. * = 'U': Upper triangle of A and B are stored;
  13376. * = 'L': Lower triangle of A and B are stored.
  13377. *
  13378. * N (input) INTEGER
  13379. * The order of the matrix pencil (A,B). N >= 0.
  13380. *
  13381. * AP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2)
  13382. * On entry, the upper or lower triangle of the symmetric matrix
  13383. * A, packed columnwise in a linear array. The j-th column of A
  13384. * is stored in the array AP as follows:
  13385. * if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
  13386. * if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n.
  13387. *
  13388. * On exit, the contents of AP are destroyed.
  13389. *
  13390. * BP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2)
  13391. * On entry, the upper or lower triangle of the symmetric matrix
  13392. * B, packed columnwise in a linear array. The j-th column of B
  13393. * is stored in the array BP as follows:
  13394. * if UPLO = 'U', BP(i + (j-1)*j/2) = B(i,j) for 1<=i<=j;
  13395. * if UPLO = 'L', BP(i + (j-1)*(2*n-j)/2) = B(i,j) for j<=i<=n.
  13396. *
  13397. * On exit, the triangular factor U or L from the Cholesky
  13398. * factorization B = U**T*U or B = L*L**T, in the same storage
  13399. * format as B.
  13400. *
  13401. * VL (input) DOUBLE PRECISION
  13402. * VU (input) DOUBLE PRECISION
  13403. * If RANGE='V', the lower and upper bounds of the interval to
  13404. * be searched for eigenvalues. VL < VU.
  13405. * Not referenced if RANGE = 'A' or 'I'.
  13406. *
  13407. * IL (input) INTEGER
  13408. * IU (input) INTEGER
  13409. * If RANGE='I', the indices (in ascending order) of the
  13410. * smallest and largest eigenvalues to be returned.
  13411. * 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
  13412. * Not referenced if RANGE = 'A' or 'V'.
  13413. *
  13414. * ABSTOL (input) DOUBLE PRECISION
  13415. * The absolute error tolerance for the eigenvalues.
  13416. * An approximate eigenvalue is accepted as converged
  13417. * when it is determined to lie in an interval [a,b]
  13418. * of width less than or equal to
  13419. *
  13420. * ABSTOL + EPS * max( |a|,|b| ) ,
  13421. *
  13422. * where EPS is the machine precision. If ABSTOL is less than
  13423. * or equal to zero, then EPS*|T| will be used in its place,
  13424. * where |T| is the 1-norm of the tridiagonal matrix obtained
  13425. * by reducing A to tridiagonal form.
  13426. *
  13427. * Eigenvalues will be computed most accurately when ABSTOL is
  13428. * set to twice the underflow threshold 2*DLAMCH('S'), not zero.
  13429. * If this routine returns with INFO>0, indicating that some
  13430. * eigenvectors did not converge, try setting ABSTOL to
  13431. * 2*DLAMCH('S').
  13432. *
  13433. * M (output) INTEGER
  13434. * The total number of eigenvalues found. 0 <= M <= N.
  13435. * If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
  13436. *
  13437. * W (output) DOUBLE PRECISION array, dimension (N)
  13438. * On normal exit, the first M elements contain the selected
  13439. * eigenvalues in ascending order.
  13440. *
  13441. * Z (output) DOUBLE PRECISION array, dimension (LDZ, max(1,M))
  13442. * If JOBZ = 'N', then Z is not referenced.
  13443. * If JOBZ = 'V', then if INFO = 0, the first M columns of Z
  13444. * contain the orthonormal eigenvectors of the matrix A
  13445. * corresponding to the selected eigenvalues, with the i-th
  13446. * column of Z holding the eigenvector associated with W(i).
  13447. * The eigenvectors are normalized as follows:
  13448. * if ITYPE = 1 or 2, Z**T*B*Z = I;
  13449. * if ITYPE = 3, Z**T*inv(B)*Z = I.
  13450. *
  13451. * If an eigenvector fails to converge, then that column of Z
  13452. * contains the latest approximation to the eigenvector, and the
  13453. * index of the eigenvector is returned in IFAIL.
  13454. * Note: the user must ensure that at least max(1,M) columns are
  13455. * supplied in the array Z; if RANGE = 'V', the exact value of M
  13456. * is not known in advance and an upper bound must be used.
  13457. *
  13458. * LDZ (input) INTEGER
  13459. * The leading dimension of the array Z. LDZ >= 1, and if
  13460. * JOBZ = 'V', LDZ >= max(1,N).
  13461. *
  13462. * WORK (workspace) DOUBLE PRECISION array, dimension (8*N)
  13463. *
  13464. * IWORK (workspace) INTEGER array, dimension (5*N)
  13465. *
  13466. * IFAIL (output) INTEGER array, dimension (N)
  13467. * If JOBZ = 'V', then if INFO = 0, the first M elements of
  13468. * IFAIL are zero. If INFO > 0, then IFAIL contains the
  13469. * indices of the eigenvectors that failed to converge.
  13470. * If JOBZ = 'N', then IFAIL is not referenced.
  13471. *
  13472. * C++ Return value: INFO (output) INTEGER
  13473. * = 0: successful exit
  13474. * < 0: if INFO = -i, the i-th argument had an illegal value
  13475. * > 0: DPPTRF or DSPEVX returned an error code:
  13476. * <= N: if INFO = i, DSPEVX failed to converge;
  13477. * i eigenvectors failed to converge. Their indices
  13478. * are stored in array IFAIL.
  13479. * > N: if INFO = N + i, for 1 <= i <= N, then the leading
  13480. * minor of order i of B is not positive definite.
  13481. * The factorization of B could not be completed and
  13482. * no eigenvalues or eigenvectors were computed.
  13483. *
  13484. * Further Details
  13485. * ===============
  13486. *
  13487. * Based on contributions by
  13488. * Mark Fahey, Department of Mathematics, Univ. of Kentucky, USA
  13489. *
  13490. * =====================================================================
  13491. *
  13492. * .. Local Scalars ..
  13493. **/
  13494. int C_DSPGVX(int itype, char jobz, char range, char uplo, int n, double* ap, double* bp, double vl, double vu, int il, int iu, double abstol, int* m, double* w, double* z, int ldz, double* work, int* iwork, int* ifail)
  13495. {
  13496. int info;
  13497. ::F_DSPGVX(&itype, &jobz, &range, &uplo, &n, ap, bp, &vl, &vu, &il, &iu, &abstol, m, w, z, &ldz, work, iwork, ifail, &info);
  13498. return info;
  13499. }
  13500. /**
  13501. * Purpose
  13502. * =======
  13503. *
  13504. * DSPRFS improves the computed solution to a system of linear
  13505. * equations when the coefficient matrix is symmetric indefinite
  13506. * and packed, and provides error bounds and backward error estimates
  13507. * for the solution.
  13508. *
  13509. * Arguments
  13510. * =========
  13511. *
  13512. * UPLO (input) CHARACTER*1
  13513. * = 'U': Upper triangle of A is stored;
  13514. * = 'L': Lower triangle of A is stored.
  13515. *
  13516. * N (input) INTEGER
  13517. * The order of the matrix A. N >= 0.
  13518. *
  13519. * NRHS (input) INTEGER
  13520. * The number of right hand sides, i.e., the number of columns
  13521. * of the matrices B and X. NRHS >= 0.
  13522. *
  13523. * AP (input) DOUBLE PRECISION array, dimension (N*(N+1)/2)
  13524. * The upper or lower triangle of the symmetric matrix A, packed
  13525. * columnwise in a linear array. The j-th column of A is stored
  13526. * in the array AP as follows:
  13527. * if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
  13528. * if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n.
  13529. *
  13530. * AFP (input) DOUBLE PRECISION array, dimension (N*(N+1)/2)
  13531. * The factored form of the matrix A. AFP contains the block
  13532. * diagonal matrix D and the multipliers used to obtain the
  13533. * factor U or L from the factorization A = U*D*U**T or
  13534. * A = L*D*L**T as computed by DSPTRF, stored as a packed
  13535. * triangular matrix.
  13536. *
  13537. * IPIV (input) INTEGER array, dimension (N)
  13538. * Details of the interchanges and the block structure of D
  13539. * as determined by DSPTRF.
  13540. *
  13541. * B (input) DOUBLE PRECISION array, dimension (LDB,NRHS)
  13542. * The right hand side matrix B.
  13543. *
  13544. * LDB (input) INTEGER
  13545. * The leading dimension of the array B. LDB >= max(1,N).
  13546. *
  13547. * X (input/output) DOUBLE PRECISION array, dimension (LDX,NRHS)
  13548. * On entry, the solution matrix X, as computed by DSPTRS.
  13549. * On exit, the improved solution matrix X.
  13550. *
  13551. * LDX (input) INTEGER
  13552. * The leading dimension of the array X. LDX >= max(1,N).
  13553. *
  13554. * FERR (output) DOUBLE PRECISION array, dimension (NRHS)
  13555. * The estimated forward error bound for each solution vector
  13556. * X(j) (the j-th column of the solution matrix X).
  13557. * If XTRUE is the true solution corresponding to X(j), FERR(j)
  13558. * is an estimated upper bound for the magnitude of the largest
  13559. * element in (X(j) - XTRUE) divided by the magnitude of the
  13560. * largest element in X(j). The estimate is as reliable as
  13561. * the estimate for RCOND, and is almost always a slight
  13562. * overestimate of the true error.
  13563. *
  13564. * BERR (output) DOUBLE PRECISION array, dimension (NRHS)
  13565. * The componentwise relative backward error of each solution
  13566. * vector X(j) (i.e., the smallest relative change in
  13567. * any element of A or B that makes X(j) an exact solution).
  13568. *
  13569. * WORK (workspace) DOUBLE PRECISION array, dimension (3*N)
  13570. *
  13571. * IWORK (workspace) INTEGER array, dimension (N)
  13572. *
  13573. * C++ Return value: INFO (output) INTEGER
  13574. * = 0: successful exit
  13575. * < 0: if INFO = -i, the i-th argument had an illegal value
  13576. *
  13577. * Internal Parameters
  13578. * ===================
  13579. *
  13580. * ITMAX is the maximum number of steps of iterative refinement.
  13581. *
  13582. * =====================================================================
  13583. *
  13584. * .. Parameters ..
  13585. **/
  13586. int C_DSPRFS(char uplo, int n, int nrhs, double* ap, double* afp, int* ipiv, double* b, int ldb, double* x, int ldx, double* ferr, double* berr, double* work, int* iwork)
  13587. {
  13588. int info;
  13589. ::F_DSPRFS(&uplo, &n, &nrhs, ap, afp, ipiv, b, &ldb, x, &ldx, ferr, berr, work, iwork, &info);
  13590. return info;
  13591. }
  13592. /**
  13593. * Purpose
  13594. * =======
  13595. *
  13596. * DSPSV computes the solution to a real system of linear equations
  13597. * A * X = B,
  13598. * where A is an N-by-N symmetric matrix stored in packed format and X
  13599. * and B are N-by-NRHS matrices.
  13600. *
  13601. * The diagonal pivoting method is used to factor A as
  13602. * A = U * D * U**T, if UPLO = 'U', or
  13603. * A = L * D * L**T, if UPLO = 'L',
  13604. * where U (or L) is a product of permutation and unit upper (lower)
  13605. * triangular matrices, D is symmetric and block diagonal with 1-by-1
  13606. * and 2-by-2 diagonal blocks. The factored form of A is then used to
  13607. * solve the system of equations A * X = B.
  13608. *
  13609. * Arguments
  13610. * =========
  13611. *
  13612. * UPLO (input) CHARACTER*1
  13613. * = 'U': Upper triangle of A is stored;
  13614. * = 'L': Lower triangle of A is stored.
  13615. *
  13616. * N (input) INTEGER
  13617. * The number of linear equations, i.e., the order of the
  13618. * matrix A. N >= 0.
  13619. *
  13620. * NRHS (input) INTEGER
  13621. * The number of right hand sides, i.e., the number of columns
  13622. * of the matrix B. NRHS >= 0.
  13623. *
  13624. * AP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2)
  13625. * On entry, the upper or lower triangle of the symmetric matrix
  13626. * A, packed columnwise in a linear array. The j-th column of A
  13627. * is stored in the array AP as follows:
  13628. * if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
  13629. * if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n.
  13630. * See below for further details.
  13631. *
  13632. * On exit, the block diagonal matrix D and the multipliers used
  13633. * to obtain the factor U or L from the factorization
  13634. * A = U*D*U**T or A = L*D*L**T as computed by DSPTRF, stored as
  13635. * a packed triangular matrix in the same storage format as A.
  13636. *
  13637. * IPIV (output) INTEGER array, dimension (N)
  13638. * Details of the interchanges and the block structure of D, as
  13639. * determined by DSPTRF. If IPIV(k) > 0, then rows and columns
  13640. * k and IPIV(k) were interchanged, and D(k,k) is a 1-by-1
  13641. * diagonal block. If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0,
  13642. * then rows and columns k-1 and -IPIV(k) were interchanged and
  13643. * D(k-1:k,k-1:k) is a 2-by-2 diagonal block. If UPLO = 'L' and
  13644. * IPIV(k) = IPIV(k+1) < 0, then rows and columns k+1 and
  13645. * -IPIV(k) were interchanged and D(k:k+1,k:k+1) is a 2-by-2
  13646. * diagonal block.
  13647. *
  13648. * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
  13649. * On entry, the N-by-NRHS right hand side matrix B.
  13650. * On exit, if INFO = 0, the N-by-NRHS solution matrix X.
  13651. *
  13652. * LDB (input) INTEGER
  13653. * The leading dimension of the array B. LDB >= max(1,N).
  13654. *
  13655. * C++ Return value: INFO (output) INTEGER
  13656. * = 0: successful exit
  13657. * < 0: if INFO = -i, the i-th argument had an illegal value
  13658. * > 0: if INFO = i, D(i,i) is exactly zero. The factorization
  13659. * has been completed, but the block diagonal matrix D is
  13660. * exactly singular, so the solution could not be
  13661. * computed.
  13662. *
  13663. * Further Details
  13664. * ===============
  13665. *
  13666. * The packed storage scheme is illustrated by the following example
  13667. * when N = 4, UPLO = 'U':
  13668. *
  13669. * Two-dimensional storage of the symmetric matrix A:
  13670. *
  13671. * a11 a12 a13 a14
  13672. * a22 a23 a24
  13673. * a33 a34 (aij = aji)
  13674. * a44
  13675. *
  13676. * Packed storage of the upper triangle of A:
  13677. *
  13678. * AP = [ a11, a12, a22, a13, a23, a33, a14, a24, a34, a44 ]
  13679. *
  13680. * =====================================================================
  13681. *
  13682. * .. External Functions ..
  13683. **/
  13684. int C_DSPSV(char uplo, int n, int nrhs, double* ap, int* ipiv, double* b, int ldb)
  13685. {
  13686. int info;
  13687. ::F_DSPSV(&uplo, &n, &nrhs, ap, ipiv, b, &ldb, &info);
  13688. return info;
  13689. }
  13690. /**
  13691. * Purpose
  13692. * =======
  13693. *
  13694. * DSPSVX uses the diagonal pivoting factorization A = U*D*U**T or
  13695. * A = L*D*L**T to compute the solution to a real system of linear
  13696. * equations A * X = B, where A is an N-by-N symmetric matrix stored
  13697. * in packed format and X and B are N-by-NRHS matrices.
  13698. *
  13699. * Error bounds on the solution and a condition estimate are also
  13700. * provided.
  13701. *
  13702. * Description
  13703. * ===========
  13704. *
  13705. * The following steps are performed:
  13706. *
  13707. * 1. If FACT = 'N', the diagonal pivoting method is used to factor A as
  13708. * A = U * D * U**T, if UPLO = 'U', or
  13709. * A = L * D * L**T, if UPLO = 'L',
  13710. * where U (or L) is a product of permutation and unit upper (lower)
  13711. * triangular matrices and D is symmetric and block diagonal with
  13712. * 1-by-1 and 2-by-2 diagonal blocks.
  13713. *
  13714. * 2. If some D(i,i)=0, so that D is exactly singular, then the routine
  13715. * returns with INFO = i. Otherwise, the factored form of A is used
  13716. * to estimate the condition number of the matrix A. If the
  13717. * reciprocal of the condition number is less than machine precision,
  13718. * C++ Return value: INFO (output) INTEGER
  13719. * to solve for X and compute error bounds as described below.
  13720. *
  13721. * 3. The system of equations is solved for X using the factored form
  13722. * of A.
  13723. *
  13724. * 4. Iterative refinement is applied to improve the computed solution
  13725. * matrix and calculate error bounds and backward error estimates
  13726. * for it.
  13727. *
  13728. * Arguments
  13729. * =========
  13730. *
  13731. * FACT (input) CHARACTER*1
  13732. * Specifies whether or not the factored form of A has been
  13733. * supplied on entry.
  13734. * = 'F': On entry, AFP and IPIV contain the factored form of
  13735. * A. AP, AFP and IPIV will not be modified.
  13736. * = 'N': The matrix A will be copied to AFP and factored.
  13737. *
  13738. * UPLO (input) CHARACTER*1
  13739. * = 'U': Upper triangle of A is stored;
  13740. * = 'L': Lower triangle of A is stored.
  13741. *
  13742. * N (input) INTEGER
  13743. * The number of linear equations, i.e., the order of the
  13744. * matrix A. N >= 0.
  13745. *
  13746. * NRHS (input) INTEGER
  13747. * The number of right hand sides, i.e., the number of columns
  13748. * of the matrices B and X. NRHS >= 0.
  13749. *
  13750. * AP (input) DOUBLE PRECISION array, dimension (N*(N+1)/2)
  13751. * The upper or lower triangle of the symmetric matrix A, packed
  13752. * columnwise in a linear array. The j-th column of A is stored
  13753. * in the array AP as follows:
  13754. * if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
  13755. * if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n.
  13756. * See below for further details.
  13757. *
  13758. * AFP (input or output) DOUBLE PRECISION array, dimension
  13759. * (N*(N+1)/2)
  13760. * If FACT = 'F', then AFP is an input argument and on entry
  13761. * contains the block diagonal matrix D and the multipliers used
  13762. * to obtain the factor U or L from the factorization
  13763. * A = U*D*U**T or A = L*D*L**T as computed by DSPTRF, stored as
  13764. * a packed triangular matrix in the same storage format as A.
  13765. *
  13766. * If FACT = 'N', then AFP is an output argument and on exit
  13767. * contains the block diagonal matrix D and the multipliers used
  13768. * to obtain the factor U or L from the factorization
  13769. * A = U*D*U**T or A = L*D*L**T as computed by DSPTRF, stored as
  13770. * a packed triangular matrix in the same storage format as A.
  13771. *
  13772. * IPIV (input or output) INTEGER array, dimension (N)
  13773. * If FACT = 'F', then IPIV is an input argument and on entry
  13774. * contains details of the interchanges and the block structure
  13775. * of D, as determined by DSPTRF.
  13776. * If IPIV(k) > 0, then rows and columns k and IPIV(k) were
  13777. * interchanged and D(k,k) is a 1-by-1 diagonal block.
  13778. * If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0, then rows and
  13779. * columns k-1 and -IPIV(k) were interchanged and D(k-1:k,k-1:k)
  13780. * is a 2-by-2 diagonal block. If UPLO = 'L' and IPIV(k) =
  13781. * IPIV(k+1) < 0, then rows and columns k+1 and -IPIV(k) were
  13782. * interchanged and D(k:k+1,k:k+1) is a 2-by-2 diagonal block.
  13783. *
  13784. * If FACT = 'N', then IPIV is an output argument and on exit
  13785. * contains details of the interchanges and the block structure
  13786. * of D, as determined by DSPTRF.
  13787. *
  13788. * B (input) DOUBLE PRECISION array, dimension (LDB,NRHS)
  13789. * The N-by-NRHS right hand side matrix B.
  13790. *
  13791. * LDB (input) INTEGER
  13792. * The leading dimension of the array B. LDB >= max(1,N).
  13793. *
  13794. * X (output) DOUBLE PRECISION array, dimension (LDX,NRHS)
  13795. * If INFO = 0 or INFO = N+1, the N-by-NRHS solution matrix X.
  13796. *
  13797. * LDX (input) INTEGER
  13798. * The leading dimension of the array X. LDX >= max(1,N).
  13799. *
  13800. * RCOND (output) DOUBLE PRECISION
  13801. * The estimate of the reciprocal condition number of the matrix
  13802. * A. If RCOND is less than the machine precision (in
  13803. * particular, if RCOND = 0), the matrix is singular to working
  13804. * precision. This condition is indicated by a return code of
  13805. * C++ Return value: INFO (output) INTEGER
  13806. *
  13807. * FERR (output) DOUBLE PRECISION array, dimension (NRHS)
  13808. * The estimated forward error bound for each solution vector
  13809. * X(j) (the j-th column of the solution matrix X).
  13810. * If XTRUE is the true solution corresponding to X(j), FERR(j)
  13811. * is an estimated upper bound for the magnitude of the largest
  13812. * element in (X(j) - XTRUE) divided by the magnitude of the
  13813. * largest element in X(j). The estimate is as reliable as
  13814. * the estimate for RCOND, and is almost always a slight
  13815. * overestimate of the true error.
  13816. *
  13817. * BERR (output) DOUBLE PRECISION array, dimension (NRHS)
  13818. * The componentwise relative backward error of each solution
  13819. * vector X(j) (i.e., the smallest relative change in
  13820. * any element of A or B that makes X(j) an exact solution).
  13821. *
  13822. * WORK (workspace) DOUBLE PRECISION array, dimension (3*N)
  13823. *
  13824. * IWORK (workspace) INTEGER array, dimension (N)
  13825. *
  13826. * C++ Return value: INFO (output) INTEGER
  13827. * = 0: successful exit
  13828. * < 0: if INFO = -i, the i-th argument had an illegal value
  13829. * > 0: if INFO = i, and i is
  13830. * <= N: D(i,i) is exactly zero. The factorization
  13831. * has been completed but the factor D is exactly
  13832. * singular, so the solution and error bounds could
  13833. * not be computed. RCOND = 0 is returned.
  13834. * = N+1: D is nonsingular, but RCOND is less than machine
  13835. * precision, meaning that the matrix is singular
  13836. * to working precision. Nevertheless, the
  13837. * solution and error bounds are computed because
  13838. * there are a number of situations where the
  13839. * computed solution can be more accurate than the
  13840. * value of RCOND would suggest.
  13841. *
  13842. * Further Details
  13843. * ===============
  13844. *
  13845. * The packed storage scheme is illustrated by the following example
  13846. * when N = 4, UPLO = 'U':
  13847. *
  13848. * Two-dimensional storage of the symmetric matrix A:
  13849. *
  13850. * a11 a12 a13 a14
  13851. * a22 a23 a24
  13852. * a33 a34 (aij = aji)
  13853. * a44
  13854. *
  13855. * Packed storage of the upper triangle of A:
  13856. *
  13857. * AP = [ a11, a12, a22, a13, a23, a33, a14, a24, a34, a44 ]
  13858. *
  13859. * =====================================================================
  13860. *
  13861. * .. Parameters ..
  13862. **/
  13863. int C_DSPSVX(char fact, char uplo, int n, int nrhs, double* ap, double* afp, int* ipiv, double* b, int ldb, double* x, int ldx, double* rcond)
  13864. {
  13865. int info;
  13866. ::F_DSPSVX(&fact, &uplo, &n, &nrhs, ap, afp, ipiv, b, &ldb, x, &ldx, rcond, &info);
  13867. return info;
  13868. }
  13869. /**
  13870. * Purpose
  13871. * =======
  13872. *
  13873. * DSPTRD reduces a real symmetric matrix A stored in packed form to
  13874. * symmetric tridiagonal form T by an orthogonal similarity
  13875. * transformation: Q**T * A * Q = T.
  13876. *
  13877. * Arguments
  13878. * =========
  13879. *
  13880. * UPLO (input) CHARACTER*1
  13881. * = 'U': Upper triangle of A is stored;
  13882. * = 'L': Lower triangle of A is stored.
  13883. *
  13884. * N (input) INTEGER
  13885. * The order of the matrix A. N >= 0.
  13886. *
  13887. * AP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2)
  13888. * On entry, the upper or lower triangle of the symmetric matrix
  13889. * A, packed columnwise in a linear array. The j-th column of A
  13890. * is stored in the array AP as follows:
  13891. * if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
  13892. * if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n.
  13893. * On exit, if UPLO = 'U', the diagonal and first superdiagonal
  13894. * of A are overwritten by the corresponding elements of the
  13895. * tridiagonal matrix T, and the elements above the first
  13896. * superdiagonal, with the array TAU, represent the orthogonal
  13897. * matrix Q as a product of elementary reflectors; if UPLO
  13898. * = 'L', the diagonal and first subdiagonal of A are over-
  13899. * written by the corresponding elements of the tridiagonal
  13900. * matrix T, and the elements below the first subdiagonal, with
  13901. * the array TAU, represent the orthogonal matrix Q as a product
  13902. * of elementary reflectors. See Further Details.
  13903. *
  13904. * D (output) DOUBLE PRECISION array, dimension (N)
  13905. * The diagonal elements of the tridiagonal matrix T:
  13906. * D(i) = A(i,i).
  13907. *
  13908. * E (output) DOUBLE PRECISION array, dimension (N-1)
  13909. * The off-diagonal elements of the tridiagonal matrix T:
  13910. * E(i) = A(i,i+1) if UPLO = 'U', E(i) = A(i+1,i) if UPLO = 'L'.
  13911. *
  13912. * TAU (output) DOUBLE PRECISION array, dimension (N-1)
  13913. * The scalar factors of the elementary reflectors (see Further
  13914. * Details).
  13915. *
  13916. * C++ Return value: INFO (output) INTEGER
  13917. * = 0: successful exit
  13918. * < 0: if INFO = -i, the i-th argument had an illegal value
  13919. *
  13920. * Further Details
  13921. * ===============
  13922. *
  13923. * If UPLO = 'U', the matrix Q is represented as a product of elementary
  13924. * reflectors
  13925. *
  13926. * Q = H(n-1) . . . H(2) H(1).
  13927. *
  13928. * Each H(i) has the form
  13929. *
  13930. * H(i) = I - tau * v * v'
  13931. *
  13932. * where tau is a real scalar, and v is a real vector with
  13933. * v(i+1:n) = 0 and v(i) = 1; v(1:i-1) is stored on exit in AP,
  13934. * overwriting A(1:i-1,i+1), and tau is stored in TAU(i).
  13935. *
  13936. * If UPLO = 'L', the matrix Q is represented as a product of elementary
  13937. * reflectors
  13938. *
  13939. * Q = H(1) H(2) . . . H(n-1).
  13940. *
  13941. * Each H(i) has the form
  13942. *
  13943. * H(i) = I - tau * v * v'
  13944. *
  13945. * where tau is a real scalar, and v is a real vector with
  13946. * v(1:i) = 0 and v(i+1) = 1; v(i+2:n) is stored on exit in AP,
  13947. * overwriting A(i+2:n,i), and tau is stored in TAU(i).
  13948. *
  13949. * =====================================================================
  13950. *
  13951. * .. Parameters ..
  13952. **/
  13953. int C_DSPTRD(char uplo, int n, double* ap, double* d, double* e, double* tau)
  13954. {
  13955. int info;
  13956. ::F_DSPTRD(&uplo, &n, ap, d, e, tau, &info);
  13957. return info;
  13958. }
  13959. /**
  13960. * Purpose
  13961. * =======
  13962. *
  13963. * DSPTRF computes the factorization of a real symmetric matrix A stored
  13964. * in packed format using the Bunch-Kaufman diagonal pivoting method:
  13965. *
  13966. * A = U*D*U**T or A = L*D*L**T
  13967. *
  13968. * where U (or L) is a product of permutation and unit upper (lower)
  13969. * triangular matrices, and D is symmetric and block diagonal with
  13970. * 1-by-1 and 2-by-2 diagonal blocks.
  13971. *
  13972. * Arguments
  13973. * =========
  13974. *
  13975. * UPLO (input) CHARACTER*1
  13976. * = 'U': Upper triangle of A is stored;
  13977. * = 'L': Lower triangle of A is stored.
  13978. *
  13979. * N (input) INTEGER
  13980. * The order of the matrix A. N >= 0.
  13981. *
  13982. * AP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2)
  13983. * On entry, the upper or lower triangle of the symmetric matrix
  13984. * A, packed columnwise in a linear array. The j-th column of A
  13985. * is stored in the array AP as follows:
  13986. * if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
  13987. * if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n.
  13988. *
  13989. * On exit, the block diagonal matrix D and the multipliers used
  13990. * to obtain the factor U or L, stored as a packed triangular
  13991. * matrix overwriting A (see below for further details).
  13992. *
  13993. * IPIV (output) INTEGER array, dimension (N)
  13994. * Details of the interchanges and the block structure of D.
  13995. * If IPIV(k) > 0, then rows and columns k and IPIV(k) were
  13996. * interchanged and D(k,k) is a 1-by-1 diagonal block.
  13997. * If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0, then rows and
  13998. * columns k-1 and -IPIV(k) were interchanged and D(k-1:k,k-1:k)
  13999. * is a 2-by-2 diagonal block. If UPLO = 'L' and IPIV(k) =
  14000. * IPIV(k+1) < 0, then rows and columns k+1 and -IPIV(k) were
  14001. * interchanged and D(k:k+1,k:k+1) is a 2-by-2 diagonal block.
  14002. *
  14003. * C++ Return value: INFO (output) INTEGER
  14004. * = 0: successful exit
  14005. * < 0: if INFO = -i, the i-th argument had an illegal value
  14006. * > 0: if INFO = i, D(i,i) is exactly zero. The factorization
  14007. * has been completed, but the block diagonal matrix D is
  14008. * exactly singular, and division by zero will occur if it
  14009. * is used to solve a system of equations.
  14010. *
  14011. * Further Details
  14012. * ===============
  14013. *
  14014. * 5-96 - Based on modifications by J. Lewis, Boeing Computer Services
  14015. * Company
  14016. *
  14017. * If UPLO = 'U', then A = U*D*U', where
  14018. * U = P(n)*U(n)* ... *P(k)U(k)* ...,
  14019. * i.e., U is a product of terms P(k)*U(k), where k decreases from n to
  14020. * 1 in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1
  14021. * and 2-by-2 diagonal blocks D(k). P(k) is a permutation matrix as
  14022. * defined by IPIV(k), and U(k) is a unit upper triangular matrix, such
  14023. * that if the diagonal block D(k) is of order s (s = 1 or 2), then
  14024. *
  14025. * ( I v 0 ) k-s
  14026. * U(k) = ( 0 I 0 ) s
  14027. * ( 0 0 I ) n-k
  14028. * k-s s n-k
  14029. *
  14030. * If s = 1, D(k) overwrites A(k,k), and v overwrites A(1:k-1,k).
  14031. * If s = 2, the upper triangle of D(k) overwrites A(k-1,k-1), A(k-1,k),
  14032. * and A(k,k), and v overwrites A(1:k-2,k-1:k).
  14033. *
  14034. * If UPLO = 'L', then A = L*D*L', where
  14035. * L = P(1)*L(1)* ... *P(k)*L(k)* ...,
  14036. * i.e., L is a product of terms P(k)*L(k), where k increases from 1 to
  14037. * n in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1
  14038. * and 2-by-2 diagonal blocks D(k). P(k) is a permutation matrix as
  14039. * defined by IPIV(k), and L(k) is a unit lower triangular matrix, such
  14040. * that if the diagonal block D(k) is of order s (s = 1 or 2), then
  14041. *
  14042. * ( I 0 0 ) k-1
  14043. * L(k) = ( 0 I 0 ) s
  14044. * ( 0 v I ) n-k-s+1
  14045. * k-1 s n-k-s+1
  14046. *
  14047. * If s = 1, D(k) overwrites A(k,k), and v overwrites A(k+1:n,k).
  14048. * If s = 2, the lower triangle of D(k) overwrites A(k,k), A(k+1,k),
  14049. * and A(k+1,k+1), and v overwrites A(k+2:n,k:k+1).
  14050. *
  14051. * =====================================================================
  14052. *
  14053. * .. Parameters ..
  14054. **/
  14055. int C_DSPTRF(char uplo, int n, double* ap, int* ipiv)
  14056. {
  14057. int info;
  14058. ::F_DSPTRF(&uplo, &n, ap, ipiv, &info);
  14059. return info;
  14060. }
  14061. /**
  14062. * Purpose
  14063. * =======
  14064. *
  14065. * DSPTRI computes the inverse of a real symmetric indefinite matrix
  14066. * A in packed storage using the factorization A = U*D*U**T or
  14067. * A = L*D*L**T computed by DSPTRF.
  14068. *
  14069. * Arguments
  14070. * =========
  14071. *
  14072. * UPLO (input) CHARACTER*1
  14073. * Specifies whether the details of the factorization are stored
  14074. * as an upper or lower triangular matrix.
  14075. * = 'U': Upper triangular, form is A = U*D*U**T;
  14076. * = 'L': Lower triangular, form is A = L*D*L**T.
  14077. *
  14078. * N (input) INTEGER
  14079. * The order of the matrix A. N >= 0.
  14080. *
  14081. * AP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2)
  14082. * On entry, the block diagonal matrix D and the multipliers
  14083. * used to obtain the factor U or L as computed by DSPTRF,
  14084. * stored as a packed triangular matrix.
  14085. *
  14086. * On exit, if INFO = 0, the (symmetric) inverse of the original
  14087. * matrix, stored as a packed triangular matrix. The j-th column
  14088. * of inv(A) is stored in the array AP as follows:
  14089. * if UPLO = 'U', AP(i + (j-1)*j/2) = inv(A)(i,j) for 1<=i<=j;
  14090. * if UPLO = 'L',
  14091. * AP(i + (j-1)*(2n-j)/2) = inv(A)(i,j) for j<=i<=n.
  14092. *
  14093. * IPIV (input) INTEGER array, dimension (N)
  14094. * Details of the interchanges and the block structure of D
  14095. * as determined by DSPTRF.
  14096. *
  14097. * WORK (workspace) DOUBLE PRECISION array, dimension (N)
  14098. *
  14099. * C++ Return value: INFO (output) INTEGER
  14100. * = 0: successful exit
  14101. * < 0: if INFO = -i, the i-th argument had an illegal value
  14102. * > 0: if INFO = i, D(i,i) = 0; the matrix is singular and its
  14103. * inverse could not be computed.
  14104. *
  14105. * =====================================================================
  14106. *
  14107. * .. Parameters ..
  14108. **/
  14109. int C_DSPTRI(char uplo, int n, double* ap, int* ipiv, double* work)
  14110. {
  14111. int info;
  14112. ::F_DSPTRI(&uplo, &n, ap, ipiv, work, &info);
  14113. return info;
  14114. }
  14115. /**
  14116. * Purpose
  14117. * =======
  14118. *
  14119. * DSPTRS solves a system of linear equations A*X = B with a real
  14120. * symmetric matrix A stored in packed format using the factorization
  14121. * A = U*D*U**T or A = L*D*L**T computed by DSPTRF.
  14122. *
  14123. * Arguments
  14124. * =========
  14125. *
  14126. * UPLO (input) CHARACTER*1
  14127. * Specifies whether the details of the factorization are stored
  14128. * as an upper or lower triangular matrix.
  14129. * = 'U': Upper triangular, form is A = U*D*U**T;
  14130. * = 'L': Lower triangular, form is A = L*D*L**T.
  14131. *
  14132. * N (input) INTEGER
  14133. * The order of the matrix A. N >= 0.
  14134. *
  14135. * NRHS (input) INTEGER
  14136. * The number of right hand sides, i.e., the number of columns
  14137. * of the matrix B. NRHS >= 0.
  14138. *
  14139. * AP (input) DOUBLE PRECISION array, dimension (N*(N+1)/2)
  14140. * The block diagonal matrix D and the multipliers used to
  14141. * obtain the factor U or L as computed by DSPTRF, stored as a
  14142. * packed triangular matrix.
  14143. *
  14144. * IPIV (input) INTEGER array, dimension (N)
  14145. * Details of the interchanges and the block structure of D
  14146. * as determined by DSPTRF.
  14147. *
  14148. * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
  14149. * On entry, the right hand side matrix B.
  14150. * On exit, the solution matrix X.
  14151. *
  14152. * LDB (input) INTEGER
  14153. * The leading dimension of the array B. LDB >= max(1,N).
  14154. *
  14155. * C++ Return value: INFO (output) INTEGER
  14156. * = 0: successful exit
  14157. * < 0: if INFO = -i, the i-th argument had an illegal value
  14158. *
  14159. * =====================================================================
  14160. *
  14161. * .. Parameters ..
  14162. **/
  14163. int C_DSPTRS(char uplo, int n, int nrhs, double* ap, int* ipiv, double* b, int ldb)
  14164. {
  14165. int info;
  14166. ::F_DSPTRS(&uplo, &n, &nrhs, ap, ipiv, b, &ldb, &info);
  14167. return info;
  14168. }
  14169. /**
  14170. * Purpose
  14171. * =======
  14172. *
  14173. * DSTEBZ computes the eigenvalues of a symmetric tridiagonal
  14174. * matrix T. The user may ask for all eigenvalues, all eigenvalues
  14175. * in the half-open interval (VL, VU], or the IL-th through IU-th
  14176. * eigenvalues.
  14177. *
  14178. * To avoid overflow, the matrix must be scaled so that its
  14179. * largest element is no greater than overflow**(1/2) *
  14180. * underflow**(1/4) in absolute value, and for greatest
  14181. * accuracy, it should not be much smaller than that.
  14182. *
  14183. * See W. Kahan "Accurate Eigenvalues of a Symmetric Tridiagonal
  14184. * Matrix", Report CS41, Computer Science Dept., Stanford
  14185. * University, July 21, 1966.
  14186. *
  14187. * Arguments
  14188. * =========
  14189. *
  14190. * RANGE (input) CHARACTER*1
  14191. * = 'A': ("All") all eigenvalues will be found.
  14192. * = 'V': ("Value") all eigenvalues in the half-open interval
  14193. * (VL, VU] will be found.
  14194. * = 'I': ("Index") the IL-th through IU-th eigenvalues (of the
  14195. * entire matrix) will be found.
  14196. *
  14197. * ORDER (input) CHARACTER*1
  14198. * = 'B': ("By Block") the eigenvalues will be grouped by
  14199. * split-off block (see IBLOCK, ISPLIT) and
  14200. * ordered from smallest to largest within
  14201. * the block.
  14202. * = 'E': ("Entire matrix")
  14203. * the eigenvalues for the entire matrix
  14204. * will be ordered from smallest to
  14205. * largest.
  14206. *
  14207. * N (input) INTEGER
  14208. * The order of the tridiagonal matrix T. N >= 0.
  14209. *
  14210. * VL (input) DOUBLE PRECISION
  14211. * VU (input) DOUBLE PRECISION
  14212. * If RANGE='V', the lower and upper bounds of the interval to
  14213. * be searched for eigenvalues. Eigenvalues less than or equal
  14214. * to VL, or greater than VU, will not be returned. VL < VU.
  14215. * Not referenced if RANGE = 'A' or 'I'.
  14216. *
  14217. * IL (input) INTEGER
  14218. * IU (input) INTEGER
  14219. * If RANGE='I', the indices (in ascending order) of the
  14220. * smallest and largest eigenvalues to be returned.
  14221. * 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
  14222. * Not referenced if RANGE = 'A' or 'V'.
  14223. *
  14224. * ABSTOL (input) DOUBLE PRECISION
  14225. * The absolute tolerance for the eigenvalues. An eigenvalue
  14226. * (or cluster) is considered to be located if it has been
  14227. * determined to lie in an interval whose width is ABSTOL or
  14228. * less. If ABSTOL is less than or equal to zero, then ULP*|T|
  14229. * will be used, where |T| means the 1-norm of T.
  14230. *
  14231. * Eigenvalues will be computed most accurately when ABSTOL is
  14232. * set to twice the underflow threshold 2*DLAMCH('S'), not zero.
  14233. *
  14234. * D (input) DOUBLE PRECISION array, dimension (N)
  14235. * The n diagonal elements of the tridiagonal matrix T.
  14236. *
  14237. * E (input) DOUBLE PRECISION array, dimension (N-1)
  14238. * The (n-1) off-diagonal elements of the tridiagonal matrix T.
  14239. *
  14240. * M (output) INTEGER
  14241. * The actual number of eigenvalues found. 0 <= M <= N.
  14242. * (See also the description of INFO=2,3.)
  14243. *
  14244. * NSPLIT (output) INTEGER
  14245. * The number of diagonal blocks in the matrix T.
  14246. * 1 <= NSPLIT <= N.
  14247. *
  14248. * W (output) DOUBLE PRECISION array, dimension (N)
  14249. * On exit, the first M elements of W will contain the
  14250. * eigenvalues. (DSTEBZ may use the remaining N-M elements as
  14251. * workspace.)
  14252. *
  14253. * IBLOCK (output) INTEGER array, dimension (N)
  14254. * At each row/column j where E(j) is zero or small, the
  14255. * matrix T is considered to split into a block diagonal
  14256. * matrix. On exit, if INFO = 0, IBLOCK(i) specifies to which
  14257. * block (from 1 to the number of blocks) the eigenvalue W(i)
  14258. * belongs. (DSTEBZ may use the remaining N-M elements as
  14259. * workspace.)
  14260. *
  14261. * ISPLIT (output) INTEGER array, dimension (N)
  14262. * The splitting points, at which T breaks up into submatrices.
  14263. * The first submatrix consists of rows/columns 1 to ISPLIT(1),
  14264. * the second of rows/columns ISPLIT(1)+1 through ISPLIT(2),
  14265. * etc., and the NSPLIT-th consists of rows/columns
  14266. * ISPLIT(NSPLIT-1)+1 through ISPLIT(NSPLIT)=N.
  14267. * (Only the first NSPLIT elements will actually be used, but
  14268. * since the user cannot know a priori what value NSPLIT will
  14269. * have, N words must be reserved for ISPLIT.)
  14270. *
  14271. * WORK (workspace) DOUBLE PRECISION array, dimension (4*N)
  14272. *
  14273. * IWORK (workspace) INTEGER array, dimension (3*N)
  14274. *
  14275. * C++ Return value: INFO (output) INTEGER
  14276. * = 0: successful exit
  14277. * < 0: if INFO = -i, the i-th argument had an illegal value
  14278. * > 0: some or all of the eigenvalues failed to converge or
  14279. * were not computed:
  14280. * =1 or 3: Bisection failed to converge for some
  14281. * eigenvalues; these eigenvalues are flagged by a
  14282. * negative block number. The effect is that the
  14283. * eigenvalues may not be as accurate as the
  14284. * absolute and relative tolerances. This is
  14285. * generally caused by unexpectedly inaccurate
  14286. * arithmetic.
  14287. * =2 or 3: RANGE='I' only: Not all of the eigenvalues
  14288. * IL:IU were found.
  14289. * Effect: M < IU+1-IL
  14290. * Cause: non-monotonic arithmetic, causing the
  14291. * Sturm sequence to be non-monotonic.
  14292. * Cure: recalculate, using RANGE='A', and pick
  14293. * out eigenvalues IL:IU. In some cases,
  14294. * increasing the PARAMETER "FUDGE" may
  14295. * make things work.
  14296. * = 4: RANGE='I', and the Gershgorin interval
  14297. * initially used was too small. No eigenvalues
  14298. * were computed.
  14299. * Probable cause: your machine has sloppy
  14300. * floating-point arithmetic.
  14301. * Cure: Increase the PARAMETER "FUDGE",
  14302. * recompile, and try again.
  14303. *
  14304. * Internal Parameters
  14305. * ===================
  14306. *
  14307. * RELFAC DOUBLE PRECISION, default = 2.0e0
  14308. * The relative tolerance. An interval (a,b] lies within
  14309. * "relative tolerance" if b-a < RELFAC*ulp*max(|a|,|b|),
  14310. * where "ulp" is the machine precision (distance from 1 to
  14311. * the next larger floating point number.)
  14312. *
  14313. * FUDGE DOUBLE PRECISION, default = 2
  14314. * A "fudge factor" to widen the Gershgorin intervals. Ideally,
  14315. * a value of 1 should work, but on machines with sloppy
  14316. * arithmetic, this needs to be larger. The default for
  14317. * publicly released versions should be large enough to handle
  14318. * the worst machine around. Note that this has no effect
  14319. * on accuracy of the solution.
  14320. *
  14321. * =====================================================================
  14322. *
  14323. * .. Parameters ..
  14324. **/
  14325. int C_DSTEBZ(char range, char order, int n, double vl, double vu, int il, int iu, double abstol, double* d, double* e, int* m, int* nsplit, double* w, int* iblock, int* isplit, double* work, int* iwork)
  14326. {
  14327. int info;
  14328. ::F_DSTEBZ(&range, &order, &n, &vl, &vu, &il, &iu, &abstol, d, e, m, nsplit, w, iblock, isplit, work, iwork, &info);
  14329. return info;
  14330. }
  14331. /**
  14332. * Purpose
  14333. * =======
  14334. *
  14335. * DSTEDC computes all eigenvalues and, optionally, eigenvectors of a
  14336. * symmetric tridiagonal matrix using the divide and conquer method.
  14337. * The eigenvectors of a full or band real symmetric matrix can also be
  14338. * found if DSYTRD or DSPTRD or DSBTRD has been used to reduce this
  14339. * matrix to tridiagonal form.
  14340. *
  14341. * This code makes very mild assumptions about floating point
  14342. * arithmetic. It will work on machines with a guard digit in
  14343. * add/subtract, or on those binary machines without guard digits
  14344. * which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or Cray-2.
  14345. * It could conceivably fail on hexadecimal or decimal machines
  14346. * without guard digits, but we know of none. See DLAED3 for details.
  14347. *
  14348. * Arguments
  14349. * =========
  14350. *
  14351. * COMPZ (input) CHARACTER*1
  14352. * = 'N': Compute eigenvalues only.
  14353. * = 'I': Compute eigenvectors of tridiagonal matrix also.
  14354. * = 'V': Compute eigenvectors of original dense symmetric
  14355. * matrix also. On entry, Z contains the orthogonal
  14356. * matrix used to reduce the original matrix to
  14357. * tridiagonal form.
  14358. *
  14359. * N (input) INTEGER
  14360. * The dimension of the symmetric tridiagonal matrix. N >= 0.
  14361. *
  14362. * D (input/output) DOUBLE PRECISION array, dimension (N)
  14363. * On entry, the diagonal elements of the tridiagonal matrix.
  14364. * On exit, if INFO = 0, the eigenvalues in ascending order.
  14365. *
  14366. * E (input/output) DOUBLE PRECISION array, dimension (N-1)
  14367. * On entry, the subdiagonal elements of the tridiagonal matrix.
  14368. * On exit, E has been destroyed.
  14369. *
  14370. * Z (input/output) DOUBLE PRECISION array, dimension (LDZ,N)
  14371. * On entry, if COMPZ = 'V', then Z contains the orthogonal
  14372. * matrix used in the reduction to tridiagonal form.
  14373. * On exit, if INFO = 0, then if COMPZ = 'V', Z contains the
  14374. * orthonormal eigenvectors of the original symmetric matrix,
  14375. * and if COMPZ = 'I', Z contains the orthonormal eigenvectors
  14376. * of the symmetric tridiagonal matrix.
  14377. * If COMPZ = 'N', then Z is not referenced.
  14378. *
  14379. * LDZ (input) INTEGER
  14380. * The leading dimension of the array Z. LDZ >= 1.
  14381. * If eigenvectors are desired, then LDZ >= max(1,N).
  14382. *
  14383. * WORK (workspace/output) DOUBLE PRECISION array,
  14384. * dimension (LWORK)
  14385. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  14386. *
  14387. * LWORK (input) INTEGER
  14388. * The dimension of the array WORK.
  14389. * If COMPZ = 'N' or N <= 1 then LWORK must be at least 1.
  14390. * If COMPZ = 'V' and N > 1 then LWORK must be at least
  14391. * ( 1 + 3*N + 2*N*lg N + 3*N**2 ),
  14392. * where lg( N ) = smallest integer k such
  14393. * that 2**k >= N.
  14394. * If COMPZ = 'I' and N > 1 then LWORK must be at least
  14395. * ( 1 + 4*N + N**2 ).
  14396. * Note that for COMPZ = 'I' or 'V', then if N is less than or
  14397. * equal to the minimum divide size, usually 25, then LWORK need
  14398. * only be max(1,2*(N-1)).
  14399. *
  14400. * If LWORK = -1, then a workspace query is assumed; the routine
  14401. * only calculates the optimal size of the WORK array, returns
  14402. * this value as the first entry of the WORK array, and no error
  14403. * message related to LWORK is issued by XERBLA.
  14404. *
  14405. * IWORK (workspace/output) INTEGER array, dimension (MAX(1,LIWORK))
  14406. * On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK.
  14407. *
  14408. * LIWORK (input) INTEGER
  14409. * The dimension of the array IWORK.
  14410. * If COMPZ = 'N' or N <= 1 then LIWORK must be at least 1.
  14411. * If COMPZ = 'V' and N > 1 then LIWORK must be at least
  14412. * ( 6 + 6*N + 5*N*lg N ).
  14413. * If COMPZ = 'I' and N > 1 then LIWORK must be at least
  14414. * ( 3 + 5*N ).
  14415. * Note that for COMPZ = 'I' or 'V', then if N is less than or
  14416. * equal to the minimum divide size, usually 25, then LIWORK
  14417. * need only be 1.
  14418. *
  14419. * If LIWORK = -1, then a workspace query is assumed; the
  14420. * routine only calculates the optimal size of the IWORK array,
  14421. * returns this value as the first entry of the IWORK array, and
  14422. * no error message related to LIWORK is issued by XERBLA.
  14423. *
  14424. * C++ Return value: INFO (output) INTEGER
  14425. * = 0: successful exit.
  14426. * < 0: if INFO = -i, the i-th argument had an illegal value.
  14427. * > 0: The algorithm failed to compute an eigenvalue while
  14428. * working on the submatrix lying in rows and columns
  14429. * C++ Return value: INFO (output) INTEGER
  14430. *
  14431. * Further Details
  14432. * ===============
  14433. *
  14434. * Based on contributions by
  14435. * Jeff Rutter, Computer Science Division, University of California
  14436. * at Berkeley, USA
  14437. * Modified by Francoise Tisseur, University of Tennessee.
  14438. *
  14439. * =====================================================================
  14440. *
  14441. * .. Parameters ..
  14442. **/
  14443. int C_DSTEDC(char compz, int n, double* d, double* e, double* z, int ldz, double* work, int lwork, int* iwork, int liwork)
  14444. {
  14445. int info;
  14446. ::F_DSTEDC(&compz, &n, d, e, z, &ldz, work, &lwork, iwork, &liwork, &info);
  14447. return info;
  14448. }
  14449. /**
  14450. * Purpose
  14451. * =======
  14452. *
  14453. * DSTEGR computes selected eigenvalues and, optionally, eigenvectors
  14454. * of a real symmetric tridiagonal matrix T. Any such unreduced matrix has
  14455. * a well defined set of pairwise different real eigenvalues, the corresponding
  14456. * real eigenvectors are pairwise orthogonal.
  14457. *
  14458. * The spectrum may be computed either completely or partially by specifying
  14459. * either an interval (VL,VU] or a range of indices IL:IU for the desired
  14460. * eigenvalues.
  14461. *
  14462. * DSTEGR is a compatability wrapper around the improved DSTEMR routine.
  14463. * See DSTEMR for further details.
  14464. *
  14465. * One important change is that the ABSTOL parameter no longer provides any
  14466. * benefit and hence is no longer used.
  14467. *
  14468. * Note : DSTEGR and DSTEMR work only on machines which follow
  14469. * IEEE-754 floating-point standard in their handling of infinities and
  14470. * NaNs. Normal execution may create these exceptiona values and hence
  14471. * may abort due to a floating point exception in environments which
  14472. * do not conform to the IEEE-754 standard.
  14473. *
  14474. * Arguments
  14475. * =========
  14476. *
  14477. * JOBZ (input) CHARACTER*1
  14478. * = 'N': Compute eigenvalues only;
  14479. * = 'V': Compute eigenvalues and eigenvectors.
  14480. *
  14481. * RANGE (input) CHARACTER*1
  14482. * = 'A': all eigenvalues will be found.
  14483. * = 'V': all eigenvalues in the half-open interval (VL,VU]
  14484. * will be found.
  14485. * = 'I': the IL-th through IU-th eigenvalues will be found.
  14486. *
  14487. * N (input) INTEGER
  14488. * The order of the matrix. N >= 0.
  14489. *
  14490. * D (input/output) DOUBLE PRECISION array, dimension (N)
  14491. * On entry, the N diagonal elements of the tridiagonal matrix
  14492. * T. On exit, D is overwritten.
  14493. *
  14494. * E (input/output) DOUBLE PRECISION array, dimension (N)
  14495. * On entry, the (N-1) subdiagonal elements of the tridiagonal
  14496. * matrix T in elements 1 to N-1 of E. E(N) need not be set on
  14497. * input, but is used internally as workspace.
  14498. * On exit, E is overwritten.
  14499. *
  14500. * VL (input) DOUBLE PRECISION
  14501. * VU (input) DOUBLE PRECISION
  14502. * If RANGE='V', the lower and upper bounds of the interval to
  14503. * be searched for eigenvalues. VL < VU.
  14504. * Not referenced if RANGE = 'A' or 'I'.
  14505. *
  14506. * IL (input) INTEGER
  14507. * IU (input) INTEGER
  14508. * If RANGE='I', the indices (in ascending order) of the
  14509. * smallest and largest eigenvalues to be returned.
  14510. * 1 <= IL <= IU <= N, if N > 0.
  14511. * Not referenced if RANGE = 'A' or 'V'.
  14512. *
  14513. * ABSTOL (input) DOUBLE PRECISION
  14514. * Unused. Was the absolute error tolerance for the
  14515. * eigenvalues/eigenvectors in previous versions.
  14516. *
  14517. * M (output) INTEGER
  14518. * The total number of eigenvalues found. 0 <= M <= N.
  14519. * If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
  14520. *
  14521. * W (output) DOUBLE PRECISION array, dimension (N)
  14522. * The first M elements contain the selected eigenvalues in
  14523. * ascending order.
  14524. *
  14525. * Z (output) DOUBLE PRECISION array, dimension (LDZ, max(1,M) )
  14526. * If JOBZ = 'V', and if INFO = 0, then the first M columns of Z
  14527. * contain the orthonormal eigenvectors of the matrix T
  14528. * corresponding to the selected eigenvalues, with the i-th
  14529. * column of Z holding the eigenvector associated with W(i).
  14530. * If JOBZ = 'N', then Z is not referenced.
  14531. * Note: the user must ensure that at least max(1,M) columns are
  14532. * supplied in the array Z; if RANGE = 'V', the exact value of M
  14533. * is not known in advance and an upper bound must be used.
  14534. * Supplying N columns is always safe.
  14535. *
  14536. * LDZ (input) INTEGER
  14537. * The leading dimension of the array Z. LDZ >= 1, and if
  14538. * JOBZ = 'V', then LDZ >= max(1,N).
  14539. *
  14540. * ISUPPZ (output) INTEGER ARRAY, dimension ( 2*max(1,M) )
  14541. * The support of the eigenvectors in Z, i.e., the indices
  14542. * indicating the nonzero elements in Z. The i-th computed eigenvector
  14543. * is nonzero only in elements ISUPPZ( 2*i-1 ) through
  14544. * ISUPPZ( 2*i ). This is relevant in the case when the matrix
  14545. * is split. ISUPPZ is only accessed when JOBZ is 'V' and N > 0.
  14546. *
  14547. * WORK (workspace/output) DOUBLE PRECISION array, dimension (LWORK)
  14548. * On exit, if INFO = 0, WORK(1) returns the optimal
  14549. * (and minimal) LWORK.
  14550. *
  14551. * LWORK (input) INTEGER
  14552. * The dimension of the array WORK. LWORK >= max(1,18*N)
  14553. * if JOBZ = 'V', and LWORK >= max(1,12*N) if JOBZ = 'N'.
  14554. * If LWORK = -1, then a workspace query is assumed; the routine
  14555. * only calculates the optimal size of the WORK array, returns
  14556. * this value as the first entry of the WORK array, and no error
  14557. * message related to LWORK is issued by XERBLA.
  14558. *
  14559. * IWORK (workspace/output) INTEGER array, dimension (LIWORK)
  14560. * On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK.
  14561. *
  14562. * LIWORK (input) INTEGER
  14563. * The dimension of the array IWORK. LIWORK >= max(1,10*N)
  14564. * if the eigenvectors are desired, and LIWORK >= max(1,8*N)
  14565. * if only the eigenvalues are to be computed.
  14566. * If LIWORK = -1, then a workspace query is assumed; the
  14567. * routine only calculates the optimal size of the IWORK array,
  14568. * returns this value as the first entry of the IWORK array, and
  14569. * no error message related to LIWORK is issued by XERBLA.
  14570. *
  14571. * C++ Return value: INFO (output) INTEGER
  14572. * On exit, INFO
  14573. * = 0: successful exit
  14574. * < 0: if INFO = -i, the i-th argument had an illegal value
  14575. * > 0: if INFO = 1X, internal error in DLARRE,
  14576. * if INFO = 2X, internal error in DLARRV.
  14577. * Here, the digit X = ABS( IINFO ) < 10, where IINFO is
  14578. * the nonzero error code returned by DLARRE or
  14579. * DLARRV, respectively.
  14580. *
  14581. * Further Details
  14582. * ===============
  14583. *
  14584. * Based on contributions by
  14585. * Inderjit Dhillon, IBM Almaden, USA
  14586. * Osni Marques, LBNL/NERSC, USA
  14587. * Christof Voemel, LBNL/NERSC, USA
  14588. *
  14589. * =====================================================================
  14590. *
  14591. * .. Local Scalars ..
  14592. **/
  14593. int C_DSTEGR(char jobz, char range, int n, double* d, double* e, double vl, double vu, int il, int iu, double abstol, int* m, double* w, double* z, int ldz, int* isuppz, double* work, int lwork, int* iwork, int liwork)
  14594. {
  14595. int info;
  14596. ::F_DSTEGR(&jobz, &range, &n, d, e, &vl, &vu, &il, &iu, &abstol, m, w, z, &ldz, isuppz, work, &lwork, iwork, &liwork, &info);
  14597. return info;
  14598. }
  14599. /**
  14600. * Purpose
  14601. * =======
  14602. *
  14603. * DSTEIN computes the eigenvectors of a real symmetric tridiagonal
  14604. * matrix T corresponding to specified eigenvalues, using inverse
  14605. * iteration.
  14606. *
  14607. * The maximum number of iterations allowed for each eigenvector is
  14608. * specified by an internal parameter MAXITS (currently set to 5).
  14609. *
  14610. * Arguments
  14611. * =========
  14612. *
  14613. * N (input) INTEGER
  14614. * The order of the matrix. N >= 0.
  14615. *
  14616. * D (input) DOUBLE PRECISION array, dimension (N)
  14617. * The n diagonal elements of the tridiagonal matrix T.
  14618. *
  14619. * E (input) DOUBLE PRECISION array, dimension (N-1)
  14620. * The (n-1) subdiagonal elements of the tridiagonal matrix
  14621. * T, in elements 1 to N-1.
  14622. *
  14623. * M (input) INTEGER
  14624. * The number of eigenvectors to be found. 0 <= M <= N.
  14625. *
  14626. * W (input) DOUBLE PRECISION array, dimension (N)
  14627. * The first M elements of W contain the eigenvalues for
  14628. * which eigenvectors are to be computed. The eigenvalues
  14629. * should be grouped by split-off block and ordered from
  14630. * smallest to largest within the block. ( The output array
  14631. * W from DSTEBZ with ORDER = 'B' is expected here. )
  14632. *
  14633. * IBLOCK (input) INTEGER array, dimension (N)
  14634. * The submatrix indices associated with the corresponding
  14635. * eigenvalues in W; IBLOCK(i)=1 if eigenvalue W(i) belongs to
  14636. * the first submatrix from the top, =2 if W(i) belongs to
  14637. * the second submatrix, etc. ( The output array IBLOCK
  14638. * from DSTEBZ is expected here. )
  14639. *
  14640. * ISPLIT (input) INTEGER array, dimension (N)
  14641. * The splitting points, at which T breaks up into submatrices.
  14642. * The first submatrix consists of rows/columns 1 to
  14643. * ISPLIT( 1 ), the second of rows/columns ISPLIT( 1 )+1
  14644. * through ISPLIT( 2 ), etc.
  14645. * ( The output array ISPLIT from DSTEBZ is expected here. )
  14646. *
  14647. * Z (output) DOUBLE PRECISION array, dimension (LDZ, M)
  14648. * The computed eigenvectors. The eigenvector associated
  14649. * with the eigenvalue W(i) is stored in the i-th column of
  14650. * Z. Any vector which fails to converge is set to its current
  14651. * iterate after MAXITS iterations.
  14652. *
  14653. * LDZ (input) INTEGER
  14654. * The leading dimension of the array Z. LDZ >= max(1,N).
  14655. *
  14656. * WORK (workspace) DOUBLE PRECISION array, dimension (5*N)
  14657. *
  14658. * IWORK (workspace) INTEGER array, dimension (N)
  14659. *
  14660. * IFAIL (output) INTEGER array, dimension (M)
  14661. * On normal exit, all elements of IFAIL are zero.
  14662. * If one or more eigenvectors fail to converge after
  14663. * MAXITS iterations, then their indices are stored in
  14664. * array IFAIL.
  14665. *
  14666. * C++ Return value: INFO (output) INTEGER
  14667. * = 0: successful exit.
  14668. * < 0: if INFO = -i, the i-th argument had an illegal value
  14669. * > 0: if INFO = i, then i eigenvectors failed to converge
  14670. * in MAXITS iterations. Their indices are stored in
  14671. * array IFAIL.
  14672. *
  14673. * Internal Parameters
  14674. * ===================
  14675. *
  14676. * MAXITS INTEGER, default = 5
  14677. * The maximum number of iterations performed.
  14678. *
  14679. * EXTRA INTEGER, default = 2
  14680. * The number of iterations performed after norm growth
  14681. * criterion is satisfied, should be at least 1.
  14682. *
  14683. * =====================================================================
  14684. *
  14685. * .. Parameters ..
  14686. **/
  14687. int C_DSTEIN(int n, double* d, double* e, int m, double* w, int* iblock, int* isplit, double* z, int ldz, double* work, int* iwork, int* ifail)
  14688. {
  14689. int info;
  14690. ::F_DSTEIN(&n, d, e, &m, w, iblock, isplit, z, &ldz, work, iwork, ifail, &info);
  14691. return info;
  14692. }
  14693. /**
  14694. * Purpose
  14695. * =======
  14696. *
  14697. * DSTEQR computes all eigenvalues and, optionally, eigenvectors of a
  14698. * symmetric tridiagonal matrix using the implicit QL or QR method.
  14699. * The eigenvectors of a full or band symmetric matrix can also be found
  14700. * if DSYTRD or DSPTRD or DSBTRD has been used to reduce this matrix to
  14701. * tridiagonal form.
  14702. *
  14703. * Arguments
  14704. * =========
  14705. *
  14706. * COMPZ (input) CHARACTER*1
  14707. * = 'N': Compute eigenvalues only.
  14708. * = 'V': Compute eigenvalues and eigenvectors of the original
  14709. * symmetric matrix. On entry, Z must contain the
  14710. * orthogonal matrix used to reduce the original matrix
  14711. * to tridiagonal form.
  14712. * = 'I': Compute eigenvalues and eigenvectors of the
  14713. * tridiagonal matrix. Z is initialized to the identity
  14714. * matrix.
  14715. *
  14716. * N (input) INTEGER
  14717. * The order of the matrix. N >= 0.
  14718. *
  14719. * D (input/output) DOUBLE PRECISION array, dimension (N)
  14720. * On entry, the diagonal elements of the tridiagonal matrix.
  14721. * On exit, if INFO = 0, the eigenvalues in ascending order.
  14722. *
  14723. * E (input/output) DOUBLE PRECISION array, dimension (N-1)
  14724. * On entry, the (n-1) subdiagonal elements of the tridiagonal
  14725. * matrix.
  14726. * On exit, E has been destroyed.
  14727. *
  14728. * Z (input/output) DOUBLE PRECISION array, dimension (LDZ, N)
  14729. * On entry, if COMPZ = 'V', then Z contains the orthogonal
  14730. * matrix used in the reduction to tridiagonal form.
  14731. * On exit, if INFO = 0, then if COMPZ = 'V', Z contains the
  14732. * orthonormal eigenvectors of the original symmetric matrix,
  14733. * and if COMPZ = 'I', Z contains the orthonormal eigenvectors
  14734. * of the symmetric tridiagonal matrix.
  14735. * If COMPZ = 'N', then Z is not referenced.
  14736. *
  14737. * LDZ (input) INTEGER
  14738. * The leading dimension of the array Z. LDZ >= 1, and if
  14739. * eigenvectors are desired, then LDZ >= max(1,N).
  14740. *
  14741. * WORK (workspace) DOUBLE PRECISION array, dimension (max(1,2*N-2))
  14742. * If COMPZ = 'N', then WORK is not referenced.
  14743. *
  14744. * C++ Return value: INFO (output) INTEGER
  14745. * = 0: successful exit
  14746. * < 0: if INFO = -i, the i-th argument had an illegal value
  14747. * > 0: the algorithm has failed to find all the eigenvalues in
  14748. * a total of 30*N iterations; if INFO = i, then i
  14749. * elements of E have not converged to zero; on exit, D
  14750. * and E contain the elements of a symmetric tridiagonal
  14751. * matrix which is orthogonally similar to the original
  14752. * matrix.
  14753. *
  14754. * =====================================================================
  14755. *
  14756. * .. Parameters ..
  14757. **/
  14758. int C_DSTEQR(char compz, int n, double* d, double* e, double* z, int ldz, double* work)
  14759. {
  14760. int info;
  14761. ::F_DSTEQR(&compz, &n, d, e, z, &ldz, work, &info);
  14762. return info;
  14763. }
  14764. /**
  14765. * Purpose
  14766. * =======
  14767. *
  14768. * DSTERF computes all eigenvalues of a symmetric tridiagonal matrix
  14769. * using the Pal-Walker-Kahan variant of the QL or QR algorithm.
  14770. *
  14771. * Arguments
  14772. * =========
  14773. *
  14774. * N (input) INTEGER
  14775. * The order of the matrix. N >= 0.
  14776. *
  14777. * D (input/output) DOUBLE PRECISION array, dimension (N)
  14778. * On entry, the n diagonal elements of the tridiagonal matrix.
  14779. * On exit, if INFO = 0, the eigenvalues in ascending order.
  14780. *
  14781. * E (input/output) DOUBLE PRECISION array, dimension (N-1)
  14782. * On entry, the (n-1) subdiagonal elements of the tridiagonal
  14783. * matrix.
  14784. * On exit, E has been destroyed.
  14785. *
  14786. * C++ Return value: INFO (output) INTEGER
  14787. * = 0: successful exit
  14788. * < 0: if INFO = -i, the i-th argument had an illegal value
  14789. * > 0: the algorithm failed to find all of the eigenvalues in
  14790. * a total of 30*N iterations; if INFO = i, then i
  14791. * elements of E have not converged to zero.
  14792. *
  14793. * =====================================================================
  14794. *
  14795. * .. Parameters ..
  14796. **/
  14797. int C_DSTERF(int n, double* d, double* e)
  14798. {
  14799. int info;
  14800. ::F_DSTERF(&n, d, e, &info);
  14801. return info;
  14802. }
  14803. /**
  14804. * Purpose
  14805. * =======
  14806. *
  14807. * DSTEV computes all eigenvalues and, optionally, eigenvectors of a
  14808. * real symmetric tridiagonal matrix A.
  14809. *
  14810. * Arguments
  14811. * =========
  14812. *
  14813. * JOBZ (input) CHARACTER*1
  14814. * = 'N': Compute eigenvalues only;
  14815. * = 'V': Compute eigenvalues and eigenvectors.
  14816. *
  14817. * N (input) INTEGER
  14818. * The order of the matrix. N >= 0.
  14819. *
  14820. * D (input/output) DOUBLE PRECISION array, dimension (N)
  14821. * On entry, the n diagonal elements of the tridiagonal matrix
  14822. * A.
  14823. * On exit, if INFO = 0, the eigenvalues in ascending order.
  14824. *
  14825. * E (input/output) DOUBLE PRECISION array, dimension (N-1)
  14826. * On entry, the (n-1) subdiagonal elements of the tridiagonal
  14827. * matrix A, stored in elements 1 to N-1 of E.
  14828. * On exit, the contents of E are destroyed.
  14829. *
  14830. * Z (output) DOUBLE PRECISION array, dimension (LDZ, N)
  14831. * If JOBZ = 'V', then if INFO = 0, Z contains the orthonormal
  14832. * eigenvectors of the matrix A, with the i-th column of Z
  14833. * holding the eigenvector associated with D(i).
  14834. * If JOBZ = 'N', then Z is not referenced.
  14835. *
  14836. * LDZ (input) INTEGER
  14837. * The leading dimension of the array Z. LDZ >= 1, and if
  14838. * JOBZ = 'V', LDZ >= max(1,N).
  14839. *
  14840. * WORK (workspace) DOUBLE PRECISION array, dimension (max(1,2*N-2))
  14841. * If JOBZ = 'N', WORK is not referenced.
  14842. *
  14843. * C++ Return value: INFO (output) INTEGER
  14844. * = 0: successful exit
  14845. * < 0: if INFO = -i, the i-th argument had an illegal value
  14846. * > 0: if INFO = i, the algorithm failed to converge; i
  14847. * off-diagonal elements of E did not converge to zero.
  14848. *
  14849. * =====================================================================
  14850. *
  14851. * .. Parameters ..
  14852. **/
  14853. int C_DSTEV(char jobz, int n, double* d, double* e, double* z, int ldz, double* work)
  14854. {
  14855. int info;
  14856. ::F_DSTEV(&jobz, &n, d, e, z, &ldz, work, &info);
  14857. return info;
  14858. }
  14859. /**
  14860. * Purpose
  14861. * =======
  14862. *
  14863. * DSTEVD computes all eigenvalues and, optionally, eigenvectors of a
  14864. * real symmetric tridiagonal matrix. If eigenvectors are desired, it
  14865. * uses a divide and conquer algorithm.
  14866. *
  14867. * The divide and conquer algorithm makes very mild assumptions about
  14868. * floating point arithmetic. It will work on machines with a guard
  14869. * digit in add/subtract, or on those binary machines without guard
  14870. * digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or
  14871. * Cray-2. It could conceivably fail on hexadecimal or decimal machines
  14872. * without guard digits, but we know of none.
  14873. *
  14874. * Arguments
  14875. * =========
  14876. *
  14877. * JOBZ (input) CHARACTER*1
  14878. * = 'N': Compute eigenvalues only;
  14879. * = 'V': Compute eigenvalues and eigenvectors.
  14880. *
  14881. * N (input) INTEGER
  14882. * The order of the matrix. N >= 0.
  14883. *
  14884. * D (input/output) DOUBLE PRECISION array, dimension (N)
  14885. * On entry, the n diagonal elements of the tridiagonal matrix
  14886. * A.
  14887. * On exit, if INFO = 0, the eigenvalues in ascending order.
  14888. *
  14889. * E (input/output) DOUBLE PRECISION array, dimension (N-1)
  14890. * On entry, the (n-1) subdiagonal elements of the tridiagonal
  14891. * matrix A, stored in elements 1 to N-1 of E.
  14892. * On exit, the contents of E are destroyed.
  14893. *
  14894. * Z (output) DOUBLE PRECISION array, dimension (LDZ, N)
  14895. * If JOBZ = 'V', then if INFO = 0, Z contains the orthonormal
  14896. * eigenvectors of the matrix A, with the i-th column of Z
  14897. * holding the eigenvector associated with D(i).
  14898. * If JOBZ = 'N', then Z is not referenced.
  14899. *
  14900. * LDZ (input) INTEGER
  14901. * The leading dimension of the array Z. LDZ >= 1, and if
  14902. * JOBZ = 'V', LDZ >= max(1,N).
  14903. *
  14904. * WORK (workspace/output) DOUBLE PRECISION array,
  14905. * dimension (LWORK)
  14906. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  14907. *
  14908. * LWORK (input) INTEGER
  14909. * The dimension of the array WORK.
  14910. * If JOBZ = 'N' or N <= 1 then LWORK must be at least 1.
  14911. * If JOBZ = 'V' and N > 1 then LWORK must be at least
  14912. * ( 1 + 4*N + N**2 ).
  14913. *
  14914. * If LWORK = -1, then a workspace query is assumed; the routine
  14915. * only calculates the optimal sizes of the WORK and IWORK
  14916. * arrays, returns these values as the first entries of the WORK
  14917. * and IWORK arrays, and no error message related to LWORK or
  14918. * LIWORK is issued by XERBLA.
  14919. *
  14920. * IWORK (workspace/output) INTEGER array, dimension (MAX(1,LIWORK))
  14921. * On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK.
  14922. *
  14923. * LIWORK (input) INTEGER
  14924. * The dimension of the array IWORK.
  14925. * If JOBZ = 'N' or N <= 1 then LIWORK must be at least 1.
  14926. * If JOBZ = 'V' and N > 1 then LIWORK must be at least 3+5*N.
  14927. *
  14928. * If LIWORK = -1, then a workspace query is assumed; the
  14929. * routine only calculates the optimal sizes of the WORK and
  14930. * IWORK arrays, returns these values as the first entries of
  14931. * the WORK and IWORK arrays, and no error message related to
  14932. * LWORK or LIWORK is issued by XERBLA.
  14933. *
  14934. * C++ Return value: INFO (output) INTEGER
  14935. * = 0: successful exit
  14936. * < 0: if INFO = -i, the i-th argument had an illegal value
  14937. * > 0: if INFO = i, the algorithm failed to converge; i
  14938. * off-diagonal elements of E did not converge to zero.
  14939. *
  14940. * =====================================================================
  14941. *
  14942. * .. Parameters ..
  14943. **/
  14944. int C_DSTEVD(char jobz, int n, double* d, double* e, double* z, int ldz, double* work, int lwork, int* iwork, int liwork)
  14945. {
  14946. int info;
  14947. ::F_DSTEVD(&jobz, &n, d, e, z, &ldz, work, &lwork, iwork, &liwork, &info);
  14948. return info;
  14949. }
  14950. /**
  14951. * Purpose
  14952. * =======
  14953. *
  14954. * DSTEVR computes selected eigenvalues and, optionally, eigenvectors
  14955. * of a real symmetric tridiagonal matrix T. Eigenvalues and
  14956. * eigenvectors can be selected by specifying either a range of values
  14957. * or a range of indices for the desired eigenvalues.
  14958. *
  14959. * Whenever possible, DSTEVR calls DSTEMR to compute the
  14960. * eigenspectrum using Relatively Robust Representations. DSTEMR
  14961. * computes eigenvalues by the dqds algorithm, while orthogonal
  14962. * eigenvectors are computed from various "good" L D L^T representations
  14963. * (also known as Relatively Robust Representations). Gram-Schmidt
  14964. * orthogonalization is avoided as far as possible. More specifically,
  14965. * the various steps of the algorithm are as follows. For the i-th
  14966. * unreduced block of T,
  14967. * (a) Compute T - sigma_i = L_i D_i L_i^T, such that L_i D_i L_i^T
  14968. * is a relatively robust representation,
  14969. * (b) Compute the eigenvalues, lambda_j, of L_i D_i L_i^T to high
  14970. * relative accuracy by the dqds algorithm,
  14971. * (c) If there is a cluster of close eigenvalues, "choose" sigma_i
  14972. * close to the cluster, and go to step (a),
  14973. * (d) Given the approximate eigenvalue lambda_j of L_i D_i L_i^T,
  14974. * compute the corresponding eigenvector by forming a
  14975. * rank-revealing twisted factorization.
  14976. * The desired accuracy of the output can be specified by the input
  14977. * parameter ABSTOL.
  14978. *
  14979. * For more details, see "A new O(n^2) algorithm for the symmetric
  14980. * tridiagonal eigenvalue/eigenvector problem", by Inderjit Dhillon,
  14981. * Computer Science Division Technical Report No. UCB//CSD-97-971,
  14982. * UC Berkeley, May 1997.
  14983. *
  14984. *
  14985. * Note 1 : DSTEVR calls DSTEMR when the full spectrum is requested
  14986. * on machines which conform to the ieee-754 floating point standard.
  14987. * DSTEVR calls DSTEBZ and DSTEIN on non-ieee machines and
  14988. * when partial spectrum requests are made.
  14989. *
  14990. * Normal execution of DSTEMR may create NaNs and infinities and
  14991. * hence may abort due to a floating point exception in environments
  14992. * which do not handle NaNs and infinities in the ieee standard default
  14993. * manner.
  14994. *
  14995. * Arguments
  14996. * =========
  14997. *
  14998. * JOBZ (input) CHARACTER*1
  14999. * = 'N': Compute eigenvalues only;
  15000. * = 'V': Compute eigenvalues and eigenvectors.
  15001. *
  15002. * RANGE (input) CHARACTER*1
  15003. * = 'A': all eigenvalues will be found.
  15004. * = 'V': all eigenvalues in the half-open interval (VL,VU]
  15005. * will be found.
  15006. * = 'I': the IL-th through IU-th eigenvalues will be found.
  15007. ********** For RANGE = 'V' or 'I' and IU - IL < N - 1, DSTEBZ and
  15008. ********** DSTEIN are called
  15009. *
  15010. * N (input) INTEGER
  15011. * The order of the matrix. N >= 0.
  15012. *
  15013. * D (input/output) DOUBLE PRECISION array, dimension (N)
  15014. * On entry, the n diagonal elements of the tridiagonal matrix
  15015. * A.
  15016. * On exit, D may be multiplied by a constant factor chosen
  15017. * to avoid over/underflow in computing the eigenvalues.
  15018. *
  15019. * E (input/output) DOUBLE PRECISION array, dimension (max(1,N-1))
  15020. * On entry, the (n-1) subdiagonal elements of the tridiagonal
  15021. * matrix A in elements 1 to N-1 of E.
  15022. * On exit, E may be multiplied by a constant factor chosen
  15023. * to avoid over/underflow in computing the eigenvalues.
  15024. *
  15025. * VL (input) DOUBLE PRECISION
  15026. * VU (input) DOUBLE PRECISION
  15027. * If RANGE='V', the lower and upper bounds of the interval to
  15028. * be searched for eigenvalues. VL < VU.
  15029. * Not referenced if RANGE = 'A' or 'I'.
  15030. *
  15031. * IL (input) INTEGER
  15032. * IU (input) INTEGER
  15033. * If RANGE='I', the indices (in ascending order) of the
  15034. * smallest and largest eigenvalues to be returned.
  15035. * 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
  15036. * Not referenced if RANGE = 'A' or 'V'.
  15037. *
  15038. * ABSTOL (input) DOUBLE PRECISION
  15039. * The absolute error tolerance for the eigenvalues.
  15040. * An approximate eigenvalue is accepted as converged
  15041. * when it is determined to lie in an interval [a,b]
  15042. * of width less than or equal to
  15043. *
  15044. * ABSTOL + EPS * max( |a|,|b| ) ,
  15045. *
  15046. * where EPS is the machine precision. If ABSTOL is less than
  15047. * or equal to zero, then EPS*|T| will be used in its place,
  15048. * where |T| is the 1-norm of the tridiagonal matrix obtained
  15049. * by reducing A to tridiagonal form.
  15050. *
  15051. * See "Computing Small Singular Values of Bidiagonal Matrices
  15052. * with Guaranteed High Relative Accuracy," by Demmel and
  15053. * Kahan, LAPACK Working Note #3.
  15054. *
  15055. * If high relative accuracy is important, set ABSTOL to
  15056. * DLAMCH( 'Safe minimum' ). Doing so will guarantee that
  15057. * eigenvalues are computed to high relative accuracy when
  15058. * possible in future releases. The current code does not
  15059. * make any guarantees about high relative accuracy, but
  15060. * future releases will. See J. Barlow and J. Demmel,
  15061. * "Computing Accurate Eigensystems of Scaled Diagonally
  15062. * Dominant Matrices", LAPACK Working Note #7, for a discussion
  15063. * of which matrices define their eigenvalues to high relative
  15064. * accuracy.
  15065. *
  15066. * M (output) INTEGER
  15067. * The total number of eigenvalues found. 0 <= M <= N.
  15068. * If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
  15069. *
  15070. * W (output) DOUBLE PRECISION array, dimension (N)
  15071. * The first M elements contain the selected eigenvalues in
  15072. * ascending order.
  15073. *
  15074. * Z (output) DOUBLE PRECISION array, dimension (LDZ, max(1,M) )
  15075. * If JOBZ = 'V', then if INFO = 0, the first M columns of Z
  15076. * contain the orthonormal eigenvectors of the matrix A
  15077. * corresponding to the selected eigenvalues, with the i-th
  15078. * column of Z holding the eigenvector associated with W(i).
  15079. * Note: the user must ensure that at least max(1,M) columns are
  15080. * supplied in the array Z; if RANGE = 'V', the exact value of M
  15081. * is not known in advance and an upper bound must be used.
  15082. *
  15083. * LDZ (input) INTEGER
  15084. * The leading dimension of the array Z. LDZ >= 1, and if
  15085. * JOBZ = 'V', LDZ >= max(1,N).
  15086. *
  15087. * ISUPPZ (output) INTEGER array, dimension ( 2*max(1,M) )
  15088. * The support of the eigenvectors in Z, i.e., the indices
  15089. * indicating the nonzero elements in Z. The i-th eigenvector
  15090. * is nonzero only in elements ISUPPZ( 2*i-1 ) through
  15091. * ISUPPZ( 2*i ).
  15092. ********** Implemented only for RANGE = 'A' or 'I' and IU - IL = N - 1
  15093. *
  15094. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  15095. * On exit, if INFO = 0, WORK(1) returns the optimal (and
  15096. * minimal) LWORK.
  15097. *
  15098. * LWORK (input) INTEGER
  15099. * The dimension of the array WORK. LWORK >= max(1,20*N).
  15100. *
  15101. * If LWORK = -1, then a workspace query is assumed; the routine
  15102. * only calculates the optimal sizes of the WORK and IWORK
  15103. * arrays, returns these values as the first entries of the WORK
  15104. * and IWORK arrays, and no error message related to LWORK or
  15105. * LIWORK is issued by XERBLA.
  15106. *
  15107. * IWORK (workspace/output) INTEGER array, dimension (MAX(1,LIWORK))
  15108. * On exit, if INFO = 0, IWORK(1) returns the optimal (and
  15109. * minimal) LIWORK.
  15110. *
  15111. * LIWORK (input) INTEGER
  15112. * The dimension of the array IWORK. LIWORK >= max(1,10*N).
  15113. *
  15114. * If LIWORK = -1, then a workspace query is assumed; the
  15115. * routine only calculates the optimal sizes of the WORK and
  15116. * IWORK arrays, returns these values as the first entries of
  15117. * the WORK and IWORK arrays, and no error message related to
  15118. * LWORK or LIWORK is issued by XERBLA.
  15119. *
  15120. * C++ Return value: INFO (output) INTEGER
  15121. * = 0: successful exit
  15122. * < 0: if INFO = -i, the i-th argument had an illegal value
  15123. * > 0: Internal error
  15124. *
  15125. * Further Details
  15126. * ===============
  15127. *
  15128. * Based on contributions by
  15129. * Inderjit Dhillon, IBM Almaden, USA
  15130. * Osni Marques, LBNL/NERSC, USA
  15131. * Ken Stanley, Computer Science Division, University of
  15132. * California at Berkeley, USA
  15133. *
  15134. * =====================================================================
  15135. *
  15136. * .. Parameters ..
  15137. **/
  15138. int C_DSTEVR(char jobz, char range, int n, double* d, double* e, double vl, double vu, int il, int iu, double abstol, int* m, double* w, double* z, int ldz, int* isuppz, double* work, int lwork, int* iwork, int liwork)
  15139. {
  15140. int info;
  15141. ::F_DSTEVR(&jobz, &range, &n, d, e, &vl, &vu, &il, &iu, &abstol, m, w, z, &ldz, isuppz, work, &lwork, iwork, &liwork, &info);
  15142. return info;
  15143. }
  15144. /**
  15145. * Purpose
  15146. * =======
  15147. *
  15148. * DSTEVX computes selected eigenvalues and, optionally, eigenvectors
  15149. * of a real symmetric tridiagonal matrix A. Eigenvalues and
  15150. * eigenvectors can be selected by specifying either a range of values
  15151. * or a range of indices for the desired eigenvalues.
  15152. *
  15153. * Arguments
  15154. * =========
  15155. *
  15156. * JOBZ (input) CHARACTER*1
  15157. * = 'N': Compute eigenvalues only;
  15158. * = 'V': Compute eigenvalues and eigenvectors.
  15159. *
  15160. * RANGE (input) CHARACTER*1
  15161. * = 'A': all eigenvalues will be found.
  15162. * = 'V': all eigenvalues in the half-open interval (VL,VU]
  15163. * will be found.
  15164. * = 'I': the IL-th through IU-th eigenvalues will be found.
  15165. *
  15166. * N (input) INTEGER
  15167. * The order of the matrix. N >= 0.
  15168. *
  15169. * D (input/output) DOUBLE PRECISION array, dimension (N)
  15170. * On entry, the n diagonal elements of the tridiagonal matrix
  15171. * A.
  15172. * On exit, D may be multiplied by a constant factor chosen
  15173. * to avoid over/underflow in computing the eigenvalues.
  15174. *
  15175. * E (input/output) DOUBLE PRECISION array, dimension (max(1,N-1))
  15176. * On entry, the (n-1) subdiagonal elements of the tridiagonal
  15177. * matrix A in elements 1 to N-1 of E.
  15178. * On exit, E may be multiplied by a constant factor chosen
  15179. * to avoid over/underflow in computing the eigenvalues.
  15180. *
  15181. * VL (input) DOUBLE PRECISION
  15182. * VU (input) DOUBLE PRECISION
  15183. * If RANGE='V', the lower and upper bounds of the interval to
  15184. * be searched for eigenvalues. VL < VU.
  15185. * Not referenced if RANGE = 'A' or 'I'.
  15186. *
  15187. * IL (input) INTEGER
  15188. * IU (input) INTEGER
  15189. * If RANGE='I', the indices (in ascending order) of the
  15190. * smallest and largest eigenvalues to be returned.
  15191. * 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
  15192. * Not referenced if RANGE = 'A' or 'V'.
  15193. *
  15194. * ABSTOL (input) DOUBLE PRECISION
  15195. * The absolute error tolerance for the eigenvalues.
  15196. * An approximate eigenvalue is accepted as converged
  15197. * when it is determined to lie in an interval [a,b]
  15198. * of width less than or equal to
  15199. *
  15200. * ABSTOL + EPS * max( |a|,|b| ) ,
  15201. *
  15202. * where EPS is the machine precision. If ABSTOL is less
  15203. * than or equal to zero, then EPS*|T| will be used in
  15204. * its place, where |T| is the 1-norm of the tridiagonal
  15205. * matrix.
  15206. *
  15207. * Eigenvalues will be computed most accurately when ABSTOL is
  15208. * set to twice the underflow threshold 2*DLAMCH('S'), not zero.
  15209. * If this routine returns with INFO>0, indicating that some
  15210. * eigenvectors did not converge, try setting ABSTOL to
  15211. * 2*DLAMCH('S').
  15212. *
  15213. * See "Computing Small Singular Values of Bidiagonal Matrices
  15214. * with Guaranteed High Relative Accuracy," by Demmel and
  15215. * Kahan, LAPACK Working Note #3.
  15216. *
  15217. * M (output) INTEGER
  15218. * The total number of eigenvalues found. 0 <= M <= N.
  15219. * If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
  15220. *
  15221. * W (output) DOUBLE PRECISION array, dimension (N)
  15222. * The first M elements contain the selected eigenvalues in
  15223. * ascending order.
  15224. *
  15225. * Z (output) DOUBLE PRECISION array, dimension (LDZ, max(1,M) )
  15226. * If JOBZ = 'V', then if INFO = 0, the first M columns of Z
  15227. * contain the orthonormal eigenvectors of the matrix A
  15228. * corresponding to the selected eigenvalues, with the i-th
  15229. * column of Z holding the eigenvector associated with W(i).
  15230. * If an eigenvector fails to converge (INFO > 0), then that
  15231. * column of Z contains the latest approximation to the
  15232. * eigenvector, and the index of the eigenvector is returned
  15233. * in IFAIL. If JOBZ = 'N', then Z is not referenced.
  15234. * Note: the user must ensure that at least max(1,M) columns are
  15235. * supplied in the array Z; if RANGE = 'V', the exact value of M
  15236. * is not known in advance and an upper bound must be used.
  15237. *
  15238. * LDZ (input) INTEGER
  15239. * The leading dimension of the array Z. LDZ >= 1, and if
  15240. * JOBZ = 'V', LDZ >= max(1,N).
  15241. *
  15242. * WORK (workspace) DOUBLE PRECISION array, dimension (5*N)
  15243. *
  15244. * IWORK (workspace) INTEGER array, dimension (5*N)
  15245. *
  15246. * IFAIL (output) INTEGER array, dimension (N)
  15247. * If JOBZ = 'V', then if INFO = 0, the first M elements of
  15248. * IFAIL are zero. If INFO > 0, then IFAIL contains the
  15249. * indices of the eigenvectors that failed to converge.
  15250. * If JOBZ = 'N', then IFAIL is not referenced.
  15251. *
  15252. * C++ Return value: INFO (output) INTEGER
  15253. * = 0: successful exit
  15254. * < 0: if INFO = -i, the i-th argument had an illegal value
  15255. * > 0: if INFO = i, then i eigenvectors failed to converge.
  15256. * Their indices are stored in array IFAIL.
  15257. *
  15258. * =====================================================================
  15259. *
  15260. * .. Parameters ..
  15261. **/
  15262. int C_DSTEVX(char jobz, char range, int n, double* d, double* e, double vl, double vu, int il, int iu, double abstol, int* m, double* w, double* z, int ldz, double* work, int* iwork, int* ifail)
  15263. {
  15264. int info;
  15265. ::F_DSTEVX(&jobz, &range, &n, d, e, &vl, &vu, &il, &iu, &abstol, m, w, z, &ldz, work, iwork, ifail, &info);
  15266. return info;
  15267. }
  15268. /**
  15269. * Purpose
  15270. * =======
  15271. *
  15272. * DSYCON estimates the reciprocal of the condition number (in the
  15273. * 1-norm) of a real symmetric matrix A using the factorization
  15274. * A = U*D*U**T or A = L*D*L**T computed by DSYTRF.
  15275. *
  15276. * An estimate is obtained for norm(inv(A)), and the reciprocal of the
  15277. * condition number is computed as RCOND = 1 / (ANORM * norm(inv(A))).
  15278. *
  15279. * Arguments
  15280. * =========
  15281. *
  15282. * UPLO (input) CHARACTER*1
  15283. * Specifies whether the details of the factorization are stored
  15284. * as an upper or lower triangular matrix.
  15285. * = 'U': Upper triangular, form is A = U*D*U**T;
  15286. * = 'L': Lower triangular, form is A = L*D*L**T.
  15287. *
  15288. * N (input) INTEGER
  15289. * The order of the matrix A. N >= 0.
  15290. *
  15291. * A (input) DOUBLE PRECISION array, dimension (LDA,N)
  15292. * The block diagonal matrix D and the multipliers used to
  15293. * obtain the factor U or L as computed by DSYTRF.
  15294. *
  15295. * LDA (input) INTEGER
  15296. * The leading dimension of the array A. LDA >= max(1,N).
  15297. *
  15298. * IPIV (input) INTEGER array, dimension (N)
  15299. * Details of the interchanges and the block structure of D
  15300. * as determined by DSYTRF.
  15301. *
  15302. * ANORM (input) DOUBLE PRECISION
  15303. * The 1-norm of the original matrix A.
  15304. *
  15305. * RCOND (output) DOUBLE PRECISION
  15306. * The reciprocal of the condition number of the matrix A,
  15307. * computed as RCOND = 1/(ANORM * AINVNM), where AINVNM is an
  15308. * estimate of the 1-norm of inv(A) computed in this routine.
  15309. *
  15310. * WORK (workspace) DOUBLE PRECISION array, dimension (2*N)
  15311. *
  15312. * IWORK (workspace) INTEGER array, dimension (N)
  15313. *
  15314. * C++ Return value: INFO (output) INTEGER
  15315. * = 0: successful exit
  15316. * < 0: if INFO = -i, the i-th argument had an illegal value
  15317. *
  15318. * =====================================================================
  15319. *
  15320. * .. Parameters ..
  15321. **/
  15322. int C_DSYCON(char uplo, int n, double* a, int lda, int* ipiv, double anorm, double* rcond, double* work, int* iwork)
  15323. {
  15324. int info;
  15325. ::F_DSYCON(&uplo, &n, a, &lda, ipiv, &anorm, rcond, work, iwork, &info);
  15326. return info;
  15327. }
  15328. /**
  15329. * Purpose
  15330. * =======
  15331. *
  15332. * DSYEV computes all eigenvalues and, optionally, eigenvectors of a
  15333. * real symmetric matrix A.
  15334. *
  15335. * Arguments
  15336. * =========
  15337. *
  15338. * JOBZ (input) CHARACTER*1
  15339. * = 'N': Compute eigenvalues only;
  15340. * = 'V': Compute eigenvalues and eigenvectors.
  15341. *
  15342. * UPLO (input) CHARACTER*1
  15343. * = 'U': Upper triangle of A is stored;
  15344. * = 'L': Lower triangle of A is stored.
  15345. *
  15346. * N (input) INTEGER
  15347. * The order of the matrix A. N >= 0.
  15348. *
  15349. * A (input/output) DOUBLE PRECISION array, dimension (LDA, N)
  15350. * On entry, the symmetric matrix A. If UPLO = 'U', the
  15351. * leading N-by-N upper triangular part of A contains the
  15352. * upper triangular part of the matrix A. If UPLO = 'L',
  15353. * the leading N-by-N lower triangular part of A contains
  15354. * the lower triangular part of the matrix A.
  15355. * On exit, if JOBZ = 'V', then if INFO = 0, A contains the
  15356. * orthonormal eigenvectors of the matrix A.
  15357. * If JOBZ = 'N', then on exit the lower triangle (if UPLO='L')
  15358. * or the upper triangle (if UPLO='U') of A, including the
  15359. * diagonal, is destroyed.
  15360. *
  15361. * LDA (input) INTEGER
  15362. * The leading dimension of the array A. LDA >= max(1,N).
  15363. *
  15364. * W (output) DOUBLE PRECISION array, dimension (N)
  15365. * If INFO = 0, the eigenvalues in ascending order.
  15366. *
  15367. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  15368. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  15369. *
  15370. * LWORK (input) INTEGER
  15371. * The length of the array WORK. LWORK >= max(1,3*N-1).
  15372. * For optimal efficiency, LWORK >= (NB+2)*N,
  15373. * where NB is the blocksize for DSYTRD returned by ILAENV.
  15374. *
  15375. * If LWORK = -1, then a workspace query is assumed; the routine
  15376. * only calculates the optimal size of the WORK array, returns
  15377. * this value as the first entry of the WORK array, and no error
  15378. * message related to LWORK is issued by XERBLA.
  15379. *
  15380. * C++ Return value: INFO (output) INTEGER
  15381. * = 0: successful exit
  15382. * < 0: if INFO = -i, the i-th argument had an illegal value
  15383. * > 0: if INFO = i, the algorithm failed to converge; i
  15384. * off-diagonal elements of an intermediate tridiagonal
  15385. * form did not converge to zero.
  15386. *
  15387. * =====================================================================
  15388. *
  15389. * .. Parameters ..
  15390. **/
  15391. int C_DSYEV(char jobz, char uplo, int n, double* a, int lda, double* w, double* work, int lwork)
  15392. {
  15393. int info;
  15394. ::F_DSYEV(&jobz, &uplo, &n, a, &lda, w, work, &lwork, &info);
  15395. return info;
  15396. }
  15397. /**
  15398. * Purpose
  15399. * =======
  15400. *
  15401. * DSYEVD computes all eigenvalues and, optionally, eigenvectors of a
  15402. * real symmetric matrix A. If eigenvectors are desired, it uses a
  15403. * divide and conquer algorithm.
  15404. *
  15405. * The divide and conquer algorithm makes very mild assumptions about
  15406. * floating point arithmetic. It will work on machines with a guard
  15407. * digit in add/subtract, or on those binary machines without guard
  15408. * digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or
  15409. * Cray-2. It could conceivably fail on hexadecimal or decimal machines
  15410. * without guard digits, but we know of none.
  15411. *
  15412. * Because of large use of BLAS of level 3, DSYEVD needs N**2 more
  15413. * workspace than DSYEVX.
  15414. *
  15415. * Arguments
  15416. * =========
  15417. *
  15418. * JOBZ (input) CHARACTER*1
  15419. * = 'N': Compute eigenvalues only;
  15420. * = 'V': Compute eigenvalues and eigenvectors.
  15421. *
  15422. * UPLO (input) CHARACTER*1
  15423. * = 'U': Upper triangle of A is stored;
  15424. * = 'L': Lower triangle of A is stored.
  15425. *
  15426. * N (input) INTEGER
  15427. * The order of the matrix A. N >= 0.
  15428. *
  15429. * A (input/output) DOUBLE PRECISION array, dimension (LDA, N)
  15430. * On entry, the symmetric matrix A. If UPLO = 'U', the
  15431. * leading N-by-N upper triangular part of A contains the
  15432. * upper triangular part of the matrix A. If UPLO = 'L',
  15433. * the leading N-by-N lower triangular part of A contains
  15434. * the lower triangular part of the matrix A.
  15435. * On exit, if JOBZ = 'V', then if INFO = 0, A contains the
  15436. * orthonormal eigenvectors of the matrix A.
  15437. * If JOBZ = 'N', then on exit the lower triangle (if UPLO='L')
  15438. * or the upper triangle (if UPLO='U') of A, including the
  15439. * diagonal, is destroyed.
  15440. *
  15441. * LDA (input) INTEGER
  15442. * The leading dimension of the array A. LDA >= max(1,N).
  15443. *
  15444. * W (output) DOUBLE PRECISION array, dimension (N)
  15445. * If INFO = 0, the eigenvalues in ascending order.
  15446. *
  15447. * WORK (workspace/output) DOUBLE PRECISION array,
  15448. * dimension (LWORK)
  15449. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  15450. *
  15451. * LWORK (input) INTEGER
  15452. * The dimension of the array WORK.
  15453. * If N <= 1, LWORK must be at least 1.
  15454. * If JOBZ = 'N' and N > 1, LWORK must be at least 2*N+1.
  15455. * If JOBZ = 'V' and N > 1, LWORK must be at least
  15456. * 1 + 6*N + 2*N**2.
  15457. *
  15458. * If LWORK = -1, then a workspace query is assumed; the routine
  15459. * only calculates the optimal sizes of the WORK and IWORK
  15460. * arrays, returns these values as the first entries of the WORK
  15461. * and IWORK arrays, and no error message related to LWORK or
  15462. * LIWORK is issued by XERBLA.
  15463. *
  15464. * IWORK (workspace/output) INTEGER array, dimension (MAX(1,LIWORK))
  15465. * On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK.
  15466. *
  15467. * LIWORK (input) INTEGER
  15468. * The dimension of the array IWORK.
  15469. * If N <= 1, LIWORK must be at least 1.
  15470. * If JOBZ = 'N' and N > 1, LIWORK must be at least 1.
  15471. * If JOBZ = 'V' and N > 1, LIWORK must be at least 3 + 5*N.
  15472. *
  15473. * If LIWORK = -1, then a workspace query is assumed; the
  15474. * routine only calculates the optimal sizes of the WORK and
  15475. * IWORK arrays, returns these values as the first entries of
  15476. * the WORK and IWORK arrays, and no error message related to
  15477. * LWORK or LIWORK is issued by XERBLA.
  15478. *
  15479. * C++ Return value: INFO (output) INTEGER
  15480. * = 0: successful exit
  15481. * < 0: if INFO = -i, the i-th argument had an illegal value
  15482. * > 0: if INFO = i and JOBZ = 'N', then the algorithm failed
  15483. * to converge; i off-diagonal elements of an intermediate
  15484. * tridiagonal form did not converge to zero;
  15485. * if INFO = i and JOBZ = 'V', then the algorithm failed
  15486. * to compute an eigenvalue while working on the submatrix
  15487. * lying in rows and columns INFO/(N+1) through
  15488. * mod(INFO,N+1).
  15489. *
  15490. * Further Details
  15491. * ===============
  15492. *
  15493. * Based on contributions by
  15494. * Jeff Rutter, Computer Science Division, University of California
  15495. * at Berkeley, USA
  15496. * Modified by Francoise Tisseur, University of Tennessee.
  15497. *
  15498. * Modified description of INFO. Sven, 16 Feb 05.
  15499. * =====================================================================
  15500. *
  15501. * .. Parameters ..
  15502. **/
  15503. int C_DSYEVD(char jobz, char uplo, int n, double* a, int lda, double* w, double* work, int lwork, int* iwork, int liwork)
  15504. {
  15505. int info;
  15506. ::F_DSYEVD(&jobz, &uplo, &n, a, &lda, w, work, &lwork, iwork, &liwork, &info);
  15507. return info;
  15508. }
  15509. /**
  15510. * Purpose
  15511. * =======
  15512. *
  15513. * DSYEVR computes selected eigenvalues and, optionally, eigenvectors
  15514. * of a real symmetric matrix A. Eigenvalues and eigenvectors can be
  15515. * selected by specifying either a range of values or a range of
  15516. * indices for the desired eigenvalues.
  15517. *
  15518. * DSYEVR first reduces the matrix A to tridiagonal form T with a call
  15519. * to DSYTRD. Then, whenever possible, DSYEVR calls DSTEMR to compute
  15520. * the eigenspectrum using Relatively Robust Representations. DSTEMR
  15521. * computes eigenvalues by the dqds algorithm, while orthogonal
  15522. * eigenvectors are computed from various "good" L D L^T representations
  15523. * (also known as Relatively Robust Representations). Gram-Schmidt
  15524. * orthogonalization is avoided as far as possible. More specifically,
  15525. * the various steps of the algorithm are as follows.
  15526. *
  15527. * For each unreduced block (submatrix) of T,
  15528. * (a) Compute T - sigma I = L D L^T, so that L and D
  15529. * define all the wanted eigenvalues to high relative accuracy.
  15530. * This means that small relative changes in the entries of D and L
  15531. * cause only small relative changes in the eigenvalues and
  15532. * eigenvectors. The standard (unfactored) representation of the
  15533. * tridiagonal matrix T does not have this property in general.
  15534. * (b) Compute the eigenvalues to suitable accuracy.
  15535. * If the eigenvectors are desired, the algorithm attains full
  15536. * accuracy of the computed eigenvalues only right before
  15537. * the corresponding vectors have to be computed, see steps c) and d).
  15538. * (c) For each cluster of close eigenvalues, select a new
  15539. * shift close to the cluster, find a new factorization, and refine
  15540. * the shifted eigenvalues to suitable accuracy.
  15541. * (d) For each eigenvalue with a large enough relative separation compute
  15542. * the corresponding eigenvector by forming a rank revealing twisted
  15543. * factorization. Go back to (c) for any clusters that remain.
  15544. *
  15545. * The desired accuracy of the output can be specified by the input
  15546. * parameter ABSTOL.
  15547. *
  15548. * For more details, see DSTEMR's documentation and:
  15549. * - Inderjit S. Dhillon and Beresford N. Parlett: "Multiple representations
  15550. * to compute orthogonal eigenvectors of symmetric tridiagonal matrices,"
  15551. * Linear Algebra and its Applications, 387(1), pp. 1-28, August 2004.
  15552. * - Inderjit Dhillon and Beresford Parlett: "Orthogonal Eigenvectors and
  15553. * Relative Gaps," SIAM Journal on Matrix Analysis and Applications, Vol. 25,
  15554. * 2004. Also LAPACK Working Note 154.
  15555. * - Inderjit Dhillon: "A new O(n^2) algorithm for the symmetric
  15556. * tridiagonal eigenvalue/eigenvector problem",
  15557. * Computer Science Division Technical Report No. UCB/CSD-97-971,
  15558. * UC Berkeley, May 1997.
  15559. *
  15560. *
  15561. * Note 1 : DSYEVR calls DSTEMR when the full spectrum is requested
  15562. * on machines which conform to the ieee-754 floating point standard.
  15563. * DSYEVR calls DSTEBZ and SSTEIN on non-ieee machines and
  15564. * when partial spectrum requests are made.
  15565. *
  15566. * Normal execution of DSTEMR may create NaNs and infinities and
  15567. * hence may abort due to a floating point exception in environments
  15568. * which do not handle NaNs and infinities in the ieee standard default
  15569. * manner.
  15570. *
  15571. * Arguments
  15572. * =========
  15573. *
  15574. * JOBZ (input) CHARACTER*1
  15575. * = 'N': Compute eigenvalues only;
  15576. * = 'V': Compute eigenvalues and eigenvectors.
  15577. *
  15578. * RANGE (input) CHARACTER*1
  15579. * = 'A': all eigenvalues will be found.
  15580. * = 'V': all eigenvalues in the half-open interval (VL,VU]
  15581. * will be found.
  15582. * = 'I': the IL-th through IU-th eigenvalues will be found.
  15583. ********** For RANGE = 'V' or 'I' and IU - IL < N - 1, DSTEBZ and
  15584. ********** DSTEIN are called
  15585. *
  15586. * UPLO (input) CHARACTER*1
  15587. * = 'U': Upper triangle of A is stored;
  15588. * = 'L': Lower triangle of A is stored.
  15589. *
  15590. * N (input) INTEGER
  15591. * The order of the matrix A. N >= 0.
  15592. *
  15593. * A (input/output) DOUBLE PRECISION array, dimension (LDA, N)
  15594. * On entry, the symmetric matrix A. If UPLO = 'U', the
  15595. * leading N-by-N upper triangular part of A contains the
  15596. * upper triangular part of the matrix A. If UPLO = 'L',
  15597. * the leading N-by-N lower triangular part of A contains
  15598. * the lower triangular part of the matrix A.
  15599. * On exit, the lower triangle (if UPLO='L') or the upper
  15600. * triangle (if UPLO='U') of A, including the diagonal, is
  15601. * destroyed.
  15602. *
  15603. * LDA (input) INTEGER
  15604. * The leading dimension of the array A. LDA >= max(1,N).
  15605. *
  15606. * VL (input) DOUBLE PRECISION
  15607. * VU (input) DOUBLE PRECISION
  15608. * If RANGE='V', the lower and upper bounds of the interval to
  15609. * be searched for eigenvalues. VL < VU.
  15610. * Not referenced if RANGE = 'A' or 'I'.
  15611. *
  15612. * IL (input) INTEGER
  15613. * IU (input) INTEGER
  15614. * If RANGE='I', the indices (in ascending order) of the
  15615. * smallest and largest eigenvalues to be returned.
  15616. * 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
  15617. * Not referenced if RANGE = 'A' or 'V'.
  15618. *
  15619. * ABSTOL (input) DOUBLE PRECISION
  15620. * The absolute error tolerance for the eigenvalues.
  15621. * An approximate eigenvalue is accepted as converged
  15622. * when it is determined to lie in an interval [a,b]
  15623. * of width less than or equal to
  15624. *
  15625. * ABSTOL + EPS * max( |a|,|b| ) ,
  15626. *
  15627. * where EPS is the machine precision. If ABSTOL is less than
  15628. * or equal to zero, then EPS*|T| will be used in its place,
  15629. * where |T| is the 1-norm of the tridiagonal matrix obtained
  15630. * by reducing A to tridiagonal form.
  15631. *
  15632. * See "Computing Small Singular Values of Bidiagonal Matrices
  15633. * with Guaranteed High Relative Accuracy," by Demmel and
  15634. * Kahan, LAPACK Working Note #3.
  15635. *
  15636. * If high relative accuracy is important, set ABSTOL to
  15637. * DLAMCH( 'Safe minimum' ). Doing so will guarantee that
  15638. * eigenvalues are computed to high relative accuracy when
  15639. * possible in future releases. The current code does not
  15640. * make any guarantees about high relative accuracy, but
  15641. * future releases will. See J. Barlow and J. Demmel,
  15642. * "Computing Accurate Eigensystems of Scaled Diagonally
  15643. * Dominant Matrices", LAPACK Working Note #7, for a discussion
  15644. * of which matrices define their eigenvalues to high relative
  15645. * accuracy.
  15646. *
  15647. * M (output) INTEGER
  15648. * The total number of eigenvalues found. 0 <= M <= N.
  15649. * If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
  15650. *
  15651. * W (output) DOUBLE PRECISION array, dimension (N)
  15652. * The first M elements contain the selected eigenvalues in
  15653. * ascending order.
  15654. *
  15655. * Z (output) DOUBLE PRECISION array, dimension (LDZ, max(1,M))
  15656. * If JOBZ = 'V', then if INFO = 0, the first M columns of Z
  15657. * contain the orthonormal eigenvectors of the matrix A
  15658. * corresponding to the selected eigenvalues, with the i-th
  15659. * column of Z holding the eigenvector associated with W(i).
  15660. * If JOBZ = 'N', then Z is not referenced.
  15661. * Note: the user must ensure that at least max(1,M) columns are
  15662. * supplied in the array Z; if RANGE = 'V', the exact value of M
  15663. * is not known in advance and an upper bound must be used.
  15664. * Supplying N columns is always safe.
  15665. *
  15666. * LDZ (input) INTEGER
  15667. * The leading dimension of the array Z. LDZ >= 1, and if
  15668. * JOBZ = 'V', LDZ >= max(1,N).
  15669. *
  15670. * ISUPPZ (output) INTEGER array, dimension ( 2*max(1,M) )
  15671. * The support of the eigenvectors in Z, i.e., the indices
  15672. * indicating the nonzero elements in Z. The i-th eigenvector
  15673. * is nonzero only in elements ISUPPZ( 2*i-1 ) through
  15674. * ISUPPZ( 2*i ).
  15675. ********** Implemented only for RANGE = 'A' or 'I' and IU - IL = N - 1
  15676. *
  15677. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  15678. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  15679. *
  15680. * LWORK (input) INTEGER
  15681. * The dimension of the array WORK. LWORK >= max(1,26*N).
  15682. * For optimal efficiency, LWORK >= (NB+6)*N,
  15683. * where NB is the max of the blocksize for DSYTRD and DORMTR
  15684. * returned by ILAENV.
  15685. *
  15686. * If LWORK = -1, then a workspace query is assumed; the routine
  15687. * only calculates the optimal size of the WORK array, returns
  15688. * this value as the first entry of the WORK array, and no error
  15689. * message related to LWORK is issued by XERBLA.
  15690. *
  15691. * IWORK (workspace/output) INTEGER array, dimension (MAX(1,LIWORK))
  15692. * On exit, if INFO = 0, IWORK(1) returns the optimal LWORK.
  15693. *
  15694. * LIWORK (input) INTEGER
  15695. * The dimension of the array IWORK. LIWORK >= max(1,10*N).
  15696. *
  15697. * If LIWORK = -1, then a workspace query is assumed; the
  15698. * routine only calculates the optimal size of the IWORK array,
  15699. * returns this value as the first entry of the IWORK array, and
  15700. * no error message related to LIWORK is issued by XERBLA.
  15701. *
  15702. * C++ Return value: INFO (output) INTEGER
  15703. * = 0: successful exit
  15704. * < 0: if INFO = -i, the i-th argument had an illegal value
  15705. * > 0: Internal error
  15706. *
  15707. * Further Details
  15708. * ===============
  15709. *
  15710. * Based on contributions by
  15711. * Inderjit Dhillon, IBM Almaden, USA
  15712. * Osni Marques, LBNL/NERSC, USA
  15713. * Ken Stanley, Computer Science Division, University of
  15714. * California at Berkeley, USA
  15715. * Jason Riedy, Computer Science Division, University of
  15716. * California at Berkeley, USA
  15717. *
  15718. * =====================================================================
  15719. *
  15720. * .. Parameters ..
  15721. **/
  15722. int C_DSYEVR(char jobz, char range, char uplo, int n, double* a, int lda, double vl, double vu, int il, int iu, double abstol, int* m, double* w, double* z, int ldz, int* isuppz, double* work, int lwork, int* iwork, int liwork)
  15723. {
  15724. int info;
  15725. ::F_DSYEVR(&jobz, &range, &uplo, &n, a, &lda, &vl, &vu, &il, &iu, &abstol, m, w, z, &ldz, isuppz, work, &lwork, iwork, &liwork, &info);
  15726. return info;
  15727. }
  15728. /**
  15729. * Purpose
  15730. * =======
  15731. *
  15732. * DSYEVX computes selected eigenvalues and, optionally, eigenvectors
  15733. * of a real symmetric matrix A. Eigenvalues and eigenvectors can be
  15734. * selected by specifying either a range of values or a range of indices
  15735. * for the desired eigenvalues.
  15736. *
  15737. * Arguments
  15738. * =========
  15739. *
  15740. * JOBZ (input) CHARACTER*1
  15741. * = 'N': Compute eigenvalues only;
  15742. * = 'V': Compute eigenvalues and eigenvectors.
  15743. *
  15744. * RANGE (input) CHARACTER*1
  15745. * = 'A': all eigenvalues will be found.
  15746. * = 'V': all eigenvalues in the half-open interval (VL,VU]
  15747. * will be found.
  15748. * = 'I': the IL-th through IU-th eigenvalues will be found.
  15749. *
  15750. * UPLO (input) CHARACTER*1
  15751. * = 'U': Upper triangle of A is stored;
  15752. * = 'L': Lower triangle of A is stored.
  15753. *
  15754. * N (input) INTEGER
  15755. * The order of the matrix A. N >= 0.
  15756. *
  15757. * A (input/output) DOUBLE PRECISION array, dimension (LDA, N)
  15758. * On entry, the symmetric matrix A. If UPLO = 'U', the
  15759. * leading N-by-N upper triangular part of A contains the
  15760. * upper triangular part of the matrix A. If UPLO = 'L',
  15761. * the leading N-by-N lower triangular part of A contains
  15762. * the lower triangular part of the matrix A.
  15763. * On exit, the lower triangle (if UPLO='L') or the upper
  15764. * triangle (if UPLO='U') of A, including the diagonal, is
  15765. * destroyed.
  15766. *
  15767. * LDA (input) INTEGER
  15768. * The leading dimension of the array A. LDA >= max(1,N).
  15769. *
  15770. * VL (input) DOUBLE PRECISION
  15771. * VU (input) DOUBLE PRECISION
  15772. * If RANGE='V', the lower and upper bounds of the interval to
  15773. * be searched for eigenvalues. VL < VU.
  15774. * Not referenced if RANGE = 'A' or 'I'.
  15775. *
  15776. * IL (input) INTEGER
  15777. * IU (input) INTEGER
  15778. * If RANGE='I', the indices (in ascending order) of the
  15779. * smallest and largest eigenvalues to be returned.
  15780. * 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
  15781. * Not referenced if RANGE = 'A' or 'V'.
  15782. *
  15783. * ABSTOL (input) DOUBLE PRECISION
  15784. * The absolute error tolerance for the eigenvalues.
  15785. * An approximate eigenvalue is accepted as converged
  15786. * when it is determined to lie in an interval [a,b]
  15787. * of width less than or equal to
  15788. *
  15789. * ABSTOL + EPS * max( |a|,|b| ) ,
  15790. *
  15791. * where EPS is the machine precision. If ABSTOL is less than
  15792. * or equal to zero, then EPS*|T| will be used in its place,
  15793. * where |T| is the 1-norm of the tridiagonal matrix obtained
  15794. * by reducing A to tridiagonal form.
  15795. *
  15796. * Eigenvalues will be computed most accurately when ABSTOL is
  15797. * set to twice the underflow threshold 2*DLAMCH('S'), not zero.
  15798. * If this routine returns with INFO>0, indicating that some
  15799. * eigenvectors did not converge, try setting ABSTOL to
  15800. * 2*DLAMCH('S').
  15801. *
  15802. * See "Computing Small Singular Values of Bidiagonal Matrices
  15803. * with Guaranteed High Relative Accuracy," by Demmel and
  15804. * Kahan, LAPACK Working Note #3.
  15805. *
  15806. * M (output) INTEGER
  15807. * The total number of eigenvalues found. 0 <= M <= N.
  15808. * If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
  15809. *
  15810. * W (output) DOUBLE PRECISION array, dimension (N)
  15811. * On normal exit, the first M elements contain the selected
  15812. * eigenvalues in ascending order.
  15813. *
  15814. * Z (output) DOUBLE PRECISION array, dimension (LDZ, max(1,M))
  15815. * If JOBZ = 'V', then if INFO = 0, the first M columns of Z
  15816. * contain the orthonormal eigenvectors of the matrix A
  15817. * corresponding to the selected eigenvalues, with the i-th
  15818. * column of Z holding the eigenvector associated with W(i).
  15819. * If an eigenvector fails to converge, then that column of Z
  15820. * contains the latest approximation to the eigenvector, and the
  15821. * index of the eigenvector is returned in IFAIL.
  15822. * If JOBZ = 'N', then Z is not referenced.
  15823. * Note: the user must ensure that at least max(1,M) columns are
  15824. * supplied in the array Z; if RANGE = 'V', the exact value of M
  15825. * is not known in advance and an upper bound must be used.
  15826. *
  15827. * LDZ (input) INTEGER
  15828. * The leading dimension of the array Z. LDZ >= 1, and if
  15829. * JOBZ = 'V', LDZ >= max(1,N).
  15830. *
  15831. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  15832. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  15833. *
  15834. * LWORK (input) INTEGER
  15835. * The length of the array WORK. LWORK >= 1, when N <= 1;
  15836. * otherwise 8*N.
  15837. * For optimal efficiency, LWORK >= (NB+3)*N,
  15838. * where NB is the max of the blocksize for DSYTRD and DORMTR
  15839. * returned by ILAENV.
  15840. *
  15841. * If LWORK = -1, then a workspace query is assumed; the routine
  15842. * only calculates the optimal size of the WORK array, returns
  15843. * this value as the first entry of the WORK array, and no error
  15844. * message related to LWORK is issued by XERBLA.
  15845. *
  15846. * IWORK (workspace) INTEGER array, dimension (5*N)
  15847. *
  15848. * IFAIL (output) INTEGER array, dimension (N)
  15849. * If JOBZ = 'V', then if INFO = 0, the first M elements of
  15850. * IFAIL are zero. If INFO > 0, then IFAIL contains the
  15851. * indices of the eigenvectors that failed to converge.
  15852. * If JOBZ = 'N', then IFAIL is not referenced.
  15853. *
  15854. * C++ Return value: INFO (output) INTEGER
  15855. * = 0: successful exit
  15856. * < 0: if INFO = -i, the i-th argument had an illegal value
  15857. * > 0: if INFO = i, then i eigenvectors failed to converge.
  15858. * Their indices are stored in array IFAIL.
  15859. *
  15860. * =====================================================================
  15861. *
  15862. * .. Parameters ..
  15863. **/
  15864. int C_DSYEVX(char jobz, char range, char uplo, int n, double* a, int lda, double vl, double vu, int il, int iu, double abstol, int* m, double* w, double* z, int ldz, double* work, int lwork, int* iwork, int* ifail)
  15865. {
  15866. int info;
  15867. ::F_DSYEVX(&jobz, &range, &uplo, &n, a, &lda, &vl, &vu, &il, &iu, &abstol, m, w, z, &ldz, work, &lwork, iwork, ifail, &info);
  15868. return info;
  15869. }
  15870. /**
  15871. * Purpose
  15872. * =======
  15873. *
  15874. * DSYGST reduces a real symmetric-definite generalized eigenproblem
  15875. * to standard form.
  15876. *
  15877. * If ITYPE = 1, the problem is A*x = lambda*B*x,
  15878. * and A is overwritten by inv(U**T)*A*inv(U) or inv(L)*A*inv(L**T)
  15879. *
  15880. * If ITYPE = 2 or 3, the problem is A*B*x = lambda*x or
  15881. * B*A*x = lambda*x, and A is overwritten by U*A*U**T or L**T*A*L.
  15882. *
  15883. * B must have been previously factorized as U**T*U or L*L**T by DPOTRF.
  15884. *
  15885. * Arguments
  15886. * =========
  15887. *
  15888. * ITYPE (input) INTEGER
  15889. * = 1: compute inv(U**T)*A*inv(U) or inv(L)*A*inv(L**T);
  15890. * = 2 or 3: compute U*A*U**T or L**T*A*L.
  15891. *
  15892. * UPLO (input) CHARACTER*1
  15893. * = 'U': Upper triangle of A is stored and B is factored as
  15894. * U**T*U;
  15895. * = 'L': Lower triangle of A is stored and B is factored as
  15896. * L*L**T.
  15897. *
  15898. * N (input) INTEGER
  15899. * The order of the matrices A and B. N >= 0.
  15900. *
  15901. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  15902. * On entry, the symmetric matrix A. If UPLO = 'U', the leading
  15903. * N-by-N upper triangular part of A contains the upper
  15904. * triangular part of the matrix A, and the strictly lower
  15905. * triangular part of A is not referenced. If UPLO = 'L', the
  15906. * leading N-by-N lower triangular part of A contains the lower
  15907. * triangular part of the matrix A, and the strictly upper
  15908. * triangular part of A is not referenced.
  15909. *
  15910. * On exit, if INFO = 0, the transformed matrix, stored in the
  15911. * same format as A.
  15912. *
  15913. * LDA (input) INTEGER
  15914. * The leading dimension of the array A. LDA >= max(1,N).
  15915. *
  15916. * B (input) DOUBLE PRECISION array, dimension (LDB,N)
  15917. * The triangular factor from the Cholesky factorization of B,
  15918. * as returned by DPOTRF.
  15919. *
  15920. * LDB (input) INTEGER
  15921. * The leading dimension of the array B. LDB >= max(1,N).
  15922. *
  15923. * C++ Return value: INFO (output) INTEGER
  15924. * = 0: successful exit
  15925. * < 0: if INFO = -i, the i-th argument had an illegal value
  15926. *
  15927. * =====================================================================
  15928. *
  15929. * .. Parameters ..
  15930. **/
  15931. int C_DSYGST(int itype, char uplo, int n, double* a, int lda, double* b, int ldb)
  15932. {
  15933. int info;
  15934. ::F_DSYGST(&itype, &uplo, &n, a, &lda, b, &ldb, &info);
  15935. return info;
  15936. }
  15937. /**
  15938. * Purpose
  15939. * =======
  15940. *
  15941. * DSYGV computes all the eigenvalues, and optionally, the eigenvectors
  15942. * of a real generalized symmetric-definite eigenproblem, of the form
  15943. * A*x=(lambda)*B*x, A*Bx=(lambda)*x, or B*A*x=(lambda)*x.
  15944. * Here A and B are assumed to be symmetric and B is also
  15945. * positive definite.
  15946. *
  15947. * Arguments
  15948. * =========
  15949. *
  15950. * ITYPE (input) INTEGER
  15951. * Specifies the problem type to be solved:
  15952. * = 1: A*x = (lambda)*B*x
  15953. * = 2: A*B*x = (lambda)*x
  15954. * = 3: B*A*x = (lambda)*x
  15955. *
  15956. * JOBZ (input) CHARACTER*1
  15957. * = 'N': Compute eigenvalues only;
  15958. * = 'V': Compute eigenvalues and eigenvectors.
  15959. *
  15960. * UPLO (input) CHARACTER*1
  15961. * = 'U': Upper triangles of A and B are stored;
  15962. * = 'L': Lower triangles of A and B are stored.
  15963. *
  15964. * N (input) INTEGER
  15965. * The order of the matrices A and B. N >= 0.
  15966. *
  15967. * A (input/output) DOUBLE PRECISION array, dimension (LDA, N)
  15968. * On entry, the symmetric matrix A. If UPLO = 'U', the
  15969. * leading N-by-N upper triangular part of A contains the
  15970. * upper triangular part of the matrix A. If UPLO = 'L',
  15971. * the leading N-by-N lower triangular part of A contains
  15972. * the lower triangular part of the matrix A.
  15973. *
  15974. * On exit, if JOBZ = 'V', then if INFO = 0, A contains the
  15975. * matrix Z of eigenvectors. The eigenvectors are normalized
  15976. * as follows:
  15977. * if ITYPE = 1 or 2, Z**T*B*Z = I;
  15978. * if ITYPE = 3, Z**T*inv(B)*Z = I.
  15979. * If JOBZ = 'N', then on exit the upper triangle (if UPLO='U')
  15980. * or the lower triangle (if UPLO='L') of A, including the
  15981. * diagonal, is destroyed.
  15982. *
  15983. * LDA (input) INTEGER
  15984. * The leading dimension of the array A. LDA >= max(1,N).
  15985. *
  15986. * B (input/output) DOUBLE PRECISION array, dimension (LDB, N)
  15987. * On entry, the symmetric positive definite matrix B.
  15988. * If UPLO = 'U', the leading N-by-N upper triangular part of B
  15989. * contains the upper triangular part of the matrix B.
  15990. * If UPLO = 'L', the leading N-by-N lower triangular part of B
  15991. * contains the lower triangular part of the matrix B.
  15992. *
  15993. * On exit, if INFO <= N, the part of B containing the matrix is
  15994. * overwritten by the triangular factor U or L from the Cholesky
  15995. * factorization B = U**T*U or B = L*L**T.
  15996. *
  15997. * LDB (input) INTEGER
  15998. * The leading dimension of the array B. LDB >= max(1,N).
  15999. *
  16000. * W (output) DOUBLE PRECISION array, dimension (N)
  16001. * If INFO = 0, the eigenvalues in ascending order.
  16002. *
  16003. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  16004. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  16005. *
  16006. * LWORK (input) INTEGER
  16007. * The length of the array WORK. LWORK >= max(1,3*N-1).
  16008. * For optimal efficiency, LWORK >= (NB+2)*N,
  16009. * where NB is the blocksize for DSYTRD returned by ILAENV.
  16010. *
  16011. * If LWORK = -1, then a workspace query is assumed; the routine
  16012. * only calculates the optimal size of the WORK array, returns
  16013. * this value as the first entry of the WORK array, and no error
  16014. * message related to LWORK is issued by XERBLA.
  16015. *
  16016. * C++ Return value: INFO (output) INTEGER
  16017. * = 0: successful exit
  16018. * < 0: if INFO = -i, the i-th argument had an illegal value
  16019. * > 0: DPOTRF or DSYEV returned an error code:
  16020. * <= N: if INFO = i, DSYEV failed to converge;
  16021. * i off-diagonal elements of an intermediate
  16022. * tridiagonal form did not converge to zero;
  16023. * > N: if INFO = N + i, for 1 <= i <= N, then the leading
  16024. * minor of order i of B is not positive definite.
  16025. * The factorization of B could not be completed and
  16026. * no eigenvalues or eigenvectors were computed.
  16027. *
  16028. * =====================================================================
  16029. *
  16030. * .. Parameters ..
  16031. **/
  16032. int C_DSYGV(int itype, char jobz, char uplo, int n, double* a, int lda, double* b, int ldb, double* w, double* work, int lwork)
  16033. {
  16034. int info;
  16035. ::F_DSYGV(&itype, &jobz, &uplo, &n, a, &lda, b, &ldb, w, work, &lwork, &info);
  16036. return info;
  16037. }
  16038. /**
  16039. * Purpose
  16040. * =======
  16041. *
  16042. * DSYGVD computes all the eigenvalues, and optionally, the eigenvectors
  16043. * of a real generalized symmetric-definite eigenproblem, of the form
  16044. * A*x=(lambda)*B*x, A*Bx=(lambda)*x, or B*A*x=(lambda)*x. Here A and
  16045. * B are assumed to be symmetric and B is also positive definite.
  16046. * If eigenvectors are desired, it uses a divide and conquer algorithm.
  16047. *
  16048. * The divide and conquer algorithm makes very mild assumptions about
  16049. * floating point arithmetic. It will work on machines with a guard
  16050. * digit in add/subtract, or on those binary machines without guard
  16051. * digits which subtract like the Cray X-MP, Cray Y-MP, Cray C-90, or
  16052. * Cray-2. It could conceivably fail on hexadecimal or decimal machines
  16053. * without guard digits, but we know of none.
  16054. *
  16055. * Arguments
  16056. * =========
  16057. *
  16058. * ITYPE (input) INTEGER
  16059. * Specifies the problem type to be solved:
  16060. * = 1: A*x = (lambda)*B*x
  16061. * = 2: A*B*x = (lambda)*x
  16062. * = 3: B*A*x = (lambda)*x
  16063. *
  16064. * JOBZ (input) CHARACTER*1
  16065. * = 'N': Compute eigenvalues only;
  16066. * = 'V': Compute eigenvalues and eigenvectors.
  16067. *
  16068. * UPLO (input) CHARACTER*1
  16069. * = 'U': Upper triangles of A and B are stored;
  16070. * = 'L': Lower triangles of A and B are stored.
  16071. *
  16072. * N (input) INTEGER
  16073. * The order of the matrices A and B. N >= 0.
  16074. *
  16075. * A (input/output) DOUBLE PRECISION array, dimension (LDA, N)
  16076. * On entry, the symmetric matrix A. If UPLO = 'U', the
  16077. * leading N-by-N upper triangular part of A contains the
  16078. * upper triangular part of the matrix A. If UPLO = 'L',
  16079. * the leading N-by-N lower triangular part of A contains
  16080. * the lower triangular part of the matrix A.
  16081. *
  16082. * On exit, if JOBZ = 'V', then if INFO = 0, A contains the
  16083. * matrix Z of eigenvectors. The eigenvectors are normalized
  16084. * as follows:
  16085. * if ITYPE = 1 or 2, Z**T*B*Z = I;
  16086. * if ITYPE = 3, Z**T*inv(B)*Z = I.
  16087. * If JOBZ = 'N', then on exit the upper triangle (if UPLO='U')
  16088. * or the lower triangle (if UPLO='L') of A, including the
  16089. * diagonal, is destroyed.
  16090. *
  16091. * LDA (input) INTEGER
  16092. * The leading dimension of the array A. LDA >= max(1,N).
  16093. *
  16094. * B (input/output) DOUBLE PRECISION array, dimension (LDB, N)
  16095. * On entry, the symmetric matrix B. If UPLO = 'U', the
  16096. * leading N-by-N upper triangular part of B contains the
  16097. * upper triangular part of the matrix B. If UPLO = 'L',
  16098. * the leading N-by-N lower triangular part of B contains
  16099. * the lower triangular part of the matrix B.
  16100. *
  16101. * On exit, if INFO <= N, the part of B containing the matrix is
  16102. * overwritten by the triangular factor U or L from the Cholesky
  16103. * factorization B = U**T*U or B = L*L**T.
  16104. *
  16105. * LDB (input) INTEGER
  16106. * The leading dimension of the array B. LDB >= max(1,N).
  16107. *
  16108. * W (output) DOUBLE PRECISION array, dimension (N)
  16109. * If INFO = 0, the eigenvalues in ascending order.
  16110. *
  16111. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  16112. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  16113. *
  16114. * LWORK (input) INTEGER
  16115. * The dimension of the array WORK.
  16116. * If N <= 1, LWORK >= 1.
  16117. * If JOBZ = 'N' and N > 1, LWORK >= 2*N+1.
  16118. * If JOBZ = 'V' and N > 1, LWORK >= 1 + 6*N + 2*N**2.
  16119. *
  16120. * If LWORK = -1, then a workspace query is assumed; the routine
  16121. * only calculates the optimal sizes of the WORK and IWORK
  16122. * arrays, returns these values as the first entries of the WORK
  16123. * and IWORK arrays, and no error message related to LWORK or
  16124. * LIWORK is issued by XERBLA.
  16125. *
  16126. * IWORK (workspace/output) INTEGER array, dimension (MAX(1,LIWORK))
  16127. * On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK.
  16128. *
  16129. * LIWORK (input) INTEGER
  16130. * The dimension of the array IWORK.
  16131. * If N <= 1, LIWORK >= 1.
  16132. * If JOBZ = 'N' and N > 1, LIWORK >= 1.
  16133. * If JOBZ = 'V' and N > 1, LIWORK >= 3 + 5*N.
  16134. *
  16135. * If LIWORK = -1, then a workspace query is assumed; the
  16136. * routine only calculates the optimal sizes of the WORK and
  16137. * IWORK arrays, returns these values as the first entries of
  16138. * the WORK and IWORK arrays, and no error message related to
  16139. * LWORK or LIWORK is issued by XERBLA.
  16140. *
  16141. * C++ Return value: INFO (output) INTEGER
  16142. * = 0: successful exit
  16143. * < 0: if INFO = -i, the i-th argument had an illegal value
  16144. * > 0: DPOTRF or DSYEVD returned an error code:
  16145. * <= N: if INFO = i and JOBZ = 'N', then the algorithm
  16146. * failed to converge; i off-diagonal elements of an
  16147. * intermediate tridiagonal form did not converge to
  16148. * zero;
  16149. * if INFO = i and JOBZ = 'V', then the algorithm
  16150. * failed to compute an eigenvalue while working on
  16151. * the submatrix lying in rows and columns INFO/(N+1)
  16152. * through mod(INFO,N+1);
  16153. * > N: if INFO = N + i, for 1 <= i <= N, then the leading
  16154. * minor of order i of B is not positive definite.
  16155. * The factorization of B could not be completed and
  16156. * no eigenvalues or eigenvectors were computed.
  16157. *
  16158. * Further Details
  16159. * ===============
  16160. *
  16161. * Based on contributions by
  16162. * Mark Fahey, Department of Mathematics, Univ. of Kentucky, USA
  16163. *
  16164. * Modified so that no backsubstitution is performed if DSYEVD fails to
  16165. * converge (NEIG in old code could be greater than N causing out of
  16166. * bounds reference to A - reported by Ralf Meyer). Also corrected the
  16167. * description of INFO and the test on ITYPE. Sven, 16 Feb 05.
  16168. * =====================================================================
  16169. *
  16170. * .. Parameters ..
  16171. **/
  16172. int C_DSYGVD(int itype, char jobz, char uplo, int n, double* a, int lda, double* b, int ldb, double* w, double* work, int lwork, int* iwork, int liwork)
  16173. {
  16174. int info;
  16175. ::F_DSYGVD(&itype, &jobz, &uplo, &n, a, &lda, b, &ldb, w, work, &lwork, iwork, &liwork, &info);
  16176. return info;
  16177. }
  16178. /**
  16179. * Purpose
  16180. * =======
  16181. *
  16182. * DSYGVX computes selected eigenvalues, and optionally, eigenvectors
  16183. * of a real generalized symmetric-definite eigenproblem, of the form
  16184. * A*x=(lambda)*B*x, A*Bx=(lambda)*x, or B*A*x=(lambda)*x. Here A
  16185. * and B are assumed to be symmetric and B is also positive definite.
  16186. * Eigenvalues and eigenvectors can be selected by specifying either a
  16187. * range of values or a range of indices for the desired eigenvalues.
  16188. *
  16189. * Arguments
  16190. * =========
  16191. *
  16192. * ITYPE (input) INTEGER
  16193. * Specifies the problem type to be solved:
  16194. * = 1: A*x = (lambda)*B*x
  16195. * = 2: A*B*x = (lambda)*x
  16196. * = 3: B*A*x = (lambda)*x
  16197. *
  16198. * JOBZ (input) CHARACTER*1
  16199. * = 'N': Compute eigenvalues only;
  16200. * = 'V': Compute eigenvalues and eigenvectors.
  16201. *
  16202. * RANGE (input) CHARACTER*1
  16203. * = 'A': all eigenvalues will be found.
  16204. * = 'V': all eigenvalues in the half-open interval (VL,VU]
  16205. * will be found.
  16206. * = 'I': the IL-th through IU-th eigenvalues will be found.
  16207. *
  16208. * UPLO (input) CHARACTER*1
  16209. * = 'U': Upper triangle of A and B are stored;
  16210. * = 'L': Lower triangle of A and B are stored.
  16211. *
  16212. * N (input) INTEGER
  16213. * The order of the matrix pencil (A,B). N >= 0.
  16214. *
  16215. * A (input/output) DOUBLE PRECISION array, dimension (LDA, N)
  16216. * On entry, the symmetric matrix A. If UPLO = 'U', the
  16217. * leading N-by-N upper triangular part of A contains the
  16218. * upper triangular part of the matrix A. If UPLO = 'L',
  16219. * the leading N-by-N lower triangular part of A contains
  16220. * the lower triangular part of the matrix A.
  16221. *
  16222. * On exit, the lower triangle (if UPLO='L') or the upper
  16223. * triangle (if UPLO='U') of A, including the diagonal, is
  16224. * destroyed.
  16225. *
  16226. * LDA (input) INTEGER
  16227. * The leading dimension of the array A. LDA >= max(1,N).
  16228. *
  16229. * B (input/output) DOUBLE PRECISION array, dimension (LDB, N)
  16230. * On entry, the symmetric matrix B. If UPLO = 'U', the
  16231. * leading N-by-N upper triangular part of B contains the
  16232. * upper triangular part of the matrix B. If UPLO = 'L',
  16233. * the leading N-by-N lower triangular part of B contains
  16234. * the lower triangular part of the matrix B.
  16235. *
  16236. * On exit, if INFO <= N, the part of B containing the matrix is
  16237. * overwritten by the triangular factor U or L from the Cholesky
  16238. * factorization B = U**T*U or B = L*L**T.
  16239. *
  16240. * LDB (input) INTEGER
  16241. * The leading dimension of the array B. LDB >= max(1,N).
  16242. *
  16243. * VL (input) DOUBLE PRECISION
  16244. * VU (input) DOUBLE PRECISION
  16245. * If RANGE='V', the lower and upper bounds of the interval to
  16246. * be searched for eigenvalues. VL < VU.
  16247. * Not referenced if RANGE = 'A' or 'I'.
  16248. *
  16249. * IL (input) INTEGER
  16250. * IU (input) INTEGER
  16251. * If RANGE='I', the indices (in ascending order) of the
  16252. * smallest and largest eigenvalues to be returned.
  16253. * 1 <= IL <= IU <= N, if N > 0; IL = 1 and IU = 0 if N = 0.
  16254. * Not referenced if RANGE = 'A' or 'V'.
  16255. *
  16256. * ABSTOL (input) DOUBLE PRECISION
  16257. * The absolute error tolerance for the eigenvalues.
  16258. * An approximate eigenvalue is accepted as converged
  16259. * when it is determined to lie in an interval [a,b]
  16260. * of width less than or equal to
  16261. *
  16262. * ABSTOL + EPS * max( |a|,|b| ) ,
  16263. *
  16264. * where EPS is the machine precision. If ABSTOL is less than
  16265. * or equal to zero, then EPS*|T| will be used in its place,
  16266. * where |T| is the 1-norm of the tridiagonal matrix obtained
  16267. * by reducing A to tridiagonal form.
  16268. *
  16269. * Eigenvalues will be computed most accurately when ABSTOL is
  16270. * set to twice the underflow threshold 2*DLAMCH('S'), not zero.
  16271. * If this routine returns with INFO>0, indicating that some
  16272. * eigenvectors did not converge, try setting ABSTOL to
  16273. * 2*DLAMCH('S').
  16274. *
  16275. * M (output) INTEGER
  16276. * The total number of eigenvalues found. 0 <= M <= N.
  16277. * If RANGE = 'A', M = N, and if RANGE = 'I', M = IU-IL+1.
  16278. *
  16279. * W (output) DOUBLE PRECISION array, dimension (N)
  16280. * On normal exit, the first M elements contain the selected
  16281. * eigenvalues in ascending order.
  16282. *
  16283. * Z (output) DOUBLE PRECISION array, dimension (LDZ, max(1,M))
  16284. * If JOBZ = 'N', then Z is not referenced.
  16285. * If JOBZ = 'V', then if INFO = 0, the first M columns of Z
  16286. * contain the orthonormal eigenvectors of the matrix A
  16287. * corresponding to the selected eigenvalues, with the i-th
  16288. * column of Z holding the eigenvector associated with W(i).
  16289. * The eigenvectors are normalized as follows:
  16290. * if ITYPE = 1 or 2, Z**T*B*Z = I;
  16291. * if ITYPE = 3, Z**T*inv(B)*Z = I.
  16292. *
  16293. * If an eigenvector fails to converge, then that column of Z
  16294. * contains the latest approximation to the eigenvector, and the
  16295. * index of the eigenvector is returned in IFAIL.
  16296. * Note: the user must ensure that at least max(1,M) columns are
  16297. * supplied in the array Z; if RANGE = 'V', the exact value of M
  16298. * is not known in advance and an upper bound must be used.
  16299. *
  16300. * LDZ (input) INTEGER
  16301. * The leading dimension of the array Z. LDZ >= 1, and if
  16302. * JOBZ = 'V', LDZ >= max(1,N).
  16303. *
  16304. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  16305. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  16306. *
  16307. * LWORK (input) INTEGER
  16308. * The length of the array WORK. LWORK >= max(1,8*N).
  16309. * For optimal efficiency, LWORK >= (NB+3)*N,
  16310. * where NB is the blocksize for DSYTRD returned by ILAENV.
  16311. *
  16312. * If LWORK = -1, then a workspace query is assumed; the routine
  16313. * only calculates the optimal size of the WORK array, returns
  16314. * this value as the first entry of the WORK array, and no error
  16315. * message related to LWORK is issued by XERBLA.
  16316. *
  16317. * IWORK (workspace) INTEGER array, dimension (5*N)
  16318. *
  16319. * IFAIL (output) INTEGER array, dimension (N)
  16320. * If JOBZ = 'V', then if INFO = 0, the first M elements of
  16321. * IFAIL are zero. If INFO > 0, then IFAIL contains the
  16322. * indices of the eigenvectors that failed to converge.
  16323. * If JOBZ = 'N', then IFAIL is not referenced.
  16324. *
  16325. * C++ Return value: INFO (output) INTEGER
  16326. * = 0: successful exit
  16327. * < 0: if INFO = -i, the i-th argument had an illegal value
  16328. * > 0: DPOTRF or DSYEVX returned an error code:
  16329. * <= N: if INFO = i, DSYEVX failed to converge;
  16330. * i eigenvectors failed to converge. Their indices
  16331. * are stored in array IFAIL.
  16332. * > N: if INFO = N + i, for 1 <= i <= N, then the leading
  16333. * minor of order i of B is not positive definite.
  16334. * The factorization of B could not be completed and
  16335. * no eigenvalues or eigenvectors were computed.
  16336. *
  16337. * Further Details
  16338. * ===============
  16339. *
  16340. * Based on contributions by
  16341. * Mark Fahey, Department of Mathematics, Univ. of Kentucky, USA
  16342. *
  16343. * =====================================================================
  16344. *
  16345. * .. Parameters ..
  16346. **/
  16347. int C_DSYGVX(int itype, char jobz, char range, char uplo, int n, double* a, int lda, double* b, int ldb, double vl, double vu, int il, int iu, double abstol, int* m, double* w, double* z, int ldz, double* work, int lwork, int* iwork, int* ifail)
  16348. {
  16349. int info;
  16350. ::F_DSYGVX(&itype, &jobz, &range, &uplo, &n, a, &lda, b, &ldb, &vl, &vu, &il, &iu, &abstol, m, w, z, &ldz, work, &lwork, iwork, ifail, &info);
  16351. return info;
  16352. }
  16353. /**
  16354. * Purpose
  16355. * =======
  16356. *
  16357. * DSYRFS improves the computed solution to a system of linear
  16358. * equations when the coefficient matrix is symmetric indefinite, and
  16359. * provides error bounds and backward error estimates for the solution.
  16360. *
  16361. * Arguments
  16362. * =========
  16363. *
  16364. * UPLO (input) CHARACTER*1
  16365. * = 'U': Upper triangle of A is stored;
  16366. * = 'L': Lower triangle of A is stored.
  16367. *
  16368. * N (input) INTEGER
  16369. * The order of the matrix A. N >= 0.
  16370. *
  16371. * NRHS (input) INTEGER
  16372. * The number of right hand sides, i.e., the number of columns
  16373. * of the matrices B and X. NRHS >= 0.
  16374. *
  16375. * A (input) DOUBLE PRECISION array, dimension (LDA,N)
  16376. * The symmetric matrix A. If UPLO = 'U', the leading N-by-N
  16377. * upper triangular part of A contains the upper triangular part
  16378. * of the matrix A, and the strictly lower triangular part of A
  16379. * is not referenced. If UPLO = 'L', the leading N-by-N lower
  16380. * triangular part of A contains the lower triangular part of
  16381. * the matrix A, and the strictly upper triangular part of A is
  16382. * not referenced.
  16383. *
  16384. * LDA (input) INTEGER
  16385. * The leading dimension of the array A. LDA >= max(1,N).
  16386. *
  16387. * AF (input) DOUBLE PRECISION array, dimension (LDAF,N)
  16388. * The factored form of the matrix A. AF contains the block
  16389. * diagonal matrix D and the multipliers used to obtain the
  16390. * factor U or L from the factorization A = U*D*U**T or
  16391. * A = L*D*L**T as computed by DSYTRF.
  16392. *
  16393. * LDAF (input) INTEGER
  16394. * The leading dimension of the array AF. LDAF >= max(1,N).
  16395. *
  16396. * IPIV (input) INTEGER array, dimension (N)
  16397. * Details of the interchanges and the block structure of D
  16398. * as determined by DSYTRF.
  16399. *
  16400. * B (input) DOUBLE PRECISION array, dimension (LDB,NRHS)
  16401. * The right hand side matrix B.
  16402. *
  16403. * LDB (input) INTEGER
  16404. * The leading dimension of the array B. LDB >= max(1,N).
  16405. *
  16406. * X (input/output) DOUBLE PRECISION array, dimension (LDX,NRHS)
  16407. * On entry, the solution matrix X, as computed by DSYTRS.
  16408. * On exit, the improved solution matrix X.
  16409. *
  16410. * LDX (input) INTEGER
  16411. * The leading dimension of the array X. LDX >= max(1,N).
  16412. *
  16413. * FERR (output) DOUBLE PRECISION array, dimension (NRHS)
  16414. * The estimated forward error bound for each solution vector
  16415. * X(j) (the j-th column of the solution matrix X).
  16416. * If XTRUE is the true solution corresponding to X(j), FERR(j)
  16417. * is an estimated upper bound for the magnitude of the largest
  16418. * element in (X(j) - XTRUE) divided by the magnitude of the
  16419. * largest element in X(j). The estimate is as reliable as
  16420. * the estimate for RCOND, and is almost always a slight
  16421. * overestimate of the true error.
  16422. *
  16423. * BERR (output) DOUBLE PRECISION array, dimension (NRHS)
  16424. * The componentwise relative backward error of each solution
  16425. * vector X(j) (i.e., the smallest relative change in
  16426. * any element of A or B that makes X(j) an exact solution).
  16427. *
  16428. * WORK (workspace) DOUBLE PRECISION array, dimension (3*N)
  16429. *
  16430. * IWORK (workspace) INTEGER array, dimension (N)
  16431. *
  16432. * C++ Return value: INFO (output) INTEGER
  16433. * = 0: successful exit
  16434. * < 0: if INFO = -i, the i-th argument had an illegal value
  16435. *
  16436. * Internal Parameters
  16437. * ===================
  16438. *
  16439. * ITMAX is the maximum number of steps of iterative refinement.
  16440. *
  16441. * =====================================================================
  16442. *
  16443. * .. Parameters ..
  16444. **/
  16445. int C_DSYRFS(char uplo, int n, int nrhs, double* a, int lda, double* af, int ldaf, int* ipiv, double* b, int ldb, double* x, int ldx, double* ferr, double* berr, double* work, int* iwork)
  16446. {
  16447. int info;
  16448. ::F_DSYRFS(&uplo, &n, &nrhs, a, &lda, af, &ldaf, ipiv, b, &ldb, x, &ldx, ferr, berr, work, iwork, &info);
  16449. return info;
  16450. }
  16451. /**
  16452. * Purpose
  16453. * =======
  16454. *
  16455. * DSYSV computes the solution to a real system of linear equations
  16456. * A * X = B,
  16457. * where A is an N-by-N symmetric matrix and X and B are N-by-NRHS
  16458. * matrices.
  16459. *
  16460. * The diagonal pivoting method is used to factor A as
  16461. * A = U * D * U**T, if UPLO = 'U', or
  16462. * A = L * D * L**T, if UPLO = 'L',
  16463. * where U (or L) is a product of permutation and unit upper (lower)
  16464. * triangular matrices, and D is symmetric and block diagonal with
  16465. * 1-by-1 and 2-by-2 diagonal blocks. The factored form of A is then
  16466. * used to solve the system of equations A * X = B.
  16467. *
  16468. * Arguments
  16469. * =========
  16470. *
  16471. * UPLO (input) CHARACTER*1
  16472. * = 'U': Upper triangle of A is stored;
  16473. * = 'L': Lower triangle of A is stored.
  16474. *
  16475. * N (input) INTEGER
  16476. * The number of linear equations, i.e., the order of the
  16477. * matrix A. N >= 0.
  16478. *
  16479. * NRHS (input) INTEGER
  16480. * The number of right hand sides, i.e., the number of columns
  16481. * of the matrix B. NRHS >= 0.
  16482. *
  16483. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  16484. * On entry, the symmetric matrix A. If UPLO = 'U', the leading
  16485. * N-by-N upper triangular part of A contains the upper
  16486. * triangular part of the matrix A, and the strictly lower
  16487. * triangular part of A is not referenced. If UPLO = 'L', the
  16488. * leading N-by-N lower triangular part of A contains the lower
  16489. * triangular part of the matrix A, and the strictly upper
  16490. * triangular part of A is not referenced.
  16491. *
  16492. * On exit, if INFO = 0, the block diagonal matrix D and the
  16493. * multipliers used to obtain the factor U or L from the
  16494. * factorization A = U*D*U**T or A = L*D*L**T as computed by
  16495. * DSYTRF.
  16496. *
  16497. * LDA (input) INTEGER
  16498. * The leading dimension of the array A. LDA >= max(1,N).
  16499. *
  16500. * IPIV (output) INTEGER array, dimension (N)
  16501. * Details of the interchanges and the block structure of D, as
  16502. * determined by DSYTRF. If IPIV(k) > 0, then rows and columns
  16503. * k and IPIV(k) were interchanged, and D(k,k) is a 1-by-1
  16504. * diagonal block. If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0,
  16505. * then rows and columns k-1 and -IPIV(k) were interchanged and
  16506. * D(k-1:k,k-1:k) is a 2-by-2 diagonal block. If UPLO = 'L' and
  16507. * IPIV(k) = IPIV(k+1) < 0, then rows and columns k+1 and
  16508. * -IPIV(k) were interchanged and D(k:k+1,k:k+1) is a 2-by-2
  16509. * diagonal block.
  16510. *
  16511. * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
  16512. * On entry, the N-by-NRHS right hand side matrix B.
  16513. * On exit, if INFO = 0, the N-by-NRHS solution matrix X.
  16514. *
  16515. * LDB (input) INTEGER
  16516. * The leading dimension of the array B. LDB >= max(1,N).
  16517. *
  16518. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  16519. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  16520. *
  16521. * LWORK (input) INTEGER
  16522. * The length of WORK. LWORK >= 1, and for best performance
  16523. * LWORK >= max(1,N*NB), where NB is the optimal blocksize for
  16524. * DSYTRF.
  16525. *
  16526. * If LWORK = -1, then a workspace query is assumed; the routine
  16527. * only calculates the optimal size of the WORK array, returns
  16528. * this value as the first entry of the WORK array, and no error
  16529. * message related to LWORK is issued by XERBLA.
  16530. *
  16531. * C++ Return value: INFO (output) INTEGER
  16532. * = 0: successful exit
  16533. * < 0: if INFO = -i, the i-th argument had an illegal value
  16534. * > 0: if INFO = i, D(i,i) is exactly zero. The factorization
  16535. * has been completed, but the block diagonal matrix D is
  16536. * exactly singular, so the solution could not be computed.
  16537. *
  16538. * =====================================================================
  16539. *
  16540. * .. Local Scalars ..
  16541. **/
  16542. int C_DSYSV(char uplo, int n, int nrhs, double* a, int lda, int* ipiv, double* b, int ldb, double* work, int lwork)
  16543. {
  16544. int info;
  16545. ::F_DSYSV(&uplo, &n, &nrhs, a, &lda, ipiv, b, &ldb, work, &lwork, &info);
  16546. return info;
  16547. }
  16548. /**
  16549. * Purpose
  16550. * =======
  16551. *
  16552. * DSYSVX uses the diagonal pivoting factorization to compute the
  16553. * solution to a real system of linear equations A * X = B,
  16554. * where A is an N-by-N symmetric matrix and X and B are N-by-NRHS
  16555. * matrices.
  16556. *
  16557. * Error bounds on the solution and a condition estimate are also
  16558. * provided.
  16559. *
  16560. * Description
  16561. * ===========
  16562. *
  16563. * The following steps are performed:
  16564. *
  16565. * 1. If FACT = 'N', the diagonal pivoting method is used to factor A.
  16566. * The form of the factorization is
  16567. * A = U * D * U**T, if UPLO = 'U', or
  16568. * A = L * D * L**T, if UPLO = 'L',
  16569. * where U (or L) is a product of permutation and unit upper (lower)
  16570. * triangular matrices, and D is symmetric and block diagonal with
  16571. * 1-by-1 and 2-by-2 diagonal blocks.
  16572. *
  16573. * 2. If some D(i,i)=0, so that D is exactly singular, then the routine
  16574. * returns with INFO = i. Otherwise, the factored form of A is used
  16575. * to estimate the condition number of the matrix A. If the
  16576. * reciprocal of the condition number is less than machine precision,
  16577. * C++ Return value: INFO (output) INTEGER
  16578. * to solve for X and compute error bounds as described below.
  16579. *
  16580. * 3. The system of equations is solved for X using the factored form
  16581. * of A.
  16582. *
  16583. * 4. Iterative refinement is applied to improve the computed solution
  16584. * matrix and calculate error bounds and backward error estimates
  16585. * for it.
  16586. *
  16587. * Arguments
  16588. * =========
  16589. *
  16590. * FACT (input) CHARACTER*1
  16591. * Specifies whether or not the factored form of A has been
  16592. * supplied on entry.
  16593. * = 'F': On entry, AF and IPIV contain the factored form of
  16594. * A. AF and IPIV will not be modified.
  16595. * = 'N': The matrix A will be copied to AF and factored.
  16596. *
  16597. * UPLO (input) CHARACTER*1
  16598. * = 'U': Upper triangle of A is stored;
  16599. * = 'L': Lower triangle of A is stored.
  16600. *
  16601. * N (input) INTEGER
  16602. * The number of linear equations, i.e., the order of the
  16603. * matrix A. N >= 0.
  16604. *
  16605. * NRHS (input) INTEGER
  16606. * The number of right hand sides, i.e., the number of columns
  16607. * of the matrices B and X. NRHS >= 0.
  16608. *
  16609. * A (input) DOUBLE PRECISION array, dimension (LDA,N)
  16610. * The symmetric matrix A. If UPLO = 'U', the leading N-by-N
  16611. * upper triangular part of A contains the upper triangular part
  16612. * of the matrix A, and the strictly lower triangular part of A
  16613. * is not referenced. If UPLO = 'L', the leading N-by-N lower
  16614. * triangular part of A contains the lower triangular part of
  16615. * the matrix A, and the strictly upper triangular part of A is
  16616. * not referenced.
  16617. *
  16618. * LDA (input) INTEGER
  16619. * The leading dimension of the array A. LDA >= max(1,N).
  16620. *
  16621. * AF (input or output) DOUBLE PRECISION array, dimension (LDAF,N)
  16622. * If FACT = 'F', then AF is an input argument and on entry
  16623. * contains the block diagonal matrix D and the multipliers used
  16624. * to obtain the factor U or L from the factorization
  16625. * A = U*D*U**T or A = L*D*L**T as computed by DSYTRF.
  16626. *
  16627. * If FACT = 'N', then AF is an output argument and on exit
  16628. * returns the block diagonal matrix D and the multipliers used
  16629. * to obtain the factor U or L from the factorization
  16630. * A = U*D*U**T or A = L*D*L**T.
  16631. *
  16632. * LDAF (input) INTEGER
  16633. * The leading dimension of the array AF. LDAF >= max(1,N).
  16634. *
  16635. * IPIV (input or output) INTEGER array, dimension (N)
  16636. * If FACT = 'F', then IPIV is an input argument and on entry
  16637. * contains details of the interchanges and the block structure
  16638. * of D, as determined by DSYTRF.
  16639. * If IPIV(k) > 0, then rows and columns k and IPIV(k) were
  16640. * interchanged and D(k,k) is a 1-by-1 diagonal block.
  16641. * If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0, then rows and
  16642. * columns k-1 and -IPIV(k) were interchanged and D(k-1:k,k-1:k)
  16643. * is a 2-by-2 diagonal block. If UPLO = 'L' and IPIV(k) =
  16644. * IPIV(k+1) < 0, then rows and columns k+1 and -IPIV(k) were
  16645. * interchanged and D(k:k+1,k:k+1) is a 2-by-2 diagonal block.
  16646. *
  16647. * If FACT = 'N', then IPIV is an output argument and on exit
  16648. * contains details of the interchanges and the block structure
  16649. * of D, as determined by DSYTRF.
  16650. *
  16651. * B (input) DOUBLE PRECISION array, dimension (LDB,NRHS)
  16652. * The N-by-NRHS right hand side matrix B.
  16653. *
  16654. * LDB (input) INTEGER
  16655. * The leading dimension of the array B. LDB >= max(1,N).
  16656. *
  16657. * X (output) DOUBLE PRECISION array, dimension (LDX,NRHS)
  16658. * If INFO = 0 or INFO = N+1, the N-by-NRHS solution matrix X.
  16659. *
  16660. * LDX (input) INTEGER
  16661. * The leading dimension of the array X. LDX >= max(1,N).
  16662. *
  16663. * RCOND (output) DOUBLE PRECISION
  16664. * The estimate of the reciprocal condition number of the matrix
  16665. * A. If RCOND is less than the machine precision (in
  16666. * particular, if RCOND = 0), the matrix is singular to working
  16667. * precision. This condition is indicated by a return code of
  16668. * C++ Return value: INFO (output) INTEGER
  16669. *
  16670. * FERR (output) DOUBLE PRECISION array, dimension (NRHS)
  16671. * The estimated forward error bound for each solution vector
  16672. * X(j) (the j-th column of the solution matrix X).
  16673. * If XTRUE is the true solution corresponding to X(j), FERR(j)
  16674. * is an estimated upper bound for the magnitude of the largest
  16675. * element in (X(j) - XTRUE) divided by the magnitude of the
  16676. * largest element in X(j). The estimate is as reliable as
  16677. * the estimate for RCOND, and is almost always a slight
  16678. * overestimate of the true error.
  16679. *
  16680. * BERR (output) DOUBLE PRECISION array, dimension (NRHS)
  16681. * The componentwise relative backward error of each solution
  16682. * vector X(j) (i.e., the smallest relative change in
  16683. * any element of A or B that makes X(j) an exact solution).
  16684. *
  16685. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  16686. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  16687. *
  16688. * LWORK (input) INTEGER
  16689. * The length of WORK. LWORK >= max(1,3*N), and for best
  16690. * performance, when FACT = 'N', LWORK >= max(1,3*N,N*NB), where
  16691. * NB is the optimal blocksize for DSYTRF.
  16692. *
  16693. * If LWORK = -1, then a workspace query is assumed; the routine
  16694. * only calculates the optimal size of the WORK array, returns
  16695. * this value as the first entry of the WORK array, and no error
  16696. * message related to LWORK is issued by XERBLA.
  16697. *
  16698. * IWORK (workspace) INTEGER array, dimension (N)
  16699. *
  16700. * C++ Return value: INFO (output) INTEGER
  16701. * = 0: successful exit
  16702. * < 0: if INFO = -i, the i-th argument had an illegal value
  16703. * > 0: if INFO = i, and i is
  16704. * <= N: D(i,i) is exactly zero. The factorization
  16705. * has been completed but the factor D is exactly
  16706. * singular, so the solution and error bounds could
  16707. * not be computed. RCOND = 0 is returned.
  16708. * = N+1: D is nonsingular, but RCOND is less than machine
  16709. * precision, meaning that the matrix is singular
  16710. * to working precision. Nevertheless, the
  16711. * solution and error bounds are computed because
  16712. * there are a number of situations where the
  16713. * computed solution can be more accurate than the
  16714. * value of RCOND would suggest.
  16715. *
  16716. * =====================================================================
  16717. *
  16718. * .. Parameters ..
  16719. **/
  16720. int C_DSYSVX(char fact, char uplo, int n, int nrhs, double* a, int lda, double* af, int ldaf, int* ipiv, double* b, int ldb, double* x, int ldx, double* rcond)
  16721. {
  16722. int info;
  16723. ::F_DSYSVX(&fact, &uplo, &n, &nrhs, a, &lda, af, &ldaf, ipiv, b, &ldb, x, &ldx, rcond, &info);
  16724. return info;
  16725. }
  16726. /**
  16727. * Purpose
  16728. * =======
  16729. *
  16730. * DSYTRD reduces a real symmetric matrix A to real symmetric
  16731. * tridiagonal form T by an orthogonal similarity transformation:
  16732. * Q**T * A * Q = T.
  16733. *
  16734. * Arguments
  16735. * =========
  16736. *
  16737. * UPLO (input) CHARACTER*1
  16738. * = 'U': Upper triangle of A is stored;
  16739. * = 'L': Lower triangle of A is stored.
  16740. *
  16741. * N (input) INTEGER
  16742. * The order of the matrix A. N >= 0.
  16743. *
  16744. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  16745. * On entry, the symmetric matrix A. If UPLO = 'U', the leading
  16746. * N-by-N upper triangular part of A contains the upper
  16747. * triangular part of the matrix A, and the strictly lower
  16748. * triangular part of A is not referenced. If UPLO = 'L', the
  16749. * leading N-by-N lower triangular part of A contains the lower
  16750. * triangular part of the matrix A, and the strictly upper
  16751. * triangular part of A is not referenced.
  16752. * On exit, if UPLO = 'U', the diagonal and first superdiagonal
  16753. * of A are overwritten by the corresponding elements of the
  16754. * tridiagonal matrix T, and the elements above the first
  16755. * superdiagonal, with the array TAU, represent the orthogonal
  16756. * matrix Q as a product of elementary reflectors; if UPLO
  16757. * = 'L', the diagonal and first subdiagonal of A are over-
  16758. * written by the corresponding elements of the tridiagonal
  16759. * matrix T, and the elements below the first subdiagonal, with
  16760. * the array TAU, represent the orthogonal matrix Q as a product
  16761. * of elementary reflectors. See Further Details.
  16762. *
  16763. * LDA (input) INTEGER
  16764. * The leading dimension of the array A. LDA >= max(1,N).
  16765. *
  16766. * D (output) DOUBLE PRECISION array, dimension (N)
  16767. * The diagonal elements of the tridiagonal matrix T:
  16768. * D(i) = A(i,i).
  16769. *
  16770. * E (output) DOUBLE PRECISION array, dimension (N-1)
  16771. * The off-diagonal elements of the tridiagonal matrix T:
  16772. * E(i) = A(i,i+1) if UPLO = 'U', E(i) = A(i+1,i) if UPLO = 'L'.
  16773. *
  16774. * TAU (output) DOUBLE PRECISION array, dimension (N-1)
  16775. * The scalar factors of the elementary reflectors (see Further
  16776. * Details).
  16777. *
  16778. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  16779. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  16780. *
  16781. * LWORK (input) INTEGER
  16782. * The dimension of the array WORK. LWORK >= 1.
  16783. * For optimum performance LWORK >= N*NB, where NB is the
  16784. * optimal blocksize.
  16785. *
  16786. * If LWORK = -1, then a workspace query is assumed; the routine
  16787. * only calculates the optimal size of the WORK array, returns
  16788. * this value as the first entry of the WORK array, and no error
  16789. * message related to LWORK is issued by XERBLA.
  16790. *
  16791. * C++ Return value: INFO (output) INTEGER
  16792. * = 0: successful exit
  16793. * < 0: if INFO = -i, the i-th argument had an illegal value
  16794. *
  16795. * Further Details
  16796. * ===============
  16797. *
  16798. * If UPLO = 'U', the matrix Q is represented as a product of elementary
  16799. * reflectors
  16800. *
  16801. * Q = H(n-1) . . . H(2) H(1).
  16802. *
  16803. * Each H(i) has the form
  16804. *
  16805. * H(i) = I - tau * v * v'
  16806. *
  16807. * where tau is a real scalar, and v is a real vector with
  16808. * v(i+1:n) = 0 and v(i) = 1; v(1:i-1) is stored on exit in
  16809. * A(1:i-1,i+1), and tau in TAU(i).
  16810. *
  16811. * If UPLO = 'L', the matrix Q is represented as a product of elementary
  16812. * reflectors
  16813. *
  16814. * Q = H(1) H(2) . . . H(n-1).
  16815. *
  16816. * Each H(i) has the form
  16817. *
  16818. * H(i) = I - tau * v * v'
  16819. *
  16820. * where tau is a real scalar, and v is a real vector with
  16821. * v(1:i) = 0 and v(i+1) = 1; v(i+2:n) is stored on exit in A(i+2:n,i),
  16822. * and tau in TAU(i).
  16823. *
  16824. * The contents of A on exit are illustrated by the following examples
  16825. * with n = 5:
  16826. *
  16827. * if UPLO = 'U': if UPLO = 'L':
  16828. *
  16829. * ( d e v2 v3 v4 ) ( d )
  16830. * ( d e v3 v4 ) ( e d )
  16831. * ( d e v4 ) ( v1 e d )
  16832. * ( d e ) ( v1 v2 e d )
  16833. * ( d ) ( v1 v2 v3 e d )
  16834. *
  16835. * where d and e denote diagonal and off-diagonal elements of T, and vi
  16836. * denotes an element of the vector defining H(i).
  16837. *
  16838. * =====================================================================
  16839. *
  16840. * .. Parameters ..
  16841. **/
  16842. int C_DSYTRD(char uplo, int n, double* a, int lda, double* d, double* e, double* tau, double* work, int lwork)
  16843. {
  16844. int info;
  16845. ::F_DSYTRD(&uplo, &n, a, &lda, d, e, tau, work, &lwork, &info);
  16846. return info;
  16847. }
  16848. /**
  16849. * Purpose
  16850. * =======
  16851. *
  16852. * DSYTRF computes the factorization of a real symmetric matrix A using
  16853. * the Bunch-Kaufman diagonal pivoting method. The form of the
  16854. * factorization is
  16855. *
  16856. * A = U*D*U**T or A = L*D*L**T
  16857. *
  16858. * where U (or L) is a product of permutation and unit upper (lower)
  16859. * triangular matrices, and D is symmetric and block diagonal with
  16860. * 1-by-1 and 2-by-2 diagonal blocks.
  16861. *
  16862. * This is the blocked version of the algorithm, calling Level 3 BLAS.
  16863. *
  16864. * Arguments
  16865. * =========
  16866. *
  16867. * UPLO (input) CHARACTER*1
  16868. * = 'U': Upper triangle of A is stored;
  16869. * = 'L': Lower triangle of A is stored.
  16870. *
  16871. * N (input) INTEGER
  16872. * The order of the matrix A. N >= 0.
  16873. *
  16874. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  16875. * On entry, the symmetric matrix A. If UPLO = 'U', the leading
  16876. * N-by-N upper triangular part of A contains the upper
  16877. * triangular part of the matrix A, and the strictly lower
  16878. * triangular part of A is not referenced. If UPLO = 'L', the
  16879. * leading N-by-N lower triangular part of A contains the lower
  16880. * triangular part of the matrix A, and the strictly upper
  16881. * triangular part of A is not referenced.
  16882. *
  16883. * On exit, the block diagonal matrix D and the multipliers used
  16884. * to obtain the factor U or L (see below for further details).
  16885. *
  16886. * LDA (input) INTEGER
  16887. * The leading dimension of the array A. LDA >= max(1,N).
  16888. *
  16889. * IPIV (output) INTEGER array, dimension (N)
  16890. * Details of the interchanges and the block structure of D.
  16891. * If IPIV(k) > 0, then rows and columns k and IPIV(k) were
  16892. * interchanged and D(k,k) is a 1-by-1 diagonal block.
  16893. * If UPLO = 'U' and IPIV(k) = IPIV(k-1) < 0, then rows and
  16894. * columns k-1 and -IPIV(k) were interchanged and D(k-1:k,k-1:k)
  16895. * is a 2-by-2 diagonal block. If UPLO = 'L' and IPIV(k) =
  16896. * IPIV(k+1) < 0, then rows and columns k+1 and -IPIV(k) were
  16897. * interchanged and D(k:k+1,k:k+1) is a 2-by-2 diagonal block.
  16898. *
  16899. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  16900. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  16901. *
  16902. * LWORK (input) INTEGER
  16903. * The length of WORK. LWORK >=1. For best performance
  16904. * LWORK >= N*NB, where NB is the block size returned by ILAENV.
  16905. *
  16906. * If LWORK = -1, then a workspace query is assumed; the routine
  16907. * only calculates the optimal size of the WORK array, returns
  16908. * this value as the first entry of the WORK array, and no error
  16909. * message related to LWORK is issued by XERBLA.
  16910. *
  16911. * C++ Return value: INFO (output) INTEGER
  16912. * = 0: successful exit
  16913. * < 0: if INFO = -i, the i-th argument had an illegal value
  16914. * > 0: if INFO = i, D(i,i) is exactly zero. The factorization
  16915. * has been completed, but the block diagonal matrix D is
  16916. * exactly singular, and division by zero will occur if it
  16917. * is used to solve a system of equations.
  16918. *
  16919. * Further Details
  16920. * ===============
  16921. *
  16922. * If UPLO = 'U', then A = U*D*U', where
  16923. * U = P(n)*U(n)* ... *P(k)U(k)* ...,
  16924. * i.e., U is a product of terms P(k)*U(k), where k decreases from n to
  16925. * 1 in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1
  16926. * and 2-by-2 diagonal blocks D(k). P(k) is a permutation matrix as
  16927. * defined by IPIV(k), and U(k) is a unit upper triangular matrix, such
  16928. * that if the diagonal block D(k) is of order s (s = 1 or 2), then
  16929. *
  16930. * ( I v 0 ) k-s
  16931. * U(k) = ( 0 I 0 ) s
  16932. * ( 0 0 I ) n-k
  16933. * k-s s n-k
  16934. *
  16935. * If s = 1, D(k) overwrites A(k,k), and v overwrites A(1:k-1,k).
  16936. * If s = 2, the upper triangle of D(k) overwrites A(k-1,k-1), A(k-1,k),
  16937. * and A(k,k), and v overwrites A(1:k-2,k-1:k).
  16938. *
  16939. * If UPLO = 'L', then A = L*D*L', where
  16940. * L = P(1)*L(1)* ... *P(k)*L(k)* ...,
  16941. * i.e., L is a product of terms P(k)*L(k), where k increases from 1 to
  16942. * n in steps of 1 or 2, and D is a block diagonal matrix with 1-by-1
  16943. * and 2-by-2 diagonal blocks D(k). P(k) is a permutation matrix as
  16944. * defined by IPIV(k), and L(k) is a unit lower triangular matrix, such
  16945. * that if the diagonal block D(k) is of order s (s = 1 or 2), then
  16946. *
  16947. * ( I 0 0 ) k-1
  16948. * L(k) = ( 0 I 0 ) s
  16949. * ( 0 v I ) n-k-s+1
  16950. * k-1 s n-k-s+1
  16951. *
  16952. * If s = 1, D(k) overwrites A(k,k), and v overwrites A(k+1:n,k).
  16953. * If s = 2, the lower triangle of D(k) overwrites A(k,k), A(k+1,k),
  16954. * and A(k+1,k+1), and v overwrites A(k+2:n,k:k+1).
  16955. *
  16956. * =====================================================================
  16957. *
  16958. * .. Local Scalars ..
  16959. **/
  16960. int C_DSYTRF(char uplo, int n, double* a, int lda, int* ipiv, double* work, int lwork)
  16961. {
  16962. int info;
  16963. ::F_DSYTRF(&uplo, &n, a, &lda, ipiv, work, &lwork, &info);
  16964. return info;
  16965. }
  16966. /**
  16967. * Purpose
  16968. * =======
  16969. *
  16970. * DSYTRI computes the inverse of a real symmetric indefinite matrix
  16971. * A using the factorization A = U*D*U**T or A = L*D*L**T computed by
  16972. * DSYTRF.
  16973. *
  16974. * Arguments
  16975. * =========
  16976. *
  16977. * UPLO (input) CHARACTER*1
  16978. * Specifies whether the details of the factorization are stored
  16979. * as an upper or lower triangular matrix.
  16980. * = 'U': Upper triangular, form is A = U*D*U**T;
  16981. * = 'L': Lower triangular, form is A = L*D*L**T.
  16982. *
  16983. * N (input) INTEGER
  16984. * The order of the matrix A. N >= 0.
  16985. *
  16986. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  16987. * On entry, the block diagonal matrix D and the multipliers
  16988. * used to obtain the factor U or L as computed by DSYTRF.
  16989. *
  16990. * On exit, if INFO = 0, the (symmetric) inverse of the original
  16991. * matrix. If UPLO = 'U', the upper triangular part of the
  16992. * inverse is formed and the part of A below the diagonal is not
  16993. * referenced; if UPLO = 'L' the lower triangular part of the
  16994. * inverse is formed and the part of A above the diagonal is
  16995. * not referenced.
  16996. *
  16997. * LDA (input) INTEGER
  16998. * The leading dimension of the array A. LDA >= max(1,N).
  16999. *
  17000. * IPIV (input) INTEGER array, dimension (N)
  17001. * Details of the interchanges and the block structure of D
  17002. * as determined by DSYTRF.
  17003. *
  17004. * WORK (workspace) DOUBLE PRECISION array, dimension (N)
  17005. *
  17006. * C++ Return value: INFO (output) INTEGER
  17007. * = 0: successful exit
  17008. * < 0: if INFO = -i, the i-th argument had an illegal value
  17009. * > 0: if INFO = i, D(i,i) = 0; the matrix is singular and its
  17010. * inverse could not be computed.
  17011. *
  17012. * =====================================================================
  17013. *
  17014. * .. Parameters ..
  17015. **/
  17016. int C_DSYTRI(char uplo, int n, double* a, int lda, int* ipiv, double* work)
  17017. {
  17018. int info;
  17019. ::F_DSYTRI(&uplo, &n, a, &lda, ipiv, work, &info);
  17020. return info;
  17021. }
  17022. /**
  17023. * Purpose
  17024. * =======
  17025. *
  17026. * DSYTRS solves a system of linear equations A*X = B with a real
  17027. * symmetric matrix A using the factorization A = U*D*U**T or
  17028. * A = L*D*L**T computed by DSYTRF.
  17029. *
  17030. * Arguments
  17031. * =========
  17032. *
  17033. * UPLO (input) CHARACTER*1
  17034. * Specifies whether the details of the factorization are stored
  17035. * as an upper or lower triangular matrix.
  17036. * = 'U': Upper triangular, form is A = U*D*U**T;
  17037. * = 'L': Lower triangular, form is A = L*D*L**T.
  17038. *
  17039. * N (input) INTEGER
  17040. * The order of the matrix A. N >= 0.
  17041. *
  17042. * NRHS (input) INTEGER
  17043. * The number of right hand sides, i.e., the number of columns
  17044. * of the matrix B. NRHS >= 0.
  17045. *
  17046. * A (input) DOUBLE PRECISION array, dimension (LDA,N)
  17047. * The block diagonal matrix D and the multipliers used to
  17048. * obtain the factor U or L as computed by DSYTRF.
  17049. *
  17050. * LDA (input) INTEGER
  17051. * The leading dimension of the array A. LDA >= max(1,N).
  17052. *
  17053. * IPIV (input) INTEGER array, dimension (N)
  17054. * Details of the interchanges and the block structure of D
  17055. * as determined by DSYTRF.
  17056. *
  17057. * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
  17058. * On entry, the right hand side matrix B.
  17059. * On exit, the solution matrix X.
  17060. *
  17061. * LDB (input) INTEGER
  17062. * The leading dimension of the array B. LDB >= max(1,N).
  17063. *
  17064. * C++ Return value: INFO (output) INTEGER
  17065. * = 0: successful exit
  17066. * < 0: if INFO = -i, the i-th argument had an illegal value
  17067. *
  17068. * =====================================================================
  17069. *
  17070. * .. Parameters ..
  17071. **/
  17072. int C_DSYTRS(char uplo, int n, int nrhs, double* a, int lda, int* ipiv, double* b, int ldb)
  17073. {
  17074. int info;
  17075. ::F_DSYTRS(&uplo, &n, &nrhs, a, &lda, ipiv, b, &ldb, &info);
  17076. return info;
  17077. }
  17078. /**
  17079. * Purpose
  17080. * =======
  17081. *
  17082. * DTBCON estimates the reciprocal of the condition number of a
  17083. * triangular band matrix A, in either the 1-norm or the infinity-norm.
  17084. *
  17085. * The norm of A is computed and an estimate is obtained for
  17086. * norm(inv(A)), then the reciprocal of the condition number is
  17087. * computed as
  17088. * RCOND = 1 / ( norm(A) * norm(inv(A)) ).
  17089. *
  17090. * Arguments
  17091. * =========
  17092. *
  17093. * NORM (input) CHARACTER*1
  17094. * Specifies whether the 1-norm condition number or the
  17095. * infinity-norm condition number is required:
  17096. * = '1' or 'O': 1-norm;
  17097. * = 'I': Infinity-norm.
  17098. *
  17099. * UPLO (input) CHARACTER*1
  17100. * = 'U': A is upper triangular;
  17101. * = 'L': A is lower triangular.
  17102. *
  17103. * DIAG (input) CHARACTER*1
  17104. * = 'N': A is non-unit triangular;
  17105. * = 'U': A is unit triangular.
  17106. *
  17107. * N (input) INTEGER
  17108. * The order of the matrix A. N >= 0.
  17109. *
  17110. * KD (input) INTEGER
  17111. * The number of superdiagonals or subdiagonals of the
  17112. * triangular band matrix A. KD >= 0.
  17113. *
  17114. * AB (input) DOUBLE PRECISION array, dimension (LDAB,N)
  17115. * The upper or lower triangular band matrix A, stored in the
  17116. * first kd+1 rows of the array. The j-th column of A is stored
  17117. * in the j-th column of the array AB as follows:
  17118. * if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
  17119. * if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd).
  17120. * If DIAG = 'U', the diagonal elements of A are not referenced
  17121. * and are assumed to be 1.
  17122. *
  17123. * LDAB (input) INTEGER
  17124. * The leading dimension of the array AB. LDAB >= KD+1.
  17125. *
  17126. * RCOND (output) DOUBLE PRECISION
  17127. * The reciprocal of the condition number of the matrix A,
  17128. * computed as RCOND = 1/(norm(A) * norm(inv(A))).
  17129. *
  17130. * WORK (workspace) DOUBLE PRECISION array, dimension (3*N)
  17131. *
  17132. * IWORK (workspace) INTEGER array, dimension (N)
  17133. *
  17134. * C++ Return value: INFO (output) INTEGER
  17135. * = 0: successful exit
  17136. * < 0: if INFO = -i, the i-th argument had an illegal value
  17137. *
  17138. * =====================================================================
  17139. *
  17140. * .. Parameters ..
  17141. **/
  17142. int C_DTBCON(char norm, char uplo, char diag, int n, int kd, double* ab, int ldab, double* rcond, double* work, int* iwork)
  17143. {
  17144. int info;
  17145. ::F_DTBCON(&norm, &uplo, &diag, &n, &kd, ab, &ldab, rcond, work, iwork, &info);
  17146. return info;
  17147. }
  17148. /**
  17149. * Purpose
  17150. * =======
  17151. *
  17152. * DTBRFS provides error bounds and backward error estimates for the
  17153. * solution to a system of linear equations with a triangular band
  17154. * coefficient matrix.
  17155. *
  17156. * The solution matrix X must be computed by DTBTRS or some other
  17157. * means before entering this routine. DTBRFS does not do iterative
  17158. * refinement because doing so cannot improve the backward error.
  17159. *
  17160. * Arguments
  17161. * =========
  17162. *
  17163. * UPLO (input) CHARACTER*1
  17164. * = 'U': A is upper triangular;
  17165. * = 'L': A is lower triangular.
  17166. *
  17167. * TRANS (input) CHARACTER*1
  17168. * Specifies the form of the system of equations:
  17169. * = 'N': A * X = B (No transpose)
  17170. * = 'T': A**T * X = B (Transpose)
  17171. * = 'C': A**H * X = B (Conjugate transpose = Transpose)
  17172. *
  17173. * DIAG (input) CHARACTER*1
  17174. * = 'N': A is non-unit triangular;
  17175. * = 'U': A is unit triangular.
  17176. *
  17177. * N (input) INTEGER
  17178. * The order of the matrix A. N >= 0.
  17179. *
  17180. * KD (input) INTEGER
  17181. * The number of superdiagonals or subdiagonals of the
  17182. * triangular band matrix A. KD >= 0.
  17183. *
  17184. * NRHS (input) INTEGER
  17185. * The number of right hand sides, i.e., the number of columns
  17186. * of the matrices B and X. NRHS >= 0.
  17187. *
  17188. * AB (input) DOUBLE PRECISION array, dimension (LDAB,N)
  17189. * The upper or lower triangular band matrix A, stored in the
  17190. * first kd+1 rows of the array. The j-th column of A is stored
  17191. * in the j-th column of the array AB as follows:
  17192. * if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
  17193. * if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd).
  17194. * If DIAG = 'U', the diagonal elements of A are not referenced
  17195. * and are assumed to be 1.
  17196. *
  17197. * LDAB (input) INTEGER
  17198. * The leading dimension of the array AB. LDAB >= KD+1.
  17199. *
  17200. * B (input) DOUBLE PRECISION array, dimension (LDB,NRHS)
  17201. * The right hand side matrix B.
  17202. *
  17203. * LDB (input) INTEGER
  17204. * The leading dimension of the array B. LDB >= max(1,N).
  17205. *
  17206. * X (input) DOUBLE PRECISION array, dimension (LDX,NRHS)
  17207. * The solution matrix X.
  17208. *
  17209. * LDX (input) INTEGER
  17210. * The leading dimension of the array X. LDX >= max(1,N).
  17211. *
  17212. * FERR (output) DOUBLE PRECISION array, dimension (NRHS)
  17213. * The estimated forward error bound for each solution vector
  17214. * X(j) (the j-th column of the solution matrix X).
  17215. * If XTRUE is the true solution corresponding to X(j), FERR(j)
  17216. * is an estimated upper bound for the magnitude of the largest
  17217. * element in (X(j) - XTRUE) divided by the magnitude of the
  17218. * largest element in X(j). The estimate is as reliable as
  17219. * the estimate for RCOND, and is almost always a slight
  17220. * overestimate of the true error.
  17221. *
  17222. * BERR (output) DOUBLE PRECISION array, dimension (NRHS)
  17223. * The componentwise relative backward error of each solution
  17224. * vector X(j) (i.e., the smallest relative change in
  17225. * any element of A or B that makes X(j) an exact solution).
  17226. *
  17227. * WORK (workspace) DOUBLE PRECISION array, dimension (3*N)
  17228. *
  17229. * IWORK (workspace) INTEGER array, dimension (N)
  17230. *
  17231. * C++ Return value: INFO (output) INTEGER
  17232. * = 0: successful exit
  17233. * < 0: if INFO = -i, the i-th argument had an illegal value
  17234. *
  17235. * =====================================================================
  17236. *
  17237. * .. Parameters ..
  17238. **/
  17239. int C_DTBRFS(char uplo, char trans, char diag, int n, int kd, int nrhs, double* ab, int ldab, double* b, int ldb, double* x, int ldx, double* ferr, double* berr, double* work, int* iwork)
  17240. {
  17241. int info;
  17242. ::F_DTBRFS(&uplo, &trans, &diag, &n, &kd, &nrhs, ab, &ldab, b, &ldb, x, &ldx, ferr, berr, work, iwork, &info);
  17243. return info;
  17244. }
  17245. /**
  17246. * Purpose
  17247. * =======
  17248. *
  17249. * DTBTRS solves a triangular system of the form
  17250. *
  17251. * A * X = B or A**T * X = B,
  17252. *
  17253. * where A is a triangular band matrix of order N, and B is an
  17254. * N-by NRHS matrix. A check is made to verify that A is nonsingular.
  17255. *
  17256. * Arguments
  17257. * =========
  17258. *
  17259. * UPLO (input) CHARACTER*1
  17260. * = 'U': A is upper triangular;
  17261. * = 'L': A is lower triangular.
  17262. *
  17263. * TRANS (input) CHARACTER*1
  17264. * Specifies the form the system of equations:
  17265. * = 'N': A * X = B (No transpose)
  17266. * = 'T': A**T * X = B (Transpose)
  17267. * = 'C': A**H * X = B (Conjugate transpose = Transpose)
  17268. *
  17269. * DIAG (input) CHARACTER*1
  17270. * = 'N': A is non-unit triangular;
  17271. * = 'U': A is unit triangular.
  17272. *
  17273. * N (input) INTEGER
  17274. * The order of the matrix A. N >= 0.
  17275. *
  17276. * KD (input) INTEGER
  17277. * The number of superdiagonals or subdiagonals of the
  17278. * triangular band matrix A. KD >= 0.
  17279. *
  17280. * NRHS (input) INTEGER
  17281. * The number of right hand sides, i.e., the number of columns
  17282. * of the matrix B. NRHS >= 0.
  17283. *
  17284. * AB (input) DOUBLE PRECISION array, dimension (LDAB,N)
  17285. * The upper or lower triangular band matrix A, stored in the
  17286. * first kd+1 rows of AB. The j-th column of A is stored
  17287. * in the j-th column of the array AB as follows:
  17288. * if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
  17289. * if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd).
  17290. * If DIAG = 'U', the diagonal elements of A are not referenced
  17291. * and are assumed to be 1.
  17292. *
  17293. * LDAB (input) INTEGER
  17294. * The leading dimension of the array AB. LDAB >= KD+1.
  17295. *
  17296. * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
  17297. * On entry, the right hand side matrix B.
  17298. * On exit, if INFO = 0, the solution matrix X.
  17299. *
  17300. * LDB (input) INTEGER
  17301. * The leading dimension of the array B. LDB >= max(1,N).
  17302. *
  17303. * C++ Return value: INFO (output) INTEGER
  17304. * = 0: successful exit
  17305. * < 0: if INFO = -i, the i-th argument had an illegal value
  17306. * > 0: if INFO = i, the i-th diagonal element of A is zero,
  17307. * indicating that the matrix is singular and the
  17308. * solutions X have not been computed.
  17309. *
  17310. * =====================================================================
  17311. *
  17312. * .. Parameters ..
  17313. **/
  17314. int C_DTBTRS(char uplo, char trans, char diag, int n, int kd, int nrhs, double* ab, int ldab, double* b, int ldb)
  17315. {
  17316. int info;
  17317. ::F_DTBTRS(&uplo, &trans, &diag, &n, &kd, &nrhs, ab, &ldab, b, &ldb, &info);
  17318. return info;
  17319. }
  17320. /**
  17321. * Purpose
  17322. * =======
  17323. *
  17324. * DTGEVC computes some or all of the right and/or left eigenvectors of
  17325. * a pair of real matrices (S,P), where S is a quasi-triangular matrix
  17326. * and P is upper triangular. Matrix pairs of this type are produced by
  17327. * the generalized Schur factorization of a matrix pair (A,B):
  17328. *
  17329. * A = Q*S*Z**T, B = Q*P*Z**T
  17330. *
  17331. * as computed by DGGHRD + DHGEQZ.
  17332. *
  17333. * The right eigenvector x and the left eigenvector y of (S,P)
  17334. * corresponding to an eigenvalue w are defined by:
  17335. *
  17336. * S*x = w*P*x, (y**H)*S = w*(y**H)*P,
  17337. *
  17338. * where y**H denotes the conjugate tranpose of y.
  17339. * The eigenvalues are not input to this routine, but are computed
  17340. * directly from the diagonal blocks of S and P.
  17341. *
  17342. * This routine returns the matrices X and/or Y of right and left
  17343. * eigenvectors of (S,P), or the products Z*X and/or Q*Y,
  17344. * where Z and Q are input matrices.
  17345. * If Q and Z are the orthogonal factors from the generalized Schur
  17346. * factorization of a matrix pair (A,B), then Z*X and Q*Y
  17347. * are the matrices of right and left eigenvectors of (A,B).
  17348. *
  17349. * Arguments
  17350. * =========
  17351. *
  17352. * SIDE (input) CHARACTER*1
  17353. * = 'R': compute right eigenvectors only;
  17354. * = 'L': compute left eigenvectors only;
  17355. * = 'B': compute both right and left eigenvectors.
  17356. *
  17357. * HOWMNY (input) CHARACTER*1
  17358. * = 'A': compute all right and/or left eigenvectors;
  17359. * = 'B': compute all right and/or left eigenvectors,
  17360. * backtransformed by the matrices in VR and/or VL;
  17361. * = 'S': compute selected right and/or left eigenvectors,
  17362. * specified by the logical array SELECT.
  17363. *
  17364. * SELECT (input) LOGICAL array, dimension (N)
  17365. * If HOWMNY='S', SELECT specifies the eigenvectors to be
  17366. * computed. If w(j) is a real eigenvalue, the corresponding
  17367. * real eigenvector is computed if SELECT(j) is .TRUE..
  17368. * If w(j) and w(j+1) are the real and imaginary parts of a
  17369. * complex eigenvalue, the corresponding complex eigenvector
  17370. * is computed if either SELECT(j) or SELECT(j+1) is .TRUE.,
  17371. * and on exit SELECT(j) is set to .TRUE. and SELECT(j+1) is
  17372. * set to .FALSE..
  17373. * Not referenced if HOWMNY = 'A' or 'B'.
  17374. *
  17375. * N (input) INTEGER
  17376. * The order of the matrices S and P. N >= 0.
  17377. *
  17378. * S (input) DOUBLE PRECISION array, dimension (LDS,N)
  17379. * The upper quasi-triangular matrix S from a generalized Schur
  17380. * factorization, as computed by DHGEQZ.
  17381. *
  17382. * LDS (input) INTEGER
  17383. * The leading dimension of array S. LDS >= max(1,N).
  17384. *
  17385. * P (input) DOUBLE PRECISION array, dimension (LDP,N)
  17386. * The upper triangular matrix P from a generalized Schur
  17387. * factorization, as computed by DHGEQZ.
  17388. * 2-by-2 diagonal blocks of P corresponding to 2-by-2 blocks
  17389. * of S must be in positive diagonal form.
  17390. *
  17391. * LDP (input) INTEGER
  17392. * The leading dimension of array P. LDP >= max(1,N).
  17393. *
  17394. * VL (input/output) DOUBLE PRECISION array, dimension (LDVL,MM)
  17395. * On entry, if SIDE = 'L' or 'B' and HOWMNY = 'B', VL must
  17396. * contain an N-by-N matrix Q (usually the orthogonal matrix Q
  17397. * of left Schur vectors returned by DHGEQZ).
  17398. * On exit, if SIDE = 'L' or 'B', VL contains:
  17399. * if HOWMNY = 'A', the matrix Y of left eigenvectors of (S,P);
  17400. * if HOWMNY = 'B', the matrix Q*Y;
  17401. * if HOWMNY = 'S', the left eigenvectors of (S,P) specified by
  17402. * SELECT, stored consecutively in the columns of
  17403. * VL, in the same order as their eigenvalues.
  17404. *
  17405. * A complex eigenvector corresponding to a complex eigenvalue
  17406. * is stored in two consecutive columns, the first holding the
  17407. * real part, and the second the imaginary part.
  17408. *
  17409. * Not referenced if SIDE = 'R'.
  17410. *
  17411. * LDVL (input) INTEGER
  17412. * The leading dimension of array VL. LDVL >= 1, and if
  17413. * SIDE = 'L' or 'B', LDVL >= N.
  17414. *
  17415. * VR (input/output) DOUBLE PRECISION array, dimension (LDVR,MM)
  17416. * On entry, if SIDE = 'R' or 'B' and HOWMNY = 'B', VR must
  17417. * contain an N-by-N matrix Z (usually the orthogonal matrix Z
  17418. * of right Schur vectors returned by DHGEQZ).
  17419. *
  17420. * On exit, if SIDE = 'R' or 'B', VR contains:
  17421. * if HOWMNY = 'A', the matrix X of right eigenvectors of (S,P);
  17422. * if HOWMNY = 'B' or 'b', the matrix Z*X;
  17423. * if HOWMNY = 'S' or 's', the right eigenvectors of (S,P)
  17424. * specified by SELECT, stored consecutively in the
  17425. * columns of VR, in the same order as their
  17426. * eigenvalues.
  17427. *
  17428. * A complex eigenvector corresponding to a complex eigenvalue
  17429. * is stored in two consecutive columns, the first holding the
  17430. * real part and the second the imaginary part.
  17431. *
  17432. * Not referenced if SIDE = 'L'.
  17433. *
  17434. * LDVR (input) INTEGER
  17435. * The leading dimension of the array VR. LDVR >= 1, and if
  17436. * SIDE = 'R' or 'B', LDVR >= N.
  17437. *
  17438. * MM (input) INTEGER
  17439. * The number of columns in the arrays VL and/or VR. MM >= M.
  17440. *
  17441. * M (output) INTEGER
  17442. * The number of columns in the arrays VL and/or VR actually
  17443. * used to store the eigenvectors. If HOWMNY = 'A' or 'B', M
  17444. * is set to N. Each selected real eigenvector occupies one
  17445. * column and each selected complex eigenvector occupies two
  17446. * columns.
  17447. *
  17448. * WORK (workspace) DOUBLE PRECISION array, dimension (6*N)
  17449. *
  17450. * C++ Return value: INFO (output) INTEGER
  17451. * = 0: successful exit.
  17452. * < 0: if INFO = -i, the i-th argument had an illegal value.
  17453. * > 0: the 2-by-2 block (INFO:INFO+1) does not have a complex
  17454. * eigenvalue.
  17455. *
  17456. * Further Details
  17457. * ===============
  17458. *
  17459. * Allocation of workspace:
  17460. * ---------- -- ---------
  17461. *
  17462. * WORK( j ) = 1-norm of j-th column of A, above the diagonal
  17463. * WORK( N+j ) = 1-norm of j-th column of B, above the diagonal
  17464. * WORK( 2*N+1:3*N ) = real part of eigenvector
  17465. * WORK( 3*N+1:4*N ) = imaginary part of eigenvector
  17466. * WORK( 4*N+1:5*N ) = real part of back-transformed eigenvector
  17467. * WORK( 5*N+1:6*N ) = imaginary part of back-transformed eigenvector
  17468. *
  17469. * Rowwise vs. columnwise solution methods:
  17470. * ------- -- ---------- -------- -------
  17471. *
  17472. * Finding a generalized eigenvector consists basically of solving the
  17473. * singular triangular system
  17474. *
  17475. * (A - w B) x = 0 (for right) or: (A - w B)**H y = 0 (for left)
  17476. *
  17477. * Consider finding the i-th right eigenvector (assume all eigenvalues
  17478. * are real). The equation to be solved is:
  17479. * n i
  17480. * 0 = sum C(j,k) v(k) = sum C(j,k) v(k) for j = i,. . .,1
  17481. * k=j k=j
  17482. *
  17483. * where C = (A - w B) (The components v(i+1:n) are 0.)
  17484. *
  17485. * The "rowwise" method is:
  17486. *
  17487. * (1) v(i) := 1
  17488. * for j = i-1,. . .,1:
  17489. * i
  17490. * (2) compute s = - sum C(j,k) v(k) and
  17491. * k=j+1
  17492. *
  17493. * (3) v(j) := s / C(j,j)
  17494. *
  17495. * Step 2 is sometimes called the "dot product" step, since it is an
  17496. * inner product between the j-th row and the portion of the eigenvector
  17497. * that has been computed so far.
  17498. *
  17499. * The "columnwise" method consists basically in doing the sums
  17500. * for all the rows in parallel. As each v(j) is computed, the
  17501. * contribution of v(j) times the j-th column of C is added to the
  17502. * partial sums. Since FORTRAN arrays are stored columnwise, this has
  17503. * the advantage that at each step, the elements of C that are accessed
  17504. * are adjacent to one another, whereas with the rowwise method, the
  17505. * elements accessed at a step are spaced LDS (and LDP) words apart.
  17506. *
  17507. * When finding left eigenvectors, the matrix in question is the
  17508. * transpose of the one in storage, so the rowwise method then
  17509. * actually accesses columns of A and B at each step, and so is the
  17510. * preferred method.
  17511. *
  17512. * =====================================================================
  17513. *
  17514. * .. Parameters ..
  17515. **/
  17516. int C_DTGEVC(char side, char howmny, int n, double* s, int lds, double* p, int ldp, double* vl, int ldvl, double* vr, int ldvr, int mm, int* m, double* work)
  17517. {
  17518. int info;
  17519. ::F_DTGEVC(&side, &howmny, &n, s, &lds, p, &ldp, vl, &ldvl, vr, &ldvr, &mm, m, work, &info);
  17520. return info;
  17521. }
  17522. /**
  17523. * Purpose
  17524. * =======
  17525. *
  17526. * DTGEXC reorders the generalized real Schur decomposition of a real
  17527. * matrix pair (A,B) using an orthogonal equivalence transformation
  17528. *
  17529. * (A, B) = Q * (A, B) * Z',
  17530. *
  17531. * so that the diagonal block of (A, B) with row index IFST is moved
  17532. * to row ILST.
  17533. *
  17534. * (A, B) must be in generalized real Schur canonical form (as returned
  17535. * by DGGES), i.e. A is block upper triangular with 1-by-1 and 2-by-2
  17536. * diagonal blocks. B is upper triangular.
  17537. *
  17538. * Optionally, the matrices Q and Z of generalized Schur vectors are
  17539. * updated.
  17540. *
  17541. * Q(in) * A(in) * Z(in)' = Q(out) * A(out) * Z(out)'
  17542. * Q(in) * B(in) * Z(in)' = Q(out) * B(out) * Z(out)'
  17543. *
  17544. *
  17545. * Arguments
  17546. * =========
  17547. *
  17548. * WANTQ (input) LOGICAL
  17549. * .TRUE. : update the left transformation matrix Q;
  17550. * .FALSE.: do not update Q.
  17551. *
  17552. * WANTZ (input) LOGICAL
  17553. * .TRUE. : update the right transformation matrix Z;
  17554. * .FALSE.: do not update Z.
  17555. *
  17556. * N (input) INTEGER
  17557. * The order of the matrices A and B. N >= 0.
  17558. *
  17559. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  17560. * On entry, the matrix A in generalized real Schur canonical
  17561. * form.
  17562. * On exit, the updated matrix A, again in generalized
  17563. * real Schur canonical form.
  17564. *
  17565. * LDA (input) INTEGER
  17566. * The leading dimension of the array A. LDA >= max(1,N).
  17567. *
  17568. * B (input/output) DOUBLE PRECISION array, dimension (LDB,N)
  17569. * On entry, the matrix B in generalized real Schur canonical
  17570. * form (A,B).
  17571. * On exit, the updated matrix B, again in generalized
  17572. * real Schur canonical form (A,B).
  17573. *
  17574. * LDB (input) INTEGER
  17575. * The leading dimension of the array B. LDB >= max(1,N).
  17576. *
  17577. * Q (input/output) DOUBLE PRECISION array, dimension (LDQ,N)
  17578. * On entry, if WANTQ = .TRUE., the orthogonal matrix Q.
  17579. * On exit, the updated matrix Q.
  17580. * If WANTQ = .FALSE., Q is not referenced.
  17581. *
  17582. * LDQ (input) INTEGER
  17583. * The leading dimension of the array Q. LDQ >= 1.
  17584. * If WANTQ = .TRUE., LDQ >= N.
  17585. *
  17586. * Z (input/output) DOUBLE PRECISION array, dimension (LDZ,N)
  17587. * On entry, if WANTZ = .TRUE., the orthogonal matrix Z.
  17588. * On exit, the updated matrix Z.
  17589. * If WANTZ = .FALSE., Z is not referenced.
  17590. *
  17591. * LDZ (input) INTEGER
  17592. * The leading dimension of the array Z. LDZ >= 1.
  17593. * If WANTZ = .TRUE., LDZ >= N.
  17594. *
  17595. * IFST (input/output) INTEGER
  17596. * ILST (input/output) INTEGER
  17597. * Specify the reordering of the diagonal blocks of (A, B).
  17598. * The block with row index IFST is moved to row ILST, by a
  17599. * sequence of swapping between adjacent blocks.
  17600. * On exit, if IFST pointed on entry to the second row of
  17601. * a 2-by-2 block, it is changed to point to the first row;
  17602. * ILST always points to the first row of the block in its
  17603. * final position (which may differ from its input value by
  17604. * +1 or -1). 1 <= IFST, ILST <= N.
  17605. *
  17606. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  17607. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  17608. *
  17609. * LWORK (input) INTEGER
  17610. * The dimension of the array WORK.
  17611. * LWORK >= 1 when N <= 1, otherwise LWORK >= 4*N + 16.
  17612. *
  17613. * If LWORK = -1, then a workspace query is assumed; the routine
  17614. * only calculates the optimal size of the WORK array, returns
  17615. * this value as the first entry of the WORK array, and no error
  17616. * message related to LWORK is issued by XERBLA.
  17617. *
  17618. * C++ Return value: INFO (output) INTEGER
  17619. * =0: successful exit.
  17620. * <0: if INFO = -i, the i-th argument had an illegal value.
  17621. * =1: The transformed matrix pair (A, B) would be too far
  17622. * from generalized Schur form; the problem is ill-
  17623. * conditioned. (A, B) may have been partially reordered,
  17624. * and ILST points to the first row of the current
  17625. * position of the block being moved.
  17626. *
  17627. * Further Details
  17628. * ===============
  17629. *
  17630. * Based on contributions by
  17631. * Bo Kagstrom and Peter Poromaa, Department of Computing Science,
  17632. * Umea University, S-901 87 Umea, Sweden.
  17633. *
  17634. * [1] B. Kagstrom; A Direct Method for Reordering Eigenvalues in the
  17635. * Generalized Real Schur Form of a Regular Matrix Pair (A, B), in
  17636. * M.S. Moonen et al (eds), Linear Algebra for Large Scale and
  17637. * Real-Time Applications, Kluwer Academic Publ. 1993, pp 195-218.
  17638. *
  17639. * =====================================================================
  17640. *
  17641. * .. Parameters ..
  17642. **/
  17643. int C_DTGEXC(int n, double* a, int lda, double* b, int ldb, double* q, int ldq, double* z, int ldz, int* ifst, int* ilst, double* work, int lwork)
  17644. {
  17645. int info;
  17646. ::F_DTGEXC(&n, a, &lda, b, &ldb, q, &ldq, z, &ldz, ifst, ilst, work, &lwork, &info);
  17647. return info;
  17648. }
  17649. /**
  17650. * Purpose
  17651. * =======
  17652. *
  17653. * DTGSEN reorders the generalized real Schur decomposition of a real
  17654. * matrix pair (A, B) (in terms of an orthonormal equivalence trans-
  17655. * formation Q' * (A, B) * Z), so that a selected cluster of eigenvalues
  17656. * appears in the leading diagonal blocks of the upper quasi-triangular
  17657. * matrix A and the upper triangular B. The leading columns of Q and
  17658. * Z form orthonormal bases of the corresponding left and right eigen-
  17659. * spaces (deflating subspaces). (A, B) must be in generalized real
  17660. * Schur canonical form (as returned by DGGES), i.e. A is block upper
  17661. * triangular with 1-by-1 and 2-by-2 diagonal blocks. B is upper
  17662. * triangular.
  17663. *
  17664. * DTGSEN also computes the generalized eigenvalues
  17665. *
  17666. * w(j) = (ALPHAR(j) + i*ALPHAI(j))/BETA(j)
  17667. *
  17668. * of the reordered matrix pair (A, B).
  17669. *
  17670. * Optionally, DTGSEN computes the estimates of reciprocal condition
  17671. * numbers for eigenvalues and eigenspaces. These are Difu[(A11,B11),
  17672. * (A22,B22)] and Difl[(A11,B11), (A22,B22)], i.e. the separation(s)
  17673. * between the matrix pairs (A11, B11) and (A22,B22) that correspond to
  17674. * the selected cluster and the eigenvalues outside the cluster, resp.,
  17675. * and norms of "projections" onto left and right eigenspaces w.r.t.
  17676. * the selected cluster in the (1,1)-block.
  17677. *
  17678. * Arguments
  17679. * =========
  17680. *
  17681. * IJOB (input) INTEGER
  17682. * Specifies whether condition numbers are required for the
  17683. * cluster of eigenvalues (PL and PR) or the deflating subspaces
  17684. * (Difu and Difl):
  17685. * =0: Only reorder w.r.t. SELECT. No extras.
  17686. * =1: Reciprocal of norms of "projections" onto left and right
  17687. * eigenspaces w.r.t. the selected cluster (PL and PR).
  17688. * =2: Upper bounds on Difu and Difl. F-norm-based estimate
  17689. * (DIF(1:2)).
  17690. * =3: Estimate of Difu and Difl. 1-norm-based estimate
  17691. * (DIF(1:2)).
  17692. * About 5 times as expensive as IJOB = 2.
  17693. * =4: Compute PL, PR and DIF (i.e. 0, 1 and 2 above): Economic
  17694. * version to get it all.
  17695. * =5: Compute PL, PR and DIF (i.e. 0, 1 and 3 above)
  17696. *
  17697. * WANTQ (input) LOGICAL
  17698. * .TRUE. : update the left transformation matrix Q;
  17699. * .FALSE.: do not update Q.
  17700. *
  17701. * WANTZ (input) LOGICAL
  17702. * .TRUE. : update the right transformation matrix Z;
  17703. * .FALSE.: do not update Z.
  17704. *
  17705. * SELECT (input) LOGICAL array, dimension (N)
  17706. * SELECT specifies the eigenvalues in the selected cluster.
  17707. * To select a real eigenvalue w(j), SELECT(j) must be set to
  17708. * .TRUE.. To select a complex conjugate pair of eigenvalues
  17709. * w(j) and w(j+1), corresponding to a 2-by-2 diagonal block,
  17710. * either SELECT(j) or SELECT(j+1) or both must be set to
  17711. * .TRUE.; a complex conjugate pair of eigenvalues must be
  17712. * either both included in the cluster or both excluded.
  17713. *
  17714. * N (input) INTEGER
  17715. * The order of the matrices A and B. N >= 0.
  17716. *
  17717. * A (input/output) DOUBLE PRECISION array, dimension(LDA,N)
  17718. * On entry, the upper quasi-triangular matrix A, with (A, B) in
  17719. * generalized real Schur canonical form.
  17720. * On exit, A is overwritten by the reordered matrix A.
  17721. *
  17722. * LDA (input) INTEGER
  17723. * The leading dimension of the array A. LDA >= max(1,N).
  17724. *
  17725. * B (input/output) DOUBLE PRECISION array, dimension(LDB,N)
  17726. * On entry, the upper triangular matrix B, with (A, B) in
  17727. * generalized real Schur canonical form.
  17728. * On exit, B is overwritten by the reordered matrix B.
  17729. *
  17730. * LDB (input) INTEGER
  17731. * The leading dimension of the array B. LDB >= max(1,N).
  17732. *
  17733. * ALPHAR (output) DOUBLE PRECISION array, dimension (N)
  17734. * ALPHAI (output) DOUBLE PRECISION array, dimension (N)
  17735. * BETA (output) DOUBLE PRECISION array, dimension (N)
  17736. * On exit, (ALPHAR(j) + ALPHAI(j)*i)/BETA(j), j=1,...,N, will
  17737. * be the generalized eigenvalues. ALPHAR(j) + ALPHAI(j)*i
  17738. * and BETA(j),j=1,...,N are the diagonals of the complex Schur
  17739. * form (S,T) that would result if the 2-by-2 diagonal blocks of
  17740. * the real generalized Schur form of (A,B) were further reduced
  17741. * to triangular form using complex unitary transformations.
  17742. * If ALPHAI(j) is zero, then the j-th eigenvalue is real; if
  17743. * positive, then the j-th and (j+1)-st eigenvalues are a
  17744. * complex conjugate pair, with ALPHAI(j+1) negative.
  17745. *
  17746. * Q (input/output) DOUBLE PRECISION array, dimension (LDQ,N)
  17747. * On entry, if WANTQ = .TRUE., Q is an N-by-N matrix.
  17748. * On exit, Q has been postmultiplied by the left orthogonal
  17749. * transformation matrix which reorder (A, B); The leading M
  17750. * columns of Q form orthonormal bases for the specified pair of
  17751. * left eigenspaces (deflating subspaces).
  17752. * If WANTQ = .FALSE., Q is not referenced.
  17753. *
  17754. * LDQ (input) INTEGER
  17755. * The leading dimension of the array Q. LDQ >= 1;
  17756. * and if WANTQ = .TRUE., LDQ >= N.
  17757. *
  17758. * Z (input/output) DOUBLE PRECISION array, dimension (LDZ,N)
  17759. * On entry, if WANTZ = .TRUE., Z is an N-by-N matrix.
  17760. * On exit, Z has been postmultiplied by the left orthogonal
  17761. * transformation matrix which reorder (A, B); The leading M
  17762. * columns of Z form orthonormal bases for the specified pair of
  17763. * left eigenspaces (deflating subspaces).
  17764. * If WANTZ = .FALSE., Z is not referenced.
  17765. *
  17766. * LDZ (input) INTEGER
  17767. * The leading dimension of the array Z. LDZ >= 1;
  17768. * If WANTZ = .TRUE., LDZ >= N.
  17769. *
  17770. * M (output) INTEGER
  17771. * The dimension of the specified pair of left and right eigen-
  17772. * spaces (deflating subspaces). 0 <= M <= N.
  17773. *
  17774. * PL (output) DOUBLE PRECISION
  17775. * PR (output) DOUBLE PRECISION
  17776. * If IJOB = 1, 4 or 5, PL, PR are lower bounds on the
  17777. * reciprocal of the norm of "projections" onto left and right
  17778. * eigenspaces with respect to the selected cluster.
  17779. * 0 < PL, PR <= 1.
  17780. * If M = 0 or M = N, PL = PR = 1.
  17781. * If IJOB = 0, 2 or 3, PL and PR are not referenced.
  17782. *
  17783. * DIF (output) DOUBLE PRECISION array, dimension (2).
  17784. * If IJOB >= 2, DIF(1:2) store the estimates of Difu and Difl.
  17785. * If IJOB = 2 or 4, DIF(1:2) are F-norm-based upper bounds on
  17786. * Difu and Difl. If IJOB = 3 or 5, DIF(1:2) are 1-norm-based
  17787. * estimates of Difu and Difl.
  17788. * If M = 0 or N, DIF(1:2) = F-norm([A, B]).
  17789. * If IJOB = 0 or 1, DIF is not referenced.
  17790. *
  17791. * WORK (workspace/output) DOUBLE PRECISION array,
  17792. * dimension (MAX(1,LWORK))
  17793. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  17794. *
  17795. * LWORK (input) INTEGER
  17796. * The dimension of the array WORK. LWORK >= 4*N+16.
  17797. * If IJOB = 1, 2 or 4, LWORK >= MAX(4*N+16, 2*M*(N-M)).
  17798. * If IJOB = 3 or 5, LWORK >= MAX(4*N+16, 4*M*(N-M)).
  17799. *
  17800. * If LWORK = -1, then a workspace query is assumed; the routine
  17801. * only calculates the optimal size of the WORK array, returns
  17802. * this value as the first entry of the WORK array, and no error
  17803. * message related to LWORK is issued by XERBLA.
  17804. *
  17805. * IWORK (workspace/output) INTEGER array, dimension (MAX(1,LIWORK))
  17806. * On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK.
  17807. *
  17808. * LIWORK (input) INTEGER
  17809. * The dimension of the array IWORK. LIWORK >= 1.
  17810. * If IJOB = 1, 2 or 4, LIWORK >= N+6.
  17811. * If IJOB = 3 or 5, LIWORK >= MAX(2*M*(N-M), N+6).
  17812. *
  17813. * If LIWORK = -1, then a workspace query is assumed; the
  17814. * routine only calculates the optimal size of the IWORK array,
  17815. * returns this value as the first entry of the IWORK array, and
  17816. * no error message related to LIWORK is issued by XERBLA.
  17817. *
  17818. * C++ Return value: INFO (output) INTEGER
  17819. * =0: Successful exit.
  17820. * <0: If INFO = -i, the i-th argument had an illegal value.
  17821. * =1: Reordering of (A, B) failed because the transformed
  17822. * matrix pair (A, B) would be too far from generalized
  17823. * Schur form; the problem is very ill-conditioned.
  17824. * (A, B) may have been partially reordered.
  17825. * If requested, 0 is returned in DIF(*), PL and PR.
  17826. *
  17827. * Further Details
  17828. * ===============
  17829. *
  17830. * DTGSEN first collects the selected eigenvalues by computing
  17831. * orthogonal U and W that move them to the top left corner of (A, B).
  17832. * In other words, the selected eigenvalues are the eigenvalues of
  17833. * (A11, B11) in:
  17834. *
  17835. * U'*(A, B)*W = (A11 A12) (B11 B12) n1
  17836. * ( 0 A22),( 0 B22) n2
  17837. * n1 n2 n1 n2
  17838. *
  17839. * where N = n1+n2 and U' means the transpose of U. The first n1 columns
  17840. * of U and W span the specified pair of left and right eigenspaces
  17841. * (deflating subspaces) of (A, B).
  17842. *
  17843. * If (A, B) has been obtained from the generalized real Schur
  17844. * decomposition of a matrix pair (C, D) = Q*(A, B)*Z', then the
  17845. * reordered generalized real Schur form of (C, D) is given by
  17846. *
  17847. * (C, D) = (Q*U)*(U'*(A, B)*W)*(Z*W)',
  17848. *
  17849. * and the first n1 columns of Q*U and Z*W span the corresponding
  17850. * deflating subspaces of (C, D) (Q and Z store Q*U and Z*W, resp.).
  17851. *
  17852. * Note that if the selected eigenvalue is sufficiently ill-conditioned,
  17853. * then its value may differ significantly from its value before
  17854. * reordering.
  17855. *
  17856. * The reciprocal condition numbers of the left and right eigenspaces
  17857. * spanned by the first n1 columns of U and W (or Q*U and Z*W) may
  17858. * be returned in DIF(1:2), corresponding to Difu and Difl, resp.
  17859. *
  17860. * The Difu and Difl are defined as:
  17861. *
  17862. * Difu[(A11, B11), (A22, B22)] = sigma-min( Zu )
  17863. * and
  17864. * Difl[(A11, B11), (A22, B22)] = Difu[(A22, B22), (A11, B11)],
  17865. *
  17866. * where sigma-min(Zu) is the smallest singular value of the
  17867. * (2*n1*n2)-by-(2*n1*n2) matrix
  17868. *
  17869. * Zu = [ kron(In2, A11) -kron(A22', In1) ]
  17870. * [ kron(In2, B11) -kron(B22', In1) ].
  17871. *
  17872. * Here, Inx is the identity matrix of size nx and A22' is the
  17873. * transpose of A22. kron(X, Y) is the Kronecker product between
  17874. * the matrices X and Y.
  17875. *
  17876. * When DIF(2) is small, small changes in (A, B) can cause large changes
  17877. * in the deflating subspace. An approximate (asymptotic) bound on the
  17878. * maximum angular error in the computed deflating subspaces is
  17879. *
  17880. * EPS * norm((A, B)) / DIF(2),
  17881. *
  17882. * where EPS is the machine precision.
  17883. *
  17884. * The reciprocal norm of the projectors on the left and right
  17885. * eigenspaces associated with (A11, B11) may be returned in PL and PR.
  17886. * They are computed as follows. First we compute L and R so that
  17887. * P*(A, B)*Q is block diagonal, where
  17888. *
  17889. * P = ( I -L ) n1 Q = ( I R ) n1
  17890. * ( 0 I ) n2 and ( 0 I ) n2
  17891. * n1 n2 n1 n2
  17892. *
  17893. * and (L, R) is the solution to the generalized Sylvester equation
  17894. *
  17895. * A11*R - L*A22 = -A12
  17896. * B11*R - L*B22 = -B12
  17897. *
  17898. * Then PL = (F-norm(L)**2+1)**(-1/2) and PR = (F-norm(R)**2+1)**(-1/2).
  17899. * An approximate (asymptotic) bound on the average absolute error of
  17900. * the selected eigenvalues is
  17901. *
  17902. * EPS * norm((A, B)) / PL.
  17903. *
  17904. * There are also global error bounds which valid for perturbations up
  17905. * to a certain restriction: A lower bound (x) on the smallest
  17906. * F-norm(E,F) for which an eigenvalue of (A11, B11) may move and
  17907. * coalesce with an eigenvalue of (A22, B22) under perturbation (E,F),
  17908. * (i.e. (A + E, B + F), is
  17909. *
  17910. * x = min(Difu,Difl)/((1/(PL*PL)+1/(PR*PR))**(1/2)+2*max(1/PL,1/PR)).
  17911. *
  17912. * An approximate bound on x can be computed from DIF(1:2), PL and PR.
  17913. *
  17914. * If y = ( F-norm(E,F) / x) <= 1, the angles between the perturbed
  17915. * (L', R') and unperturbed (L, R) left and right deflating subspaces
  17916. * associated with the selected cluster in the (1,1)-blocks can be
  17917. * bounded as
  17918. *
  17919. * max-angle(L, L') <= arctan( y * PL / (1 - y * (1 - PL * PL)**(1/2))
  17920. * max-angle(R, R') <= arctan( y * PR / (1 - y * (1 - PR * PR)**(1/2))
  17921. *
  17922. * See LAPACK User's Guide section 4.11 or the following references
  17923. * for more information.
  17924. *
  17925. * Note that if the default method for computing the Frobenius-norm-
  17926. * based estimate DIF is not wanted (see DLATDF), then the parameter
  17927. * IDIFJB (see below) should be changed from 3 to 4 (routine DLATDF
  17928. * (IJOB = 2 will be used)). See DTGSYL for more details.
  17929. *
  17930. * Based on contributions by
  17931. * Bo Kagstrom and Peter Poromaa, Department of Computing Science,
  17932. * Umea University, S-901 87 Umea, Sweden.
  17933. *
  17934. * References
  17935. * ==========
  17936. *
  17937. * [1] B. Kagstrom; A Direct Method for Reordering Eigenvalues in the
  17938. * Generalized Real Schur Form of a Regular Matrix Pair (A, B), in
  17939. * M.S. Moonen et al (eds), Linear Algebra for Large Scale and
  17940. * Real-Time Applications, Kluwer Academic Publ. 1993, pp 195-218.
  17941. *
  17942. * [2] B. Kagstrom and P. Poromaa; Computing Eigenspaces with Specified
  17943. * Eigenvalues of a Regular Matrix Pair (A, B) and Condition
  17944. * Estimation: Theory, Algorithms and Software,
  17945. * Report UMINF - 94.04, Department of Computing Science, Umea
  17946. * University, S-901 87 Umea, Sweden, 1994. Also as LAPACK Working
  17947. * Note 87. To appear in Numerical Algorithms, 1996.
  17948. *
  17949. * [3] B. Kagstrom and P. Poromaa, LAPACK-Style Algorithms and Software
  17950. * for Solving the Generalized Sylvester Equation and Estimating the
  17951. * Separation between Regular Matrix Pairs, Report UMINF - 93.23,
  17952. * Department of Computing Science, Umea University, S-901 87 Umea,
  17953. * Sweden, December 1993, Revised April 1994, Also as LAPACK Working
  17954. * Note 75. To appear in ACM Trans. on Math. Software, Vol 22, No 1,
  17955. * 1996.
  17956. *
  17957. * =====================================================================
  17958. *
  17959. * .. Parameters ..
  17960. **/
  17961. int C_DTGSEN(int ijob, int n, double* a, int lda, double* b, int ldb, double* alphar, double* alphai, double* beta, double* q, int ldq, double* z, int ldz, int* m, double* pl, double* pr, double* dif, double* work, int lwork, int* iwork, int liwork)
  17962. {
  17963. int info;
  17964. ::F_DTGSEN(&ijob, &n, a, &lda, b, &ldb, alphar, alphai, beta, q, &ldq, z, &ldz, m, pl, pr, dif, work, &lwork, iwork, &liwork, &info);
  17965. return info;
  17966. }
  17967. /**
  17968. * Purpose
  17969. * =======
  17970. *
  17971. * DTGSJA computes the generalized singular value decomposition (GSVD)
  17972. * of two real upper triangular (or trapezoidal) matrices A and B.
  17973. *
  17974. * On entry, it is assumed that matrices A and B have the following
  17975. * forms, which may be obtained by the preprocessing subroutine DGGSVP
  17976. * from a general M-by-N matrix A and P-by-N matrix B:
  17977. *
  17978. * N-K-L K L
  17979. * A = K ( 0 A12 A13 ) if M-K-L >= 0;
  17980. * L ( 0 0 A23 )
  17981. * M-K-L ( 0 0 0 )
  17982. *
  17983. * N-K-L K L
  17984. * A = K ( 0 A12 A13 ) if M-K-L < 0;
  17985. * M-K ( 0 0 A23 )
  17986. *
  17987. * N-K-L K L
  17988. * B = L ( 0 0 B13 )
  17989. * P-L ( 0 0 0 )
  17990. *
  17991. * where the K-by-K matrix A12 and L-by-L matrix B13 are nonsingular
  17992. * upper triangular; A23 is L-by-L upper triangular if M-K-L >= 0,
  17993. * otherwise A23 is (M-K)-by-L upper trapezoidal.
  17994. *
  17995. * On exit,
  17996. *
  17997. * U'*A*Q = D1*( 0 R ), V'*B*Q = D2*( 0 R ),
  17998. *
  17999. * where U, V and Q are orthogonal matrices, Z' denotes the transpose
  18000. * of Z, R is a nonsingular upper triangular matrix, and D1 and D2 are
  18001. * ``diagonal'' matrices, which are of the following structures:
  18002. *
  18003. * If M-K-L >= 0,
  18004. *
  18005. * K L
  18006. * D1 = K ( I 0 )
  18007. * L ( 0 C )
  18008. * M-K-L ( 0 0 )
  18009. *
  18010. * K L
  18011. * D2 = L ( 0 S )
  18012. * P-L ( 0 0 )
  18013. *
  18014. * N-K-L K L
  18015. * ( 0 R ) = K ( 0 R11 R12 ) K
  18016. * L ( 0 0 R22 ) L
  18017. *
  18018. * where
  18019. *
  18020. * C = diag( ALPHA(K+1), ... , ALPHA(K+L) ),
  18021. * S = diag( BETA(K+1), ... , BETA(K+L) ),
  18022. * C**2 + S**2 = I.
  18023. *
  18024. * R is stored in A(1:K+L,N-K-L+1:N) on exit.
  18025. *
  18026. * If M-K-L < 0,
  18027. *
  18028. * K M-K K+L-M
  18029. * D1 = K ( I 0 0 )
  18030. * M-K ( 0 C 0 )
  18031. *
  18032. * K M-K K+L-M
  18033. * D2 = M-K ( 0 S 0 )
  18034. * K+L-M ( 0 0 I )
  18035. * P-L ( 0 0 0 )
  18036. *
  18037. * N-K-L K M-K K+L-M
  18038. * ( 0 R ) = K ( 0 R11 R12 R13 )
  18039. * M-K ( 0 0 R22 R23 )
  18040. * K+L-M ( 0 0 0 R33 )
  18041. *
  18042. * where
  18043. * C = diag( ALPHA(K+1), ... , ALPHA(M) ),
  18044. * S = diag( BETA(K+1), ... , BETA(M) ),
  18045. * C**2 + S**2 = I.
  18046. *
  18047. * R = ( R11 R12 R13 ) is stored in A(1:M, N-K-L+1:N) and R33 is stored
  18048. * ( 0 R22 R23 )
  18049. * in B(M-K+1:L,N+M-K-L+1:N) on exit.
  18050. *
  18051. * The computation of the orthogonal transformation matrices U, V or Q
  18052. * is optional. These matrices may either be formed explicitly, or they
  18053. * may be postmultiplied into input matrices U1, V1, or Q1.
  18054. *
  18055. * Arguments
  18056. * =========
  18057. *
  18058. * JOBU (input) CHARACTER*1
  18059. * = 'U': U must contain an orthogonal matrix U1 on entry, and
  18060. * the product U1*U is returned;
  18061. * = 'I': U is initialized to the unit matrix, and the
  18062. * orthogonal matrix U is returned;
  18063. * = 'N': U is not computed.
  18064. *
  18065. * JOBV (input) CHARACTER*1
  18066. * = 'V': V must contain an orthogonal matrix V1 on entry, and
  18067. * the product V1*V is returned;
  18068. * = 'I': V is initialized to the unit matrix, and the
  18069. * orthogonal matrix V is returned;
  18070. * = 'N': V is not computed.
  18071. *
  18072. * JOBQ (input) CHARACTER*1
  18073. * = 'Q': Q must contain an orthogonal matrix Q1 on entry, and
  18074. * the product Q1*Q is returned;
  18075. * = 'I': Q is initialized to the unit matrix, and the
  18076. * orthogonal matrix Q is returned;
  18077. * = 'N': Q is not computed.
  18078. *
  18079. * M (input) INTEGER
  18080. * The number of rows of the matrix A. M >= 0.
  18081. *
  18082. * P (input) INTEGER
  18083. * The number of rows of the matrix B. P >= 0.
  18084. *
  18085. * N (input) INTEGER
  18086. * The number of columns of the matrices A and B. N >= 0.
  18087. *
  18088. * K (input) INTEGER
  18089. * L (input) INTEGER
  18090. * K and L specify the subblocks in the input matrices A and B:
  18091. * A23 = A(K+1:MIN(K+L,M),N-L+1:N) and B13 = B(1:L,N-L+1:N)
  18092. * of A and B, whose GSVD is going to be computed by DTGSJA.
  18093. * See Further Details.
  18094. *
  18095. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  18096. * On entry, the M-by-N matrix A.
  18097. * On exit, A(N-K+1:N,1:MIN(K+L,M) ) contains the triangular
  18098. * matrix R or part of R. See Purpose for details.
  18099. *
  18100. * LDA (input) INTEGER
  18101. * The leading dimension of the array A. LDA >= max(1,M).
  18102. *
  18103. * B (input/output) DOUBLE PRECISION array, dimension (LDB,N)
  18104. * On entry, the P-by-N matrix B.
  18105. * On exit, if necessary, B(M-K+1:L,N+M-K-L+1:N) contains
  18106. * a part of R. See Purpose for details.
  18107. *
  18108. * LDB (input) INTEGER
  18109. * The leading dimension of the array B. LDB >= max(1,P).
  18110. *
  18111. * TOLA (input) DOUBLE PRECISION
  18112. * TOLB (input) DOUBLE PRECISION
  18113. * TOLA and TOLB are the convergence criteria for the Jacobi-
  18114. * Kogbetliantz iteration procedure. Generally, they are the
  18115. * same as used in the preprocessing step, say
  18116. * TOLA = max(M,N)*norm(A)*MAZHEPS,
  18117. * TOLB = max(P,N)*norm(B)*MAZHEPS.
  18118. *
  18119. * ALPHA (output) DOUBLE PRECISION array, dimension (N)
  18120. * BETA (output) DOUBLE PRECISION array, dimension (N)
  18121. * On exit, ALPHA and BETA contain the generalized singular
  18122. * value pairs of A and B;
  18123. * ALPHA(1:K) = 1,
  18124. * BETA(1:K) = 0,
  18125. * and if M-K-L >= 0,
  18126. * ALPHA(K+1:K+L) = diag(C),
  18127. * BETA(K+1:K+L) = diag(S),
  18128. * or if M-K-L < 0,
  18129. * ALPHA(K+1:M)= C, ALPHA(M+1:K+L)= 0
  18130. * BETA(K+1:M) = S, BETA(M+1:K+L) = 1.
  18131. * Furthermore, if K+L < N,
  18132. * ALPHA(K+L+1:N) = 0 and
  18133. * BETA(K+L+1:N) = 0.
  18134. *
  18135. * U (input/output) DOUBLE PRECISION array, dimension (LDU,M)
  18136. * On entry, if JOBU = 'U', U must contain a matrix U1 (usually
  18137. * the orthogonal matrix returned by DGGSVP).
  18138. * On exit,
  18139. * if JOBU = 'I', U contains the orthogonal matrix U;
  18140. * if JOBU = 'U', U contains the product U1*U.
  18141. * If JOBU = 'N', U is not referenced.
  18142. *
  18143. * LDU (input) INTEGER
  18144. * The leading dimension of the array U. LDU >= max(1,M) if
  18145. * JOBU = 'U'; LDU >= 1 otherwise.
  18146. *
  18147. * V (input/output) DOUBLE PRECISION array, dimension (LDV,P)
  18148. * On entry, if JOBV = 'V', V must contain a matrix V1 (usually
  18149. * the orthogonal matrix returned by DGGSVP).
  18150. * On exit,
  18151. * if JOBV = 'I', V contains the orthogonal matrix V;
  18152. * if JOBV = 'V', V contains the product V1*V.
  18153. * If JOBV = 'N', V is not referenced.
  18154. *
  18155. * LDV (input) INTEGER
  18156. * The leading dimension of the array V. LDV >= max(1,P) if
  18157. * JOBV = 'V'; LDV >= 1 otherwise.
  18158. *
  18159. * Q (input/output) DOUBLE PRECISION array, dimension (LDQ,N)
  18160. * On entry, if JOBQ = 'Q', Q must contain a matrix Q1 (usually
  18161. * the orthogonal matrix returned by DGGSVP).
  18162. * On exit,
  18163. * if JOBQ = 'I', Q contains the orthogonal matrix Q;
  18164. * if JOBQ = 'Q', Q contains the product Q1*Q.
  18165. * If JOBQ = 'N', Q is not referenced.
  18166. *
  18167. * LDQ (input) INTEGER
  18168. * The leading dimension of the array Q. LDQ >= max(1,N) if
  18169. * JOBQ = 'Q'; LDQ >= 1 otherwise.
  18170. *
  18171. * WORK (workspace) DOUBLE PRECISION array, dimension (2*N)
  18172. *
  18173. * NCYCLE (output) INTEGER
  18174. * The number of cycles required for convergence.
  18175. *
  18176. * C++ Return value: INFO (output) INTEGER
  18177. * = 0: successful exit
  18178. * < 0: if INFO = -i, the i-th argument had an illegal value.
  18179. * = 1: the procedure does not converge after MAXIT cycles.
  18180. *
  18181. * Internal Parameters
  18182. * ===================
  18183. *
  18184. * MAXIT INTEGER
  18185. * MAXIT specifies the total loops that the iterative procedure
  18186. * may take. If after MAXIT cycles, the routine fails to
  18187. * converge, we return INFO = 1.
  18188. *
  18189. * Further Details
  18190. * ===============
  18191. *
  18192. * DTGSJA essentially uses a variant of Kogbetliantz algorithm to reduce
  18193. * min(L,M-K)-by-L triangular (or trapezoidal) matrix A23 and L-by-L
  18194. * matrix B13 to the form:
  18195. *
  18196. * U1'*A13*Q1 = C1*R1; V1'*B13*Q1 = S1*R1,
  18197. *
  18198. * where U1, V1 and Q1 are orthogonal matrix, and Z' is the transpose
  18199. * of Z. C1 and S1 are diagonal matrices satisfying
  18200. *
  18201. * C1**2 + S1**2 = I,
  18202. *
  18203. * and R1 is an L-by-L nonsingular upper triangular matrix.
  18204. *
  18205. * =====================================================================
  18206. *
  18207. * .. Parameters ..
  18208. **/
  18209. int C_DTGSJA(char jobu, char jobv, char jobq, int m, int p, int n, int k, int l, double* a, int lda, double* b, int ldb, double tola, double tolb, double* alpha, double* beta, double* u, int ldu, double* v, int ldv, double* q, int ldq, double* work, int* ncycle)
  18210. {
  18211. int info;
  18212. ::F_DTGSJA(&jobu, &jobv, &jobq, &m, &p, &n, &k, &l, a, &lda, b, &ldb, &tola, &tolb, alpha, beta, u, &ldu, v, &ldv, q, &ldq, work, ncycle, &info);
  18213. return info;
  18214. }
  18215. /**
  18216. * Purpose
  18217. * =======
  18218. *
  18219. * DTGSNA estimates reciprocal condition numbers for specified
  18220. * eigenvalues and/or eigenvectors of a matrix pair (A, B) in
  18221. * generalized real Schur canonical form (or of any matrix pair
  18222. * (Q*A*Z', Q*B*Z') with orthogonal matrices Q and Z, where
  18223. * Z' denotes the transpose of Z.
  18224. *
  18225. * (A, B) must be in generalized real Schur form (as returned by DGGES),
  18226. * i.e. A is block upper triangular with 1-by-1 and 2-by-2 diagonal
  18227. * blocks. B is upper triangular.
  18228. *
  18229. *
  18230. * Arguments
  18231. * =========
  18232. *
  18233. * JOB (input) CHARACTER*1
  18234. * Specifies whether condition numbers are required for
  18235. * eigenvalues (S) or eigenvectors (DIF):
  18236. * = 'E': for eigenvalues only (S);
  18237. * = 'V': for eigenvectors only (DIF);
  18238. * = 'B': for both eigenvalues and eigenvectors (S and DIF).
  18239. *
  18240. * HOWMNY (input) CHARACTER*1
  18241. * = 'A': compute condition numbers for all eigenpairs;
  18242. * = 'S': compute condition numbers for selected eigenpairs
  18243. * specified by the array SELECT.
  18244. *
  18245. * SELECT (input) LOGICAL array, dimension (N)
  18246. * If HOWMNY = 'S', SELECT specifies the eigenpairs for which
  18247. * condition numbers are required. To select condition numbers
  18248. * for the eigenpair corresponding to a real eigenvalue w(j),
  18249. * SELECT(j) must be set to .TRUE.. To select condition numbers
  18250. * corresponding to a complex conjugate pair of eigenvalues w(j)
  18251. * and w(j+1), either SELECT(j) or SELECT(j+1) or both, must be
  18252. * set to .TRUE..
  18253. * If HOWMNY = 'A', SELECT is not referenced.
  18254. *
  18255. * N (input) INTEGER
  18256. * The order of the square matrix pair (A, B). N >= 0.
  18257. *
  18258. * A (input) DOUBLE PRECISION array, dimension (LDA,N)
  18259. * The upper quasi-triangular matrix A in the pair (A,B).
  18260. *
  18261. * LDA (input) INTEGER
  18262. * The leading dimension of the array A. LDA >= max(1,N).
  18263. *
  18264. * B (input) DOUBLE PRECISION array, dimension (LDB,N)
  18265. * The upper triangular matrix B in the pair (A,B).
  18266. *
  18267. * LDB (input) INTEGER
  18268. * The leading dimension of the array B. LDB >= max(1,N).
  18269. *
  18270. * VL (input) DOUBLE PRECISION array, dimension (LDVL,M)
  18271. * If JOB = 'E' or 'B', VL must contain left eigenvectors of
  18272. * (A, B), corresponding to the eigenpairs specified by HOWMNY
  18273. * and SELECT. The eigenvectors must be stored in consecutive
  18274. * columns of VL, as returned by DTGEVC.
  18275. * If JOB = 'V', VL is not referenced.
  18276. *
  18277. * LDVL (input) INTEGER
  18278. * The leading dimension of the array VL. LDVL >= 1.
  18279. * If JOB = 'E' or 'B', LDVL >= N.
  18280. *
  18281. * VR (input) DOUBLE PRECISION array, dimension (LDVR,M)
  18282. * If JOB = 'E' or 'B', VR must contain right eigenvectors of
  18283. * (A, B), corresponding to the eigenpairs specified by HOWMNY
  18284. * and SELECT. The eigenvectors must be stored in consecutive
  18285. * columns ov VR, as returned by DTGEVC.
  18286. * If JOB = 'V', VR is not referenced.
  18287. *
  18288. * LDVR (input) INTEGER
  18289. * The leading dimension of the array VR. LDVR >= 1.
  18290. * If JOB = 'E' or 'B', LDVR >= N.
  18291. *
  18292. * S (output) DOUBLE PRECISION array, dimension (MM)
  18293. * If JOB = 'E' or 'B', the reciprocal condition numbers of the
  18294. * selected eigenvalues, stored in consecutive elements of the
  18295. * array. For a complex conjugate pair of eigenvalues two
  18296. * consecutive elements of S are set to the same value. Thus
  18297. * S(j), DIF(j), and the j-th columns of VL and VR all
  18298. * correspond to the same eigenpair (but not in general the
  18299. * j-th eigenpair, unless all eigenpairs are selected).
  18300. * If JOB = 'V', S is not referenced.
  18301. *
  18302. * DIF (output) DOUBLE PRECISION array, dimension (MM)
  18303. * If JOB = 'V' or 'B', the estimated reciprocal condition
  18304. * numbers of the selected eigenvectors, stored in consecutive
  18305. * elements of the array. For a complex eigenvector two
  18306. * consecutive elements of DIF are set to the same value. If
  18307. * the eigenvalues cannot be reordered to compute DIF(j), DIF(j)
  18308. * is set to 0; this can only occur when the true value would be
  18309. * very small anyway.
  18310. * If JOB = 'E', DIF is not referenced.
  18311. *
  18312. * MM (input) INTEGER
  18313. * The number of elements in the arrays S and DIF. MM >= M.
  18314. *
  18315. * M (output) INTEGER
  18316. * The number of elements of the arrays S and DIF used to store
  18317. * the specified condition numbers; for each selected real
  18318. * eigenvalue one element is used, and for each selected complex
  18319. * conjugate pair of eigenvalues, two elements are used.
  18320. * If HOWMNY = 'A', M is set to N.
  18321. *
  18322. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  18323. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  18324. *
  18325. * LWORK (input) INTEGER
  18326. * The dimension of the array WORK. LWORK >= max(1,N).
  18327. * If JOB = 'V' or 'B' LWORK >= 2*N*(N+2)+16.
  18328. *
  18329. * If LWORK = -1, then a workspace query is assumed; the routine
  18330. * only calculates the optimal size of the WORK array, returns
  18331. * this value as the first entry of the WORK array, and no error
  18332. * message related to LWORK is issued by XERBLA.
  18333. *
  18334. * IWORK (workspace) INTEGER array, dimension (N + 6)
  18335. * If JOB = 'E', IWORK is not referenced.
  18336. *
  18337. * C++ Return value: INFO (output) INTEGER
  18338. * =0: Successful exit
  18339. * <0: If INFO = -i, the i-th argument had an illegal value
  18340. *
  18341. *
  18342. * Further Details
  18343. * ===============
  18344. *
  18345. * The reciprocal of the condition number of a generalized eigenvalue
  18346. * w = (a, b) is defined as
  18347. *
  18348. * S(w) = (|u'Av|**2 + |u'Bv|**2)**(1/2) / (norm(u)*norm(v))
  18349. *
  18350. * where u and v are the left and right eigenvectors of (A, B)
  18351. * corresponding to w; |z| denotes the absolute value of the complex
  18352. * number, and norm(u) denotes the 2-norm of the vector u.
  18353. * The pair (a, b) corresponds to an eigenvalue w = a/b (= u'Av/u'Bv)
  18354. * of the matrix pair (A, B). If both a and b equal zero, then (A B) is
  18355. * singular and S(I) = -1 is returned.
  18356. *
  18357. * An approximate error bound on the chordal distance between the i-th
  18358. * computed generalized eigenvalue w and the corresponding exact
  18359. * eigenvalue lambda is
  18360. *
  18361. * chord(w, lambda) <= EPS * norm(A, B) / S(I)
  18362. *
  18363. * where EPS is the machine precision.
  18364. *
  18365. * The reciprocal of the condition number DIF(i) of right eigenvector u
  18366. * and left eigenvector v corresponding to the generalized eigenvalue w
  18367. * is defined as follows:
  18368. *
  18369. * a) If the i-th eigenvalue w = (a,b) is real
  18370. *
  18371. * Suppose U and V are orthogonal transformations such that
  18372. *
  18373. * U'*(A, B)*V = (S, T) = ( a * ) ( b * ) 1
  18374. * ( 0 S22 ),( 0 T22 ) n-1
  18375. * 1 n-1 1 n-1
  18376. *
  18377. * Then the reciprocal condition number DIF(i) is
  18378. *
  18379. * Difl((a, b), (S22, T22)) = sigma-min( Zl ),
  18380. *
  18381. * where sigma-min(Zl) denotes the smallest singular value of the
  18382. * 2(n-1)-by-2(n-1) matrix
  18383. *
  18384. * Zl = [ kron(a, In-1) -kron(1, S22) ]
  18385. * [ kron(b, In-1) -kron(1, T22) ] .
  18386. *
  18387. * Here In-1 is the identity matrix of size n-1. kron(X, Y) is the
  18388. * Kronecker product between the matrices X and Y.
  18389. *
  18390. * Note that if the default method for computing DIF(i) is wanted
  18391. * (see DLATDF), then the parameter DIFDRI (see below) should be
  18392. * changed from 3 to 4 (routine DLATDF(IJOB = 2 will be used)).
  18393. * See DTGSYL for more details.
  18394. *
  18395. * b) If the i-th and (i+1)-th eigenvalues are complex conjugate pair,
  18396. *
  18397. * Suppose U and V are orthogonal transformations such that
  18398. *
  18399. * U'*(A, B)*V = (S, T) = ( S11 * ) ( T11 * ) 2
  18400. * ( 0 S22 ),( 0 T22) n-2
  18401. * 2 n-2 2 n-2
  18402. *
  18403. * and (S11, T11) corresponds to the complex conjugate eigenvalue
  18404. * pair (w, conjg(w)). There exist unitary matrices U1 and V1 such
  18405. * that
  18406. *
  18407. * U1'*S11*V1 = ( s11 s12 ) and U1'*T11*V1 = ( t11 t12 )
  18408. * ( 0 s22 ) ( 0 t22 )
  18409. *
  18410. * where the generalized eigenvalues w = s11/t11 and
  18411. * conjg(w) = s22/t22.
  18412. *
  18413. * Then the reciprocal condition number DIF(i) is bounded by
  18414. *
  18415. * min( d1, max( 1, |real(s11)/real(s22)| )*d2 )
  18416. *
  18417. * where, d1 = Difl((s11, t11), (s22, t22)) = sigma-min(Z1), where
  18418. * Z1 is the complex 2-by-2 matrix
  18419. *
  18420. * Z1 = [ s11 -s22 ]
  18421. * [ t11 -t22 ],
  18422. *
  18423. * This is done by computing (using real arithmetic) the
  18424. * roots of the characteristical polynomial det(Z1' * Z1 - lambda I),
  18425. * where Z1' denotes the conjugate transpose of Z1 and det(X) denotes
  18426. * the determinant of X.
  18427. *
  18428. * and d2 is an upper bound on Difl((S11, T11), (S22, T22)), i.e. an
  18429. * upper bound on sigma-min(Z2), where Z2 is (2n-2)-by-(2n-2)
  18430. *
  18431. * Z2 = [ kron(S11', In-2) -kron(I2, S22) ]
  18432. * [ kron(T11', In-2) -kron(I2, T22) ]
  18433. *
  18434. * Note that if the default method for computing DIF is wanted (see
  18435. * DLATDF), then the parameter DIFDRI (see below) should be changed
  18436. * from 3 to 4 (routine DLATDF(IJOB = 2 will be used)). See DTGSYL
  18437. * for more details.
  18438. *
  18439. * For each eigenvalue/vector specified by SELECT, DIF stores a
  18440. * Frobenius norm-based estimate of Difl.
  18441. *
  18442. * An approximate error bound for the i-th computed eigenvector VL(i) or
  18443. * VR(i) is given by
  18444. *
  18445. * EPS * norm(A, B) / DIF(i).
  18446. *
  18447. * See ref. [2-3] for more details and further references.
  18448. *
  18449. * Based on contributions by
  18450. * Bo Kagstrom and Peter Poromaa, Department of Computing Science,
  18451. * Umea University, S-901 87 Umea, Sweden.
  18452. *
  18453. * References
  18454. * ==========
  18455. *
  18456. * [1] B. Kagstrom; A Direct Method for Reordering Eigenvalues in the
  18457. * Generalized Real Schur Form of a Regular Matrix Pair (A, B), in
  18458. * M.S. Moonen et al (eds), Linear Algebra for Large Scale and
  18459. * Real-Time Applications, Kluwer Academic Publ. 1993, pp 195-218.
  18460. *
  18461. * [2] B. Kagstrom and P. Poromaa; Computing Eigenspaces with Specified
  18462. * Eigenvalues of a Regular Matrix Pair (A, B) and Condition
  18463. * Estimation: Theory, Algorithms and Software,
  18464. * Report UMINF - 94.04, Department of Computing Science, Umea
  18465. * University, S-901 87 Umea, Sweden, 1994. Also as LAPACK Working
  18466. * Note 87. To appear in Numerical Algorithms, 1996.
  18467. *
  18468. * [3] B. Kagstrom and P. Poromaa, LAPACK-Style Algorithms and Software
  18469. * for Solving the Generalized Sylvester Equation and Estimating the
  18470. * Separation between Regular Matrix Pairs, Report UMINF - 93.23,
  18471. * Department of Computing Science, Umea University, S-901 87 Umea,
  18472. * Sweden, December 1993, Revised April 1994, Also as LAPACK Working
  18473. * Note 75. To appear in ACM Trans. on Math. Software, Vol 22,
  18474. * No 1, 1996.
  18475. *
  18476. * =====================================================================
  18477. *
  18478. * .. Parameters ..
  18479. **/
  18480. int C_DTGSNA(char job, char howmny, int n, double* a, int lda, double* b, int ldb, double* vl, int ldvl, double* vr, int ldvr, double* s, double* dif, int mm, int* m, double* work, int lwork, int* iwork)
  18481. {
  18482. int info;
  18483. ::F_DTGSNA(&job, &howmny, &n, a, &lda, b, &ldb, vl, &ldvl, vr, &ldvr, s, dif, &mm, m, work, &lwork, iwork, &info);
  18484. return info;
  18485. }
  18486. /**
  18487. * Purpose
  18488. * =======
  18489. *
  18490. * DTGSYL solves the generalized Sylvester equation:
  18491. *
  18492. * A * R - L * B = scale * C (1)
  18493. * D * R - L * E = scale * F
  18494. *
  18495. * where R and L are unknown m-by-n matrices, (A, D), (B, E) and
  18496. * (C, F) are given matrix pairs of size m-by-m, n-by-n and m-by-n,
  18497. * respectively, with real entries. (A, D) and (B, E) must be in
  18498. * generalized (real) Schur canonical form, i.e. A, B are upper quasi
  18499. * triangular and D, E are upper triangular.
  18500. *
  18501. * The solution (R, L) overwrites (C, F). 0 <= SCALE <= 1 is an output
  18502. * scaling factor chosen to avoid overflow.
  18503. *
  18504. * In matrix notation (1) is equivalent to solve Zx = scale b, where
  18505. * Z is defined as
  18506. *
  18507. * Z = [ kron(In, A) -kron(B', Im) ] (2)
  18508. * [ kron(In, D) -kron(E', Im) ].
  18509. *
  18510. * Here Ik is the identity matrix of size k and X' is the transpose of
  18511. * X. kron(X, Y) is the Kronecker product between the matrices X and Y.
  18512. *
  18513. * If TRANS = 'T', DTGSYL solves the transposed system Z'*y = scale*b,
  18514. * which is equivalent to solve for R and L in
  18515. *
  18516. * A' * R + D' * L = scale * C (3)
  18517. * R * B' + L * E' = scale * (-F)
  18518. *
  18519. * This case (TRANS = 'T') is used to compute an one-norm-based estimate
  18520. * of Dif[(A,D), (B,E)], the separation between the matrix pairs (A,D)
  18521. * and (B,E), using DLACON.
  18522. *
  18523. * If IJOB >= 1, DTGSYL computes a Frobenius norm-based estimate
  18524. * of Dif[(A,D),(B,E)]. That is, the reciprocal of a lower bound on the
  18525. * reciprocal of the smallest singular value of Z. See [1-2] for more
  18526. * information.
  18527. *
  18528. * This is a level 3 BLAS algorithm.
  18529. *
  18530. * Arguments
  18531. * =========
  18532. *
  18533. * TRANS (input) CHARACTER*1
  18534. * = 'N', solve the generalized Sylvester equation (1).
  18535. * = 'T', solve the 'transposed' system (3).
  18536. *
  18537. * IJOB (input) INTEGER
  18538. * Specifies what kind of functionality to be performed.
  18539. * =0: solve (1) only.
  18540. * =1: The functionality of 0 and 3.
  18541. * =2: The functionality of 0 and 4.
  18542. * =3: Only an estimate of Dif[(A,D), (B,E)] is computed.
  18543. * (look ahead strategy IJOB = 1 is used).
  18544. * =4: Only an estimate of Dif[(A,D), (B,E)] is computed.
  18545. * ( DGECON on sub-systems is used ).
  18546. * Not referenced if TRANS = 'T'.
  18547. *
  18548. * M (input) INTEGER
  18549. * The order of the matrices A and D, and the row dimension of
  18550. * the matrices C, F, R and L.
  18551. *
  18552. * N (input) INTEGER
  18553. * The order of the matrices B and E, and the column dimension
  18554. * of the matrices C, F, R and L.
  18555. *
  18556. * A (input) DOUBLE PRECISION array, dimension (LDA, M)
  18557. * The upper quasi triangular matrix A.
  18558. *
  18559. * LDA (input) INTEGER
  18560. * The leading dimension of the array A. LDA >= max(1, M).
  18561. *
  18562. * B (input) DOUBLE PRECISION array, dimension (LDB, N)
  18563. * The upper quasi triangular matrix B.
  18564. *
  18565. * LDB (input) INTEGER
  18566. * The leading dimension of the array B. LDB >= max(1, N).
  18567. *
  18568. * C (input/output) DOUBLE PRECISION array, dimension (LDC, N)
  18569. * On entry, C contains the right-hand-side of the first matrix
  18570. * equation in (1) or (3).
  18571. * On exit, if IJOB = 0, 1 or 2, C has been overwritten by
  18572. * the solution R. If IJOB = 3 or 4 and TRANS = 'N', C holds R,
  18573. * the solution achieved during the computation of the
  18574. * Dif-estimate.
  18575. *
  18576. * LDC (input) INTEGER
  18577. * The leading dimension of the array C. LDC >= max(1, M).
  18578. *
  18579. * D (input) DOUBLE PRECISION array, dimension (LDD, M)
  18580. * The upper triangular matrix D.
  18581. *
  18582. * LDD (input) INTEGER
  18583. * The leading dimension of the array D. LDD >= max(1, M).
  18584. *
  18585. * E (input) DOUBLE PRECISION array, dimension (LDE, N)
  18586. * The upper triangular matrix E.
  18587. *
  18588. * LDE (input) INTEGER
  18589. * The leading dimension of the array E. LDE >= max(1, N).
  18590. *
  18591. * F (input/output) DOUBLE PRECISION array, dimension (LDF, N)
  18592. * On entry, F contains the right-hand-side of the second matrix
  18593. * equation in (1) or (3).
  18594. * On exit, if IJOB = 0, 1 or 2, F has been overwritten by
  18595. * the solution L. If IJOB = 3 or 4 and TRANS = 'N', F holds L,
  18596. * the solution achieved during the computation of the
  18597. * Dif-estimate.
  18598. *
  18599. * LDF (input) INTEGER
  18600. * The leading dimension of the array F. LDF >= max(1, M).
  18601. *
  18602. * DIF (output) DOUBLE PRECISION
  18603. * On exit DIF is the reciprocal of a lower bound of the
  18604. * reciprocal of the Dif-function, i.e. DIF is an upper bound of
  18605. * Dif[(A,D), (B,E)] = sigma_min(Z), where Z as in (2).
  18606. * IF IJOB = 0 or TRANS = 'T', DIF is not touched.
  18607. *
  18608. * SCALE (output) DOUBLE PRECISION
  18609. * On exit SCALE is the scaling factor in (1) or (3).
  18610. * If 0 < SCALE < 1, C and F hold the solutions R and L, resp.,
  18611. * to a slightly perturbed system but the input matrices A, B, D
  18612. * and E have not been changed. If SCALE = 0, C and F hold the
  18613. * solutions R and L, respectively, to the homogeneous system
  18614. * with C = F = 0. Normally, SCALE = 1.
  18615. *
  18616. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  18617. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  18618. *
  18619. * LWORK (input) INTEGER
  18620. * The dimension of the array WORK. LWORK > = 1.
  18621. * If IJOB = 1 or 2 and TRANS = 'N', LWORK >= max(1,2*M*N).
  18622. *
  18623. * If LWORK = -1, then a workspace query is assumed; the routine
  18624. * only calculates the optimal size of the WORK array, returns
  18625. * this value as the first entry of the WORK array, and no error
  18626. * message related to LWORK is issued by XERBLA.
  18627. *
  18628. * IWORK (workspace) INTEGER array, dimension (M+N+6)
  18629. *
  18630. * C++ Return value: INFO (output) INTEGER
  18631. * =0: successful exit
  18632. * <0: If INFO = -i, the i-th argument had an illegal value.
  18633. * >0: (A, D) and (B, E) have common or close eigenvalues.
  18634. *
  18635. * Further Details
  18636. * ===============
  18637. *
  18638. * Based on contributions by
  18639. * Bo Kagstrom and Peter Poromaa, Department of Computing Science,
  18640. * Umea University, S-901 87 Umea, Sweden.
  18641. *
  18642. * [1] B. Kagstrom and P. Poromaa, LAPACK-Style Algorithms and Software
  18643. * for Solving the Generalized Sylvester Equation and Estimating the
  18644. * Separation between Regular Matrix Pairs, Report UMINF - 93.23,
  18645. * Department of Computing Science, Umea University, S-901 87 Umea,
  18646. * Sweden, December 1993, Revised April 1994, Also as LAPACK Working
  18647. * Note 75. To appear in ACM Trans. on Math. Software, Vol 22,
  18648. * No 1, 1996.
  18649. *
  18650. * [2] B. Kagstrom, A Perturbation Analysis of the Generalized Sylvester
  18651. * Equation (AR - LB, DR - LE ) = (C, F), SIAM J. Matrix Anal.
  18652. * Appl., 15(4):1045-1060, 1994
  18653. *
  18654. * [3] B. Kagstrom and L. Westin, Generalized Schur Methods with
  18655. * Condition Estimators for Solving the Generalized Sylvester
  18656. * Equation, IEEE Transactions on Automatic Control, Vol. 34, No. 7,
  18657. * July 1989, pp 745-751.
  18658. *
  18659. * =====================================================================
  18660. * Replaced various illegal calls to DCOPY by calls to DLASET.
  18661. * Sven Hammarling, 1/5/02.
  18662. *
  18663. * .. Parameters ..
  18664. **/
  18665. int C_DTGSYL(char trans, int ijob, int m, int n, double* a, int lda, double* b, int ldb, double* c, int ldc, double* d, int ldd, double* e, int lde, double* f, int ldf, double* dif, double* scale, double* work, int lwork, int* iwork)
  18666. {
  18667. int info;
  18668. ::F_DTGSYL(&trans, &ijob, &m, &n, a, &lda, b, &ldb, c, &ldc, d, &ldd, e, &lde, f, &ldf, dif, scale, work, &lwork, iwork, &info);
  18669. return info;
  18670. }
  18671. /**
  18672. * Purpose
  18673. * =======
  18674. *
  18675. * DTPCON estimates the reciprocal of the condition number of a packed
  18676. * triangular matrix A, in either the 1-norm or the infinity-norm.
  18677. *
  18678. * The norm of A is computed and an estimate is obtained for
  18679. * norm(inv(A)), then the reciprocal of the condition number is
  18680. * computed as
  18681. * RCOND = 1 / ( norm(A) * norm(inv(A)) ).
  18682. *
  18683. * Arguments
  18684. * =========
  18685. *
  18686. * NORM (input) CHARACTER*1
  18687. * Specifies whether the 1-norm condition number or the
  18688. * infinity-norm condition number is required:
  18689. * = '1' or 'O': 1-norm;
  18690. * = 'I': Infinity-norm.
  18691. *
  18692. * UPLO (input) CHARACTER*1
  18693. * = 'U': A is upper triangular;
  18694. * = 'L': A is lower triangular.
  18695. *
  18696. * DIAG (input) CHARACTER*1
  18697. * = 'N': A is non-unit triangular;
  18698. * = 'U': A is unit triangular.
  18699. *
  18700. * N (input) INTEGER
  18701. * The order of the matrix A. N >= 0.
  18702. *
  18703. * AP (input) DOUBLE PRECISION array, dimension (N*(N+1)/2)
  18704. * The upper or lower triangular matrix A, packed columnwise in
  18705. * a linear array. The j-th column of A is stored in the array
  18706. * AP as follows:
  18707. * if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
  18708. * if UPLO = 'L', AP(i + (j-1)*(2n-j)/2) = A(i,j) for j<=i<=n.
  18709. * If DIAG = 'U', the diagonal elements of A are not referenced
  18710. * and are assumed to be 1.
  18711. *
  18712. * RCOND (output) DOUBLE PRECISION
  18713. * The reciprocal of the condition number of the matrix A,
  18714. * computed as RCOND = 1/(norm(A) * norm(inv(A))).
  18715. *
  18716. * WORK (workspace) DOUBLE PRECISION array, dimension (3*N)
  18717. *
  18718. * IWORK (workspace) INTEGER array, dimension (N)
  18719. *
  18720. * C++ Return value: INFO (output) INTEGER
  18721. * = 0: successful exit
  18722. * < 0: if INFO = -i, the i-th argument had an illegal value
  18723. *
  18724. * =====================================================================
  18725. *
  18726. * .. Parameters ..
  18727. **/
  18728. int C_DTPCON(char norm, char uplo, char diag, int n, double* ap, double* rcond, double* work, int* iwork)
  18729. {
  18730. int info;
  18731. ::F_DTPCON(&norm, &uplo, &diag, &n, ap, rcond, work, iwork, &info);
  18732. return info;
  18733. }
  18734. /**
  18735. * Purpose
  18736. * =======
  18737. *
  18738. * DTPRFS provides error bounds and backward error estimates for the
  18739. * solution to a system of linear equations with a triangular packed
  18740. * coefficient matrix.
  18741. *
  18742. * The solution matrix X must be computed by DTPTRS or some other
  18743. * means before entering this routine. DTPRFS does not do iterative
  18744. * refinement because doing so cannot improve the backward error.
  18745. *
  18746. * Arguments
  18747. * =========
  18748. *
  18749. * UPLO (input) CHARACTER*1
  18750. * = 'U': A is upper triangular;
  18751. * = 'L': A is lower triangular.
  18752. *
  18753. * TRANS (input) CHARACTER*1
  18754. * Specifies the form of the system of equations:
  18755. * = 'N': A * X = B (No transpose)
  18756. * = 'T': A**T * X = B (Transpose)
  18757. * = 'C': A**H * X = B (Conjugate transpose = Transpose)
  18758. *
  18759. * DIAG (input) CHARACTER*1
  18760. * = 'N': A is non-unit triangular;
  18761. * = 'U': A is unit triangular.
  18762. *
  18763. * N (input) INTEGER
  18764. * The order of the matrix A. N >= 0.
  18765. *
  18766. * NRHS (input) INTEGER
  18767. * The number of right hand sides, i.e., the number of columns
  18768. * of the matrices B and X. NRHS >= 0.
  18769. *
  18770. * AP (input) DOUBLE PRECISION array, dimension (N*(N+1)/2)
  18771. * The upper or lower triangular matrix A, packed columnwise in
  18772. * a linear array. The j-th column of A is stored in the array
  18773. * AP as follows:
  18774. * if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
  18775. * if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n.
  18776. * If DIAG = 'U', the diagonal elements of A are not referenced
  18777. * and are assumed to be 1.
  18778. *
  18779. * B (input) DOUBLE PRECISION array, dimension (LDB,NRHS)
  18780. * The right hand side matrix B.
  18781. *
  18782. * LDB (input) INTEGER
  18783. * The leading dimension of the array B. LDB >= max(1,N).
  18784. *
  18785. * X (input) DOUBLE PRECISION array, dimension (LDX,NRHS)
  18786. * The solution matrix X.
  18787. *
  18788. * LDX (input) INTEGER
  18789. * The leading dimension of the array X. LDX >= max(1,N).
  18790. *
  18791. * FERR (output) DOUBLE PRECISION array, dimension (NRHS)
  18792. * The estimated forward error bound for each solution vector
  18793. * X(j) (the j-th column of the solution matrix X).
  18794. * If XTRUE is the true solution corresponding to X(j), FERR(j)
  18795. * is an estimated upper bound for the magnitude of the largest
  18796. * element in (X(j) - XTRUE) divided by the magnitude of the
  18797. * largest element in X(j). The estimate is as reliable as
  18798. * the estimate for RCOND, and is almost always a slight
  18799. * overestimate of the true error.
  18800. *
  18801. * BERR (output) DOUBLE PRECISION array, dimension (NRHS)
  18802. * The componentwise relative backward error of each solution
  18803. * vector X(j) (i.e., the smallest relative change in
  18804. * any element of A or B that makes X(j) an exact solution).
  18805. *
  18806. * WORK (workspace) DOUBLE PRECISION array, dimension (3*N)
  18807. *
  18808. * IWORK (workspace) INTEGER array, dimension (N)
  18809. *
  18810. * C++ Return value: INFO (output) INTEGER
  18811. * = 0: successful exit
  18812. * < 0: if INFO = -i, the i-th argument had an illegal value
  18813. *
  18814. * =====================================================================
  18815. *
  18816. * .. Parameters ..
  18817. **/
  18818. int C_DTPRFS(char uplo, char trans, char diag, int n, int nrhs, double* ap, double* b, int ldb, double* x, int ldx, double* ferr, double* berr, double* work, int* iwork)
  18819. {
  18820. int info;
  18821. ::F_DTPRFS(&uplo, &trans, &diag, &n, &nrhs, ap, b, &ldb, x, &ldx, ferr, berr, work, iwork, &info);
  18822. return info;
  18823. }
  18824. /**
  18825. * Purpose
  18826. * =======
  18827. *
  18828. * DTPTRI computes the inverse of a real upper or lower triangular
  18829. * matrix A stored in packed format.
  18830. *
  18831. * Arguments
  18832. * =========
  18833. *
  18834. * UPLO (input) CHARACTER*1
  18835. * = 'U': A is upper triangular;
  18836. * = 'L': A is lower triangular.
  18837. *
  18838. * DIAG (input) CHARACTER*1
  18839. * = 'N': A is non-unit triangular;
  18840. * = 'U': A is unit triangular.
  18841. *
  18842. * N (input) INTEGER
  18843. * The order of the matrix A. N >= 0.
  18844. *
  18845. * AP (input/output) DOUBLE PRECISION array, dimension (N*(N+1)/2)
  18846. * On entry, the upper or lower triangular matrix A, stored
  18847. * columnwise in a linear array. The j-th column of A is stored
  18848. * in the array AP as follows:
  18849. * if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
  18850. * if UPLO = 'L', AP(i + (j-1)*((2*n-j)/2) = A(i,j) for j<=i<=n.
  18851. * See below for further details.
  18852. * On exit, the (triangular) inverse of the original matrix, in
  18853. * the same packed storage format.
  18854. *
  18855. * C++ Return value: INFO (output) INTEGER
  18856. * = 0: successful exit
  18857. * < 0: if INFO = -i, the i-th argument had an illegal value
  18858. * > 0: if INFO = i, A(i,i) is exactly zero. The triangular
  18859. * matrix is singular and its inverse can not be computed.
  18860. *
  18861. * Further Details
  18862. * ===============
  18863. *
  18864. * A triangular matrix A can be transferred to packed storage using one
  18865. * of the following program segments:
  18866. *
  18867. * UPLO = 'U': UPLO = 'L':
  18868. *
  18869. * JC = 1 JC = 1
  18870. * DO 2 J = 1, N DO 2 J = 1, N
  18871. * DO 1 I = 1, J DO 1 I = J, N
  18872. * AP(JC+I-1) = A(I,J) AP(JC+I-J) = A(I,J)
  18873. * 1 CONTINUE 1 CONTINUE
  18874. * JC = JC + J JC = JC + N - J + 1
  18875. * 2 CONTINUE 2 CONTINUE
  18876. *
  18877. * =====================================================================
  18878. *
  18879. * .. Parameters ..
  18880. **/
  18881. int C_DTPTRI(char uplo, char diag, int n, double* ap)
  18882. {
  18883. int info;
  18884. ::F_DTPTRI(&uplo, &diag, &n, ap, &info);
  18885. return info;
  18886. }
  18887. /**
  18888. * Purpose
  18889. * =======
  18890. *
  18891. * DTPTRS solves a triangular system of the form
  18892. *
  18893. * A * X = B or A**T * X = B,
  18894. *
  18895. * where A is a triangular matrix of order N stored in packed format,
  18896. * and B is an N-by-NRHS matrix. A check is made to verify that A is
  18897. * nonsingular.
  18898. *
  18899. * Arguments
  18900. * =========
  18901. *
  18902. * UPLO (input) CHARACTER*1
  18903. * = 'U': A is upper triangular;
  18904. * = 'L': A is lower triangular.
  18905. *
  18906. * TRANS (input) CHARACTER*1
  18907. * Specifies the form of the system of equations:
  18908. * = 'N': A * X = B (No transpose)
  18909. * = 'T': A**T * X = B (Transpose)
  18910. * = 'C': A**H * X = B (Conjugate transpose = Transpose)
  18911. *
  18912. * DIAG (input) CHARACTER*1
  18913. * = 'N': A is non-unit triangular;
  18914. * = 'U': A is unit triangular.
  18915. *
  18916. * N (input) INTEGER
  18917. * The order of the matrix A. N >= 0.
  18918. *
  18919. * NRHS (input) INTEGER
  18920. * The number of right hand sides, i.e., the number of columns
  18921. * of the matrix B. NRHS >= 0.
  18922. *
  18923. * AP (input) DOUBLE PRECISION array, dimension (N*(N+1)/2)
  18924. * The upper or lower triangular matrix A, packed columnwise in
  18925. * a linear array. The j-th column of A is stored in the array
  18926. * AP as follows:
  18927. * if UPLO = 'U', AP(i + (j-1)*j/2) = A(i,j) for 1<=i<=j;
  18928. * if UPLO = 'L', AP(i + (j-1)*(2*n-j)/2) = A(i,j) for j<=i<=n.
  18929. *
  18930. * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
  18931. * On entry, the right hand side matrix B.
  18932. * On exit, if INFO = 0, the solution matrix X.
  18933. *
  18934. * LDB (input) INTEGER
  18935. * The leading dimension of the array B. LDB >= max(1,N).
  18936. *
  18937. * C++ Return value: INFO (output) INTEGER
  18938. * = 0: successful exit
  18939. * < 0: if INFO = -i, the i-th argument had an illegal value
  18940. * > 0: if INFO = i, the i-th diagonal element of A is zero,
  18941. * indicating that the matrix is singular and the
  18942. * solutions X have not been computed.
  18943. *
  18944. * =====================================================================
  18945. *
  18946. * .. Parameters ..
  18947. **/
  18948. int C_DTPTRS(char uplo, char trans, char diag, int n, int nrhs, double* ap, double* b, int ldb)
  18949. {
  18950. int info;
  18951. ::F_DTPTRS(&uplo, &trans, &diag, &n, &nrhs, ap, b, &ldb, &info);
  18952. return info;
  18953. }
  18954. /**
  18955. * Purpose
  18956. * =======
  18957. *
  18958. * DTRCON estimates the reciprocal of the condition number of a
  18959. * triangular matrix A, in either the 1-norm or the infinity-norm.
  18960. *
  18961. * The norm of A is computed and an estimate is obtained for
  18962. * norm(inv(A)), then the reciprocal of the condition number is
  18963. * computed as
  18964. * RCOND = 1 / ( norm(A) * norm(inv(A)) ).
  18965. *
  18966. * Arguments
  18967. * =========
  18968. *
  18969. * NORM (input) CHARACTER*1
  18970. * Specifies whether the 1-norm condition number or the
  18971. * infinity-norm condition number is required:
  18972. * = '1' or 'O': 1-norm;
  18973. * = 'I': Infinity-norm.
  18974. *
  18975. * UPLO (input) CHARACTER*1
  18976. * = 'U': A is upper triangular;
  18977. * = 'L': A is lower triangular.
  18978. *
  18979. * DIAG (input) CHARACTER*1
  18980. * = 'N': A is non-unit triangular;
  18981. * = 'U': A is unit triangular.
  18982. *
  18983. * N (input) INTEGER
  18984. * The order of the matrix A. N >= 0.
  18985. *
  18986. * A (input) DOUBLE PRECISION array, dimension (LDA,N)
  18987. * The triangular matrix A. If UPLO = 'U', the leading N-by-N
  18988. * upper triangular part of the array A contains the upper
  18989. * triangular matrix, and the strictly lower triangular part of
  18990. * A is not referenced. If UPLO = 'L', the leading N-by-N lower
  18991. * triangular part of the array A contains the lower triangular
  18992. * matrix, and the strictly upper triangular part of A is not
  18993. * referenced. If DIAG = 'U', the diagonal elements of A are
  18994. * also not referenced and are assumed to be 1.
  18995. *
  18996. * LDA (input) INTEGER
  18997. * The leading dimension of the array A. LDA >= max(1,N).
  18998. *
  18999. * RCOND (output) DOUBLE PRECISION
  19000. * The reciprocal of the condition number of the matrix A,
  19001. * computed as RCOND = 1/(norm(A) * norm(inv(A))).
  19002. *
  19003. * WORK (workspace) DOUBLE PRECISION array, dimension (3*N)
  19004. *
  19005. * IWORK (workspace) INTEGER array, dimension (N)
  19006. *
  19007. * C++ Return value: INFO (output) INTEGER
  19008. * = 0: successful exit
  19009. * < 0: if INFO = -i, the i-th argument had an illegal value
  19010. *
  19011. * =====================================================================
  19012. *
  19013. * .. Parameters ..
  19014. **/
  19015. int C_DTRCON(char norm, char uplo, char diag, int n, double* a, int lda, double* rcond, double* work, int* iwork)
  19016. {
  19017. int info;
  19018. ::F_DTRCON(&norm, &uplo, &diag, &n, a, &lda, rcond, work, iwork, &info);
  19019. return info;
  19020. }
  19021. /**
  19022. * Purpose
  19023. * =======
  19024. *
  19025. * DTREVC computes some or all of the right and/or left eigenvectors of
  19026. * a real upper quasi-triangular matrix T.
  19027. * Matrices of this type are produced by the Schur factorization of
  19028. * a real general matrix: A = Q*T*Q**T, as computed by DHSEQR.
  19029. *
  19030. * The right eigenvector x and the left eigenvector y of T corresponding
  19031. * to an eigenvalue w are defined by:
  19032. *
  19033. * T*x = w*x, (y**H)*T = w*(y**H)
  19034. *
  19035. * where y**H denotes the conjugate transpose of y.
  19036. * The eigenvalues are not input to this routine, but are read directly
  19037. * from the diagonal blocks of T.
  19038. *
  19039. * This routine returns the matrices X and/or Y of right and left
  19040. * eigenvectors of T, or the products Q*X and/or Q*Y, where Q is an
  19041. * input matrix. If Q is the orthogonal factor that reduces a matrix
  19042. * A to Schur form T, then Q*X and Q*Y are the matrices of right and
  19043. * left eigenvectors of A.
  19044. *
  19045. * Arguments
  19046. * =========
  19047. *
  19048. * SIDE (input) CHARACTER*1
  19049. * = 'R': compute right eigenvectors only;
  19050. * = 'L': compute left eigenvectors only;
  19051. * = 'B': compute both right and left eigenvectors.
  19052. *
  19053. * HOWMNY (input) CHARACTER*1
  19054. * = 'A': compute all right and/or left eigenvectors;
  19055. * = 'B': compute all right and/or left eigenvectors,
  19056. * backtransformed by the matrices in VR and/or VL;
  19057. * = 'S': compute selected right and/or left eigenvectors,
  19058. * as indicated by the logical array SELECT.
  19059. *
  19060. * SELECT (input/output) LOGICAL array, dimension (N)
  19061. * If HOWMNY = 'S', SELECT specifies the eigenvectors to be
  19062. * computed.
  19063. * If w(j) is a real eigenvalue, the corresponding real
  19064. * eigenvector is computed if SELECT(j) is .TRUE..
  19065. * If w(j) and w(j+1) are the real and imaginary parts of a
  19066. * complex eigenvalue, the corresponding complex eigenvector is
  19067. * computed if either SELECT(j) or SELECT(j+1) is .TRUE., and
  19068. * on exit SELECT(j) is set to .TRUE. and SELECT(j+1) is set to
  19069. * .FALSE..
  19070. * Not referenced if HOWMNY = 'A' or 'B'.
  19071. *
  19072. * N (input) INTEGER
  19073. * The order of the matrix T. N >= 0.
  19074. *
  19075. * T (input) DOUBLE PRECISION array, dimension (LDT,N)
  19076. * The upper quasi-triangular matrix T in Schur canonical form.
  19077. *
  19078. * LDT (input) INTEGER
  19079. * The leading dimension of the array T. LDT >= max(1,N).
  19080. *
  19081. * VL (input/output) DOUBLE PRECISION array, dimension (LDVL,MM)
  19082. * On entry, if SIDE = 'L' or 'B' and HOWMNY = 'B', VL must
  19083. * contain an N-by-N matrix Q (usually the orthogonal matrix Q
  19084. * of Schur vectors returned by DHSEQR).
  19085. * On exit, if SIDE = 'L' or 'B', VL contains:
  19086. * if HOWMNY = 'A', the matrix Y of left eigenvectors of T;
  19087. * if HOWMNY = 'B', the matrix Q*Y;
  19088. * if HOWMNY = 'S', the left eigenvectors of T specified by
  19089. * SELECT, stored consecutively in the columns
  19090. * of VL, in the same order as their
  19091. * eigenvalues.
  19092. * A complex eigenvector corresponding to a complex eigenvalue
  19093. * is stored in two consecutive columns, the first holding the
  19094. * real part, and the second the imaginary part.
  19095. * Not referenced if SIDE = 'R'.
  19096. *
  19097. * LDVL (input) INTEGER
  19098. * The leading dimension of the array VL. LDVL >= 1, and if
  19099. * SIDE = 'L' or 'B', LDVL >= N.
  19100. *
  19101. * VR (input/output) DOUBLE PRECISION array, dimension (LDVR,MM)
  19102. * On entry, if SIDE = 'R' or 'B' and HOWMNY = 'B', VR must
  19103. * contain an N-by-N matrix Q (usually the orthogonal matrix Q
  19104. * of Schur vectors returned by DHSEQR).
  19105. * On exit, if SIDE = 'R' or 'B', VR contains:
  19106. * if HOWMNY = 'A', the matrix X of right eigenvectors of T;
  19107. * if HOWMNY = 'B', the matrix Q*X;
  19108. * if HOWMNY = 'S', the right eigenvectors of T specified by
  19109. * SELECT, stored consecutively in the columns
  19110. * of VR, in the same order as their
  19111. * eigenvalues.
  19112. * A complex eigenvector corresponding to a complex eigenvalue
  19113. * is stored in two consecutive columns, the first holding the
  19114. * real part and the second the imaginary part.
  19115. * Not referenced if SIDE = 'L'.
  19116. *
  19117. * LDVR (input) INTEGER
  19118. * The leading dimension of the array VR. LDVR >= 1, and if
  19119. * SIDE = 'R' or 'B', LDVR >= N.
  19120. *
  19121. * MM (input) INTEGER
  19122. * The number of columns in the arrays VL and/or VR. MM >= M.
  19123. *
  19124. * M (output) INTEGER
  19125. * The number of columns in the arrays VL and/or VR actually
  19126. * used to store the eigenvectors.
  19127. * If HOWMNY = 'A' or 'B', M is set to N.
  19128. * Each selected real eigenvector occupies one column and each
  19129. * selected complex eigenvector occupies two columns.
  19130. *
  19131. * WORK (workspace) DOUBLE PRECISION array, dimension (3*N)
  19132. *
  19133. * C++ Return value: INFO (output) INTEGER
  19134. * = 0: successful exit
  19135. * < 0: if INFO = -i, the i-th argument had an illegal value
  19136. *
  19137. * Further Details
  19138. * ===============
  19139. *
  19140. * The algorithm used in this program is basically backward (forward)
  19141. * substitution, with scaling to make the the code robust against
  19142. * possible overflow.
  19143. *
  19144. * Each eigenvector is normalized so that the element of largest
  19145. * magnitude has magnitude 1; here the magnitude of a complex number
  19146. * (x,y) is taken to be |x| + |y|.
  19147. *
  19148. * =====================================================================
  19149. *
  19150. * .. Parameters ..
  19151. **/
  19152. int C_DTREVC(char side, char howmny, int n, double* t, int ldt, double* vl, int ldvl, double* vr, int ldvr, int mm, int* m, double* work)
  19153. {
  19154. int info;
  19155. ::F_DTREVC(&side, &howmny, &n, t, &ldt, vl, &ldvl, vr, &ldvr, &mm, m, work, &info);
  19156. return info;
  19157. }
  19158. /**
  19159. * Purpose
  19160. * =======
  19161. *
  19162. * DTREXC reorders the real Schur factorization of a real matrix
  19163. * A = Q*T*Q**T, so that the diagonal block of T with row index IFST is
  19164. * moved to row ILST.
  19165. *
  19166. * The real Schur form T is reordered by an orthogonal similarity
  19167. * transformation Z**T*T*Z, and optionally the matrix Q of Schur vectors
  19168. * is updated by postmultiplying it with Z.
  19169. *
  19170. * T must be in Schur canonical form (as returned by DHSEQR), that is,
  19171. * block upper triangular with 1-by-1 and 2-by-2 diagonal blocks; each
  19172. * 2-by-2 diagonal block has its diagonal elements equal and its
  19173. * off-diagonal elements of opposite sign.
  19174. *
  19175. * Arguments
  19176. * =========
  19177. *
  19178. * COMPQ (input) CHARACTER*1
  19179. * = 'V': update the matrix Q of Schur vectors;
  19180. * = 'N': do not update Q.
  19181. *
  19182. * N (input) INTEGER
  19183. * The order of the matrix T. N >= 0.
  19184. *
  19185. * T (input/output) DOUBLE PRECISION array, dimension (LDT,N)
  19186. * On entry, the upper quasi-triangular matrix T, in Schur
  19187. * Schur canonical form.
  19188. * On exit, the reordered upper quasi-triangular matrix, again
  19189. * in Schur canonical form.
  19190. *
  19191. * LDT (input) INTEGER
  19192. * The leading dimension of the array T. LDT >= max(1,N).
  19193. *
  19194. * Q (input/output) DOUBLE PRECISION array, dimension (LDQ,N)
  19195. * On entry, if COMPQ = 'V', the matrix Q of Schur vectors.
  19196. * On exit, if COMPQ = 'V', Q has been postmultiplied by the
  19197. * orthogonal transformation matrix Z which reorders T.
  19198. * If COMPQ = 'N', Q is not referenced.
  19199. *
  19200. * LDQ (input) INTEGER
  19201. * The leading dimension of the array Q. LDQ >= max(1,N).
  19202. *
  19203. * IFST (input/output) INTEGER
  19204. * ILST (input/output) INTEGER
  19205. * Specify the reordering of the diagonal blocks of T.
  19206. * The block with row index IFST is moved to row ILST, by a
  19207. * sequence of transpositions between adjacent blocks.
  19208. * On exit, if IFST pointed on entry to the second row of a
  19209. * 2-by-2 block, it is changed to point to the first row; ILST
  19210. * always points to the first row of the block in its final
  19211. * position (which may differ from its input value by +1 or -1).
  19212. * 1 <= IFST <= N; 1 <= ILST <= N.
  19213. *
  19214. * WORK (workspace) DOUBLE PRECISION array, dimension (N)
  19215. *
  19216. * C++ Return value: INFO (output) INTEGER
  19217. * = 0: successful exit
  19218. * < 0: if INFO = -i, the i-th argument had an illegal value
  19219. * = 1: two adjacent blocks were too close to swap (the problem
  19220. * is very ill-conditioned); T may have been partially
  19221. * reordered, and ILST points to the first row of the
  19222. * current position of the block being moved.
  19223. *
  19224. * =====================================================================
  19225. *
  19226. * .. Parameters ..
  19227. **/
  19228. int C_DTREXC(char compq, int n, double* t, int ldt, double* q, int ldq, int* ifst, int* ilst, double* work)
  19229. {
  19230. int info;
  19231. ::F_DTREXC(&compq, &n, t, &ldt, q, &ldq, ifst, ilst, work, &info);
  19232. return info;
  19233. }
  19234. /**
  19235. * Purpose
  19236. * =======
  19237. *
  19238. * DTRRFS provides error bounds and backward error estimates for the
  19239. * solution to a system of linear equations with a triangular
  19240. * coefficient matrix.
  19241. *
  19242. * The solution matrix X must be computed by DTRTRS or some other
  19243. * means before entering this routine. DTRRFS does not do iterative
  19244. * refinement because doing so cannot improve the backward error.
  19245. *
  19246. * Arguments
  19247. * =========
  19248. *
  19249. * UPLO (input) CHARACTER*1
  19250. * = 'U': A is upper triangular;
  19251. * = 'L': A is lower triangular.
  19252. *
  19253. * TRANS (input) CHARACTER*1
  19254. * Specifies the form of the system of equations:
  19255. * = 'N': A * X = B (No transpose)
  19256. * = 'T': A**T * X = B (Transpose)
  19257. * = 'C': A**H * X = B (Conjugate transpose = Transpose)
  19258. *
  19259. * DIAG (input) CHARACTER*1
  19260. * = 'N': A is non-unit triangular;
  19261. * = 'U': A is unit triangular.
  19262. *
  19263. * N (input) INTEGER
  19264. * The order of the matrix A. N >= 0.
  19265. *
  19266. * NRHS (input) INTEGER
  19267. * The number of right hand sides, i.e., the number of columns
  19268. * of the matrices B and X. NRHS >= 0.
  19269. *
  19270. * A (input) DOUBLE PRECISION array, dimension (LDA,N)
  19271. * The triangular matrix A. If UPLO = 'U', the leading N-by-N
  19272. * upper triangular part of the array A contains the upper
  19273. * triangular matrix, and the strictly lower triangular part of
  19274. * A is not referenced. If UPLO = 'L', the leading N-by-N lower
  19275. * triangular part of the array A contains the lower triangular
  19276. * matrix, and the strictly upper triangular part of A is not
  19277. * referenced. If DIAG = 'U', the diagonal elements of A are
  19278. * also not referenced and are assumed to be 1.
  19279. *
  19280. * LDA (input) INTEGER
  19281. * The leading dimension of the array A. LDA >= max(1,N).
  19282. *
  19283. * B (input) DOUBLE PRECISION array, dimension (LDB,NRHS)
  19284. * The right hand side matrix B.
  19285. *
  19286. * LDB (input) INTEGER
  19287. * The leading dimension of the array B. LDB >= max(1,N).
  19288. *
  19289. * X (input) DOUBLE PRECISION array, dimension (LDX,NRHS)
  19290. * The solution matrix X.
  19291. *
  19292. * LDX (input) INTEGER
  19293. * The leading dimension of the array X. LDX >= max(1,N).
  19294. *
  19295. * FERR (output) DOUBLE PRECISION array, dimension (NRHS)
  19296. * The estimated forward error bound for each solution vector
  19297. * X(j) (the j-th column of the solution matrix X).
  19298. * If XTRUE is the true solution corresponding to X(j), FERR(j)
  19299. * is an estimated upper bound for the magnitude of the largest
  19300. * element in (X(j) - XTRUE) divided by the magnitude of the
  19301. * largest element in X(j). The estimate is as reliable as
  19302. * the estimate for RCOND, and is almost always a slight
  19303. * overestimate of the true error.
  19304. *
  19305. * BERR (output) DOUBLE PRECISION array, dimension (NRHS)
  19306. * The componentwise relative backward error of each solution
  19307. * vector X(j) (i.e., the smallest relative change in
  19308. * any element of A or B that makes X(j) an exact solution).
  19309. *
  19310. * WORK (workspace) DOUBLE PRECISION array, dimension (3*N)
  19311. *
  19312. * IWORK (workspace) INTEGER array, dimension (N)
  19313. *
  19314. * C++ Return value: INFO (output) INTEGER
  19315. * = 0: successful exit
  19316. * < 0: if INFO = -i, the i-th argument had an illegal value
  19317. *
  19318. * =====================================================================
  19319. *
  19320. * .. Parameters ..
  19321. **/
  19322. int C_DTRRFS(char uplo, char trans, char diag, int n, int nrhs, double* a, int lda, double* b, int ldb, double* x, int ldx, double* ferr, double* berr, double* work, int* iwork)
  19323. {
  19324. int info;
  19325. ::F_DTRRFS(&uplo, &trans, &diag, &n, &nrhs, a, &lda, b, &ldb, x, &ldx, ferr, berr, work, iwork, &info);
  19326. return info;
  19327. }
  19328. /**
  19329. * Purpose
  19330. * =======
  19331. *
  19332. * DTRSEN reorders the real Schur factorization of a real matrix
  19333. * A = Q*T*Q**T, so that a selected cluster of eigenvalues appears in
  19334. * the leading diagonal blocks of the upper quasi-triangular matrix T,
  19335. * and the leading columns of Q form an orthonormal basis of the
  19336. * corresponding right invariant subspace.
  19337. *
  19338. * Optionally the routine computes the reciprocal condition numbers of
  19339. * the cluster of eigenvalues and/or the invariant subspace.
  19340. *
  19341. * T must be in Schur canonical form (as returned by DHSEQR), that is,
  19342. * block upper triangular with 1-by-1 and 2-by-2 diagonal blocks; each
  19343. * 2-by-2 diagonal block has its diagonal elemnts equal and its
  19344. * off-diagonal elements of opposite sign.
  19345. *
  19346. * Arguments
  19347. * =========
  19348. *
  19349. * JOB (input) CHARACTER*1
  19350. * Specifies whether condition numbers are required for the
  19351. * cluster of eigenvalues (S) or the invariant subspace (SEP):
  19352. * = 'N': none;
  19353. * = 'E': for eigenvalues only (S);
  19354. * = 'V': for invariant subspace only (SEP);
  19355. * = 'B': for both eigenvalues and invariant subspace (S and
  19356. * SEP).
  19357. *
  19358. * COMPQ (input) CHARACTER*1
  19359. * = 'V': update the matrix Q of Schur vectors;
  19360. * = 'N': do not update Q.
  19361. *
  19362. * SELECT (input) LOGICAL array, dimension (N)
  19363. * SELECT specifies the eigenvalues in the selected cluster. To
  19364. * select a real eigenvalue w(j), SELECT(j) must be set to
  19365. * .TRUE.. To select a complex conjugate pair of eigenvalues
  19366. * w(j) and w(j+1), corresponding to a 2-by-2 diagonal block,
  19367. * either SELECT(j) or SELECT(j+1) or both must be set to
  19368. * .TRUE.; a complex conjugate pair of eigenvalues must be
  19369. * either both included in the cluster or both excluded.
  19370. *
  19371. * N (input) INTEGER
  19372. * The order of the matrix T. N >= 0.
  19373. *
  19374. * T (input/output) DOUBLE PRECISION array, dimension (LDT,N)
  19375. * On entry, the upper quasi-triangular matrix T, in Schur
  19376. * canonical form.
  19377. * On exit, T is overwritten by the reordered matrix T, again in
  19378. * Schur canonical form, with the selected eigenvalues in the
  19379. * leading diagonal blocks.
  19380. *
  19381. * LDT (input) INTEGER
  19382. * The leading dimension of the array T. LDT >= max(1,N).
  19383. *
  19384. * Q (input/output) DOUBLE PRECISION array, dimension (LDQ,N)
  19385. * On entry, if COMPQ = 'V', the matrix Q of Schur vectors.
  19386. * On exit, if COMPQ = 'V', Q has been postmultiplied by the
  19387. * orthogonal transformation matrix which reorders T; the
  19388. * leading M columns of Q form an orthonormal basis for the
  19389. * specified invariant subspace.
  19390. * If COMPQ = 'N', Q is not referenced.
  19391. *
  19392. * LDQ (input) INTEGER
  19393. * The leading dimension of the array Q.
  19394. * LDQ >= 1; and if COMPQ = 'V', LDQ >= N.
  19395. *
  19396. * WR (output) DOUBLE PRECISION array, dimension (N)
  19397. * WI (output) DOUBLE PRECISION array, dimension (N)
  19398. * The real and imaginary parts, respectively, of the reordered
  19399. * eigenvalues of T. The eigenvalues are stored in the same
  19400. * order as on the diagonal of T, with WR(i) = T(i,i) and, if
  19401. * T(i:i+1,i:i+1) is a 2-by-2 diagonal block, WI(i) > 0 and
  19402. * WI(i+1) = -WI(i). Note that if a complex eigenvalue is
  19403. * sufficiently ill-conditioned, then its value may differ
  19404. * significantly from its value before reordering.
  19405. *
  19406. * M (output) INTEGER
  19407. * The dimension of the specified invariant subspace.
  19408. * 0 < = M <= N.
  19409. *
  19410. * S (output) DOUBLE PRECISION
  19411. * If JOB = 'E' or 'B', S is a lower bound on the reciprocal
  19412. * condition number for the selected cluster of eigenvalues.
  19413. * S cannot underestimate the true reciprocal condition number
  19414. * by more than a factor of sqrt(N). If M = 0 or N, S = 1.
  19415. * If JOB = 'N' or 'V', S is not referenced.
  19416. *
  19417. * SEP (output) DOUBLE PRECISION
  19418. * If JOB = 'V' or 'B', SEP is the estimated reciprocal
  19419. * condition number of the specified invariant subspace. If
  19420. * M = 0 or N, SEP = norm(T).
  19421. * If JOB = 'N' or 'E', SEP is not referenced.
  19422. *
  19423. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  19424. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  19425. *
  19426. * LWORK (input) INTEGER
  19427. * The dimension of the array WORK.
  19428. * If JOB = 'N', LWORK >= max(1,N);
  19429. * if JOB = 'E', LWORK >= max(1,M*(N-M));
  19430. * if JOB = 'V' or 'B', LWORK >= max(1,2*M*(N-M)).
  19431. *
  19432. * If LWORK = -1, then a workspace query is assumed; the routine
  19433. * only calculates the optimal size of the WORK array, returns
  19434. * this value as the first entry of the WORK array, and no error
  19435. * message related to LWORK is issued by XERBLA.
  19436. *
  19437. * IWORK (workspace) INTEGER array, dimension (MAX(1,LIWORK))
  19438. * On exit, if INFO = 0, IWORK(1) returns the optimal LIWORK.
  19439. *
  19440. * LIWORK (input) INTEGER
  19441. * The dimension of the array IWORK.
  19442. * If JOB = 'N' or 'E', LIWORK >= 1;
  19443. * if JOB = 'V' or 'B', LIWORK >= max(1,M*(N-M)).
  19444. *
  19445. * If LIWORK = -1, then a workspace query is assumed; the
  19446. * routine only calculates the optimal size of the IWORK array,
  19447. * returns this value as the first entry of the IWORK array, and
  19448. * no error message related to LIWORK is issued by XERBLA.
  19449. *
  19450. * C++ Return value: INFO (output) INTEGER
  19451. * = 0: successful exit
  19452. * < 0: if INFO = -i, the i-th argument had an illegal value
  19453. * = 1: reordering of T failed because some eigenvalues are too
  19454. * close to separate (the problem is very ill-conditioned);
  19455. * T may have been partially reordered, and WR and WI
  19456. * contain the eigenvalues in the same order as in T; S and
  19457. * SEP (if requested) are set to zero.
  19458. *
  19459. * Further Details
  19460. * ===============
  19461. *
  19462. * DTRSEN first collects the selected eigenvalues by computing an
  19463. * orthogonal transformation Z to move them to the top left corner of T.
  19464. * In other words, the selected eigenvalues are the eigenvalues of T11
  19465. * in:
  19466. *
  19467. * Z'*T*Z = ( T11 T12 ) n1
  19468. * ( 0 T22 ) n2
  19469. * n1 n2
  19470. *
  19471. * where N = n1+n2 and Z' means the transpose of Z. The first n1 columns
  19472. * of Z span the specified invariant subspace of T.
  19473. *
  19474. * If T has been obtained from the real Schur factorization of a matrix
  19475. * A = Q*T*Q', then the reordered real Schur factorization of A is given
  19476. * by A = (Q*Z)*(Z'*T*Z)*(Q*Z)', and the first n1 columns of Q*Z span
  19477. * the corresponding invariant subspace of A.
  19478. *
  19479. * The reciprocal condition number of the average of the eigenvalues of
  19480. * T11 may be returned in S. S lies between 0 (very badly conditioned)
  19481. * and 1 (very well conditioned). It is computed as follows. First we
  19482. * compute R so that
  19483. *
  19484. * P = ( I R ) n1
  19485. * ( 0 0 ) n2
  19486. * n1 n2
  19487. *
  19488. * is the projector on the invariant subspace associated with T11.
  19489. * R is the solution of the Sylvester equation:
  19490. *
  19491. * T11*R - R*T22 = T12.
  19492. *
  19493. * Let F-norm(M) denote the Frobenius-norm of M and 2-norm(M) denote
  19494. * the two-norm of M. Then S is computed as the lower bound
  19495. *
  19496. * (1 + F-norm(R)**2)**(-1/2)
  19497. *
  19498. * on the reciprocal of 2-norm(P), the true reciprocal condition number.
  19499. * S cannot underestimate 1 / 2-norm(P) by more than a factor of
  19500. * sqrt(N).
  19501. *
  19502. * An approximate error bound for the computed average of the
  19503. * eigenvalues of T11 is
  19504. *
  19505. * EPS * norm(T) / S
  19506. *
  19507. * where EPS is the machine precision.
  19508. *
  19509. * The reciprocal condition number of the right invariant subspace
  19510. * spanned by the first n1 columns of Z (or of Q*Z) is returned in SEP.
  19511. * SEP is defined as the separation of T11 and T22:
  19512. *
  19513. * sep( T11, T22 ) = sigma-min( C )
  19514. *
  19515. * where sigma-min(C) is the smallest singular value of the
  19516. * n1*n2-by-n1*n2 matrix
  19517. *
  19518. * C = kprod( I(n2), T11 ) - kprod( transpose(T22), I(n1) )
  19519. *
  19520. * I(m) is an m by m identity matrix, and kprod denotes the Kronecker
  19521. * product. We estimate sigma-min(C) by the reciprocal of an estimate of
  19522. * the 1-norm of inverse(C). The true reciprocal 1-norm of inverse(C)
  19523. * cannot differ from sigma-min(C) by more than a factor of sqrt(n1*n2).
  19524. *
  19525. * When SEP is small, small changes in T can cause large changes in
  19526. * the invariant subspace. An approximate bound on the maximum angular
  19527. * error in the computed right invariant subspace is
  19528. *
  19529. * EPS * norm(T) / SEP
  19530. *
  19531. * =====================================================================
  19532. *
  19533. * .. Parameters ..
  19534. **/
  19535. int C_DTRSEN(char job, char compq, int n, double* t, int ldt, double* q, int ldq, double* wr, double* wi, int* m, double* s, double* sep, double* work, int lwork, int* iwork, int liwork)
  19536. {
  19537. int info;
  19538. ::F_DTRSEN(&job, &compq, &n, t, &ldt, q, &ldq, wr, wi, m, s, sep, work, &lwork, iwork, &liwork, &info);
  19539. return info;
  19540. }
  19541. /**
  19542. * Purpose
  19543. * =======
  19544. *
  19545. * DTRSNA estimates reciprocal condition numbers for specified
  19546. * eigenvalues and/or right eigenvectors of a real upper
  19547. * quasi-triangular matrix T (or of any matrix Q*T*Q**T with Q
  19548. * orthogonal).
  19549. *
  19550. * T must be in Schur canonical form (as returned by DHSEQR), that is,
  19551. * block upper triangular with 1-by-1 and 2-by-2 diagonal blocks; each
  19552. * 2-by-2 diagonal block has its diagonal elements equal and its
  19553. * off-diagonal elements of opposite sign.
  19554. *
  19555. * Arguments
  19556. * =========
  19557. *
  19558. * JOB (input) CHARACTER*1
  19559. * Specifies whether condition numbers are required for
  19560. * eigenvalues (S) or eigenvectors (SEP):
  19561. * = 'E': for eigenvalues only (S);
  19562. * = 'V': for eigenvectors only (SEP);
  19563. * = 'B': for both eigenvalues and eigenvectors (S and SEP).
  19564. *
  19565. * HOWMNY (input) CHARACTER*1
  19566. * = 'A': compute condition numbers for all eigenpairs;
  19567. * = 'S': compute condition numbers for selected eigenpairs
  19568. * specified by the array SELECT.
  19569. *
  19570. * SELECT (input) LOGICAL array, dimension (N)
  19571. * If HOWMNY = 'S', SELECT specifies the eigenpairs for which
  19572. * condition numbers are required. To select condition numbers
  19573. * for the eigenpair corresponding to a real eigenvalue w(j),
  19574. * SELECT(j) must be set to .TRUE.. To select condition numbers
  19575. * corresponding to a complex conjugate pair of eigenvalues w(j)
  19576. * and w(j+1), either SELECT(j) or SELECT(j+1) or both, must be
  19577. * set to .TRUE..
  19578. * If HOWMNY = 'A', SELECT is not referenced.
  19579. *
  19580. * N (input) INTEGER
  19581. * The order of the matrix T. N >= 0.
  19582. *
  19583. * T (input) DOUBLE PRECISION array, dimension (LDT,N)
  19584. * The upper quasi-triangular matrix T, in Schur canonical form.
  19585. *
  19586. * LDT (input) INTEGER
  19587. * The leading dimension of the array T. LDT >= max(1,N).
  19588. *
  19589. * VL (input) DOUBLE PRECISION array, dimension (LDVL,M)
  19590. * If JOB = 'E' or 'B', VL must contain left eigenvectors of T
  19591. * (or of any Q*T*Q**T with Q orthogonal), corresponding to the
  19592. * eigenpairs specified by HOWMNY and SELECT. The eigenvectors
  19593. * must be stored in consecutive columns of VL, as returned by
  19594. * DHSEIN or DTREVC.
  19595. * If JOB = 'V', VL is not referenced.
  19596. *
  19597. * LDVL (input) INTEGER
  19598. * The leading dimension of the array VL.
  19599. * LDVL >= 1; and if JOB = 'E' or 'B', LDVL >= N.
  19600. *
  19601. * VR (input) DOUBLE PRECISION array, dimension (LDVR,M)
  19602. * If JOB = 'E' or 'B', VR must contain right eigenvectors of T
  19603. * (or of any Q*T*Q**T with Q orthogonal), corresponding to the
  19604. * eigenpairs specified by HOWMNY and SELECT. The eigenvectors
  19605. * must be stored in consecutive columns of VR, as returned by
  19606. * DHSEIN or DTREVC.
  19607. * If JOB = 'V', VR is not referenced.
  19608. *
  19609. * LDVR (input) INTEGER
  19610. * The leading dimension of the array VR.
  19611. * LDVR >= 1; and if JOB = 'E' or 'B', LDVR >= N.
  19612. *
  19613. * S (output) DOUBLE PRECISION array, dimension (MM)
  19614. * If JOB = 'E' or 'B', the reciprocal condition numbers of the
  19615. * selected eigenvalues, stored in consecutive elements of the
  19616. * array. For a complex conjugate pair of eigenvalues two
  19617. * consecutive elements of S are set to the same value. Thus
  19618. * S(j), SEP(j), and the j-th columns of VL and VR all
  19619. * correspond to the same eigenpair (but not in general the
  19620. * j-th eigenpair, unless all eigenpairs are selected).
  19621. * If JOB = 'V', S is not referenced.
  19622. *
  19623. * SEP (output) DOUBLE PRECISION array, dimension (MM)
  19624. * If JOB = 'V' or 'B', the estimated reciprocal condition
  19625. * numbers of the selected eigenvectors, stored in consecutive
  19626. * elements of the array. For a complex eigenvector two
  19627. * consecutive elements of SEP are set to the same value. If
  19628. * the eigenvalues cannot be reordered to compute SEP(j), SEP(j)
  19629. * is set to 0; this can only occur when the true value would be
  19630. * very small anyway.
  19631. * If JOB = 'E', SEP is not referenced.
  19632. *
  19633. * MM (input) INTEGER
  19634. * The number of elements in the arrays S (if JOB = 'E' or 'B')
  19635. * and/or SEP (if JOB = 'V' or 'B'). MM >= M.
  19636. *
  19637. * M (output) INTEGER
  19638. * The number of elements of the arrays S and/or SEP actually
  19639. * used to store the estimated condition numbers.
  19640. * If HOWMNY = 'A', M is set to N.
  19641. *
  19642. * WORK (workspace) DOUBLE PRECISION array, dimension (LDWORK,N+6)
  19643. * If JOB = 'E', WORK is not referenced.
  19644. *
  19645. * LDWORK (input) INTEGER
  19646. * The leading dimension of the array WORK.
  19647. * LDWORK >= 1; and if JOB = 'V' or 'B', LDWORK >= N.
  19648. *
  19649. * IWORK (workspace) INTEGER array, dimension (2*(N-1))
  19650. * If JOB = 'E', IWORK is not referenced.
  19651. *
  19652. * C++ Return value: INFO (output) INTEGER
  19653. * = 0: successful exit
  19654. * < 0: if INFO = -i, the i-th argument had an illegal value
  19655. *
  19656. * Further Details
  19657. * ===============
  19658. *
  19659. * The reciprocal of the condition number of an eigenvalue lambda is
  19660. * defined as
  19661. *
  19662. * S(lambda) = |v'*u| / (norm(u)*norm(v))
  19663. *
  19664. * where u and v are the right and left eigenvectors of T corresponding
  19665. * to lambda; v' denotes the conjugate-transpose of v, and norm(u)
  19666. * denotes the Euclidean norm. These reciprocal condition numbers always
  19667. * lie between zero (very badly conditioned) and one (very well
  19668. * conditioned). If n = 1, S(lambda) is defined to be 1.
  19669. *
  19670. * An approximate error bound for a computed eigenvalue W(i) is given by
  19671. *
  19672. * EPS * norm(T) / S(i)
  19673. *
  19674. * where EPS is the machine precision.
  19675. *
  19676. * The reciprocal of the condition number of the right eigenvector u
  19677. * corresponding to lambda is defined as follows. Suppose
  19678. *
  19679. * T = ( lambda c )
  19680. * ( 0 T22 )
  19681. *
  19682. * Then the reciprocal condition number is
  19683. *
  19684. * SEP( lambda, T22 ) = sigma-min( T22 - lambda*I )
  19685. *
  19686. * where sigma-min denotes the smallest singular value. We approximate
  19687. * the smallest singular value by the reciprocal of an estimate of the
  19688. * one-norm of the inverse of T22 - lambda*I. If n = 1, SEP(1) is
  19689. * defined to be abs(T(1,1)).
  19690. *
  19691. * An approximate error bound for a computed right eigenvector VR(i)
  19692. * is given by
  19693. *
  19694. * EPS * norm(T) / SEP(i)
  19695. *
  19696. * =====================================================================
  19697. *
  19698. * .. Parameters ..
  19699. **/
  19700. int C_DTRSNA(char job, char howmny, int n, double* t, int ldt, double* vl, int ldvl, double* vr, int ldvr, double* s, double* sep, int mm, int* m, double* work, int ldwork, int* iwork)
  19701. {
  19702. int info;
  19703. ::F_DTRSNA(&job, &howmny, &n, t, &ldt, vl, &ldvl, vr, &ldvr, s, sep, &mm, m, work, &ldwork, iwork, &info);
  19704. return info;
  19705. }
  19706. /**
  19707. * Purpose
  19708. * =======
  19709. *
  19710. * DTRSYL solves the real Sylvester matrix equation:
  19711. *
  19712. * op(A)*X + X*op(B) = scale*C or
  19713. * op(A)*X - X*op(B) = scale*C,
  19714. *
  19715. * where op(A) = A or A**T, and A and B are both upper quasi-
  19716. * triangular. A is M-by-M and B is N-by-N; the right hand side C and
  19717. * the solution X are M-by-N; and scale is an output scale factor, set
  19718. * <= 1 to avoid overflow in X.
  19719. *
  19720. * A and B must be in Schur canonical form (as returned by DHSEQR), that
  19721. * is, block upper triangular with 1-by-1 and 2-by-2 diagonal blocks;
  19722. * each 2-by-2 diagonal block has its diagonal elements equal and its
  19723. * off-diagonal elements of opposite sign.
  19724. *
  19725. * Arguments
  19726. * =========
  19727. *
  19728. * TRANA (input) CHARACTER*1
  19729. * Specifies the option op(A):
  19730. * = 'N': op(A) = A (No transpose)
  19731. * = 'T': op(A) = A**T (Transpose)
  19732. * = 'C': op(A) = A**H (Conjugate transpose = Transpose)
  19733. *
  19734. * TRANB (input) CHARACTER*1
  19735. * Specifies the option op(B):
  19736. * = 'N': op(B) = B (No transpose)
  19737. * = 'T': op(B) = B**T (Transpose)
  19738. * = 'C': op(B) = B**H (Conjugate transpose = Transpose)
  19739. *
  19740. * ISGN (input) INTEGER
  19741. * Specifies the sign in the equation:
  19742. * = +1: solve op(A)*X + X*op(B) = scale*C
  19743. * = -1: solve op(A)*X - X*op(B) = scale*C
  19744. *
  19745. * M (input) INTEGER
  19746. * The order of the matrix A, and the number of rows in the
  19747. * matrices X and C. M >= 0.
  19748. *
  19749. * N (input) INTEGER
  19750. * The order of the matrix B, and the number of columns in the
  19751. * matrices X and C. N >= 0.
  19752. *
  19753. * A (input) DOUBLE PRECISION array, dimension (LDA,M)
  19754. * The upper quasi-triangular matrix A, in Schur canonical form.
  19755. *
  19756. * LDA (input) INTEGER
  19757. * The leading dimension of the array A. LDA >= max(1,M).
  19758. *
  19759. * B (input) DOUBLE PRECISION array, dimension (LDB,N)
  19760. * The upper quasi-triangular matrix B, in Schur canonical form.
  19761. *
  19762. * LDB (input) INTEGER
  19763. * The leading dimension of the array B. LDB >= max(1,N).
  19764. *
  19765. * C (input/output) DOUBLE PRECISION array, dimension (LDC,N)
  19766. * On entry, the M-by-N right hand side matrix C.
  19767. * On exit, C is overwritten by the solution matrix X.
  19768. *
  19769. * LDC (input) INTEGER
  19770. * The leading dimension of the array C. LDC >= max(1,M)
  19771. *
  19772. * SCALE (output) DOUBLE PRECISION
  19773. * The scale factor, scale, set <= 1 to avoid overflow in X.
  19774. *
  19775. * C++ Return value: INFO (output) INTEGER
  19776. * = 0: successful exit
  19777. * < 0: if INFO = -i, the i-th argument had an illegal value
  19778. * = 1: A and B have common or very close eigenvalues; perturbed
  19779. * values were used to solve the equation (but the matrices
  19780. * A and B are unchanged).
  19781. *
  19782. * =====================================================================
  19783. *
  19784. * .. Parameters ..
  19785. **/
  19786. int C_DTRSYL(char trana, char tranb, int isgn, int m, int n, double* a, int lda, double* b, int ldb, double* c, int ldc, double* scale)
  19787. {
  19788. int info;
  19789. ::F_DTRSYL(&trana, &tranb, &isgn, &m, &n, a, &lda, b, &ldb, c, &ldc, scale, &info);
  19790. return info;
  19791. }
  19792. /**
  19793. * Purpose
  19794. * =======
  19795. *
  19796. * DTRTRI computes the inverse of a real upper or lower triangular
  19797. * matrix A.
  19798. *
  19799. * This is the Level 3 BLAS version of the algorithm.
  19800. *
  19801. * Arguments
  19802. * =========
  19803. *
  19804. * UPLO (input) CHARACTER*1
  19805. * = 'U': A is upper triangular;
  19806. * = 'L': A is lower triangular.
  19807. *
  19808. * DIAG (input) CHARACTER*1
  19809. * = 'N': A is non-unit triangular;
  19810. * = 'U': A is unit triangular.
  19811. *
  19812. * N (input) INTEGER
  19813. * The order of the matrix A. N >= 0.
  19814. *
  19815. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  19816. * On entry, the triangular matrix A. If UPLO = 'U', the
  19817. * leading N-by-N upper triangular part of the array A contains
  19818. * the upper triangular matrix, and the strictly lower
  19819. * triangular part of A is not referenced. If UPLO = 'L', the
  19820. * leading N-by-N lower triangular part of the array A contains
  19821. * the lower triangular matrix, and the strictly upper
  19822. * triangular part of A is not referenced. If DIAG = 'U', the
  19823. * diagonal elements of A are also not referenced and are
  19824. * assumed to be 1.
  19825. * On exit, the (triangular) inverse of the original matrix, in
  19826. * the same storage format.
  19827. *
  19828. * LDA (input) INTEGER
  19829. * The leading dimension of the array A. LDA >= max(1,N).
  19830. *
  19831. * C++ Return value: INFO (output) INTEGER
  19832. * = 0: successful exit
  19833. * < 0: if INFO = -i, the i-th argument had an illegal value
  19834. * > 0: if INFO = i, A(i,i) is exactly zero. The triangular
  19835. * matrix is singular and its inverse can not be computed.
  19836. *
  19837. * =====================================================================
  19838. *
  19839. * .. Parameters ..
  19840. **/
  19841. int C_DTRTRI(char uplo, char diag, int n, double* a, int lda)
  19842. {
  19843. int info;
  19844. ::F_DTRTRI(&uplo, &diag, &n, a, &lda, &info);
  19845. return info;
  19846. }
  19847. /**
  19848. * Purpose
  19849. * =======
  19850. *
  19851. * DTRTRS solves a triangular system of the form
  19852. *
  19853. * A * X = B or A**T * X = B,
  19854. *
  19855. * where A is a triangular matrix of order N, and B is an N-by-NRHS
  19856. * matrix. A check is made to verify that A is nonsingular.
  19857. *
  19858. * Arguments
  19859. * =========
  19860. *
  19861. * UPLO (input) CHARACTER*1
  19862. * = 'U': A is upper triangular;
  19863. * = 'L': A is lower triangular.
  19864. *
  19865. * TRANS (input) CHARACTER*1
  19866. * Specifies the form of the system of equations:
  19867. * = 'N': A * X = B (No transpose)
  19868. * = 'T': A**T * X = B (Transpose)
  19869. * = 'C': A**H * X = B (Conjugate transpose = Transpose)
  19870. *
  19871. * DIAG (input) CHARACTER*1
  19872. * = 'N': A is non-unit triangular;
  19873. * = 'U': A is unit triangular.
  19874. *
  19875. * N (input) INTEGER
  19876. * The order of the matrix A. N >= 0.
  19877. *
  19878. * NRHS (input) INTEGER
  19879. * The number of right hand sides, i.e., the number of columns
  19880. * of the matrix B. NRHS >= 0.
  19881. *
  19882. * A (input) DOUBLE PRECISION array, dimension (LDA,N)
  19883. * The triangular matrix A. If UPLO = 'U', the leading N-by-N
  19884. * upper triangular part of the array A contains the upper
  19885. * triangular matrix, and the strictly lower triangular part of
  19886. * A is not referenced. If UPLO = 'L', the leading N-by-N lower
  19887. * triangular part of the array A contains the lower triangular
  19888. * matrix, and the strictly upper triangular part of A is not
  19889. * referenced. If DIAG = 'U', the diagonal elements of A are
  19890. * also not referenced and are assumed to be 1.
  19891. *
  19892. * LDA (input) INTEGER
  19893. * The leading dimension of the array A. LDA >= max(1,N).
  19894. *
  19895. * B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS)
  19896. * On entry, the right hand side matrix B.
  19897. * On exit, if INFO = 0, the solution matrix X.
  19898. *
  19899. * LDB (input) INTEGER
  19900. * The leading dimension of the array B. LDB >= max(1,N).
  19901. *
  19902. * C++ Return value: INFO (output) INTEGER
  19903. * = 0: successful exit
  19904. * < 0: if INFO = -i, the i-th argument had an illegal value
  19905. * > 0: if INFO = i, the i-th diagonal element of A is zero,
  19906. * indicating that the matrix is singular and the solutions
  19907. * X have not been computed.
  19908. *
  19909. * =====================================================================
  19910. *
  19911. * .. Parameters ..
  19912. **/
  19913. int C_DTRTRS(char uplo, char trans, char diag, int n, int nrhs, double* a, int lda, double* b, int ldb)
  19914. {
  19915. int info;
  19916. ::F_DTRTRS(&uplo, &trans, &diag, &n, &nrhs, a, &lda, b, &ldb, &info);
  19917. return info;
  19918. }
  19919. /**
  19920. * Purpose
  19921. * =======
  19922. *
  19923. * This routine is deprecated and has been replaced by routine DTZRZF.
  19924. *
  19925. * DTZRQF reduces the M-by-N ( M<=N ) real upper trapezoidal matrix A
  19926. * to upper triangular form by means of orthogonal transformations.
  19927. *
  19928. * The upper trapezoidal matrix A is factored as
  19929. *
  19930. * A = ( R 0 ) * Z,
  19931. *
  19932. * where Z is an N-by-N orthogonal matrix and R is an M-by-M upper
  19933. * triangular matrix.
  19934. *
  19935. * Arguments
  19936. * =========
  19937. *
  19938. * M (input) INTEGER
  19939. * The number of rows of the matrix A. M >= 0.
  19940. *
  19941. * N (input) INTEGER
  19942. * The number of columns of the matrix A. N >= M.
  19943. *
  19944. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  19945. * On entry, the leading M-by-N upper trapezoidal part of the
  19946. * array A must contain the matrix to be factorized.
  19947. * On exit, the leading M-by-M upper triangular part of A
  19948. * contains the upper triangular matrix R, and elements M+1 to
  19949. * N of the first M rows of A, with the array TAU, represent the
  19950. * orthogonal matrix Z as a product of M elementary reflectors.
  19951. *
  19952. * LDA (input) INTEGER
  19953. * The leading dimension of the array A. LDA >= max(1,M).
  19954. *
  19955. * TAU (output) DOUBLE PRECISION array, dimension (M)
  19956. * The scalar factors of the elementary reflectors.
  19957. *
  19958. * C++ Return value: INFO (output) INTEGER
  19959. * = 0: successful exit
  19960. * < 0: if INFO = -i, the i-th argument had an illegal value
  19961. *
  19962. * Further Details
  19963. * ===============
  19964. *
  19965. * The factorization is obtained by Householder's method. The kth
  19966. * transformation matrix, Z( k ), which is used to introduce zeros into
  19967. * the ( m - k + 1 )th row of A, is given in the form
  19968. *
  19969. * Z( k ) = ( I 0 ),
  19970. * ( 0 T( k ) )
  19971. *
  19972. * where
  19973. *
  19974. * T( k ) = I - tau*u( k )*u( k )', u( k ) = ( 1 ),
  19975. * ( 0 )
  19976. * ( z( k ) )
  19977. *
  19978. * tau is a scalar and z( k ) is an ( n - m ) element vector.
  19979. * tau and z( k ) are chosen to annihilate the elements of the kth row
  19980. * of X.
  19981. *
  19982. * The scalar tau is returned in the kth element of TAU and the vector
  19983. * u( k ) in the kth row of A, such that the elements of z( k ) are
  19984. * in a( k, m + 1 ), ..., a( k, n ). The elements of R are returned in
  19985. * the upper triangular part of A.
  19986. *
  19987. * Z is given by
  19988. *
  19989. * Z = Z( 1 ) * Z( 2 ) * ... * Z( m ).
  19990. *
  19991. * =====================================================================
  19992. *
  19993. * .. Parameters ..
  19994. **/
  19995. int C_DTZRQF(int m, int n, double* a, int lda, double* tau)
  19996. {
  19997. int info;
  19998. ::F_DTZRQF(&m, &n, a, &lda, tau, &info);
  19999. return info;
  20000. }
  20001. /**
  20002. * Purpose
  20003. * =======
  20004. *
  20005. * DTZRZF reduces the M-by-N ( M<=N ) real upper trapezoidal matrix A
  20006. * to upper triangular form by means of orthogonal transformations.
  20007. *
  20008. * The upper trapezoidal matrix A is factored as
  20009. *
  20010. * A = ( R 0 ) * Z,
  20011. *
  20012. * where Z is an N-by-N orthogonal matrix and R is an M-by-M upper
  20013. * triangular matrix.
  20014. *
  20015. * Arguments
  20016. * =========
  20017. *
  20018. * M (input) INTEGER
  20019. * The number of rows of the matrix A. M >= 0.
  20020. *
  20021. * N (input) INTEGER
  20022. * The number of columns of the matrix A. N >= M.
  20023. *
  20024. * A (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  20025. * On entry, the leading M-by-N upper trapezoidal part of the
  20026. * array A must contain the matrix to be factorized.
  20027. * On exit, the leading M-by-M upper triangular part of A
  20028. * contains the upper triangular matrix R, and elements M+1 to
  20029. * N of the first M rows of A, with the array TAU, represent the
  20030. * orthogonal matrix Z as a product of M elementary reflectors.
  20031. *
  20032. * LDA (input) INTEGER
  20033. * The leading dimension of the array A. LDA >= max(1,M).
  20034. *
  20035. * TAU (output) DOUBLE PRECISION array, dimension (M)
  20036. * The scalar factors of the elementary reflectors.
  20037. *
  20038. * WORK (workspace/output) DOUBLE PRECISION array, dimension (MAX(1,LWORK))
  20039. * On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  20040. *
  20041. * LWORK (input) INTEGER
  20042. * The dimension of the array WORK. LWORK >= max(1,M).
  20043. * For optimum performance LWORK >= M*NB, where NB is
  20044. * the optimal blocksize.
  20045. *
  20046. * If LWORK = -1, then a workspace query is assumed; the routine
  20047. * only calculates the optimal size of the WORK array, returns
  20048. * this value as the first entry of the WORK array, and no error
  20049. * message related to LWORK is issued by XERBLA.
  20050. *
  20051. * C++ Return value: INFO (output) INTEGER
  20052. * = 0: successful exit
  20053. * < 0: if INFO = -i, the i-th argument had an illegal value
  20054. *
  20055. * Further Details
  20056. * ===============
  20057. *
  20058. * Based on contributions by
  20059. * A. Petitet, Computer Science Dept., Univ. of Tenn., Knoxville, USA
  20060. *
  20061. * The factorization is obtained by Householder's method. The kth
  20062. * transformation matrix, Z( k ), which is used to introduce zeros into
  20063. * the ( m - k + 1 )th row of A, is given in the form
  20064. *
  20065. * Z( k ) = ( I 0 ),
  20066. * ( 0 T( k ) )
  20067. *
  20068. * where
  20069. *
  20070. * T( k ) = I - tau*u( k )*u( k )', u( k ) = ( 1 ),
  20071. * ( 0 )
  20072. * ( z( k ) )
  20073. *
  20074. * tau is a scalar and z( k ) is an ( n - m ) element vector.
  20075. * tau and z( k ) are chosen to annihilate the elements of the kth row
  20076. * of X.
  20077. *
  20078. * The scalar tau is returned in the kth element of TAU and the vector
  20079. * u( k ) in the kth row of A, such that the elements of z( k ) are
  20080. * in a( k, m + 1 ), ..., a( k, n ). The elements of R are returned in
  20081. * the upper triangular part of A.
  20082. *
  20083. * Z is given by
  20084. *
  20085. * Z = Z( 1 ) * Z( 2 ) * ... * Z( m ).
  20086. *
  20087. * =====================================================================
  20088. *
  20089. * .. Parameters ..
  20090. **/
  20091. int C_DTZRZF(int m, int n, double* a, int lda, double* tau, double* work, int lwork)
  20092. {
  20093. int info;
  20094. ::F_DTZRZF(&m, &n, a, &lda, tau, work, &lwork, &info);
  20095. return info;
  20096. }
  20097. }