* SinCos overloads added, resolves #22663

git-svn-id: trunk@22139 -
This commit is contained in:
florian 2012-08-19 22:09:03 +00:00
parent e1ad1a02d2
commit 1da4c0c3ce
4 changed files with 70 additions and 3 deletions

1
.gitattributes vendored
View File

@ -11442,6 +11442,7 @@ tests/test/units/math/tmask.pp svneol=native#text/plain
tests/test/units/math/tmask2.pp svneol=native#text/plain
tests/test/units/math/tnaninf.pp svneol=native#text/plain
tests/test/units/math/tpower.pp svneol=native#text/pascal
tests/test/units/math/tsincos.pp svneol=native#text/pascal
tests/test/units/math/ttrig1.pp svneol=native#text/plain
tests/test/units/matrix/tinv1.pp svneol=native#text/pascal
tests/test/units/objects/testobj.pp svneol=native#text/plain

View File

@ -24,7 +24,7 @@ function arctan2(y,x : float) : float;assembler;
{$define FPC_MATH_HAS_SINCOS}
procedure sincos(theta : float;out sinus,cosinus : float);assembler;
procedure sincos(theta : extended;out sinus,cosinus : extended);assembler;
asm
fldt theta
fsincos
@ -34,6 +34,26 @@ procedure sincos(theta : float;out sinus,cosinus : float);assembler;
end;
procedure sincos(theta : double;out sinus,cosinus : double);assembler;
asm
fldl theta
fsincos
fstpl (%edx)
fstpl (%eax)
fwait
end;
procedure sincos(theta : single;out sinus,cosinus : single);assembler;
asm
flds theta
fsincos
fstps (%edx)
fstps (%eax)
fwait
end;
{$define FPC_MATH_HAS_TAN}
function tan(x : float) : float;assembler;
asm

View File

@ -256,7 +256,16 @@ function radtocycle(rad : float) : float;inline;
function tan(x : float) : float;
function cotan(x : float) : float;
function cot(x : float) : float; inline;
procedure sincos(theta : float;out sinus,cosinus : float);
{$ifdef FPC_HAS_TYPE_SINGLE}
procedure sincos(theta : single;out sinus,cosinus : single);
{$endif}
{$ifdef FPC_HAS_TYPE_DOUBLE}
procedure sincos(theta : double;out sinus,cosinus : double);
{$endif}
{$ifdef FPC_HAS_TYPE_EXTENDED}
procedure sincos(theta : extended;out sinus,cosinus : extended);
{$endif}
function secant(x : float) : float; inline;
function cosecant(x : float) : float; inline;
@ -682,11 +691,31 @@ end;
{$ifndef FPC_MATH_HAS_SINCOS}
procedure sincos(theta : float;out sinus,cosinus : float);
{$ifdef FPC_HAS_TYPE_SINGLE}
procedure sincos(theta : single;out sinus,cosinus : single);
begin
sinus:=sin(theta);
cosinus:=cos(theta);
end;
{$endif}
{$ifdef FPC_HAS_TYPE_DOUBLE}
procedure sincos(theta : double;out sinus,cosinus : double);
begin
sinus:=sin(theta);
cosinus:=cos(theta);
end;
{$endif}
{$ifdef FPC_HAS_TYPE_EXTENDED}
procedure sincos(theta : extended;out sinus,cosinus : extended);
begin
sinus:=sin(theta);
cosinus:=cos(theta);
end;
{$endif}
{$endif FPC_MATH_HAS_SINCOS}

View File

@ -0,0 +1,17 @@
uses
math;
var
s1,s2 : single;
d1,d2 : double;
e1,e2 : extended;
begin
sincos(0,s1,s2);
sincos(0,d1,d2);
sincos(0,e1,e2);
if not(SameValue(s1,0)) or not(SameValue(s2,1)) or not(SameValue(d1,0)) or
not(SameValue(d2,1)) or not(SameValue(e1,0)) or not(SameValue(e2,1)) then
halt(1);
writeln('ok');
end.