|
|
|
type
TComplex is record
Re,Im: TFloat;
end record;
constant Eps: TFloat:= to_float(0.001,float_exponent_width,float_fraction_width);
|
|
|
|
|
|
function MCompl (X,Y: in TFloat) return TComplex is
variable
Z: TComplex;
XX,YY: TFloat;
begin
XX:=X;
YY:=Y;
if Abs(X)<Eps*Eps*Eps then XX:=to_float
(0,float_exponent_width,float_fraction_width); end if;
if Abs(Y)<Eps*Eps*Eps then YY:=to_floa
(0,float_exponent_width,float_fraction_width); end if;
Z.Re:=XX;
Z.Im:=YY;
return Z;
end MCompl; |
|
|
|
function CompSum(X,Y: in TComplex) return TComplex is
variable
Z: TComplex;
begin
Z.Re:=X.Re+Y.Re;
Z.Im:=X.Im+Y.Im;
return Z;
end CompSum; |
|
|
|
function CompSub(X,Y: in TComplex) return TComplex is
variable
Z: TComplex;
begin
Z.Re:=X.Re-Y.Re;
Z.Im:=X.Im-Y.Im;
return Z;
end CompSub; |
|
|
|
function CompMul(X,Y: in TComplex) return TComplex is
variable
Z: TComplex;
begin
Z.Re:=X.Re*Y.Re-X.Im*Y.Im;
Z.Im:=X.Re*Y.Im+Y.Re*X.Im;
return Z;
end CompMul; |
|
|
|
procedure CompDiv(X,Y: in TComplex; Z: out TComplex; Success: out boolean) is
variable
FSuccess: boolean;
begin
FSuccess:=TRUE;
if Abs(Sqr(Y.Re)+Sqr(Y.Im))<Eps then FSuccess:=FALSE;
end if;
Z.Re:=(X.Re*Y.Re+X.Im*Y.Im)/(Sqr(Y.Re)+Sqr(Y.Im));
Z.Im:=(Y.Re*X.Im-X.Re*Y.Im)/(Sqr(Y.Re)+Sqr(Y.Im));
Success:=FSuccess;
end CompDiv; |
|
|
|
fn CompSqr X |
|
|
|
fn CompSqrt |
|
|
|
fn Diskr |
|
|
|
function DiskrComp(P1,P2,P3,P4,P5,P6,P7,P8,P9: in TComplex) return
TComplex is
variable
S1,S2,S3,S4,S5,S6,D1,D2,A: TComplex;
begin
-- Diskr:=P1*P5*P9+P4*P8*P3+P7*P2*P6-P7*P5*P3-P1*P8*P6-P4*P2*P9;
S1:=CompMul(P1,CompMul(P5,P9));
S2:=CompMul(P4,CompMul(P8,P3));
S3:=CompMul(P7,CompMul(P2,P6));
S4:=CompMul(P7,CompMul(P5,P3));
S5:=CompMul(P1,CompMul(P8,P6));
S6:=CompMul(P4,CompMul(P2,P9));
D1:=CompSum(S1,CompSum(S2,S3));
D2:=CompSum(S4,CompSum(S5,S6));
return CompSub(D1,D2);
end DiskrComp; |
|
|
|
fn Sc |
|
|
|
fn ArcSin X |
|
|
|
fn ArcCos X |
|
|
|
fn Fi Sa Ca Sb Cb |
|
|
|
fn LinLin X1 Y1 X2 Y2 X3 Y3 X4 Y4 &XX &YY &ZZ =
|
|
|
|
fn ProcA X1 Y1 X2 Y2 &Xt &Yt V &XD =
|
|
|
|
procedure LinLinComp(X1,Y1,X2,Y2,X3,Y3,X4,Y4: in TComplex; signal
XX,YY,ZZ: Out TComplex; signal Prizn: Out boolean) is
variable
A1,B1,C1,A2,B2,C2,XXF,YYF,ZZF: TComplex;
B: boolean;
begin
B:=FALSE;
A1:=CompSub(Y1,Y2); B1:=CompSub(X2,X1);
A2:=CompSub(Y3,Y4); B2:=CompSub(X4,X3);
ZZF:=CompSub(CompMul(A1,B2),CompMul(B1,A2));
if Abs(ZZF.Re)>Eps then
C1:=CompSub(CompMul(X1,Y2),CompMul(Y1,X2));
C2:=CompSub(CompMul(X3,Y4),CompMul(Y3,X4));
CompDiv(CompSub(CompMul(B1,C2),CompMul (C1,B2)),ZZF,XXF,B);
CompDiv(CompSub(CompMul(C1,A2),CompMul(A1,C2)),ZZF,YYF,B);
ZZ<=MCompl(to_float
(1,float_exponent_width,float_fraction_width),to_float
(0,float_exponent_width,float_fraction_width));
XX<=XXF;
YY<=YYF;
B:=TRUE;
end if;
if (Abs(ZZF.Re)<=Eps) or (Abs(XXF.Re)>to_float
(1000000000,float_exponent_width,float_fraction_width)) or (Abs
(YYF.Re)>to_float(1000000000,float_exponent_width,float_fraction_width)) then
XX<=B1;
YY<=CompSub(MCompl(to_float
(0,float_exponent_width,float_fraction_width),to_float
(0,float_exponent_width,float_fraction_width)),A1);
ZZ<=MCompl(to_float
(0,float_exponent_width,float_fraction_width),to_float
(0,float_exponent_width,float_fraction_width));
end if;
Prizn<=B;
end LinLinComp; |
|
|
|
fn ComDuga |
|
|