Mercurial > hg > octave-lyh
comparison src/eig.cc @ 620:8e4e7e5f307e
[project @ 1994-08-16 04:36:32 by jwe]
author | jwe |
---|---|
date | Tue, 16 Aug 1994 04:36:32 +0000 |
parents | 20fbad23ae51 |
children | fae2bd91c027 |
comparison
equal
deleted
inserted
replaced
619:8778be2e70e7 | 620:8e4e7e5f307e |
---|---|
58 if (flag != 0) | 58 if (flag != 0) |
59 { | 59 { |
60 if (flag < 0) | 60 if (flag < 0) |
61 gripe_empty_arg ("eig", 0); | 61 gripe_empty_arg ("eig", 0); |
62 Matrix m; | 62 Matrix m; |
63 retval.resize (2); | 63 retval(1) = m; |
64 retval(0) = m; | 64 retval(0) = m; |
65 retval(1) = m; | |
66 } | 65 } |
67 else | 66 else |
68 gripe_empty_arg ("eig", 1); | 67 gripe_empty_arg ("eig", 1); |
69 | 68 |
70 return retval; | 69 return retval; |
77 } | 76 } |
78 | 77 |
79 Matrix tmp; | 78 Matrix tmp; |
80 ComplexMatrix ctmp; | 79 ComplexMatrix ctmp; |
81 EIG result; | 80 EIG result; |
82 switch (arg.const_type ()) | 81 if (arg.is_real_scalar ()) |
83 { | 82 { |
84 case tree_constant_rep::scalar_constant: | |
85 tmp.resize (1, 1); | 83 tmp.resize (1, 1); |
86 tmp.elem (0, 0) = arg.double_value (); | 84 tmp.elem (0, 0) = arg.double_value (); |
87 result = EIG (tmp); | 85 result = EIG (tmp); |
88 break; | 86 } |
89 case tree_constant_rep::matrix_constant: | 87 else if (arg.is_real_matrix ()) |
88 { | |
90 tmp = arg.matrix_value (); | 89 tmp = arg.matrix_value (); |
91 result = EIG (tmp); | 90 result = EIG (tmp); |
92 break; | 91 } |
93 case tree_constant_rep::complex_scalar_constant: | 92 else if (arg.is_complex_scalar ()) |
93 { | |
94 ctmp.resize (1, 1); | 94 ctmp.resize (1, 1); |
95 ctmp.elem (0, 0) = arg.complex_value (); | 95 ctmp.elem (0, 0) = arg.complex_value (); |
96 result = EIG (ctmp); | 96 result = EIG (ctmp); |
97 break; | 97 } |
98 case tree_constant_rep::complex_matrix_constant: | 98 else if (arg.is_complex_matrix ()) |
99 { | |
99 ctmp = arg.complex_matrix_value (); | 100 ctmp = arg.complex_matrix_value (); |
100 result = EIG (ctmp); | 101 result = EIG (ctmp); |
101 break; | 102 } |
102 default: | 103 else |
103 panic_impossible (); | 104 { |
104 break; | 105 gripe_wrong_type_arg ("eig", tmp); |
106 return retval; | |
105 } | 107 } |
106 | 108 |
107 if (nargout == 0 || nargout == 1) | 109 if (nargout == 0 || nargout == 1) |
108 { | 110 { |
109 retval.resize (1); | |
110 retval(0) = result.eigenvalues (), 1; | 111 retval(0) = result.eigenvalues (), 1; |
111 } | 112 } |
112 else | 113 else |
113 { | 114 { |
114 // Blame it on Matlab. | 115 // Blame it on Matlab. |
115 | 116 |
116 ComplexDiagMatrix d (result.eigenvalues ()); | 117 ComplexDiagMatrix d (result.eigenvalues ()); |
117 | 118 |
118 retval.resize (2); | 119 retval(1) = d; |
119 retval(0) = result.eigenvectors (); | 120 retval(0) = result.eigenvectors (); |
120 retval(1) = d; | |
121 } | 121 } |
122 | 122 |
123 return retval; | 123 return retval; |
124 } | 124 } |
125 | 125 |