Mercurial > hg > octave-jordi
comparison src/DLD-FUNCTIONS/find.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 | f5005d9510f4 |
children | 87865ed7405f |
comparison
equal
deleted
inserted
replaced
7788:45f5faba05a2 | 7789:82be108cc558 |
---|---|
60 // Search for the number of elements to return. | 60 // Search for the number of elements to return. |
61 while (k < nel && k > -1 && n_to_find != count) | 61 while (k < nel && k > -1 && n_to_find != count) |
62 { | 62 { |
63 OCTAVE_QUIT; | 63 OCTAVE_QUIT; |
64 | 64 |
65 if (nda(k) != 0.0) | 65 if (nda(k) != static_cast<T> (0.0)) |
66 { | 66 { |
67 end_el = k; | 67 end_el = k; |
68 if (start_el == -1) | 68 if (start_el == -1) |
69 start_el = k; | 69 start_el = k; |
70 count++; | 70 count++; |
123 | 123 |
124 for (k = start_el; k < end_el; k++) | 124 for (k = start_el; k < end_el; k++) |
125 { | 125 { |
126 OCTAVE_QUIT; | 126 OCTAVE_QUIT; |
127 | 127 |
128 if (nda(k) != 0.0) | 128 if (nda(k) != static_cast<T> (0.0)) |
129 { | 129 { |
130 idx(count) = k + 1; | 130 idx(count) = k + 1; |
131 | 131 |
132 octave_idx_type xr = k % nr; | 132 octave_idx_type xr = k % nr; |
133 i_idx(count) = xr + 1; | 133 i_idx(count) = xr + 1; |
175 template octave_value_list find_nonzero_elem_idx (const Array<double>&, int, | 175 template octave_value_list find_nonzero_elem_idx (const Array<double>&, int, |
176 octave_idx_type, int); | 176 octave_idx_type, int); |
177 | 177 |
178 template octave_value_list find_nonzero_elem_idx (const Array<Complex>&, int, | 178 template octave_value_list find_nonzero_elem_idx (const Array<Complex>&, int, |
179 octave_idx_type, int); | 179 octave_idx_type, int); |
180 | |
181 template octave_value_list find_nonzero_elem_idx (const Array<float>&, int, | |
182 octave_idx_type, int); | |
183 | |
184 template octave_value_list find_nonzero_elem_idx (const Array<FloatComplex>&, | |
185 int, octave_idx_type, int); | |
180 | 186 |
181 template <typename T> | 187 template <typename T> |
182 octave_value_list | 188 octave_value_list |
183 find_nonzero_elem_idx (const Sparse<T>& v, int nargout, | 189 find_nonzero_elem_idx (const Sparse<T>& v, int nargout, |
184 octave_idx_type n_to_find, int direction) | 190 octave_idx_type n_to_find, int direction) |
456 else | 462 else |
457 gripe_wrong_type_arg ("find", arg); | 463 gripe_wrong_type_arg ("find", arg); |
458 } | 464 } |
459 else | 465 else |
460 { | 466 { |
461 if (arg.is_real_type ()) | 467 if (arg.is_single_type ()) |
462 { | 468 { |
463 NDArray nda = arg.array_value (); | 469 if (arg.is_real_type ()) |
464 | 470 { |
465 if (! error_state) | 471 FloatNDArray nda = arg.float_array_value (); |
466 retval = find_nonzero_elem_idx (nda, nargout, | 472 |
467 n_to_find, direction); | 473 if (! error_state) |
468 } | 474 retval = find_nonzero_elem_idx (nda, nargout, |
469 else if (arg.is_complex_type ()) | 475 n_to_find, direction); |
470 { | 476 } |
471 ComplexNDArray cnda = arg.complex_array_value (); | 477 else if (arg.is_complex_type ()) |
472 | 478 { |
473 if (! error_state) | 479 FloatComplexNDArray cnda = arg.float_complex_array_value (); |
474 retval = find_nonzero_elem_idx (cnda, nargout, | 480 |
475 n_to_find, direction); | 481 if (! error_state) |
476 } | 482 retval = find_nonzero_elem_idx (cnda, nargout, |
477 else if (arg.is_string ()) | 483 n_to_find, direction); |
478 { | 484 } |
479 charNDArray cnda = arg.char_array_value (); | |
480 | |
481 if (! error_state) | |
482 retval = find_nonzero_elem_idx (cnda, nargout, | |
483 n_to_find, direction); | |
484 } | 485 } |
485 else | 486 else |
486 { | 487 { |
487 gripe_wrong_type_arg ("find", arg); | 488 if (arg.is_real_type ()) |
489 { | |
490 NDArray nda = arg.array_value (); | |
491 | |
492 if (! error_state) | |
493 retval = find_nonzero_elem_idx (nda, nargout, | |
494 n_to_find, direction); | |
495 } | |
496 else if (arg.is_complex_type ()) | |
497 { | |
498 ComplexNDArray cnda = arg.complex_array_value (); | |
499 | |
500 if (! error_state) | |
501 retval = find_nonzero_elem_idx (cnda, nargout, | |
502 n_to_find, direction); | |
503 } | |
504 else if (arg.is_string ()) | |
505 { | |
506 charNDArray cnda = arg.char_array_value (); | |
507 | |
508 if (! error_state) | |
509 retval = find_nonzero_elem_idx (cnda, nargout, | |
510 n_to_find, direction); | |
511 } | |
512 else | |
513 { | |
514 gripe_wrong_type_arg ("find", arg); | |
515 } | |
488 } | 516 } |
489 } | 517 } |
490 | 518 |
491 return retval; | 519 return retval; |
492 } | 520 } |