Board index » delphi » Delphi Math Unit

Delphi Math Unit

I want use mathematical function but when I put MATH in the uses sections,
Delphi says that the File doesn't exist.

Where can I find the Math Unit ???

 

Re:Delphi Math Unit


In <01bb629a.d2e79aa0$a15033c2@Fabrice>, "Fabrice" <fle...@teaser.fr> writes:

Quote
>I want use mathematical function but when I put MATH in the uses sections,
>Delphi says that the File doesn't exist.

>Where can I find the Math Unit ???

I've not had to use a 'math unit' before.  Most functions are in the SysUtils unit.
What function do you want to use?

Richard Knapp

Re:Delphi Math Unit


On Tue, 25 Jun 1996 15:32:58 +0200, "Fabrice" <fle...@teaser.fr>
wrote:

Quote
>I want use mathematical function but when I put MATH in the uses sections,
>Delphi says that the File doesn't exist.

>Where can I find the Math Unit ???

It was only included in the Developer and C/S versions, for some
reason.  If you have one of those, it should be in with your other DCU
files, and you can see the source in source/rtl/sys/math.pas.

Duncan Murdoch

Re:Delphi Math Unit


Quote
Fabrice wrote:

> I want use mathematical function but when I put MATH in the uses sections,
> Delphi says that the File doesn't exist.

> Where can I find the Math Unit ???

        Are we talking D1 or D2 here?

--
David Ullrich
Sig file accidentally deleted - sorry.

Re:Delphi Math Unit


Fabrice (fle...@teaser.fr) :
: I want use mathematical function but when I put MATH in the uses sections,
: Delphi says that the File doesn't exist.
: Where can I find the Math Unit ???

 In Delphi 2

  C:\Delphi\Lib\math.dcu
  C:\Delphi\source\rtl\sys\math.pas

--
F J Hsu              b2506...@csie.ntu.edu.tw

Re:Delphi Math Unit


b2506033 (b2506...@csie.ntu.edu.tw) :
: Fabrice (fle...@teaser.fr) :
: : I want use mathematical function but when I put MATH in the uses sections,
: : Delphi says that the File doesn't exist.
: : Where can I find the Math Unit ???
:  In Delphi 2
:   C:\Delphi\Lib\math.dcu
:   C:\Delphi\source\rtl\sys\math.pas

   I can't use those functions most of the time.

uses math;
var
  i : integer;
  d : array[1..100] of double;
  m : Extended;
begin
  for i := 1 to 98 do
    d[i] := getdata;

  //   m := Mean(d);
  //   the Mean(d) will get mean from d[1] to d[100].
  //   *sigh*
end;

--
F J Hsu         b2506...@csie.ntu.edu.tw

Re:Delphi Math Unit


Quote
b2506033 wrote:

>    I can't use those functions most of the time.

> uses math;
> var
>   i : integer;
>   d : array[1..100] of double;
>   m : Extended;
> begin
>   for i := 1 to 98 do
>     d[i] := getdata;

>   //   m := Mean(d);
>   //   the Mean(d) will get mean from d[1] to d[100].
>   //   *sigh*
> end;

I don't think it's unreasonable for Mean to assume you want to perform
the calculation on the entire array, however it would be very easy to
write your own version of Mean which doesn't use the whole array.  Here
is an example of how one could be written:

function MeanEx(const Data: array of Double; HighIndex: Integer): Extended;
// Calculates the mean of array Data up to element HighIndex
begin
  if HighIndex > High(Data) then HighIndex := High(Data);
  Result := SUM(Data) / (HighIndex - Low(Data) + 1)
end;
--

        -Steve Teixeira
         steix...@borland.com

Re:Delphi Math Unit


Quote
Steve Teixeira wrote:

> b2506033 wrote:

> >    I can't use those functions most of the time.

> > uses math;
> > var
> >   i : integer;
> >   d : array[1..100] of double;
> >   m : Extended;
> > begin
> >   for i := 1 to 98 do
> >     d[i] := getdata;

> >   //   m := Mean(d);
> >   //   the Mean(d) will get mean from d[1] to d[100].
> >   //   *sigh*
> > end;

> I don't think it's unreasonable for Mean to assume you want to perform
> the calculation on the entire array, however it would be very easy to
> write your own version of Mean which doesn't use the whole array.  Here
> is an example of how one could be written:

> function MeanEx(const Data: array of Double; HighIndex: Integer): Extended;
> // Calculates the mean of array Data up to element HighIndex
> begin
>   if HighIndex > High(Data) then HighIndex := High(Data);
>   Result := SUM(Data) / (HighIndex - Low(Data) + 1)
> end;

Doh!  That was lame of me... I meant to say use this function:

function SumEx(const Data: array of Double; NumElements: Integer): Extended;
var
  I: Integer;
begin
  Result := 0.0;
  if NumElements > High(Data) + 1 then NumElements := High(Data) + 1;
  for I := Low(Data) to NumElements - 1 do
    Result := Result + Data[I];
end;

function MeanEx(const Data: array of Double; NumElements: Integer): Extended;
begin
  if NumElements > High(Data) + 1 then NumElements := High(Data) + 1;
  Result := SumEx(Data, NumElements) / NumElements;
end;
--

        -Steve Teixeira
         steix...@borland.com

Other Threads