PageRenderTime 51ms CodeModel.GetById 32ms RepoModel.GetById 0ms app.codeStats 1ms

/src/lib/libqt/lapack_intfc.cc

https://gitlab.com/y-shao/psi4public
C++ | 12343 lines | 893 code | 121 blank | 11329 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. * withou