comparison src/DLD-FUNCTIONS/qr.cc @ 7789:82be108cc558

First attempt at single precision tyeps * * * corrections to qrupdate single precision routines * * * prefer demotion to single over promotion to double * * * Add single precision support to log2 function * * * Trivial PROJECT file update * * * Cache optimized hermitian/transpose methods * * * Add tests for tranpose/hermitian and ChangeLog entry for new transpose code
author David Bateman <dbateman@free.fr>
date Sun, 27 Apr 2008 22:34:17 +0200
parents efccca5f2ad7
children 87865ed7405f
comparison
equal deleted inserted replaced
7788:45f5faba05a2 7789:82be108cc558
30 30
31 #include "CmplxQR.h" 31 #include "CmplxQR.h"
32 #include "CmplxQRP.h" 32 #include "CmplxQRP.h"
33 #include "dbleQR.h" 33 #include "dbleQR.h"
34 #include "dbleQRP.h" 34 #include "dbleQRP.h"
35 #include "fCmplxQR.h"
36 #include "fCmplxQRP.h"
37 #include "floatQR.h"
38 #include "floatQRP.h"
35 #include "SparseQR.h" 39 #include "SparseQR.h"
36 #include "SparseCmplxQR.h" 40 #include "SparseCmplxQR.h"
37 41
38 42
39 #include "defun-dld.h" 43 #include "defun-dld.h"
273 else 277 else
274 { 278 {
275 QR::type type = (nargout == 0 || nargout == 1) ? QR::raw 279 QR::type type = (nargout == 0 || nargout == 1) ? QR::raw
276 : (nargin == 2 ? QR::economy : QR::std); 280 : (nargin == 2 ? QR::economy : QR::std);
277 281
278 if (arg.is_real_type ()) 282 if (arg.is_single_type ())
279 { 283 {
280 Matrix m = arg.matrix_value (); 284 if (arg.is_real_type ())
281
282 if (! error_state)
283 { 285 {
284 switch (nargout) 286 FloatMatrix m = arg.float_matrix_value ();
287
288 if (! error_state)
285 { 289 {
286 case 0: 290 switch (nargout)
287 case 1: 291 {
288 { 292 case 0:
289 QR fact (m, type); 293 case 1:
290 retval(0) = fact.R (); 294 {
291 } 295 FloatQR fact (m, type);
292 break; 296 retval(0) = fact.R ();
293 297 }
294 case 2: 298 break;
295 { 299
296 QR fact (m, type); 300 case 2:
297 retval(1) = fact.R (); 301 {
298 retval(0) = fact.Q (); 302 FloatQR fact (m, type);
299 } 303 retval(1) = fact.R ();
300 break; 304 retval(0) = fact.Q ();
301 305 }
302 default: 306 break;
303 { 307
304 QRP fact (m, type); 308 default:
305 retval(2) = fact.P (); 309 {
306 retval(1) = fact.R (); 310 FloatQRP fact (m, type);
307 retval(0) = fact.Q (); 311 retval(2) = fact.P ();
308 } 312 retval(1) = fact.R ();
309 break; 313 retval(0) = fact.Q ();
314 }
315 break;
316 }
310 } 317 }
311 } 318 }
312 } 319 else if (arg.is_complex_type ())
313 else if (arg.is_complex_type ())
314 {
315 ComplexMatrix m = arg.complex_matrix_value ();
316
317 if (! error_state)
318 { 320 {
319 switch (nargout) 321 FloatComplexMatrix m = arg.float_complex_matrix_value ();
322
323 if (! error_state)
320 { 324 {
321 case 0: 325 switch (nargout)
322 case 1: 326 {
323 { 327 case 0:
324 ComplexQR fact (m, type); 328 case 1:
325 retval(0) = fact.R (); 329 {
326 } 330 FloatComplexQR fact (m, type);
327 break; 331 retval(0) = fact.R ();
328 332 }
329 case 2: 333 break;
330 { 334
331 ComplexQR fact (m, type); 335 case 2:
332 retval(1) = fact.R (); 336 {
333 retval(0) = fact.Q (); 337 FloatComplexQR fact (m, type);
334 } 338 retval(1) = fact.R ();
335 break; 339 retval(0) = fact.Q ();
336 340 }
337 default: 341 break;
338 { 342
339 ComplexQRP fact (m, type); 343 default:
340 retval(2) = fact.P (); 344 {
341 retval(1) = fact.R (); 345 FloatComplexQRP fact (m, type);
342 retval(0) = fact.Q (); 346 retval(2) = fact.P ();
343 } 347 retval(1) = fact.R ();
344 break; 348 retval(0) = fact.Q ();
349 }
350 break;
351 }
345 } 352 }
346 } 353 }
347 } 354 }
348 else 355 else
349 gripe_wrong_type_arg ("qr", arg); 356 {
357 if (arg.is_real_type ())
358 {
359 Matrix m = arg.matrix_value ();
360
361 if (! error_state)
362 {
363 switch (nargout)
364 {
365 case 0:
366 case 1:
367 {
368 QR fact (m, type);
369 retval(0) = fact.R ();
370 }
371 break;
372
373 case 2:
374 {
375 QR fact (m, type);
376 retval(1) = fact.R ();
377 retval(0) = fact.Q ();
378 }
379 break;
380
381 default:
382 {
383 QRP fact (m, type);
384 retval(2) = fact.P ();
385 retval(1) = fact.R ();
386 retval(0) = fact.Q ();
387 }
388 break;
389 }
390 }
391 }
392 else if (arg.is_complex_type ())
393 {
394 ComplexMatrix m = arg.complex_matrix_value ();
395
396 if (! error_state)
397 {
398 switch (nargout)
399 {
400 case 0:
401 case 1:
402 {
403 ComplexQR fact (m, type);
404 retval(0) = fact.R ();
405 }
406 break;
407
408 case 2:
409 {
410 ComplexQR fact (m, type);
411 retval(1) = fact.R ();
412 retval(0) = fact.Q ();
413 }
414 break;
415
416 default:
417 {
418 ComplexQRP fact (m, type);
419 retval(2) = fact.P ();
420 retval(1) = fact.R ();
421 retval(0) = fact.Q ();
422 }
423 break;
424 }
425 }
426 }
427 else
428 gripe_wrong_type_arg ("qr", arg);
429 }
350 } 430 }
351 431
352 return retval; 432 return retval;
353 } 433 }
354 434