comparison armadillo-2.4.4/include/armadillo_bits/fn_syl_lyap.hpp @ 0:8b6102e2a9b0

Armadillo Library
author maxzanoni76 <max.zanoni@eecs.qmul.ac.uk>
date Wed, 11 Apr 2012 09:27:06 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:8b6102e2a9b0
1 // Copyright (C) 2011-2012 NICTA (www.nicta.com.au)
2 // Copyright (C) 2011-2012 Conrad Sanderson
3 //
4 // This file is part of the Armadillo C++ library.
5 // It is provided without any warranty of fitness
6 // for any purpose. You can redistribute this file
7 // and/or modify it under the terms of the GNU
8 // Lesser General Public License (LGPL) as published
9 // by the Free Software Foundation, either version 3
10 // of the License or (at your option) any later version.
11 // (see http://www.opensource.org/licenses for more info)
12
13
14 //! \addtogroup fn_syl_lyap
15 //! @{
16
17
18 //! find the solution of the Sylvester equation AX + XB = C
19 template<typename T1, typename T2, typename T3>
20 inline
21 bool
22 syl
23 (
24 Mat <typename T1::elem_type> & out,
25 const Base<typename T1::elem_type,T1>& in_A,
26 const Base<typename T1::elem_type,T2>& in_B,
27 const Base<typename T1::elem_type,T3>& in_C,
28 const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
29 )
30 {
31 arma_extra_debug_sigprint();
32 arma_ignore(junk);
33
34 typedef typename T1::elem_type eT;
35
36 const unwrap_check<T1> tmp_A(in_A.get_ref(), out);
37 const unwrap_check<T2> tmp_B(in_B.get_ref(), out);
38 const unwrap_check<T3> tmp_C(in_C.get_ref(), out);
39
40 const Mat<eT>& A = tmp_A.M;
41 const Mat<eT>& B = tmp_B.M;
42 const Mat<eT>& C = tmp_C.M;
43
44 const bool status = auxlib::syl(out, A, B, C);
45
46 if(status == false)
47 {
48 out.reset();
49 arma_bad("syl(): equation appears to be singular", false);
50 }
51
52 return status;
53 }
54
55
56
57 template<typename T1, typename T2, typename T3>
58 inline
59 Mat<typename T1::elem_type>
60 syl
61 (
62 const Base<typename T1::elem_type,T1>& in_A,
63 const Base<typename T1::elem_type,T2>& in_B,
64 const Base<typename T1::elem_type,T3>& in_C,
65 const typename arma_blas_type_only<typename T1::elem_type>::result* junk = 0
66 )
67 {
68 arma_extra_debug_sigprint();
69 arma_ignore(junk);
70
71 typedef typename T1::elem_type eT;
72
73 const unwrap<T1> tmp_A( in_A.get_ref() );
74 const unwrap<T2> tmp_B( in_B.get_ref() );
75 const unwrap<T3> tmp_C( in_C.get_ref() );
76
77 const Mat<eT>& A = tmp_A.M;
78 const Mat<eT>& B = tmp_B.M;
79 const Mat<eT>& C = tmp_C.M;
80
81 Mat<eT> out;
82
83 const bool status = auxlib::syl(out, A, B, C);
84
85 if(status == false)
86 {
87 out.reset();
88 arma_bad("syl(): equation appears to be singular");
89 }
90
91 return out;
92 }
93
94
95
96 //! @}