-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMathBase.SharedTypes.pas
More file actions
73 lines (59 loc) · 1.76 KB
/
Copy pathMathBase.SharedTypes.pas
File metadata and controls
73 lines (59 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
unit MathBase.SharedTypes;
{-----------------------------------------------------------------------------
MathBase.SharedTypes
Common numeric array types and helper records shared across all math libs.
Provides:
- TIntegerArray, TDoubleArray, TSingleArray, TExtendedArray
- TDoublePair (lower/upper interval record)
-----------------------------------------------------------------------------}
{$mode objfpc}{$H+}{$J-}
{$modeswitch advancedrecords}
interface
uses
Classes, SysUtils;
type
{ Standardized numeric array types }
TIntegerArray = array of Integer;
TDoubleArray = array of Double;
TSingleArray = array of Single;
TExtendedArray = array of Extended;
{ A record representing a numeric range or interval }
TDoublePair = record
Lower: Double;
Upper: Double;
end;
{ Convert integer array to double array }
function ToDoubleArray(const Data: TIntegerArray): TDoubleArray; overload;
{ Convert single array to double array }
function ToDoubleArray(const Data: TSingleArray): TDoubleArray; overload;
{ Convert extended array to double array }
function ToDoubleArray(const Data: TExtendedArray): TDoubleArray; overload;
implementation
function ToDoubleArray(const Data: TIntegerArray): TDoubleArray;
var
I: Integer;
begin
Result := nil;
SetLength(Result, Length(Data));
for I := 0 to High(Data) do
Result[I] := Data[I];
end;
function ToDoubleArray(const Data: TSingleArray): TDoubleArray;
var
I: Integer;
begin
Result := nil;
SetLength(Result, Length(Data));
for I := 0 to High(Data) do
Result[I] := Data[I];
end;
function ToDoubleArray(const Data: TExtendedArray): TDoubleArray;
var
I: Integer;
begin
Result := nil;
SetLength(Result, Length(Data));
for I := 0 to High(Data) do
Result[I] := Data[I];
end;
end.