Re: Finding maximum of an array



I have my first results. The algorithm spent about half the time finding the
maximum value in a matrix (in the lower diagonal), and half the time
resizing the matrix. On a 3200 x 3200 matrix, the time spent finding the
maximum value (up to a matrix of size 2x2) was 12.8 seconds. With the
indexing system, it now takes only 0.3 seconds.

The total computation time went from 25 seconds to 13 seconds. At this
point, there is no reason why I would want to use integer comparisons since
those comparisons only affect the first part of the procedure (now reduced
to 0.3 seconds). The new bottleneck is now the reduction of the matrix. I
did managed to reduce this part by half (I didn't some unecessary moves),
and now the new bottleneck is this procedure that moves values in all
vectors (columns) of single value.

The procedure below delete for a M x M matrix the value in a single column L
by shifting to the left every value to the right of this column.


procedure SMatrix.ShiftAll(L, M : LongInt);
var
I, Ms: LongInt;
begin
Ms := (M-L)*4; // compute the size of the data to move
for I := 0 to M - 1 do begin // for every row in the matrix
PtRow := Matrix.Items[I]; // get the pointer of the array of
single values
Move(PtRow^[L+1],PtRow^[L],Ms); // move left all values after L
end;
end;

I do use the FastMove unit, so I wonder whether there is anything I can do
to speed ut the above procedure.

If not, then a solution could be to use the index of maximum values to store
information about rows that would normally be removed and simply try to
ignore them rather than removing them. I would have to keep working with a
large matrix, which may take more time for some operations, but overall, the
speed improvements could be quite important.

Any suggestion,

Richard



"Dennis" <marianndkc@xxxxxxxxxxxxxxx> wrote in message
news:4813985a$1@xxxxxxxxxxxxxxxxxxxxxxxxx
Hi

Interesting. Let us hear what your conclusions are when you get to them.
Then perhaps there will be a need to do some low level optimizations on
the
new algorithm.

Best regards
Dennis Kjaer Christensen




.