Nektar++
NekLinSys.hpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: NekLinSys.hpp
4 //
5 // For more information, please see: http://www.nektar.info
6 //
7 // The MIT License
8 //
9 // Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10 // Department of Aeronautics, Imperial College London (UK), and Scientific
11 // Computing and Imaging Institute, University of Utah (USA).
12 //
13 // Permission is hereby granted, free of charge, to any person obtaining a
14 // copy of this software and associated documentation files (the "Software"),
15 // to deal in the Software without restriction, including without limitation
16 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
17 // and/or sell copies of the Software, and to permit persons to whom the
18 // Software is furnished to do so, subject to the following conditions:
19 //
20 // The above copyright notice and this permission notice shall be included
21 // in all copies or substantial portions of the Software.
22 //
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29 // DEALINGS IN THE SOFTWARE.
30 //
31 // Description:
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #ifndef NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_NEK_LINSYS_HPP
36 #define NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_NEK_LINSYS_HPP
37 
46 #include <iostream>
47 
48 #include <type_traits>
49 
50 #ifdef max
51 #undef max
52 #endif
53 
54 #ifdef min
55 #undef min
56 #endif
57 
58 namespace Nektar
59 {
60 template <typename DataType> struct IsSharedPointer : public std::false_type
61 {
62 };
63 
64 template <typename DataType>
65 struct IsSharedPointer<std::shared_ptr<DataType>> : public std::true_type
66 {
67 };
68 
69 // The solving of the linear system is located in this class instead of in the
70 // LinearSystem class because XCode gcc 4.2 didn't compile it correctly when it
71 // was moved to the LinearSystem class.
73 {
74  template <typename BVectorType, typename XVectorType>
75  static void Solve(const BVectorType &b, XVectorType &x,
76  MatrixStorage m_matrixType,
77  const Array<OneD, const int> &m_ipivot, unsigned int n,
78  const Array<OneD, const double> &A, char m_transposeFlag,
79  unsigned int m_numberOfSubDiagonals,
80  unsigned int m_numberOfSuperDiagonals)
81  {
82  switch (m_matrixType)
83  {
84  case eFULL:
85  {
86  x = b;
87  int info = 0;
88  Lapack::Dgetrs('N', n, 1, A.get(), n, (int *)m_ipivot.get(),
89  x.GetRawPtr(), n, info);
90  if (info < 0)
91  {
92  std::string message =
93  "ERROR: The " + std::to_string(-info) +
94  "th parameter had an illegal parameter for dgetrs";
95  ASSERTL0(false, message.c_str());
96  }
97  }
98  break;
99  case eDIAGONAL:
100  for (unsigned int i = 0; i < A.size(); ++i)
101  {
102  x[i] = b[i] * A[i];
103  }
104  break;
105  case eUPPER_TRIANGULAR:
106  {
107  x = b;
108  int info = 0;
109  Lapack::Dtptrs('U', m_transposeFlag, 'N', n, 1, A.get(),
110  x.GetRawPtr(), n, info);
111 
112  if (info < 0)
113  {
114  std::string message =
115  "ERROR: The " + std::to_string(-info) +
116  "th parameter had an illegal parameter for dtrtrs";
117  ASSERTL0(false, message.c_str());
118  }
119  else if (info > 0)
120  {
121  std::string message =
122  "ERROR: The " + std::to_string(-info) +
123  "th diagonal element of A is 0 for dtrtrs";
124  ASSERTL0(false, message.c_str());
125  }
126  }
127  break;
128  case eLOWER_TRIANGULAR:
129  {
130  x = b;
131  int info = 0;
132  Lapack::Dtptrs('L', m_transposeFlag, 'N', n, 1, A.get(),
133  x.GetRawPtr(), n, info);
134 
135  if (info < 0)
136  {
137  std::string message =
138  "ERROR: The " + std::to_string(-info) +
139  "th parameter had an illegal parameter for dtrtrs";
140  ASSERTL0(false, message.c_str());
141  }
142  else if (info > 0)
143  {
144  std::string message =
145  "ERROR: The " + std::to_string(-info) +
146  "th diagonal element of A is 0 for dtrtrs";
147  ASSERTL0(false, message.c_str());
148  }
149  }
150  break;
151  case eSYMMETRIC:
152  {
153  x = b;
154  int info = 0;
155  Lapack::Dsptrs('U', n, 1, A.get(), m_ipivot.get(),
156  x.GetRawPtr(), x.GetRows(), info);
157  if (info < 0)
158  {
159  std::string message =
160  "ERROR: The " + std::to_string(-info) +
161  "th parameter had an illegal parameter for dsptrs";
162  ASSERTL0(false, message.c_str());
163  }
164  }
165  break;
167  {
168  x = b;
169  int info = 0;
170  Lapack::Dpptrs('U', n, 1, A.get(), x.GetRawPtr(), x.GetRows(),
171  info);
172  if (info < 0)
173  {
174  std::string message =
175  "ERROR: The " + std::to_string(-info) +
176  "th parameter had an illegal parameter for dpptrs";
177  ASSERTL0(false, message.c_str());
178  }
179  }
180  break;
181  case eBANDED:
182  {
183  x = b;
184  int KL = m_numberOfSubDiagonals;
185  int KU = m_numberOfSuperDiagonals;
186  int info = 0;
187 
188  Lapack::Dgbtrs(m_transposeFlag, n, KL, KU, 1, A.get(),
189  2 * KL + KU + 1, m_ipivot.get(), x.GetRawPtr(),
190  n, info);
191 
192  if (info < 0)
193  {
194  std::string message =
195  "ERROR: The " + std::to_string(-info) +
196  "th parameter had an illegal parameter for dgbtrs";
197  ASSERTL0(false, message.c_str());
198  }
199  }
200  break;
202  {
203  x = b;
204  int KU = m_numberOfSuperDiagonals;
205  int info = 0;
206 
207  Lapack::Dpbtrs('U', n, KU, 1, A.get(), KU + 1, x.GetRawPtr(), n,
208  info);
209 
210  if (info < 0)
211  {
212  std::string message =
213  "ERROR: The " + std::to_string(-info) +
214  "th parameter had an illegal parameter for dpbtrs";
215  ASSERTL0(false, message.c_str());
216  }
217  }
218  break;
219  case eSYMMETRIC_BANDED:
220  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
221  break;
223  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
224  break;
226  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
227  break;
228 
229  default:
230  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
231  }
232  }
233 
234  template <typename BVectorType, typename XVectorType>
235  static void SolveTranspose(const BVectorType &b, XVectorType &x,
236  MatrixStorage m_matrixType,
237  const Array<OneD, const int> &m_ipivot,
238  unsigned int n,
240  char m_transposeFlag,
241  unsigned int m_numberOfSubDiagonals,
242  unsigned int m_numberOfSuperDiagonals)
243  {
244  switch (m_matrixType)
245  {
246  case eFULL:
247  {
248  x = b;
249  int info = 0;
250  Lapack::Dgetrs('T', n, 1, A.get(), n, (int *)m_ipivot.get(),
251  x.GetRawPtr(), n, info);
252 
253  if (info < 0)
254  {
255  std::string message =
256  "ERROR: The " + std::to_string(-info) +
257  "th parameter had an illegal parameter for dgetrs";
258  ASSERTL0(false, message.c_str());
259  }
260  }
261 
262  break;
263  case eDIAGONAL:
264  Solve(b, x, m_matrixType, m_ipivot, n, A, m_transposeFlag,
265  m_numberOfSubDiagonals, m_numberOfSuperDiagonals);
266  break;
267  case eUPPER_TRIANGULAR:
268  {
269  char trans = m_transposeFlag;
270  if (trans == 'N')
271  {
272  trans = 'T';
273  }
274  else
275  {
276  trans = 'N';
277  }
278 
279  x = b;
280  int info = 0;
281  Lapack::Dtptrs('U', trans, 'N', n, 1, A.get(), x.GetRawPtr(), n,
282  info);
283 
284  if (info < 0)
285  {
286  std::string message =
287  "ERROR: The " + std::to_string(-info) +
288  "th parameter had an illegal parameter for dtrtrs";
289  ASSERTL0(false, message.c_str());
290  }
291  else if (info > 0)
292  {
293  std::string message =
294  "ERROR: The " + std::to_string(-info) +
295  "th diagonal element of A is 0 for dtrtrs";
296  ASSERTL0(false, message.c_str());
297  }
298  }
299 
300  break;
301  case eLOWER_TRIANGULAR:
302  {
303  char trans = m_transposeFlag;
304  if (trans == 'N')
305  {
306  trans = 'T';
307  }
308  else
309  {
310  trans = 'N';
311  }
312  x = b;
313  int info = 0;
314  Lapack::Dtptrs('L', trans, 'N', n, 1, A.get(), x.GetRawPtr(), n,
315  info);
316 
317  if (info < 0)
318  {
319  std::string message =
320  "ERROR: The " + std::to_string(-info) +
321  "th parameter had an illegal parameter for dtrtrs";
322  ASSERTL0(false, message.c_str());
323  }
324  else if (info > 0)
325  {
326  std::string message =
327  "ERROR: The " + std::to_string(-info) +
328  "th diagonal element of A is 0 for dtrtrs";
329  ASSERTL0(false, message.c_str());
330  }
331  }
332  break;
333  case eSYMMETRIC:
336  Solve(b, x, m_matrixType, m_ipivot, n, A, m_transposeFlag,
337  m_numberOfSubDiagonals, m_numberOfSuperDiagonals);
338  break;
339  case eBANDED:
340  {
341  x = b;
342  int KL = m_numberOfSubDiagonals;
343  int KU = m_numberOfSuperDiagonals;
344  int info = 0;
345 
346  Lapack::Dgbtrs(m_transposeFlag, n, KL, KU, 1, A.get(),
347  2 * KL + KU + 1, m_ipivot.get(), x.GetRawPtr(),
348  n, info);
349 
350  if (info < 0)
351  {
352  std::string message =
353  "ERROR: The " + std::to_string(-info) +
354  "th parameter had an illegal parameter for dgbtrs";
355  ASSERTL0(false, message.c_str());
356  }
357  }
358  break;
359  case eSYMMETRIC_BANDED:
360  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
361  break;
363  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
364  break;
366  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
367  break;
368 
369  default:
370  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
371  }
372  }
373 };
374 
376 {
377 public:
378  template <typename MatrixType>
379  explicit LinearSystem(const std::shared_ptr<MatrixType> &theA,
380  PointerWrapper wrapperType = eCopy)
381  : n(theA->GetRows()), A(theA->GetPtr(), eVECTOR_WRAPPER), m_ipivot(),
382  m_numberOfSubDiagonals(theA->GetNumberOfSubDiagonals()),
383  m_numberOfSuperDiagonals(theA->GetNumberOfSuperDiagonals()),
384  m_matrixType(theA->GetType()),
385  m_transposeFlag(theA->GetTransposeFlag())
386  {
387  // At some point we should fix this. We should upate the copy of
388  // A to be transposd for this to work.
389  ASSERTL0(theA->GetTransposeFlag() == 'N',
390  "LinearSystem requires a non-transposed matrix.");
391  ASSERTL0((wrapperType == eWrapper && theA->GetType() != eBANDED) ||
392  wrapperType == eCopy,
393  "Banded matrices can't be wrapped");
394 
395  if (wrapperType == eCopy)
396  {
397  A = Array<OneD, double>(theA->GetPtr().size());
398  CopyArray(theA->GetPtr(), A);
399  }
400 
401  FactorMatrix(*theA);
402  }
403 
404  template <typename MatrixType>
405  explicit LinearSystem(const MatrixType &theA,
406  PointerWrapper wrapperType = eCopy)
407  : n(theA.GetRows()), A(theA.GetPtr(), eVECTOR_WRAPPER), m_ipivot(),
408  m_numberOfSubDiagonals(theA.GetNumberOfSubDiagonals()),
409  m_numberOfSuperDiagonals(theA.GetNumberOfSuperDiagonals()),
410  m_matrixType(theA.GetType()), m_transposeFlag(theA.GetTransposeFlag())
411  {
412  // At some point we should fix this. We should upate the copy of
413  // A to be transposd for this to work.
414  ASSERTL0(theA.GetTransposeFlag() == 'N',
415  "LinearSystem requires a non-transposed matrix.");
416  ASSERTL0((wrapperType == eWrapper && theA.GetType() != eBANDED) ||
417  wrapperType == eCopy,
418  "Banded matrices can't be wrapped");
419 
420  if (wrapperType == eCopy)
421  {
422  A = Array<OneD, double>(theA.GetPtr().size());
423  CopyArray(theA.GetPtr(), A);
424  }
425 
426  FactorMatrix(theA);
427  }
428 
430  : n(rhs.n), A(rhs.A), m_ipivot(rhs.m_ipivot),
434  {
435  }
436 
438  {
439  LinearSystem temp(rhs);
440  swap(temp);
441  return *this;
442  }
443 
445  {
446  }
447 
448  // In the following calls to Solve, VectorType must be a NekVector.
449  // Anything else won't compile.
450  template <typename VectorType>
451  RawType_t<VectorType> Solve(const VectorType &b)
452  {
459  return x;
460  }
461 
462  template <typename BType, typename XType>
463  void Solve(const BType &b, XType &x) const
464  {
470  }
471 
472  // Transpose variant of solve
473  template <typename VectorType>
475  {
482  return x;
483  }
484 
485  template <typename BType, typename XType>
486  void SolveTranspose(const BType &b, XType &x) const
487  {
493  }
494 
495  unsigned int GetRows() const
496  {
497  return n;
498  }
499  unsigned int GetColumns() const
500  {
501  return n;
502  }
503 
504 private:
505  template <typename MatrixType> void FactorMatrix(const MatrixType &theA)
506  {
507  switch (m_matrixType)
508  {
509  case eFULL:
510  {
511  int m = theA.GetRows();
512  int n = theA.GetColumns();
513 
514  int pivotSize = std::max(1, std::min(m, n));
515  int info = 0;
516  m_ipivot = Array<OneD, int>(pivotSize);
517 
518  Lapack::Dgetrf(m, n, A.get(), m, m_ipivot.get(), info);
519 
520  if (info < 0)
521  {
522  std::string message =
523  "ERROR: The " + std::to_string(-info) +
524  "th parameter had an illegal parameter for dgetrf";
525  ASSERTL0(false, message.c_str());
526  }
527  else if (info > 0)
528  {
529  std::string message =
530  "ERROR: Element u_" + std::to_string(info) +
531  std::to_string(info) + " is 0 from dgetrf";
532  ASSERTL0(false, message.c_str());
533  }
534  }
535  break;
536  case eDIAGONAL:
537  for (unsigned int i = 0; i < theA.GetColumns(); ++i)
538  {
539  A[i] = 1.0 / theA(i, i);
540  }
541  break;
542  case eUPPER_TRIANGULAR:
543  case eLOWER_TRIANGULAR:
544  break;
545  case eSYMMETRIC:
546  {
547  int info = 0;
548  int pivotSize = theA.GetRows();
549  m_ipivot = Array<OneD, int>(pivotSize);
550 
551  Lapack::Dsptrf('U', theA.GetRows(), A.get(), m_ipivot.get(),
552  info);
553 
554  if (info < 0)
555  {
556  std::string message =
557  "ERROR: The " + std::to_string(-info) +
558  "th parameter had an illegal parameter for dsptrf";
559  NEKERROR(ErrorUtil::efatal, message.c_str());
560  }
561  else if (info > 0)
562  {
563  std::string message =
564  "ERROR: Element u_" + std::to_string(info) +
565  std::to_string(info) + " is 0 from dsptrf";
566  NEKERROR(ErrorUtil::efatal, message.c_str());
567  }
568  }
569  break;
571  {
572  int info = 0;
573  Lapack::Dpptrf('U', theA.GetRows(), A.get(), info);
574 
575  if (info < 0)
576  {
577  std::string message =
578  "ERROR: The " + std::to_string(-info) +
579  "th parameter had an illegal parameter for dpptrf";
580  NEKERROR(ErrorUtil::efatal, message.c_str());
581  }
582  else if (info > 0)
583  {
584  std::string message =
585  "ERROR: The leading minor of order " +
586  std::to_string(info) +
587  " is not positive definite from dpptrf";
588  NEKERROR(ErrorUtil::efatal, message.c_str());
589  }
590  }
591  break;
592  case eBANDED:
593  {
594  int M = n;
595  int N = n;
596  int KL = m_numberOfSubDiagonals;
597  int KU = m_numberOfSuperDiagonals;
598 
599  // The array we pass in to dgbtrf must have enough space for KL
600  // subdiagonals and KL+KU superdiagonals (see lapack users
601  // guide, in the section discussing band storage.
602  unsigned int requiredStorageSize =
604  KL + KU);
605 
606  unsigned int rawRows = KL + KU + 1;
607  A = Array<OneD, double>(requiredStorageSize);
608 
609  // Put the extra elements up front.
610  for (unsigned int i = 0; i < theA.GetColumns(); ++i)
611  {
612  std::copy(theA.GetRawPtr() + i * rawRows,
613  theA.GetRawPtr() + (i + 1) * rawRows,
614  A.get() + (i + 1) * KL + i * rawRows);
615  }
616 
617  int info = 0;
618  int pivotSize = theA.GetRows();
619  m_ipivot = Array<OneD, int>(pivotSize);
620 
621  Lapack::Dgbtrf(M, N, KL, KU, A.get(), 2 * KL + KU + 1,
622  m_ipivot.get(), info);
623 
624  if (info < 0)
625  {
626  std::string message =
627  "ERROR: The " + std::to_string(-info) +
628  "th parameter had an illegal parameter for dgbtrf";
629  NEKERROR(ErrorUtil::efatal, message.c_str());
630  }
631  else if (info > 0)
632  {
633  std::string message =
634  "ERROR: Element u_" + std::to_string(info) +
635  std::to_string(info) + " is 0 from dgbtrf";
636  NEKERROR(ErrorUtil::efatal, message.c_str());
637  }
638  }
639  break;
641  {
642  ASSERTL1(
644  std::string("Number of sub- and superdiagonals should ") +
645  std::string("be equal for a symmetric banded matrix"));
646 
647  int KU = m_numberOfSuperDiagonals;
648  int info = 0;
649  Lapack::Dpbtrf('U', theA.GetRows(), KU, A.get(), KU + 1, info);
650 
651  if (info < 0)
652  {
653  std::string message =
654  "ERROR: The " + std::to_string(-info) +
655  "th parameter had an illegal parameter for dpbtrf";
656  NEKERROR(ErrorUtil::efatal, message.c_str());
657  }
658  else if (info > 0)
659  {
660  std::string message =
661  "ERROR: The leading minor of order " +
662  std::to_string(info) +
663  " is not positive definite from dpbtrf";
664  NEKERROR(ErrorUtil::efatal, message.c_str());
665  }
666  }
667  break;
668  case eSYMMETRIC_BANDED:
669  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
670  break;
672  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
673  break;
675  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
676  break;
677 
678  default:
679  NEKERROR(ErrorUtil::efatal, "Unhandled matrix type");
680  }
681  }
682 
683  void swap(LinearSystem &rhs)
684  {
685  std::swap(n, rhs.n);
686  std::swap(A, rhs.A);
687  std::swap(m_ipivot, rhs.m_ipivot);
690  std::swap(m_matrixType, rhs.m_matrixType);
691  std::swap(m_transposeFlag, rhs.m_transposeFlag);
692  }
693 
694  unsigned int n;
701 };
702 } // namespace Nektar
703 
704 #endif // NEKTAR_LIB_UTILITIES_LINEAR_ALGEBRA_NEK_LINSYS_HPP
#define ASSERTL0(condition, msg)
Definition: ErrorUtil.hpp:215
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
Definition: ErrorUtil.hpp:209
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Definition: ErrorUtil.hpp:249
unsigned int GetColumns() const
Definition: NekLinSys.hpp:499
Array< OneD, double > A
Definition: NekLinSys.hpp:695
LinearSystem(const MatrixType &theA, PointerWrapper wrapperType=eCopy)
Definition: NekLinSys.hpp:405
void swap(LinearSystem &rhs)
Definition: NekLinSys.hpp:683
RawType_t< VectorType > SolveTranspose(const VectorType &b)
Definition: NekLinSys.hpp:474
RawType_t< VectorType > Solve(const VectorType &b)
Definition: NekLinSys.hpp:451
void Solve(const BType &b, XType &x) const
Definition: NekLinSys.hpp:463
LinearSystem(const std::shared_ptr< MatrixType > &theA, PointerWrapper wrapperType=eCopy)
Definition: NekLinSys.hpp:379
Array< OneD, int > m_ipivot
Definition: NekLinSys.hpp:696
void FactorMatrix(const MatrixType &theA)
Definition: NekLinSys.hpp:505
void SolveTranspose(const BType &b, XType &x) const
Definition: NekLinSys.hpp:486
LinearSystem(const LinearSystem &rhs)
Definition: NekLinSys.hpp:429
unsigned int m_numberOfSuperDiagonals
Definition: NekLinSys.hpp:698
unsigned int m_numberOfSubDiagonals
Definition: NekLinSys.hpp:697
MatrixStorage m_matrixType
Definition: NekLinSys.hpp:699
LinearSystem & operator=(const LinearSystem &rhs)
Definition: NekLinSys.hpp:437
unsigned int GetRows() const
Definition: NekLinSys.hpp:495
def copy(self)
Definition: pycml.py:2663
static void Dpptrs(const char &uplo, const int &n, const int &nrhs, const double *ap, double *b, const int &ldb, int &info)
Solve a real Positive defiinte symmetric matrix problem using Cholesky factorization.
Definition: Lapack.hpp:225
static void Dgbtrf(const int &m, const int &n, const int &kl, const int &ku, double *a, const int &lda, int *ipiv, int &info)
General banded matrix LU factorisation.
Definition: Lapack.hpp:250
static void Dsptrs(const char &uplo, const int &n, const int &nrhs, const double *ap, const int *ipiv, double *b, const int &ldb, int &info)
Solve a real symmetric matrix problem using Bunch-Kaufman pivoting.
Definition: Lapack.hpp:191
static void Dgetrf(const int &m, const int &n, double *a, const int &lda, int *ipiv, int &info)
General matrix LU factorisation.
Definition: Lapack.hpp:281
static void Dpptrf(const char &uplo, const int &n, double *ap, int &info)
Cholesky factor a real Positive Definite packed-symmetric matrix.
Definition: Lapack.hpp:218
static void Dgetrs(const char &trans, const int &n, const int &nrhs, const double *a, const int &lda, int *ipiv, double *b, const int &ldb, int &info)
General matrix LU backsolve.
Definition: Lapack.hpp:288
static void Dsptrf(const char &uplo, const int &n, double *ap, int *ipiv, int &info)
factor a real packed-symmetric matrix using Bunch-Kaufman pivoting.
Definition: Lapack.hpp:165
static void Dpbtrf(const char &uplo, const int &n, const int &kd, double *ab, const int &ldab, int &info)
Cholesky factorize a real positive-definite banded-symmetric matrix.
Definition: Lapack.hpp:234
static void Dgbtrs(const char &trans, const int &n, const int &kl, const int &ku, const int &nrhs, const double *a, const int &lda, const int *ipiv, double *b, const int &ldb, int &info)
Solve general banded matrix using LU factorisation.
Definition: Lapack.hpp:258
static void Dtptrs(const char &uplo, const char &trans, const char &diag, const int &n, const int &nrhs, const double *a, double *b, const int &ldb, int &info)
Definition: Lapack.hpp:381
static void Dpbtrs(const char &uplo, const int &n, const int &kd, const int &nrhs, const double *ab, const int &ldab, double *b, const int &ldb, int &info)
Solve a real, Positive definite banded symmetric matrix problem using Cholesky factorization.
Definition: Lapack.hpp:242
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
@ eVECTOR_WRAPPER
typename RawType< T >::type RawType_t
Definition: RawType.hpp:70
@ eLOWER_TRIANGULAR_BANDED
@ ePOSITIVE_DEFINITE_SYMMETRIC_BANDED
@ ePOSITIVE_DEFINITE_SYMMETRIC
@ eUPPER_TRIANGULAR_BANDED
PointerWrapper
Specifies if the pointer passed to a NekMatrix or NekVector is copied into an internal representation...
void CopyArray(const Array< OneD, ConstDataType > &source, Array< OneD, DataType > &dest)
static unsigned int GetRequiredStorageSize(unsigned int totalRows, unsigned int totalColumns, unsigned int subDiags, unsigned int superDiags)
Calculates and returns the storage size required.
Definition: MatrixFuncs.cpp:44
static void SolveTranspose(const BVectorType &b, XVectorType &x, MatrixStorage m_matrixType, const Array< OneD, const int > &m_ipivot, unsigned int n, const Array< OneD, const double > &A, char m_transposeFlag, unsigned int m_numberOfSubDiagonals, unsigned int m_numberOfSuperDiagonals)
Definition: NekLinSys.hpp:235
static void Solve(const BVectorType &b, XVectorType &x, MatrixStorage m_matrixType, const Array< OneD, const int > &m_ipivot, unsigned int n, const Array< OneD, const double > &A, char m_transposeFlag, unsigned int m_numberOfSubDiagonals, unsigned int m_numberOfSuperDiagonals)
Definition: NekLinSys.hpp:75