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 #include "TMV_SymSVDiv.h"
23 #include "tmv/TMV_SymMatrix.h"
24 #include "tmv/TMV_Matrix.h"
25 #include "tmv/TMV_Vector.h"
26 #include "tmv/TMV_DiagMatrix.h"
27 #include "tmv/TMV_DiagMatrixArith.h"
28 #include "tmv/TMV_SymMatrixArithFunc.h"
29 #include <ostream>
30 
31 namespace tmv {
32 
33 
34     template <class T, class T1>
HermSV_Inverse(const GenMatrix<T1> & U,const GenDiagMatrix<TMV_RealType (T1)> & SS,ptrdiff_t kmax,SymMatrixView<T> sinv)35     void HermSV_Inverse(
36         const GenMatrix<T1>& U, const GenDiagMatrix<TMV_RealType(T1)>& SS,
37         ptrdiff_t kmax, SymMatrixView<T> sinv)
38     {
39         TMVAssert(sinv.isherm());
40         Matrix<T,ColMajor> SinvUt = U.adjoint().rowRange(0,kmax) /
41             SS.subDiagMatrix(0,kmax);
42         SymMultMM<false>(T(1),U.colRange(0,kmax),SinvUt,sinv);
43     }
44 
45     template <class T, class T1>
SymSV_Inverse(const GenMatrix<T1> & U,const GenDiagMatrix<TMV_RealType (T1)> & SS,const GenMatrix<T1> & Vt,ptrdiff_t kmax,SymMatrixView<T> sinv)46     void SymSV_Inverse(
47         const GenMatrix<T1>& U, const GenDiagMatrix<TMV_RealType(T1)>& SS,
48         const GenMatrix<T1>& Vt, ptrdiff_t kmax, SymMatrixView<T> sinv)
49     {
50         // A = U S Vt
51         // A^-1 = V S^-1 Ut
52         Matrix<T,ColMajor> SinvUt = U.adjoint().rowRange(0,kmax) /
53             SS.subDiagMatrix(0,kmax);
54         SymMultMM<false>(T(1),Vt.adjoint().colRange(0,kmax),SinvUt,sinv);
55     }
56 
57 #ifdef INST_INT
58 #undef INST_INT
59 #endif
60 
61 #define InstFile "TMV_SymSVInverse.inst"
62 #include "TMV_Inst.h"
63 #undef InstFile
64 
65 } // namespace tmv
66 
67 
68