|
In article <fqnhru$je3$1@fred.mathworks.com>,
Omni Domni <eloykarakh@hotmail.com> wrote:
>Suppose we have a matrix of the form
>A=[1 5 4 1 6 6 1]
>What is the fastest way to create a new matrix that
>contains each element of A only once:
>B=[1 5 4 6]
>note: matrix A contains only integers
Asking for the "fastest way" is always a bit troublesome.
The "fastest way" may depend upon the number of inputs, or upon
the amount of repetition, or upon the range of values involved
and the amount of memory available. And on some platforms,
the "fastest" way might involve writing a MEX routine that exploits
processor-specific instructions. For example, if all of the
integer values turn out to be exactly representable in single
precision then using single precision SSE instructions might
turn out to be faster above a minimum vector size... but on
a different processor in the same family, SSE instructions might
turn out to be slower than using double precision and multiple
floating point instructions (because there might be multiple cores
and although each double precision instruction might be slower than
an SSE single precision instruction, you wouldn't have contention
from both cores trying to use the same SSE unit.)
--
"Tired minds don't plan well. Sleep first, plan later."
-- Walter Reisch
|