TMtxByte.Max Method

Overload List

#SignatureDescription
1function Max: Integer;Maximum value.
└ indexed: function Max(Index: Integer; Len: Integer): Integer;
2function Max(out aIndex: Integer): Integer;Calculate the maximum value of all calling object elements.
└ indexed: function Max(out aIndex: Integer; Index: Integer; Len: Integer): Integer;

Overload 1: function Max: Integer;

Maximum value.

Returns: Int32 - The maximum value of all calling object elements. The result is an integer value.

Examples
var a: Matrix;
    b: double;
begin
    a.SetIt(2,2,False,[1,2,3,4]);
    b := a.Max; // b = 4
end;
var
    a: Matrix;
    result: double;
begin
    a := [[1.0, 2.0], [3.0, 4.0]];
    result := a.Max;
    if Abs(result - 4.0) > 1e-10 then
        raise Exception.Create('Matrix.Max: expected 4.0, got ' + result.ToString);
end;

Indexed: function Max(Index: Integer; Len: Integer): Integer;

Calculate the maximum value from calling object elements [Index]..[Index+Len-1].

#NameTypeDescription
1IndexIntegerstart index
2LenIntegerelement count

Returns: Int32

Remarks:

The result is an integer value. An exception is raised if array borders are overrun.

Examples
Uses MtxVecInt;

procedure Example;
var a: TVecInt;
max, ind: integer;
begin
    CreateIt(a);
    try
        a.SetIt([1,2,3,4]);
        max := a.Max(ind); // max=4, ind = 3
    finally
        FreeIt(a);
    end
end;

Overload 2: function Max(out aIndex: Integer): Integer;

Calculate the maximum value of all calling object elements.

#NameDescription
1aIndexStores maximum value index.

Returns: Int32 - the maximum of all calling vector integer elements in-place.

Examples
var
    a: TMtxInt;
    ind: Integer;
begin
MtxVecInt.CreateIt(out a);
try
a.SetIt(new int[] {1,2,3,4})
int max = a.Max(out ind); //max=3, ind = 3
finally
MtxVecInt.FreeIt(ref a);
end;
end;

Indexed: function Max(out aIndex: Integer; Index: Integer; Len: Integer): Integer;

Calculate the maximum value of calling object elements [Index..Index+Len-1].

#NameDescription
1aIndexReturns maximum value index.
2IndexThe starting index at which to start the search.
3LenThe number of elements to search starting from Index.

Returns: Int32 - the maximum of calling vector integer elements [Index..Index+Len-1].

Remarks:

An exception is raised if array borders are overrun/underrun.

Examples
Uses MtxExprInt;

procedure Example;
var a: MatrixInt;
max, ind: integer;
begin
    a := [[1, 2], [3, 4]];
    max := a.Max(ind); // max = 4, ind = 3
end;