帮助中的一段话

blucecat 2003-09-12 05:55:26
Unit

Math

Category

Statistical routines

function SumOfSquares(const Data: array of Double): Extended;

Description

SumOfSquares returns the sum of the squares of the Data values: Data[0]^2 + Data[1]^2 + Data[2]^2...



Data[0]^2 + Data[1]^2 + Data[2]^2...

有这种用法吗?
...全文
47 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
blucecat 2003-09-16
  • 打赏
  • 举报
回复
我知道这个函数是干什么的,但这帮助也太滥了吧

要不也许在某种情况下 ^这个东西可以作为幂运算符

我原来是这样认为的,但现在大家都没见过这种用法,我想就怪在帮助的身上吧

有没有人提出异议?没有久结了
dawnming 2003-09-13
  • 打赏
  • 举报
回复
帮你up一下
我原本不是一头猪
mib3000 2003-09-13
  • 打赏
  • 举报
回复
学习
FrameSniper 2003-09-13
  • 打赏
  • 举报
回复
补充一点,你可以去看看Power和IntPower两个函数的源代码:

IntPower函数用来计算范围从3.6x10^-4951到1.1 x 10^4932的正实数的任意整数次幂!

function IntPower(const Base: Extended; const Exponent: Integer): Extended;
asm
//不用看了,本来我还说给楼主讲解讲解的,MMD,一看是纯汇编,免了!我自己都看不懂!
end;

Power则是在IntPower的基础上对幂进行了扩展!

function Power(const Base, Exponent: Extended): Extended;
begin
if Exponent = 0.0 then
Result := 1.0 { n**0 = 1 }
else if (Base = 0.0) and (Exponent > 0.0) then
Result := 0.0 { 0**n = 0, n > 0 }
else if (Frac(Exponent) = 0.0) and (Abs(Exponent) <= MaxInt) then
Result := IntPower(Base, Integer(Trunc(Exponent)))
else
Result := Exp(Exponent * Ln(Base))
end;
FrameSniper 2003-09-13
  • 打赏
  • 举报
回复
HOHO!帮助中那样写只是为了说明,并没有说Delphi里面求幂运算要这样用吧!

看看SumOfSquares函数的源代码:

function SumOfSquares(const Data: array of Double): Extended;
var
I: Integer;
begin
Result := 0.0;
for I := Low(Data) to High(Data) do
Result := Result + Sqr(Data[I]);
end;

平方是用Sqr函数,呵呵!所以这里这样写就象楼上说的那样只是为了说明!
kingecg 2003-09-13
  • 打赏
  • 举报
回复
^在delphi里代表幂运算
nyf1220 2003-09-12
  • 打赏
  • 举报
回复
恩,同意楼上的
SumOfSquares
从字面看都这个意思,但pascal里有没有那可不清楚了:)

lxpbuaa 2003-09-12
  • 打赏
  • 举报
回复
帮助中使用:
Data[0]^2 + Data[1]^2 + Data[2]^2
说明这个函数的意思,但是在Pascal中并不能直接使用^作乘方运算。

—————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
—————————————————————————————————
lxpbuaa 2003-09-12
  • 打赏
  • 举报
回复
看它的字面意思就知道是求平方和了。如:

implementation

uses Math;

procedure TForm1.Button1Click(Sender: TObject);
var
Data: array[0..1] of Double;
R: Double;
begin
Data[0] := 3.0;
Data[1] := 4.0;
R := SumOfSquares(Data);
ShowMessage(FloatToStr(R)); //显示24
end;

—————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
—————————————————————————————————
coolfilm 2003-09-12
  • 打赏
  • 举报
回复
up
cow8063 2003-09-12
  • 打赏
  • 举报
回复
这是算什么幂的吧
IwantFlay 2003-09-12
  • 打赏
  • 举报
回复
Data[0]^2是 data[0]*data[0]吧.记得pascal语言中^好象是有这个意思的
sixgj 2003-09-12
  • 打赏
  • 举报
回复
没见过,没用过。
Storm2008 2003-09-12
  • 打赏
  • 举报
回复
实验一下了

5,386

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧