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