Mercurial > hg > octave-nkf
comparison src/qr.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 |
---|---|
86 } | 86 } |
87 | 87 |
88 QR::type type = nargout == 1 ? QR::raw | 88 QR::type type = nargout == 1 ? QR::raw |
89 : (nargin == 3 ? QR::economy : QR::std); | 89 : (nargin == 3 ? QR::economy : QR::std); |
90 | 90 |
91 switch (tmp.const_type ()) | 91 if (tmp.is_real_matrix ()) |
92 { | 92 { |
93 case tree_constant_rep::matrix_constant: | 93 Matrix m = tmp.matrix_value (); |
94 { | 94 if (nargout < 3) |
95 Matrix m = tmp.matrix_value (); | 95 { |
96 if (nargout < 3) | 96 QR fact (m, type); |
97 { | 97 retval(1) = fact.R (); |
98 QR fact (m, type); | 98 retval(0) = fact.Q (); |
99 retval(1) = fact.R (); | 99 } |
100 retval(0) = fact.Q (); | 100 else |
101 } | 101 { |
102 else | 102 QRP fact (m, type); |
103 { | 103 retval(2) = fact.P (); |
104 QRP fact (m, type); | 104 retval(1) = fact.R (); |
105 retval(2) = fact.P (); | 105 retval(0) = fact.Q (); |
106 retval(1) = fact.R (); | 106 } |
107 retval(0) = fact.Q (); | |
108 } | |
109 } | |
110 break; | |
111 case tree_constant_rep::complex_matrix_constant: | |
112 { | |
113 ComplexMatrix m = tmp.complex_matrix_value (); | |
114 if (nargout < 3) | |
115 { | |
116 ComplexQR fact (m, type); | |
117 retval(1) = fact.R (); | |
118 retval(0) = fact.Q (); | |
119 } | |
120 else | |
121 { | |
122 ComplexQRP fact (m, type); | |
123 retval(2) = fact.P (); | |
124 retval(1) = fact.R (); | |
125 retval(0) = fact.Q (); | |
126 } | |
127 } | |
128 break; | |
129 case tree_constant_rep::scalar_constant: | |
130 { | |
131 double d = tmp.double_value (); | |
132 if (nargout == 1) | |
133 retval(0) = d; | |
134 else | |
135 { | |
136 retval(2) = 1.0; | |
137 retval(1) = d; | |
138 retval(0) = 1.0; | |
139 } | |
140 } | |
141 break; | |
142 case tree_constant_rep::complex_scalar_constant: | |
143 { | |
144 Complex c = tmp.complex_value (); | |
145 if (nargout == 1) | |
146 retval(0) = c; | |
147 else | |
148 { | |
149 retval(2) = 1.0; | |
150 retval(1) = c; | |
151 retval(0) = 1.0; | |
152 } | |
153 } | |
154 break; | |
155 default: | |
156 break; | |
157 } | 107 } |
108 else if (tmp.is_complex_matrix ()) | |
109 { | |
110 ComplexMatrix m = tmp.complex_matrix_value (); | |
111 if (nargout < 3) | |
112 { | |
113 ComplexQR fact (m, type); | |
114 retval(1) = fact.R (); | |
115 retval(0) = fact.Q (); | |
116 } | |
117 else | |
118 { | |
119 ComplexQRP fact (m, type); | |
120 retval(2) = fact.P (); | |
121 retval(1) = fact.R (); | |
122 retval(0) = fact.Q (); | |
123 } | |
124 } | |
125 else if (tmp.is_real_scalar ()) | |
126 { | |
127 double d = tmp.double_value (); | |
128 if (nargout == 1) | |
129 retval(0) = d; | |
130 else | |
131 { | |
132 retval(2) = 1.0; | |
133 retval(1) = d; | |
134 retval(0) = 1.0; | |
135 } | |
136 } | |
137 else if (tmp.is_complex_scalar ()) | |
138 { | |
139 Complex c = tmp.complex_value (); | |
140 if (nargout == 1) | |
141 retval(0) = c; | |
142 else | |
143 { | |
144 retval(2) = 1.0; | |
145 retval(1) = c; | |
146 retval(0) = 1.0; | |
147 } | |
148 } | |
149 else | |
150 { | |
151 gripe_wrong_type_arg ("qr", tmp); | |
152 } | |
153 | |
158 return retval; | 154 return retval; |
159 } | 155 } |
160 | 156 |
161 /* | 157 /* |
162 ;;; Local Variables: *** | 158 ;;; Local Variables: *** |