Mercurial > hg > octave-jordi
diff 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 |
line wrap: on
line diff
--- a/src/DLD-FUNCTIONS/find.cc +++ b/src/DLD-FUNCTIONS/find.cc @@ -62,7 +62,7 @@ { OCTAVE_QUIT; - if (nda(k) != 0.0) + if (nda(k) != static_cast<T> (0.0)) { end_el = k; if (start_el == -1) @@ -125,7 +125,7 @@ { OCTAVE_QUIT; - if (nda(k) != 0.0) + if (nda(k) != static_cast<T> (0.0)) { idx(count) = k + 1; @@ -178,6 +178,12 @@ template octave_value_list find_nonzero_elem_idx (const Array<Complex>&, int, octave_idx_type, int); +template octave_value_list find_nonzero_elem_idx (const Array<float>&, int, + octave_idx_type, int); + +template octave_value_list find_nonzero_elem_idx (const Array<FloatComplex>&, + int, octave_idx_type, int); + template <typename T> octave_value_list find_nonzero_elem_idx (const Sparse<T>& v, int nargout, @@ -458,33 +464,55 @@ } else { - if (arg.is_real_type ()) + if (arg.is_single_type ()) { - NDArray nda = arg.array_value (); - - if (! error_state) - retval = find_nonzero_elem_idx (nda, nargout, - n_to_find, direction); - } - else if (arg.is_complex_type ()) - { - ComplexNDArray cnda = arg.complex_array_value (); + if (arg.is_real_type ()) + { + FloatNDArray nda = arg.float_array_value (); - if (! error_state) - retval = find_nonzero_elem_idx (cnda, nargout, - n_to_find, direction); - } - else if (arg.is_string ()) - { - charNDArray cnda = arg.char_array_value (); + if (! error_state) + retval = find_nonzero_elem_idx (nda, nargout, + n_to_find, direction); + } + else if (arg.is_complex_type ()) + { + FloatComplexNDArray cnda = arg.float_complex_array_value (); - if (! error_state) - retval = find_nonzero_elem_idx (cnda, nargout, - n_to_find, direction); + if (! error_state) + retval = find_nonzero_elem_idx (cnda, nargout, + n_to_find, direction); + } } else { - gripe_wrong_type_arg ("find", arg); + if (arg.is_real_type ()) + { + NDArray nda = arg.array_value (); + + if (! error_state) + retval = find_nonzero_elem_idx (nda, nargout, + n_to_find, direction); + } + else if (arg.is_complex_type ()) + { + ComplexNDArray cnda = arg.complex_array_value (); + + if (! error_state) + retval = find_nonzero_elem_idx (cnda, nargout, + n_to_find, direction); + } + else if (arg.is_string ()) + { + charNDArray cnda = arg.char_array_value (); + + if (! error_state) + retval = find_nonzero_elem_idx (cnda, nargout, + n_to_find, direction); + } + else + { + gripe_wrong_type_arg ("find", arg); + } } }