ВУЗ:
Составители:
Рубрика:
44
procedure DynamicRVector.Subtract(v: DynamicRVector);
var i: Integer;
begin
if Length(self.comp)=Length(v.comp) then
for i:=0 to Length(self.comp)-1 do self.comp[i].Subtract(v.comp[i])
else raise Exception.Create('Invalid Operation');
end;
function DynamicRVector.ScalarProduct(v: DynamicRVector): Rational;
var i: Integer; temp: Rational;
begin
if Length(self.comp)=Length(v.comp)
then begin
result:=Rational.Create;
for i:=0 to Length(self.comp)-1 do begin
temp:=self.comp[i].Dot(v.comp[i]) as Rational;
result.Add(temp);
temp.Destroy;
end;
end
else raise Exception.Create('Invalid Operation');
end;
function DynamicRVector.GetLength: Real;
var i: Integer;
begin
result:=0;
for i:=0 to Length(self.comp)-1 do
result:=result+sqr(self.comp[i].GetNum/self.comp[i].GetDen);
result:=sqrt(result);
end;
function DynamicRVector.IsEqual(v: DynamicRVector): Boolean;
var i: Integer;
begin
if Length(self.comp)=Length(v.comp) then begin
result:=true;
for i:=0 to Length(self.comp)-1 do
if not(self.comp[i].IsEqual(v.comp[i])) then result:=false;
end
else result:=false; // исключение не возбуждается
end;
procedure DynamicRVector.Assign(v: DynamicRVector);
var i: Integer;
begin
if Length(self.comp)=Length(v.comp) then
for i:=0 to Length(self.comp)-1 do self.comp[i].Assign(v.comp[i])
else raise Exception.Create('Invalid Operation');
end;
procedure DynamicRVector.Subtract(v: DynamicRVector);
var i: Integer;
begin
if Length(self.comp)=Length(v.comp) then
for i:=0 to Length(self.comp)-1 do self.comp[i].Subtract(v.comp[i])
else raise Exception.Create('Invalid Operation');
end;
function DynamicRVector.ScalarProduct(v: DynamicRVector): Rational;
var i: Integer; temp: Rational;
begin
if Length(self.comp)=Length(v.comp)
then begin
result:=Rational.Create;
for i:=0 to Length(self.comp)-1 do begin
temp:=self.comp[i].Dot(v.comp[i]) as Rational;
result.Add(temp);
temp.Destroy;
end;
end
else raise Exception.Create('Invalid Operation');
end;
function DynamicRVector.GetLength: Real;
var i: Integer;
begin
result:=0;
for i:=0 to Length(self.comp)-1 do
result:=result+sqr(self.comp[i].GetNum/self.comp[i].GetDen);
result:=sqrt(result);
end;
function DynamicRVector.IsEqual(v: DynamicRVector): Boolean;
var i: Integer;
begin
if Length(self.comp)=Length(v.comp) then begin
result:=true;
for i:=0 to Length(self.comp)-1 do
if not(self.comp[i].IsEqual(v.comp[i])) then result:=false;
end
else result:=false; // исключение не возбуждается
end;
procedure DynamicRVector.Assign(v: DynamicRVector);
var i: Integer;
begin
if Length(self.comp)=Length(v.comp) then
for i:=0 to Length(self.comp)-1 do self.comp[i].Assign(v.comp[i])
else raise Exception.Create('Invalid Operation');
end;
44
Страницы
- « первая
- ‹ предыдущая
- …
- 42
- 43
- 44
- 45
- 46
- …
- следующая ›
- последняя »
