Mercurial > hg > octave-lyh
diff src/DLD-FUNCTIONS/lookup.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 | 4fbaba9abec1 |
children | 9d080df0c843 |
line wrap: on
line diff
--- a/src/DLD-FUNCTIONS/lookup.cc +++ b/src/DLD-FUNCTIONS/lookup.cc @@ -180,33 +180,64 @@ // in the case of a complex array, absolute values will be used for compatibility // (though it's not too meaningful). + ArrayN<octave_idx_type> idx; - NDArray table = (argtable.is_complex_type ()) - ? argtable.complex_array_value ().abs () - : argtable.array_value (); + if (argtable.is_single_type () || argy.is_single_type ()) + { + FloatNDArray table = (argtable.is_complex_type ()) + ? argtable.float_complex_array_value ().abs () + : argtable.float_array_value (); - NDArray y = (argy.is_complex_type ()) - ? argy.complex_array_value ().abs () - : argy.array_value (); + FloatNDArray y = (argy.is_complex_type ()) + ? argy.float_complex_array_value ().abs () + : argy.float_array_value (); + + idx = ArrayN<octave_idx_type> (y.dims ()); - ArrayN<octave_idx_type> idx (y.dims ()); + // determine whether the array is descending. + bool desc = is_descending (table.data (), table.length ()); + octave_idx_type offset = left_inf ? 1 : 0; + octave_idx_type size = table.length () - offset - (right_inf ? 1 : 0); + if (size < 0) + size = 0; - // determine whether the array is descending. - bool desc = is_descending (table.data (), table.length ()); - octave_idx_type offset = left_inf ? 1 : 0; - octave_idx_type size = table.length () - offset - (right_inf ? 1 : 0); - if (size < 0) - size = 0; + if (desc) + seq_lookup (table.data (), offset, size, + y.data (), y.length (), idx.fortran_vec (), + std::greater<float> ()); + else + seq_lookup (table.data (), offset, size, + y.data (), y.length (), idx.fortran_vec (), + std::less<float> ()); + } + else + { + NDArray table = (argtable.is_complex_type ()) + ? argtable.complex_array_value ().abs () + : argtable.array_value (); + + NDArray y = (argy.is_complex_type ()) + ? argy.complex_array_value ().abs () + : argy.array_value (); - if (desc) - seq_lookup (table.data (), offset, size, - y.data (), y.length (), idx.fortran_vec (), - std::greater<double> ()); - else - seq_lookup (table.data (), offset, size, - y.data (), y.length (), idx.fortran_vec (), - std::less<double> ()); + idx = ArrayN<octave_idx_type> (y.dims ()); + + // determine whether the array is descending. + bool desc = is_descending (table.data (), table.length ()); + octave_idx_type offset = left_inf ? 1 : 0; + octave_idx_type size = table.length () - offset - (right_inf ? 1 : 0); + if (size < 0) + size = 0; + if (desc) + seq_lookup (table.data (), offset, size, + y.data (), y.length (), idx.fortran_vec (), + std::greater<double> ()); + else + seq_lookup (table.data (), offset, size, + y.data (), y.length (), idx.fortran_vec (), + std::less<double> ()); + } //retval(0) = idx; assign (retval(0), idx);