1 /////////////////////////////////////////////////////////////////////////////// 2 // // 3 // The Template Matrix/Vector Library for C++ was created by Mike Jarvis // 4 // Copyright (C) 1998 - 2016 // 5 // All rights reserved // 6 // // 7 // The project is hosted at https://code.google.com/p/tmv-cpp/ // 8 // where you can find the current version and current documention. // 9 // // 10 // For concerns or problems with the software, Mike may be contacted at // 11 // mike_jarvis17 [at] gmail. // 12 // // 13 // This software is licensed under a FreeBSD license. The file // 14 // TMV_LICENSE should have bee included with this distribution. // 15 // It not, you can get a copy from https://code.google.com/p/tmv-cpp/. // 16 // // 17 // Essentially, you can use this software however you want provided that // 18 // you include the TMV_LICENSE file in any distribution that uses it. // 19 // // 20 /////////////////////////////////////////////////////////////////////////////// 21 22 #ifndef TMV_QRDiv_H 23 #define TMV_QRDiv_H 24 25 #include "tmv/TMV_BaseMatrix.h" 26 #include "tmv/TMV_BaseTriMatrix.h" 27 28 namespace tmv { 29 30 // Decompose A (input as QRx) into Q R. 31 // On output, Q is stored in the lower triangle part of QRx as 32 // Householder vectors, and the beta vector. 33 // R is the upper triangle part of QRx 34 template <typename T> 35 void QR_Decompose( 36 MatrixView<T> QRx, VectorView<T> beta, T& signdet); 37 38 template <typename T> 39 void QR_Decompose( 40 MatrixView<T> Q, UpperTriMatrixView<T> R, T& signdet); 41 42 template <typename T> 43 void GetQFromQR(MatrixView<T> Q, const GenVector<T>& beta); 44 45 template <typename T, typename T1> 46 void Q_LDivEq( 47 const GenMatrix<T1>& Q, const GenVector<T1>& beta, 48 MatrixView<T> m); 49 template <typename T, typename T1> 50 void Q_RDivEq( 51 const GenMatrix<T1>& Q, const GenVector<T1>& beta, 52 MatrixView<T> m); 53 54 55 template <typename T, typename T1, typename T2> 56 void QR_LDiv( 57 const GenMatrix<T1>& QR, const GenVector<T1>& beta, const ptrdiff_t* P, 58 const GenMatrix<T2>& m, MatrixView<T> x, ptrdiff_t N1); 59 template <typename T, typename T1> 60 void QR_LDivEq( 61 const GenMatrix<T1>& QR, const GenVector<T1>& beta, const ptrdiff_t* P, 62 MatrixView<T> m, ptrdiff_t N1); 63 template <typename T, typename T1, typename T2> 64 void QR_RDiv( 65 const GenMatrix<T1>& QR, const GenVector<T1>& beta, const ptrdiff_t* P, 66 const GenMatrix<T2>& m, MatrixView<T> x, ptrdiff_t N1); 67 template <typename T, typename T1> 68 void QR_RDivEq( 69 const GenMatrix<T1>& QR, const GenVector<T1>& beta, const ptrdiff_t* P, 70 MatrixView<T> m, ptrdiff_t N1); 71 template <typename T, typename T1> 72 void QR_Inverse( 73 const GenMatrix<T1>& QRx, const GenVector<T1>& beta, const ptrdiff_t* P, 74 MatrixView<T> minv, ptrdiff_t N1); 75 76 // Specialize disallowed complex combinations: 77 #define CT std::complex<T> 78 template <typename T> Q_LDivEq(const GenMatrix<CT> &,const GenVector<CT> &,MatrixView<T>)79 inline void Q_LDivEq( 80 const GenMatrix<CT>& , const GenVector<CT>& , 81 MatrixView<T> ) 82 { TMVAssert(TMV_FALSE); } 83 template <typename T> Q_RDivEq(const GenMatrix<CT> &,const GenVector<CT> &,MatrixView<T>)84 inline void Q_RDivEq( 85 const GenMatrix<CT>& , const GenVector<CT>& , 86 MatrixView<T> ) 87 { TMVAssert(TMV_FALSE); } 88 89 90 template <typename T> QR_LDiv(const GenMatrix<CT> &,const GenVector<CT> &,const ptrdiff_t *,const GenMatrix<CT> &,MatrixView<T>,ptrdiff_t)91 inline void QR_LDiv( 92 const GenMatrix<CT>& , const GenVector<CT>& , const ptrdiff_t* , 93 const GenMatrix<CT>& , MatrixView<T> , ptrdiff_t ) 94 { TMVAssert(TMV_FALSE); } 95 template <typename T> QR_LDiv(const GenMatrix<CT> &,const GenVector<CT> &,const ptrdiff_t *,const GenMatrix<T> &,MatrixView<T>,ptrdiff_t)96 inline void QR_LDiv( 97 const GenMatrix<CT>& , const GenVector<CT>& , const ptrdiff_t* , 98 const GenMatrix<T>& , MatrixView<T> , ptrdiff_t ) 99 { TMVAssert(TMV_FALSE); } 100 template <typename T> QR_LDiv(const GenMatrix<T> &,const GenVector<T> &,const ptrdiff_t *,const GenMatrix<CT> &,MatrixView<T>,ptrdiff_t)101 inline void QR_LDiv( 102 const GenMatrix<T>& , const GenVector<T>& , const ptrdiff_t* , 103 const GenMatrix<CT>& , MatrixView<T> , ptrdiff_t ) 104 { TMVAssert(TMV_FALSE); } 105 template <typename T> QR_LDivEq(const GenMatrix<CT> &,const GenVector<CT> &,const ptrdiff_t *,MatrixView<T>,ptrdiff_t)106 inline void QR_LDivEq( 107 const GenMatrix<CT>& , const GenVector<CT>& , const ptrdiff_t* , 108 MatrixView<T> , ptrdiff_t ) 109 { TMVAssert(TMV_FALSE); } 110 template <typename T> QR_RDiv(const GenMatrix<CT> &,const GenVector<CT> &,const ptrdiff_t *,const GenMatrix<CT> &,MatrixView<T>,ptrdiff_t)111 inline void QR_RDiv( 112 const GenMatrix<CT>& , const GenVector<CT>& , const ptrdiff_t* , 113 const GenMatrix<CT>& , MatrixView<T> , ptrdiff_t ) 114 { TMVAssert(TMV_FALSE); } 115 template <typename T> QR_RDiv(const GenMatrix<CT> &,const GenVector<CT> &,const ptrdiff_t *,const GenMatrix<T> &,MatrixView<T>,ptrdiff_t)116 inline void QR_RDiv( 117 const GenMatrix<CT>& , const GenVector<CT>& , const ptrdiff_t* , 118 const GenMatrix<T>& , MatrixView<T> , ptrdiff_t ) 119 { TMVAssert(TMV_FALSE); } 120 template <typename T> QR_RDiv(const GenMatrix<T> &,const GenVector<T> &,const ptrdiff_t *,const GenMatrix<CT> &,MatrixView<T>,ptrdiff_t)121 inline void QR_RDiv( 122 const GenMatrix<T>& , const GenVector<T>& , const ptrdiff_t* , 123 const GenMatrix<CT>& , MatrixView<T> , ptrdiff_t ) 124 { TMVAssert(TMV_FALSE); } 125 template <typename T> QR_RDivEq(const GenMatrix<CT> &,const GenVector<CT> &,const ptrdiff_t *,MatrixView<T>,ptrdiff_t)126 inline void QR_RDivEq( 127 const GenMatrix<CT>& , const GenVector<CT>& , const ptrdiff_t* , 128 MatrixView<T> , ptrdiff_t ) 129 { TMVAssert(TMV_FALSE); } 130 template <typename T> QR_Inverse(const GenMatrix<CT> &,const GenVector<CT> &,const ptrdiff_t *,MatrixView<T>,ptrdiff_t)131 inline void QR_Inverse( 132 const GenMatrix<CT>& , const GenVector<CT>& , const ptrdiff_t* , 133 MatrixView<T> , ptrdiff_t ) 134 { TMVAssert(TMV_FALSE); } 135 #undef CT 136 137 138 } 139 140 #endif 141