Mercurial > hg > octave-nkf
comparison liboctave/dRowVector.cc @ 1947:5ab3c25a3cf9
[project @ 1996-02-14 01:50:42 by jwe]
author | jwe |
---|---|
date | Wed, 14 Feb 1996 01:50:42 +0000 |
parents | 1281a23a34dd |
children | 1b57120c997b |
comparison
equal
deleted
inserted
replaced
1946:ec07d85b4152 | 1947:5ab3c25a3cf9 |
---|---|
209 // row vector by matrix -> row vector | 209 // row vector by matrix -> row vector |
210 | 210 |
211 RowVector | 211 RowVector |
212 operator * (const RowVector& v, const Matrix& a) | 212 operator * (const RowVector& v, const Matrix& a) |
213 { | 213 { |
214 RowVector retval; | |
215 | |
214 int len = v.length (); | 216 int len = v.length (); |
217 | |
215 if (a.rows () != len) | 218 if (a.rows () != len) |
216 { | 219 (*current_liboctave_error_handler) |
217 (*current_liboctave_error_handler) | 220 ("nonconformant vector multiplication attempted"); |
218 ("nonconformant vector multiplication attempted"); | 221 else |
219 return RowVector (); | 222 { |
220 } | 223 int a_nr = a.rows (); |
221 | 224 int a_nc = a.cols (); |
222 if (len == 0) | 225 |
223 return RowVector (a.cols (), 0.0); | 226 if (len == 0) |
224 | 227 retval.resize (a_nc, 0.0); |
225 // Transpose A to form A'*x == (x'*A)' | 228 else |
226 | 229 { |
227 int a_nr = a.rows (); | 230 // Transpose A to form A'*x == (x'*A)' |
228 int a_nc = a.cols (); | 231 |
229 | 232 int ld = a_nr; |
230 int ld = a_nr; | 233 |
231 | 234 retval.resize (a_nc); |
232 double *y = new double [a_nc]; | 235 double *y = retval.fortran_vec (); |
233 | 236 |
234 F77_FCN (dgemv, DGEMV) ("T", a_nr, a_nc, 1.0, a.data (), ld, | 237 F77_XFCN (dgemv, DGEMV, ("T", a_nr, a_nc, 1.0, a.data (), |
235 v.data (), 1, 0.0, y, 1, 1L); | 238 ld, v.data (), 1, 0.0, y, 1, 1L)); |
236 | 239 |
237 return RowVector (y, a_nc); | 240 if (f77_exception_encountered) |
241 (*current_liboctave_error_handler) | |
242 ("unrecoverable error in dgemv"); | |
243 } | |
244 } | |
245 | |
246 return retval; | |
238 } | 247 } |
239 | 248 |
240 // other operations | 249 // other operations |
241 | 250 |
242 RowVector | 251 RowVector |
351 // row vector by column vector -> scalar | 360 // row vector by column vector -> scalar |
352 | 361 |
353 double | 362 double |
354 operator * (const RowVector& v, const ColumnVector& a) | 363 operator * (const RowVector& v, const ColumnVector& a) |
355 { | 364 { |
365 double retval = 0.0; | |
366 | |
356 int len = v.length (); | 367 int len = v.length (); |
368 | |
357 if (len != a.length ()) | 369 if (len != a.length ()) |
358 { | 370 (*current_liboctave_error_handler) |
359 (*current_liboctave_error_handler) | 371 ("nonconformant vector multiplication attempted"); |
360 ("nonconformant vector multiplication attempted"); | 372 else if (len != 0) |
361 return 0.0; | 373 retval = F77_FCN (ddot, DDOT) (len, v.data (), 1, a.data (), 1); |
362 } | 374 |
363 | 375 return retval; |
364 return F77_FCN (ddot, DDOT) (len, v.data (), 1, a.data (), 1); | |
365 } | 376 } |
366 | 377 |
367 Complex | 378 Complex |
368 operator * (const RowVector& v, const ComplexColumnVector& a) | 379 operator * (const RowVector& v, const ComplexColumnVector& a) |
369 { | 380 { |