[Lazarus] Help with algorithm

Etienne Leblois etienne.leblois at free.fr
Sat Dec 21 11:43:35 CET 2013


Greetings from Lyon, France,

In this kind of transformation, a *reverse* procedure to fill in the 
result from the source is typically needed with signature like

type TReverseProj = object
    // parameters to memorize
   procedure set( { some parameters} );
   procedure reverse(target_line, target_column :integer ; var 
source_line, source_column :integer);
end;

procedure TReverseProj.set( { some parameters} );
begin
   // setting the parameters for the reverse transformation
end;

procedure TReverseProj.reverse(target_line, target_column :integer ; var 
source_line, source_column :integer);
begin
   // applying the reverse transformation
end;

It is likely that the source position for "same_line_next 
column_in_target" can be written more simply that the full reverse (to 
be checked in equations, write on a paper reverse for (i,j) and (i,j+1) 
and see what is the difference).

To take benefit of this the last returned position must be memorized in 
the object and a routine added with signature like

procedure TReverseProj.shift_tarjet_cell(var 
source_line_for_shifted_cell, source_column_for_shifted_cell :integer);
begin
   // shifting source according to the shift in cell
end;

So the full reverse will be called only at the begin of each line

For generality calculation and storage must be handled in floating point 
(single, double...) ; just the result is rounded.

Regards,

Etienne.




More information about the Lazarus mailing list