diff options
author | Sunil Shetye | 2019-05-16 12:18:48 +0530 |
---|---|---|
committer | Sunil Shetye | 2019-05-29 11:08:01 +0530 |
commit | 26b77d7593b5ee0792b6b556f5569ea4227c2b02 (patch) | |
tree | 8f92052234b01bf39b9c3a6e3cb12b3962d96b1b /src | |
parent | 5a73e6bec4a12db7afae9de300e39256f754d8d3 (diff) | |
download | scilab2c-26b77d7593b5ee0792b6b556f5569ea4227c2b02.tar.gz scilab2c-26b77d7593b5ee0792b6b556f5569ea4227c2b02.tar.bz2 scilab2c-26b77d7593b5ee0792b6b556f5569ea4227c2b02.zip |
convert to unix format
Diffstat (limited to 'src')
94 files changed, 3040 insertions, 3040 deletions
diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionAbs.sci b/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionAbs.sci index 8bbbf644..8d0b9a8a 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionAbs.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionAbs.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() disp(abs(7)) disp(abs(-3)) diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionConj.sci b/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionConj.sci index 3cceb0d1..d23b77c9 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionConj.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionConj.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= FLOAT -function mainfunction()
+function mainfunction() s1=[1+%i*3 1-%i*7;-1+5*%i 1-%i*7;-1+5*%i -1-6*%i] s2=conj(s1); @@ -8,7 +8,7 @@ disp(s2); s3=[1 1;-1+5*%i 1-%i*7;-1+5*%i -1-6*%i] s4=conj(s3); -disp(s4);
+disp(s4); s5=1+%i*3 s6=conj(s5); @@ -17,11 +17,11 @@ disp(s6); s7=1-%i*3 s8=conj(s7); -disp(s8);
+disp(s8); s9=[1+%i*3 1-%i*7;-1 7;-1+5*%i -1-6*%i] s10=conj(s9); -disp(s10);
+disp(s10); s11=[1+%i*3 1;-1+5*%i 1;-1 -1-6*%i] s12=conj(s11); diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionFind.sci b/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionFind.sci index 2a093e9c..329af47f 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionFind.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionFind.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() a = 1 disp(find(a==0)) diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionFind2d.sci b/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionFind2d.sci index 2857b80b..bf7ed22d 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionFind2d.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionFind2d.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() a = 1 [u1,v1]=find(a==0); diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionIsEmpty.sci b/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionIsEmpty.sci index 9c975ad7..fa6c77f4 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionIsEmpty.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionIsEmpty.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test isempty diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionIsNan.sci b/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionIsNan.sci index 9d4eac4f..37e1ac10 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionIsNan.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionIsNan.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test isnan diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionLength.sci b/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionLength.sci index 7509073c..e6e5b99b 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionLength.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionLength.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test length diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionSign.sci b/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionSign.sci index 6a1ce45c..f0dff288 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionSign.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionSign.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test sign diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionSize.sci b/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionSize.sci index 067365db..888a0c3c 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionSize.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionSize.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test sign diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionType.sci b/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionType.sci index db837346..a92d6099 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionType.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/auxiliaryFunctions/mainfunctionType.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test type diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionACos.sci b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionACos.sci index e0225554..3044e026 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionACos.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionACos.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test acos diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionACosh.sci b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionACosh.sci index 08739198..b0a83a9c 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionACosh.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionACosh.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test acos diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionASin.sci b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionASin.sci index 83fdef40..5dcb9e6a 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionASin.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionASin.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= FLOAT -function mainfunction()
+function mainfunction() //test asin diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionASinh.sci b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionASinh.sci index 967341ef..52c6245c 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionASinh.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionASinh.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test asinh diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionATan.sci b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionATan.sci index ae5e83db..91cfba6b 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionATan.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionATan.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test atan diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionATan2.sci b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionATan2.sci index fa8d0a16..801ce585 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionATan2.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionATan2.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test atan2 diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionATanh.sci b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionATanh.sci index d81af8d7..a23deedb 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionATanh.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionATanh.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test atanh diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionCeil_Fix_Floor_Int_Round.sci b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionCeil_Fix_Floor_Int_Round.sci index a5930c21..96ce7f6e 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionCeil_Fix_Floor_Int_Round.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionCeil_Fix_Floor_Int_Round.sci @@ -1,6 +1,6 @@ -//SCI2C: DEFAULT_PRECISION= DOUBLE
+//SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() // test ceil/fix/floor/int/round diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionCos.sci b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionCos.sci index d86406b1..f0a4a15a 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionCos.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionCos.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test cos diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionCosh.sci b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionCosh.sci index 915396ff..268ced3d 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionCosh.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionCosh.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test cosh diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionExp_Expm.sci b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionExp_Expm.sci index d56328d1..957f7b29 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionExp_Expm.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionExp_Expm.sci @@ -1,5 +1,5 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test exp and expm diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionLog.sci b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionLog.sci index 925182cb..d3e52e2b 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionLog.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionLog.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test log diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionLog10.sci b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionLog10.sci index c8b48552..8af14d28 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionLog10.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionLog10.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test log10 diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionLog1p.sci b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionLog1p.sci index 3c929e80..74831ae7 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionLog1p.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionLog1p.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test log1p diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionPow0.sci b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionPow0.sci index 0a19a9b9..d8a1fc88 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionPow0.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionPow0.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= FLOAT -function mainfunction()
+function mainfunction() //test pow0 diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionPow_MatrixPow.sci b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionPow_MatrixPow.sci index 3706353b..8f0e9f5f 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionPow_MatrixPow.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionPow_MatrixPow.sci @@ -1,4 +1,4 @@ -//SCI2C: DEFAULT_PRECISION= DOUBLE
+//SCI2C: DEFAULT_PRECISION= DOUBLE function mainfunction() diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionSin.sci b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionSin.sci index db01d7bd..817e219a 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionSin.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionSin.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test sin diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionSinh.sci b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionSinh.sci index c16af3e7..6e2380ab 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionSinh.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionSinh.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test sinh diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionSqrt.sci b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionSqrt.sci index ba64d189..a7d91d2d 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionSqrt.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionSqrt.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test sqrt diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionTan.sci b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionTan.sci index 67572f08..bfed76d2 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionTan.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionTan.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test tan diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionTanh.sci b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionTanh.sci index b282d6d9..95a21cb3 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionTanh.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/elementary Functions/mainfunctionTanh.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test tanh diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/implicitList/mainfunctionImplicitList.sci b/src/Scilab2C/SCI2CTests/Mes_tests/implicitList/mainfunctionImplicitList.sci index 8d7c6912..db618253 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/implicitList/mainfunctionImplicitList.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/implicitList/mainfunctionImplicitList.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test OpColon diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/mainfunctionOpIns.sci b/src/Scilab2C/SCI2CTests/Mes_tests/mainfunctionOpIns.sci index 37c7375e..dc7d68f5 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/mainfunctionOpIns.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/mainfunctionOpIns.sci @@ -1,6 +1,6 @@ -//SCI2C: DEFAULT_PRECISION= DOUBLE
+//SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() // test OpIns diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/mainfunctionOpLogEq.sci b/src/Scilab2C/SCI2CTests/Mes_tests/mainfunctionOpLogEq.sci index 86ab7251..4d57b0c7 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/mainfunctionOpLogEq.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/mainfunctionOpLogEq.sci @@ -1,6 +1,6 @@ -//SCI2C: DEFAULT_PRECISION= DOUBLE
+//SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() // test OpEqual diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/mainfunctionOpLogNe.sci b/src/Scilab2C/SCI2CTests/Mes_tests/mainfunctionOpLogNe.sci index d1212dac..714a33f7 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/mainfunctionOpLogNe.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/mainfunctionOpLogNe.sci @@ -1,6 +1,6 @@ -//SCI2C: DEFAULT_PRECISION= DOUBLE
+//SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() // test OpEqual diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/mainfunctionOpLogNot.sci b/src/Scilab2C/SCI2CTests/Mes_tests/mainfunctionOpLogNot.sci index 6f17a306..0c84325b 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/mainfunctionOpLogNot.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/mainfunctionOpLogNot.sci @@ -1,6 +1,6 @@ -//SCI2C: DEFAULT_PRECISION= DOUBLE
+//SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() // test OpLogNot diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/matrixOperations/mainfunctionChol.sci b/src/Scilab2C/SCI2CTests/Mes_tests/matrixOperations/mainfunctionChol.sci index 46f8c409..732ed740 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/matrixOperations/mainfunctionChol.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/matrixOperations/mainfunctionChol.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test chol diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/matrixOperations/mainfunctionDet.sci b/src/Scilab2C/SCI2CTests/Mes_tests/matrixOperations/mainfunctionDet.sci index fbd59649..c4300e24 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/matrixOperations/mainfunctionDet.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/matrixOperations/mainfunctionDet.sci @@ -1,5 +1,5 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test det diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/matrixOperations/mainfunctionEye.sci b/src/Scilab2C/SCI2CTests/Mes_tests/matrixOperations/mainfunctionEye.sci index b077c9f4..b52ded74 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/matrixOperations/mainfunctionEye.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/matrixOperations/mainfunctionEye.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test eye diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/matrixOperations/mainfunctionInversion.sci b/src/Scilab2C/SCI2CTests/Mes_tests/matrixOperations/mainfunctionInversion.sci index 71645901..606fcdcf 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/matrixOperations/mainfunctionInversion.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/matrixOperations/mainfunctionInversion.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test inversion diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/matrixOperations/mainfunctionOnes.sci b/src/Scilab2C/SCI2CTests/Mes_tests/matrixOperations/mainfunctionOnes.sci index 15b57b61..f62b7929 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/matrixOperations/mainfunctionOnes.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/matrixOperations/mainfunctionOnes.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test ones diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/matrixOperations/mainfunctionOpApex_OpDotApex.sci b/src/Scilab2C/SCI2CTests/Mes_tests/matrixOperations/mainfunctionOpApex_OpDotApex.sci index 3f3822ea..5e803fb3 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/matrixOperations/mainfunctionOpApex_OpDotApex.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/matrixOperations/mainfunctionOpApex_OpDotApex.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test OpApex(transpose&conj) & OpDotApex(transpose) diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/matrixOperations/mainfunctionSpec_Spec2.sci b/src/Scilab2C/SCI2CTests/Mes_tests/matrixOperations/mainfunctionSpec_Spec2.sci index 36b63d7f..c829b50c 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/matrixOperations/mainfunctionSpec_Spec2.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/matrixOperations/mainfunctionSpec_Spec2.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test spec diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/matrixOperations/mainfunctionZeros.sci b/src/Scilab2C/SCI2CTests/Mes_tests/matrixOperations/mainfunctionZeros.sci index 7b4b0f9d..7d00286d 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/matrixOperations/mainfunctionZeros.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/matrixOperations/mainfunctionZeros.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test zeros diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/operations/mainfunctionOpMinus.sci b/src/Scilab2C/SCI2CTests/Mes_tests/operations/mainfunctionOpMinus.sci index 4445143b..bc11c8c4 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/operations/mainfunctionOpMinus.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/operations/mainfunctionOpMinus.sci @@ -1,5 +1,5 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test soustraction diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/operations/mainfunctionOpPlus.sci b/src/Scilab2C/SCI2CTests/Mes_tests/operations/mainfunctionOpPlus.sci index 3cef1468..0118d2dc 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/operations/mainfunctionOpPlus.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/operations/mainfunctionOpPlus.sci @@ -1,5 +1,5 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test addition diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/operations/mainfunctionOpSlash_OpDotSlash.sci b/src/Scilab2C/SCI2CTests/Mes_tests/operations/mainfunctionOpSlash_OpDotSlash.sci index 5523a19f..894c7b90 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/operations/mainfunctionOpSlash_OpDotSlash.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/operations/mainfunctionOpSlash_OpDotSlash.sci @@ -1,5 +1,5 @@ //SCI2C: DEFAULT_PRECISION= FLOAT -function mainfunction()
+function mainfunction() //test division diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/signalProcessing/mainfunctionConvol.sci b/src/Scilab2C/SCI2CTests/Mes_tests/signalProcessing/mainfunctionConvol.sci index 41c38603..f7edf5c5 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/signalProcessing/mainfunctionConvol.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/signalProcessing/mainfunctionConvol.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test convol diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/signalProcessing/mainfunctionFft.sci b/src/Scilab2C/SCI2CTests/Mes_tests/signalProcessing/mainfunctionFft.sci index e9d11acd..0b96cdd7 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/signalProcessing/mainfunctionFft.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/signalProcessing/mainfunctionFft.sci @@ -1,6 +1,6 @@ -//SCI2C: DEFAULT_PRECISION= DOUBLE
+//SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() // test fftshift diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/signalProcessing/mainfunctionFftShift.sci b/src/Scilab2C/SCI2CTests/Mes_tests/signalProcessing/mainfunctionFftShift.sci index b562894f..2e5f84b6 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/signalProcessing/mainfunctionFftShift.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/signalProcessing/mainfunctionFftShift.sci @@ -1,6 +1,6 @@ -//SCI2C: DEFAULT_PRECISION= DOUBLE
+//SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() // test fftshift diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/signalProcessing/mainfunctionIfft.sci b/src/Scilab2C/SCI2CTests/Mes_tests/signalProcessing/mainfunctionIfft.sci index 3da3e39b..0e0fc0f0 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/signalProcessing/mainfunctionIfft.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/signalProcessing/mainfunctionIfft.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test ifft diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/signalProcessing/mainfunctionLev.sci b/src/Scilab2C/SCI2CTests/Mes_tests/signalProcessing/mainfunctionLev.sci index 274567db..15a8cbce 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/signalProcessing/mainfunctionLev.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/signalProcessing/mainfunctionLev.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test lev diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/statistic Functions/mainfunctionMean.sci b/src/Scilab2C/SCI2CTests/Mes_tests/statistic Functions/mainfunctionMean.sci index ab4b0bc5..dbd5f223 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/statistic Functions/mainfunctionMean.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/statistic Functions/mainfunctionMean.sci @@ -1,7 +1,7 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test mean diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/statistic Functions/mainfunctionSum.sci b/src/Scilab2C/SCI2CTests/Mes_tests/statistic Functions/mainfunctionSum.sci index 7302398e..d3595196 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/statistic Functions/mainfunctionSum.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/statistic Functions/mainfunctionSum.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test sum diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/statistic Functions/mainfunctionVariance.sci b/src/Scilab2C/SCI2CTests/Mes_tests/statistic Functions/mainfunctionVariance.sci index 716d61e3..901c79b1 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/statistic Functions/mainfunctionVariance.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/statistic Functions/mainfunctionVariance.sci @@ -1,6 +1,6 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() //test variance diff --git a/src/Scilab2C/SCI2CTests/Mes_tests/type/mainfunctionReal_Imag.sci b/src/Scilab2C/SCI2CTests/Mes_tests/type/mainfunctionReal_Imag.sci index 02b5c3a7..9513e48c 100644 --- a/src/Scilab2C/SCI2CTests/Mes_tests/type/mainfunctionReal_Imag.sci +++ b/src/Scilab2C/SCI2CTests/Mes_tests/type/mainfunctionReal_Imag.sci @@ -1,7 +1,7 @@ //SCI2C: DEFAULT_PRECISION= DOUBLE function mainfunction() -
+ disp(real(4)); disp(imag(4)); diff --git a/src/Scilab2C/SCI2CTests/test000_TrigonIdentity/SCI2CInputParameters.sce b/src/Scilab2C/SCI2CTests/test000_TrigonIdentity/SCI2CInputParameters.sce index 84590e7b..3bfb97cc 100644 --- a/src/Scilab2C/SCI2CTests/test000_TrigonIdentity/SCI2CInputParameters.sce +++ b/src/Scilab2C/SCI2CTests/test000_TrigonIdentity/SCI2CInputParameters.sce @@ -1,89 +1,89 @@ -// -----------------------------------------------------------------
-// === hArtes/PoliBa/GAP SCI2C tool ===
-// === Authors: ===
-// === Raffaele Nutricato ===
-// === raffaele.nutricato@tiscali.it ===
-// === Alberto Morea ===
-// === ===
-// === *************** ===
-// === USER PARAMETERS ===
-// === *************** ===
-// === ===
-//
-// Copyright 2007 Raffaele Nutricato.
-// Contact: raffaele.nutricato@tiscali.it
-// -----------------------------------------------------------------
-
-
-// ------------------------------------------
-// --- Specify Paths of User Scilab code. ---
-// ------------------------------------------
-// UserSciCodeMainDir = 'D:\Nutricato\OpenProjects\FP6_hArtes\WP2_SCI2C\Software\svnhartes\src\Scilab2C\SCI2CTests\test999_WorkingDir';
-UserSciCodeMainDir = '../SCI2CTests/test999_WorkingDir';
-
-// --- Path + filename of the .sci main file of the code to be translated. ---
-// It is the entry point.
-UserScilabMainFile = fullfile(UserSciCodeMainDir,'scilabcode\mainfunction.sci');
-
-// --- List of the paths containing the .sci files written by the user. ---
-UserSciFilesPaths = ...
- [...
- fullfile(UserSciCodeMainDir,'scilabcode');...
- ];
-
-// --------------------------
-// --- End Specify paths. ---
-// --------------------------
-
-
-// ----------------------------
-// --- Select the run mode. ---
-// ----------------------------
-//RunMode = 'GenLibraryStructure';
-//RunMode = 'Translate';
-RunMode = 'All';
-
-// --- Select one of the following options. ---
-
-// 'GenLibraryStructure';
-// Generates the library structure and exits. It is very
-// useful when the user wants to manually change the files stored in that structure
-// before running the translation. 'GenLibraryStructure' option forces SCI2C to remove
-// the already existing WorkingDir and OutCCCodeDir directories.
-
-// 'Translate';
-// Performs the translation without generating the library structure. It means that the library
-// structure must be already existing. This is useful when the user doesn't want to spend time
-// to generate again that structure or when he wants to force the SCI2C tool to access to
-// a manually-changed library structure. 'Translate' option forces SCI2C to don't remove
-// the already existing WorkingDir. Only OutCCCodeDir directory will be removed.
-
-// 'All';
-// Performs all the actions listed above.
-
-// --------------------------------
-// --- End Select the run mode. ---
-// --------------------------------
-
-
-// ----------------------------
-// --- Translation Options. ---
-// ----------------------------
-// --- Enable (1) / Disable (0) copy of Scilab code into C code. ---
-// If 1 the Scilab code will be copied into the C code in order to show
-// how each Scilab code line has been translated into C code.
-CopySciCodeIntoCCode = 1;
-
-// --- Select the path style for the C code. ---
-// It can be:
-// windows
-// unix
-// cygwin
-CCompilerPathStyle = 'cygwin';
-
-// --- Path + File name of the main SCI2C library header file.
-// Sci2CLibMainHeaderFName = 'D:\Nutricato\OpenProjects\FP6_hArtes\WP2_SCI2C\Software\svnhartes\src\Scilab2C\Scilab2C\CFiles\sci2cincludes\sci2clib.h';
-Sci2CLibMainHeaderFName = '../../../Scilab2C/CFiles/sci2cincludes/sci2clib.h';
-// --------------------------------
-// --- End Translation Options. ---
-// --------------------------------
+// ----------------------------------------------------------------- +// === hArtes/PoliBa/GAP SCI2C tool === +// === Authors: === +// === Raffaele Nutricato === +// === raffaele.nutricato@tiscali.it === +// === Alberto Morea === +// === === +// === *************** === +// === USER PARAMETERS === +// === *************** === +// === === +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + + +// ------------------------------------------ +// --- Specify Paths of User Scilab code. --- +// ------------------------------------------ +// UserSciCodeMainDir = 'D:\Nutricato\OpenProjects\FP6_hArtes\WP2_SCI2C\Software\svnhartes\src\Scilab2C\SCI2CTests\test999_WorkingDir'; +UserSciCodeMainDir = '../SCI2CTests/test999_WorkingDir'; + +// --- Path + filename of the .sci main file of the code to be translated. --- +// It is the entry point. +UserScilabMainFile = fullfile(UserSciCodeMainDir,'scilabcode\mainfunction.sci'); + +// --- List of the paths containing the .sci files written by the user. --- +UserSciFilesPaths = ... + [... + fullfile(UserSciCodeMainDir,'scilabcode');... + ]; + +// -------------------------- +// --- End Specify paths. --- +// -------------------------- + + +// ---------------------------- +// --- Select the run mode. --- +// ---------------------------- +//RunMode = 'GenLibraryStructure'; +//RunMode = 'Translate'; +RunMode = 'All'; + +// --- Select one of the following options. --- + +// 'GenLibraryStructure'; +// Generates the library structure and exits. It is very +// useful when the user wants to manually change the files stored in that structure +// before running the translation. 'GenLibraryStructure' option forces SCI2C to remove +// the already existing WorkingDir and OutCCCodeDir directories. + +// 'Translate'; +// Performs the translation without generating the library structure. It means that the library +// structure must be already existing. This is useful when the user doesn't want to spend time +// to generate again that structure or when he wants to force the SCI2C tool to access to +// a manually-changed library structure. 'Translate' option forces SCI2C to don't remove +// the already existing WorkingDir. Only OutCCCodeDir directory will be removed. + +// 'All'; +// Performs all the actions listed above. + +// -------------------------------- +// --- End Select the run mode. --- +// -------------------------------- + + +// ---------------------------- +// --- Translation Options. --- +// ---------------------------- +// --- Enable (1) / Disable (0) copy of Scilab code into C code. --- +// If 1 the Scilab code will be copied into the C code in order to show +// how each Scilab code line has been translated into C code. +CopySciCodeIntoCCode = 1; + +// --- Select the path style for the C code. --- +// It can be: +// windows +// unix +// cygwin +CCompilerPathStyle = 'cygwin'; + +// --- Path + File name of the main SCI2C library header file. +// Sci2CLibMainHeaderFName = 'D:\Nutricato\OpenProjects\FP6_hArtes\WP2_SCI2C\Software\svnhartes\src\Scilab2C\Scilab2C\CFiles\sci2cincludes\sci2clib.h'; +Sci2CLibMainHeaderFName = '../../../Scilab2C/CFiles/sci2cincludes/sci2clib.h'; +// -------------------------------- +// --- End Translation Options. --- +// -------------------------------- diff --git a/src/Scilab2C/SCI2CTests/test000_TrigonIdentity/scilabcode/mainfunction.sci b/src/Scilab2C/SCI2CTests/test000_TrigonIdentity/scilabcode/mainfunction.sci index e39f7648..842a517e 100644 --- a/src/Scilab2C/SCI2CTests/test000_TrigonIdentity/scilabcode/mainfunction.sci +++ b/src/Scilab2C/SCI2CTests/test000_TrigonIdentity/scilabcode/mainfunction.sci @@ -1,6 +1,6 @@ -//SCI2C: DEFAULT_PRECISION= DOUBLE
+//SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() // ------------------------------ // --- Simple Scalar Addition --- @@ -27,4 +27,4 @@ w = cos(sin(cos(x*3)*2).* x+ones(3,6).*cos(x-sin(y*2))); distxw = sqrt(x.^2 + w.^2); disp(distxw); endfunction -
\ No newline at end of file + diff --git a/src/Scilab2C/SCI2CTests/test001_LinearRegression/SCI2CInputParameters.sce b/src/Scilab2C/SCI2CTests/test001_LinearRegression/SCI2CInputParameters.sce index 84590e7b..3bfb97cc 100644 --- a/src/Scilab2C/SCI2CTests/test001_LinearRegression/SCI2CInputParameters.sce +++ b/src/Scilab2C/SCI2CTests/test001_LinearRegression/SCI2CInputParameters.sce @@ -1,89 +1,89 @@ -// -----------------------------------------------------------------
-// === hArtes/PoliBa/GAP SCI2C tool ===
-// === Authors: ===
-// === Raffaele Nutricato ===
-// === raffaele.nutricato@tiscali.it ===
-// === Alberto Morea ===
-// === ===
-// === *************** ===
-// === USER PARAMETERS ===
-// === *************** ===
-// === ===
-//
-// Copyright 2007 Raffaele Nutricato.
-// Contact: raffaele.nutricato@tiscali.it
-// -----------------------------------------------------------------
-
-
-// ------------------------------------------
-// --- Specify Paths of User Scilab code. ---
-// ------------------------------------------
-// UserSciCodeMainDir = 'D:\Nutricato\OpenProjects\FP6_hArtes\WP2_SCI2C\Software\svnhartes\src\Scilab2C\SCI2CTests\test999_WorkingDir';
-UserSciCodeMainDir = '../SCI2CTests/test999_WorkingDir';
-
-// --- Path + filename of the .sci main file of the code to be translated. ---
-// It is the entry point.
-UserScilabMainFile = fullfile(UserSciCodeMainDir,'scilabcode\mainfunction.sci');
-
-// --- List of the paths containing the .sci files written by the user. ---
-UserSciFilesPaths = ...
- [...
- fullfile(UserSciCodeMainDir,'scilabcode');...
- ];
-
-// --------------------------
-// --- End Specify paths. ---
-// --------------------------
-
-
-// ----------------------------
-// --- Select the run mode. ---
-// ----------------------------
-//RunMode = 'GenLibraryStructure';
-//RunMode = 'Translate';
-RunMode = 'All';
-
-// --- Select one of the following options. ---
-
-// 'GenLibraryStructure';
-// Generates the library structure and exits. It is very
-// useful when the user wants to manually change the files stored in that structure
-// before running the translation. 'GenLibraryStructure' option forces SCI2C to remove
-// the already existing WorkingDir and OutCCCodeDir directories.
-
-// 'Translate';
-// Performs the translation without generating the library structure. It means that the library
-// structure must be already existing. This is useful when the user doesn't want to spend time
-// to generate again that structure or when he wants to force the SCI2C tool to access to
-// a manually-changed library structure. 'Translate' option forces SCI2C to don't remove
-// the already existing WorkingDir. Only OutCCCodeDir directory will be removed.
-
-// 'All';
-// Performs all the actions listed above.
-
-// --------------------------------
-// --- End Select the run mode. ---
-// --------------------------------
-
-
-// ----------------------------
-// --- Translation Options. ---
-// ----------------------------
-// --- Enable (1) / Disable (0) copy of Scilab code into C code. ---
-// If 1 the Scilab code will be copied into the C code in order to show
-// how each Scilab code line has been translated into C code.
-CopySciCodeIntoCCode = 1;
-
-// --- Select the path style for the C code. ---
-// It can be:
-// windows
-// unix
-// cygwin
-CCompilerPathStyle = 'cygwin';
-
-// --- Path + File name of the main SCI2C library header file.
-// Sci2CLibMainHeaderFName = 'D:\Nutricato\OpenProjects\FP6_hArtes\WP2_SCI2C\Software\svnhartes\src\Scilab2C\Scilab2C\CFiles\sci2cincludes\sci2clib.h';
-Sci2CLibMainHeaderFName = '../../../Scilab2C/CFiles/sci2cincludes/sci2clib.h';
-// --------------------------------
-// --- End Translation Options. ---
-// --------------------------------
+// ----------------------------------------------------------------- +// === hArtes/PoliBa/GAP SCI2C tool === +// === Authors: === +// === Raffaele Nutricato === +// === raffaele.nutricato@tiscali.it === +// === Alberto Morea === +// === === +// === *************** === +// === USER PARAMETERS === +// === *************** === +// === === +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + + +// ------------------------------------------ +// --- Specify Paths of User Scilab code. --- +// ------------------------------------------ +// UserSciCodeMainDir = 'D:\Nutricato\OpenProjects\FP6_hArtes\WP2_SCI2C\Software\svnhartes\src\Scilab2C\SCI2CTests\test999_WorkingDir'; +UserSciCodeMainDir = '../SCI2CTests/test999_WorkingDir'; + +// --- Path + filename of the .sci main file of the code to be translated. --- +// It is the entry point. +UserScilabMainFile = fullfile(UserSciCodeMainDir,'scilabcode\mainfunction.sci'); + +// --- List of the paths containing the .sci files written by the user. --- +UserSciFilesPaths = ... + [... + fullfile(UserSciCodeMainDir,'scilabcode');... + ]; + +// -------------------------- +// --- End Specify paths. --- +// -------------------------- + + +// ---------------------------- +// --- Select the run mode. --- +// ---------------------------- +//RunMode = 'GenLibraryStructure'; +//RunMode = 'Translate'; +RunMode = 'All'; + +// --- Select one of the following options. --- + +// 'GenLibraryStructure'; +// Generates the library structure and exits. It is very +// useful when the user wants to manually change the files stored in that structure +// before running the translation. 'GenLibraryStructure' option forces SCI2C to remove +// the already existing WorkingDir and OutCCCodeDir directories. + +// 'Translate'; +// Performs the translation without generating the library structure. It means that the library +// structure must be already existing. This is useful when the user doesn't want to spend time +// to generate again that structure or when he wants to force the SCI2C tool to access to +// a manually-changed library structure. 'Translate' option forces SCI2C to don't remove +// the already existing WorkingDir. Only OutCCCodeDir directory will be removed. + +// 'All'; +// Performs all the actions listed above. + +// -------------------------------- +// --- End Select the run mode. --- +// -------------------------------- + + +// ---------------------------- +// --- Translation Options. --- +// ---------------------------- +// --- Enable (1) / Disable (0) copy of Scilab code into C code. --- +// If 1 the Scilab code will be copied into the C code in order to show +// how each Scilab code line has been translated into C code. +CopySciCodeIntoCCode = 1; + +// --- Select the path style for the C code. --- +// It can be: +// windows +// unix +// cygwin +CCompilerPathStyle = 'cygwin'; + +// --- Path + File name of the main SCI2C library header file. +// Sci2CLibMainHeaderFName = 'D:\Nutricato\OpenProjects\FP6_hArtes\WP2_SCI2C\Software\svnhartes\src\Scilab2C\Scilab2C\CFiles\sci2cincludes\sci2clib.h'; +Sci2CLibMainHeaderFName = '../../../Scilab2C/CFiles/sci2cincludes/sci2clib.h'; +// -------------------------------- +// --- End Translation Options. --- +// -------------------------------- diff --git a/src/Scilab2C/SCI2CTests/test001_LinearRegression/scilabcode/mainfunction.sci b/src/Scilab2C/SCI2CTests/test001_LinearRegression/scilabcode/mainfunction.sci index a29a1c9e..390b7b66 100644 --- a/src/Scilab2C/SCI2CTests/test001_LinearRegression/scilabcode/mainfunction.sci +++ b/src/Scilab2C/SCI2CTests/test001_LinearRegression/scilabcode/mainfunction.sci @@ -1,6 +1,6 @@ -//SCI2C: DEFAULT_PRECISION= DOUBLE
+//SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() // Knowing that // (1) P * (V^gamma) = C @@ -28,8 +28,8 @@ a = (sum(y)*sum(x.^2)-sum(x)*sum(x.*y))./(length(x)*sum(x.^2)-sum(x).*sum(x)); b = (length(x)*sum(x.*y)-sum(x)*sum(y))./(length(x)*sum(x.^2)-sum(x).*sum(x)); // Other way to compute a and b -beq = sum((x-mean(x)).*(y-mean(y)))./sum((x-mean(x)).^2);
-aeq = mean(y)-mean(x)*beq;
+beq = sum((x-mean(x)).*(y-mean(y)))./sum((x-mean(x)).^2); +aeq = mean(y)-mean(x)*beq; C = 10 .^a; gamma = -b; diff --git a/src/Scilab2C/SCI2CTests/test999_WorkingDir/SCI2CInputParameters.sce b/src/Scilab2C/SCI2CTests/test999_WorkingDir/SCI2CInputParameters.sce index 52d8c7d5..8d733b65 100644 --- a/src/Scilab2C/SCI2CTests/test999_WorkingDir/SCI2CInputParameters.sce +++ b/src/Scilab2C/SCI2CTests/test999_WorkingDir/SCI2CInputParameters.sce @@ -1,89 +1,89 @@ -// -----------------------------------------------------------------
-// === hArtes/PoliBa/GAP SCI2C tool ===
-// === Authors: ===
-// === Raffaele Nutricato ===
-// === raffaele.nutricato@tiscali.it ===
-// === Alberto Morea ===
-// === ===
-// === *************** ===
-// === USER PARAMETERS ===
-// === *************** ===
-// === ===
-//
-// Copyright 2007 Raffaele Nutricato.
-// Contact: raffaele.nutricato@tiscali.it
-// -----------------------------------------------------------------
-
-
-// ------------------------------------------
-// --- Specify Paths of User Scilab code. ---
-// ------------------------------------------
-// UserSciCodeMainDir = 'D:\Nutricato\OpenProjects\FP6_hArtes\WP2_SCI2C\Software\svnhartes\src\Scilab2C\SCI2CTests\test999_WorkingDir';
-UserSciCodeMainDir = '../SCI2CTests/test999_WorkingDir';
-
-// --- Path + filename of the .sci main file of the code to be translated. ---
-// It is the entry point.
-UserScilabMainFile = fullfile(UserSciCodeMainDir,'scilabcode/mainfunction.sci');
-
-// --- List of the paths containing the .sci files written by the user. ---
-UserSciFilesPaths = ...
- [...
- fullfile(UserSciCodeMainDir,'scilabcode');...
- ];
-
-// --------------------------
-// --- End Specify paths. ---
-// --------------------------
-
-
-// ----------------------------
-// --- Select the run mode. ---
-// ----------------------------
-//RunMode = 'GenLibraryStructure';
-//RunMode = 'Translate';
-RunMode = 'All';
-
-// --- Select one of the following options. ---
-
-// 'GenLibraryStructure';
-// Generates the library structure and exits. It is very
-// useful when the user wants to manually change the files stored in that structure
-// before running the translation. 'GenLibraryStructure' option forces SCI2C to remove
-// the already existing WorkingDir and OutCCCodeDir directories.
-
-// 'Translate';
-// Performs the translation without generating the library structure. It means that the library
-// structure must be already existing. This is useful when the user doesn't want to spend time
-// to generate again that structure or when he wants to force the SCI2C tool to access to
-// a manually-changed library structure. 'Translate' option forces SCI2C to don't remove
-// the already existing WorkingDir. Only OutCCCodeDir directory will be removed.
-
-// 'All';
-// Performs all the actions listed above.
-
-// --------------------------------
-// --- End Select the run mode. ---
-// --------------------------------
-
-
-// ----------------------------
-// --- Translation Options. ---
-// ----------------------------
-// --- Enable (1) / Disable (0) copy of Scilab code into C code. ---
-// If 1 the Scilab code will be copied into the C code in order to show
-// how each Scilab code line has been translated into C code.
-CopySciCodeIntoCCode = 1;
-
-// --- Select the path style for the C code. ---
-// It can be:
-// windows
-// unix
-// cygwin
-CCompilerPathStyle = 'unix';
-
-// --- Path + File name of the main SCI2C library header file.
-// Sci2CLibMainHeaderFName = 'D:\Nutricato\OpenProjects\FP6_hArtes\WP2_SCI2C\Software\svnhartes\src\Scilab2C\Scilab2C\CFiles\sci2cincludes\sci2clib.h';
-Sci2CLibMainHeaderFName = '../../../Scilab2C/CFiles/sci2cincludes/sci2clib.h';
-// --------------------------------
-// --- End Translation Options. ---
-// --------------------------------
+// ----------------------------------------------------------------- +// === hArtes/PoliBa/GAP SCI2C tool === +// === Authors: === +// === Raffaele Nutricato === +// === raffaele.nutricato@tiscali.it === +// === Alberto Morea === +// === === +// === *************** === +// === USER PARAMETERS === +// === *************** === +// === === +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + + +// ------------------------------------------ +// --- Specify Paths of User Scilab code. --- +// ------------------------------------------ +// UserSciCodeMainDir = 'D:\Nutricato\OpenProjects\FP6_hArtes\WP2_SCI2C\Software\svnhartes\src\Scilab2C\SCI2CTests\test999_WorkingDir'; +UserSciCodeMainDir = '../SCI2CTests/test999_WorkingDir'; + +// --- Path + filename of the .sci main file of the code to be translated. --- +// It is the entry point. +UserScilabMainFile = fullfile(UserSciCodeMainDir,'scilabcode/mainfunction.sci'); + +// --- List of the paths containing the .sci files written by the user. --- +UserSciFilesPaths = ... + [... + fullfile(UserSciCodeMainDir,'scilabcode');... + ]; + +// -------------------------- +// --- End Specify paths. --- +// -------------------------- + + +// ---------------------------- +// --- Select the run mode. --- +// ---------------------------- +//RunMode = 'GenLibraryStructure'; +//RunMode = 'Translate'; +RunMode = 'All'; + +// --- Select one of the following options. --- + +// 'GenLibraryStructure'; +// Generates the library structure and exits. It is very +// useful when the user wants to manually change the files stored in that structure +// before running the translation. 'GenLibraryStructure' option forces SCI2C to remove +// the already existing WorkingDir and OutCCCodeDir directories. + +// 'Translate'; +// Performs the translation without generating the library structure. It means that the library +// structure must be already existing. This is useful when the user doesn't want to spend time +// to generate again that structure or when he wants to force the SCI2C tool to access to +// a manually-changed library structure. 'Translate' option forces SCI2C to don't remove +// the already existing WorkingDir. Only OutCCCodeDir directory will be removed. + +// 'All'; +// Performs all the actions listed above. + +// -------------------------------- +// --- End Select the run mode. --- +// -------------------------------- + + +// ---------------------------- +// --- Translation Options. --- +// ---------------------------- +// --- Enable (1) / Disable (0) copy of Scilab code into C code. --- +// If 1 the Scilab code will be copied into the C code in order to show +// how each Scilab code line has been translated into C code. +CopySciCodeIntoCCode = 1; + +// --- Select the path style for the C code. --- +// It can be: +// windows +// unix +// cygwin +CCompilerPathStyle = 'unix'; + +// --- Path + File name of the main SCI2C library header file. +// Sci2CLibMainHeaderFName = 'D:\Nutricato\OpenProjects\FP6_hArtes\WP2_SCI2C\Software\svnhartes\src\Scilab2C\Scilab2C\CFiles\sci2cincludes\sci2clib.h'; +Sci2CLibMainHeaderFName = '../../../Scilab2C/CFiles/sci2cincludes/sci2clib.h'; +// -------------------------------- +// --- End Translation Options. --- +// -------------------------------- diff --git a/src/Scilab2C/SCI2CTests/test999_WorkingDir/scilabcode/mainfunction.sci b/src/Scilab2C/SCI2CTests/test999_WorkingDir/scilabcode/mainfunction.sci index e39f7648..842a517e 100644 --- a/src/Scilab2C/SCI2CTests/test999_WorkingDir/scilabcode/mainfunction.sci +++ b/src/Scilab2C/SCI2CTests/test999_WorkingDir/scilabcode/mainfunction.sci @@ -1,6 +1,6 @@ -//SCI2C: DEFAULT_PRECISION= DOUBLE
+//SCI2C: DEFAULT_PRECISION= DOUBLE -function mainfunction()
+function mainfunction() // ------------------------------ // --- Simple Scalar Addition --- @@ -27,4 +27,4 @@ w = cos(sin(cos(x*3)*2).* x+ones(3,6).*cos(x-sin(y*2))); distxw = sqrt(x.^2 + w.^2); disp(distxw); endfunction -
\ No newline at end of file + diff --git a/src/c/auxiliaryFunctions/includes/dynlib_auxiliaryfunctions.h b/src/c/auxiliaryFunctions/includes/dynlib_auxiliaryfunctions.h index 09b1bea8..a2e741a1 100644 --- a/src/c/auxiliaryFunctions/includes/dynlib_auxiliaryfunctions.h +++ b/src/c/auxiliaryFunctions/includes/dynlib_auxiliaryfunctions.h @@ -1,26 +1,26 @@ -/*
-* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-* Copyright (C) 2009 - DIGITEO - Allan CORNET
-*
-* This file must be used under the terms of the CeCILL.
-* This source file is licensed as described in the file COPYING, which
-* you should have received as part of this distribution. The terms
-* are also available at
-* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
-*
-*/
-
-#ifndef __DYNLIB_AUXILIARYFUNCTIONS_H__
-#define __DYNLIB_AUXILIARYFUNCTIONS_H__
-
-#if defined(_MSC_VER) && defined(_USRDLL)
- #if AUXILIARYFUNCTIONS_EXPORTS
- #define EXTERN_AUXFUNCT __declspec (dllexport)
- #else
- #define EXTERN_AUXFUNCT __declspec (dllimport)
- #endif
-#else
- #define EXTERN_AUXFUNCT
-#endif
-
-#endif /* __DYNLIB_AUXILIARYFUNCTIONS_H__ */
+/* +* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +* Copyright (C) 2009 - DIGITEO - Allan CORNET +* +* This file must be used under the terms of the CeCILL. +* This source file is licensed as described in the file COPYING, which +* you should have received as part of this distribution. The terms +* are also available at +* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +* +*/ + +#ifndef __DYNLIB_AUXILIARYFUNCTIONS_H__ +#define __DYNLIB_AUXILIARYFUNCTIONS_H__ + +#if defined(_MSC_VER) && defined(_USRDLL) + #if AUXILIARYFUNCTIONS_EXPORTS + #define EXTERN_AUXFUNCT __declspec (dllexport) + #else + #define EXTERN_AUXFUNCT __declspec (dllimport) + #endif +#else + #define EXTERN_AUXFUNCT +#endif + +#endif /* __DYNLIB_AUXILIARYFUNCTIONS_H__ */ diff --git a/src/c/auxiliaryFunctions/interfaces/int_length.h b/src/c/auxiliaryFunctions/interfaces/int_length.h index fe84a92a..130601e3 100644 --- a/src/c/auxiliaryFunctions/interfaces/int_length.h +++ b/src/c/auxiliaryFunctions/interfaces/int_length.h @@ -32,39 +32,39 @@ #ifndef __INT_LENGTH_H__ #define __INT_LENGTH_H__ -#define s0lengths0(in) \
+#define s0lengths0(in) \ slengths(in) -#define d0lengthd0(in) \
+#define d0lengthd0(in) \ dlengths(in) -
-#define c0lengths0(in) \
+ +#define c0lengths0(in) \ clengths(in) -#define z0lengthd0(in) \
+#define z0lengthd0(in) \ zlengths(in) -#define g0lengths0(in) \
+#define g0lengths0(in) \ slengths(in) -#define g0lengthd0(in) \
+#define g0lengthd0(in) \ dlengths(in) -#define s2lengths0(inptr,insizeptr) \
+#define s2lengths0(inptr,insizeptr) \ slengtha(inptr, insizeptr[0]*insizeptr[1]) -#define d2lengthd0(inptr,insizeptr) \
+#define d2lengthd0(inptr,insizeptr) \ dlengtha(inptr, insizeptr[0]*insizeptr[1]) -#define c2lengths0(inptr,insizeptr) \
+#define c2lengths0(inptr,insizeptr) \ clengtha(inptr, insizeptr[0]*insizeptr[1]) -#define z2lengthd0(inptr,insizeptr) \
+#define z2lengthd0(inptr,insizeptr) \ zlengtha(inptr, insizeptr[0]*insizeptr[1]) -#define g2lengths0(inptr,insizeptr) \
+#define g2lengths0(inptr,insizeptr) \ slengtha(inptr, insizeptr[0]*insizeptr[1]) -#define g2lengthd0(inptr,insizeptr) \
+#define g2lengthd0(inptr,insizeptr) \ dlengtha(inptr, insizeptr[0]*insizeptr[1]) #endif /* !__INT_LENGTH_H__ */ diff --git a/src/c/auxiliaryFunctions/isnan/sisnans.c b/src/c/auxiliaryFunctions/isnan/sisnans.c index 905890b8..39484bd9 100644 --- a/src/c/auxiliaryFunctions/isnan/sisnans.c +++ b/src/c/auxiliaryFunctions/isnan/sisnans.c @@ -1,23 +1,23 @@ -/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2007-2008 - INRIA - Bruno JOFRET
- *
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
-
-
-#ifdef _WIN32
-#include <math.h>
-#endif
-
-#include "isnan.h"
-
-float sisnans(float in) {
- return isnan(in) ? (float)1 :(float)0;
-}
-
+/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2007-2008 - INRIA - Bruno JOFRET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + + +#ifdef _WIN32 +#include <math.h> +#endif + +#include "isnan.h" + +float sisnans(float in) { + return isnan(in) ? (float)1 :(float)0; +} + diff --git a/src/c/elementaryFunctions/acos/cacoss.c b/src/c/elementaryFunctions/acos/cacoss.c index 97420313..6e12ed8a 100644 --- a/src/c/elementaryFunctions/acos/cacoss.c +++ b/src/c/elementaryFunctions/acos/cacoss.c @@ -1,147 +1,147 @@ -/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2007-2008 - INRIA - Bruno JOFRET
- * Copyright (C) Bruno Pincon
- *
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
-
-/*
- * This fonction is a translation of fortran wacos write by Bruno Pincon <Bruno.Pincon@iecn.u-nancy.fr>
- * REFERENCE
- * This is a Fortran-77 translation of an algorithm by
- * T.E. Hull, T. F. Fairgrieve and P.T.P. Tang which
- * appears in their article :
- * "Implementing the Complex Arcsine and Arccosine
- * Functions Using Exception Handling", ACM, TOMS,
- * Vol 23, No. 3, Sept 1997, p. 299-335
- */
-
-#include "acos.h"
-#include "atan.h"
-#include "log.h"
-#include "log1p.h"
-#include "sqrt.h"
-#include "abs.h"
-#include "lapack.h"
-#include "min.h"
-#include "max.h"
-
-#define localSign(x) (x>0 ? 1.0f : -1.0f)
-
-floatComplex cacoss(floatComplex z) {
- static float sfltPi = 3.1415926535897932384626433f;
- static float sfltPi_2 = 1.5707963267948966192313216f;
- static float sfltLn2 = 0.6931471805599453094172321f;
- static float sfltAcross = 1.5f;
- static float sfltBcross = 0.6417f;
-
- float fltLsup = ssqrts((float) getOverflowThreshold())/8.0f;
- float fltLinf = 4.0f * ssqrts((float) getUnderflowThreshold());
- float fltEpsm = ssqrts((float) getRelativeMachinePrecision());
-
- float fltAbsReal = sabss(creals(z));
- float fltAbsImg = sabss(cimags(z));
- float fltSignReal = localSign(creals(z));
- float fltSignImg = localSign(cimags(z));
-
- float fltR = 0, fltS = 0, fltA = 0, fltB = 0;
-
- float fltTemp = 0;
-
- float _pfltReal = 0;
- float _pfltImg = 0;
-
- if( min(fltAbsReal, fltAbsImg) > fltLinf && max(fltAbsReal, fltAbsImg) <= fltLsup)
- {/* we are in the safe region */
- fltR = ssqrts( (fltAbsReal + 1 )*(fltAbsReal + 1 ) + fltAbsImg*fltAbsImg);
- fltS = ssqrts( (fltAbsReal - 1 )*(fltAbsReal - 1 ) + fltAbsImg*fltAbsImg);
- fltA = 0.5f * ( fltR + fltS );
- fltB = fltAbsReal / fltA;
-
-
- /* compute the real part */
- if(fltB <= sfltBcross)
- _pfltReal = sacoss(fltB);
- else if( fltAbsReal <= 1)
- _pfltReal = satans(ssqrts(0.5f * (fltA + fltAbsReal) * (fltAbsImg*fltAbsImg / (fltR + (fltAbsReal + 1)) + (fltS + (1 - fltAbsReal)))) / fltAbsReal);
- else
- _pfltReal = satans((fltAbsImg * ssqrts(0.5f * ((fltA + fltAbsReal) / (fltR + (fltAbsReal + 1)) + (fltA + fltAbsReal) / (fltS + (fltAbsReal - 1))))) / fltAbsReal);
-
- /* compute the imaginary part */
- if(fltA <= sfltAcross)
- {
- float fltImg1 = 0;
-
- if(fltAbsReal < 1)
- /* Am1 = 0.5d0*((y**2)/(R+(x+1.d0))+(y**2)/(S+(1.d0-x))) */
- fltImg1 = 0.5f * (fltAbsImg*fltAbsImg / (fltR + (fltAbsReal + 1)) + fltAbsImg*fltAbsImg / (fltS + (1 - fltAbsReal)));
- else
- /* Am1 = 0.5d0*((y**2)/(R+(x+1.d0))+(S+(x-1.d0))) */
- fltImg1 = 0.5f * (fltAbsImg*fltAbsImg / (fltR + (fltAbsReal + 1)) + (fltS + (fltAbsReal - 1)));
- /* ai = logp1(Am1 + sqrt(Am1*(A+1.d0))) */
- fltTemp = fltImg1 + ssqrts(fltImg1 *( fltA + 1));
- _pfltImg = slog1ps(fltTemp);
- }
- else
- /* ai = log(A + sqrt(A**2 - 1.d0)) */
- _pfltImg = slogs(fltA + ssqrts(fltA*fltA - 1));
- }
- else
- {/* evaluation in the special regions ... */
- if(fltAbsImg <= fltEpsm * sabss(fltAbsReal - 1))
- {
- if(fltAbsReal < 1)
- {
- _pfltReal = sacoss(fltAbsReal);
- _pfltImg = fltAbsImg / ssqrts((1 + fltAbsReal) * (1 - fltAbsReal));
- }
- else
- {
- _pfltReal = 0;
- if(fltAbsReal <= fltLsup)
- {
- fltTemp = (fltAbsReal - 1) + ssqrts((fltAbsReal - 1) * (fltAbsReal + 1));
- _pfltImg = slog1ps(fltTemp);
- }
- else
- _pfltImg = sfltLn2 + slogs(fltAbsReal);
- }
- }
- else if(fltAbsImg < fltLinf)
- {
- _pfltReal = ssqrts(fltAbsImg);
- _pfltImg = _pfltReal;
- }
- else if((fltEpsm * fltAbsImg - 1 >= fltAbsReal))
- {
- _pfltReal = sfltPi_2;
- _pfltImg = sfltLn2 + slogs(fltAbsImg);
- }
- else if(fltAbsReal > 1)
- {
- _pfltReal = satans(fltAbsImg / fltAbsReal);
- fltTemp = (fltAbsReal / fltAbsImg)*(fltAbsReal / fltAbsImg);
- _pfltImg = sfltLn2 + slogs(fltAbsImg) + 0.5f * slog1ps(fltTemp);
- }
- else
- {
- float fltTemp2 = ssqrts(1 + fltAbsImg*fltAbsImg);
- _pfltReal = sfltPi_2;
- fltTemp = 2 * fltAbsImg * (fltAbsImg + fltTemp2);
- _pfltImg = 0.5f * slog1ps(fltTemp);
- }
- }
- if(fltSignReal < 0)
- _pfltReal = sfltPi - _pfltReal;
-
- if(fltAbsImg != 0 || fltSignReal < 0)
- _pfltImg = - fltSignImg * _pfltImg;
-
- return FloatComplex(_pfltReal, _pfltImg);
-}
+/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2007-2008 - INRIA - Bruno JOFRET + * Copyright (C) Bruno Pincon + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + +/* + * This fonction is a translation of fortran wacos write by Bruno Pincon <Bruno.Pincon@iecn.u-nancy.fr> + * REFERENCE + * This is a Fortran-77 translation of an algorithm by + * T.E. Hull, T. F. Fairgrieve and P.T.P. Tang which + * appears in their article : + * "Implementing the Complex Arcsine and Arccosine + * Functions Using Exception Handling", ACM, TOMS, + * Vol 23, No. 3, Sept 1997, p. 299-335 + */ + +#include "acos.h" +#include "atan.h" +#include "log.h" +#include "log1p.h" +#include "sqrt.h" +#include "abs.h" +#include "lapack.h" +#include "min.h" +#include "max.h" + +#define localSign(x) (x>0 ? 1.0f : -1.0f) + +floatComplex cacoss(floatComplex z) { + static float sfltPi = 3.1415926535897932384626433f; + static float sfltPi_2 = 1.5707963267948966192313216f; + static float sfltLn2 = 0.6931471805599453094172321f; + static float sfltAcross = 1.5f; + static float sfltBcross = 0.6417f; + + float fltLsup = ssqrts((float) getOverflowThreshold())/8.0f; + float fltLinf = 4.0f * ssqrts((float) getUnderflowThreshold()); + float fltEpsm = ssqrts((float) getRelativeMachinePrecision()); + + float fltAbsReal = sabss(creals(z)); + float fltAbsImg = sabss(cimags(z)); + float fltSignReal = localSign(creals(z)); + float fltSignImg = localSign(cimags(z)); + + float fltR = 0, fltS = 0, fltA = 0, fltB = 0; + + float fltTemp = 0; + + float _pfltReal = 0; + float _pfltImg = 0; + + if( min(fltAbsReal, fltAbsImg) > fltLinf && max(fltAbsReal, fltAbsImg) <= fltLsup) + {/* we are in the safe region */ + fltR = ssqrts( (fltAbsReal + 1 )*(fltAbsReal + 1 ) + fltAbsImg*fltAbsImg); + fltS = ssqrts( (fltAbsReal - 1 )*(fltAbsReal - 1 ) + fltAbsImg*fltAbsImg); + fltA = 0.5f * ( fltR + fltS ); + fltB = fltAbsReal / fltA; + + + /* compute the real part */ + if(fltB <= sfltBcross) + _pfltReal = sacoss(fltB); + else if( fltAbsReal <= 1) + _pfltReal = satans(ssqrts(0.5f * (fltA + fltAbsReal) * (fltAbsImg*fltAbsImg / (fltR + (fltAbsReal + 1)) + (fltS + (1 - fltAbsReal)))) / fltAbsReal); + else + _pfltReal = satans((fltAbsImg * ssqrts(0.5f * ((fltA + fltAbsReal) / (fltR + (fltAbsReal + 1)) + (fltA + fltAbsReal) / (fltS + (fltAbsReal - 1))))) / fltAbsReal); + + /* compute the imaginary part */ + if(fltA <= sfltAcross) + { + float fltImg1 = 0; + + if(fltAbsReal < 1) + /* Am1 = 0.5d0*((y**2)/(R+(x+1.d0))+(y**2)/(S+(1.d0-x))) */ + fltImg1 = 0.5f * (fltAbsImg*fltAbsImg / (fltR + (fltAbsReal + 1)) + fltAbsImg*fltAbsImg / (fltS + (1 - fltAbsReal))); + else + /* Am1 = 0.5d0*((y**2)/(R+(x+1.d0))+(S+(x-1.d0))) */ + fltImg1 = 0.5f * (fltAbsImg*fltAbsImg / (fltR + (fltAbsReal + 1)) + (fltS + (fltAbsReal - 1))); + /* ai = logp1(Am1 + sqrt(Am1*(A+1.d0))) */ + fltTemp = fltImg1 + ssqrts(fltImg1 *( fltA + 1)); + _pfltImg = slog1ps(fltTemp); + } + else + /* ai = log(A + sqrt(A**2 - 1.d0)) */ + _pfltImg = slogs(fltA + ssqrts(fltA*fltA - 1)); + } + else + {/* evaluation in the special regions ... */ + if(fltAbsImg <= fltEpsm * sabss(fltAbsReal - 1)) + { + if(fltAbsReal < 1) + { + _pfltReal = sacoss(fltAbsReal); + _pfltImg = fltAbsImg / ssqrts((1 + fltAbsReal) * (1 - fltAbsReal)); + } + else + { + _pfltReal = 0; + if(fltAbsReal <= fltLsup) + { + fltTemp = (fltAbsReal - 1) + ssqrts((fltAbsReal - 1) * (fltAbsReal + 1)); + _pfltImg = slog1ps(fltTemp); + } + else + _pfltImg = sfltLn2 + slogs(fltAbsReal); + } + } + else if(fltAbsImg < fltLinf) + { + _pfltReal = ssqrts(fltAbsImg); + _pfltImg = _pfltReal; + } + else if((fltEpsm * fltAbsImg - 1 >= fltAbsReal)) + { + _pfltReal = sfltPi_2; + _pfltImg = sfltLn2 + slogs(fltAbsImg); + } + else if(fltAbsReal > 1) + { + _pfltReal = satans(fltAbsImg / fltAbsReal); + fltTemp = (fltAbsReal / fltAbsImg)*(fltAbsReal / fltAbsImg); + _pfltImg = sfltLn2 + slogs(fltAbsImg) + 0.5f * slog1ps(fltTemp); + } + else + { + float fltTemp2 = ssqrts(1 + fltAbsImg*fltAbsImg); + _pfltReal = sfltPi_2; + fltTemp = 2 * fltAbsImg * (fltAbsImg + fltTemp2); + _pfltImg = 0.5f * slog1ps(fltTemp); + } + } + if(fltSignReal < 0) + _pfltReal = sfltPi - _pfltReal; + + if(fltAbsImg != 0 || fltSignReal < 0) + _pfltImg = - fltSignImg * _pfltImg; + + return FloatComplex(_pfltReal, _pfltImg); +} diff --git a/src/c/elementaryFunctions/acos/zacoss.c b/src/c/elementaryFunctions/acos/zacoss.c index de6f3fe9..10da477c 100644 --- a/src/c/elementaryFunctions/acos/zacoss.c +++ b/src/c/elementaryFunctions/acos/zacoss.c @@ -1,147 +1,147 @@ -/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2007-2008 - INRIA - Bruno JOFRET
- * Copyright (C) Bruno Pincon
- *
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
-
-/*
- * This fonction is a translation of fortran wacos write by Bruno Pincon <Bruno.Pincon@iecn.u-nancy.fr>
- * REFERENCE
- * This is a Fortran-77 translation of an algorithm by
- * T.E. Hull, T. F. Fairgrieve and P.T.P. Tang which
- * appears in their article :
- * "Implementing the Complex Arcsine and Arccosine
- * Functions Using Exception Handling", ACM, TOMS,
- * Vol 23, No. 3, Sept 1997, p. 299-335
- */
-
-#include "acos.h"
-#include "atan.h"
-#include "log.h"
-#include "log1p.h"
-#include "sqrt.h"
-#include "abs.h"
-#include "lapack.h"
-#include "min.h"
-#include "max.h"
-
-#define localSign(x) (x>0 ? 1 : -1)
-
-doubleComplex zacoss(doubleComplex z) {
- static double sdblPi = 3.1415926535897932384626433;
- static double sdblPi_2 = 1.5707963267948966192313216;
- static double sdblLn2 = 0.6931471805599453094172321;
- static double sdblAcross = 1.5;
- static double sdblBcross = 0.6417;
-
- double dblLsup = dsqrts(getOverflowThreshold())/8.0;
- double dblLinf = 4.0 * dsqrts(getUnderflowThreshold());
- double dblEpsm = dsqrts(getRelativeMachinePrecision());
-
- double dblAbsReal = dabss(zreals(z));
- double dblAbsImg = dabss(zimags(z));
- double dblSignReal = localSign(zreals(z));
- double dblSignImg = localSign(zimags(z));
-
- double dblR = 0, dblS = 0, dblA = 0, dblB = 0;
-
- double dblTemp = 0;
-
- double _pdblReal = 0;
- double _pdblImg = 0;
-
- if( min(dblAbsReal, dblAbsImg) > dblLinf && max(dblAbsReal, dblAbsImg) <= dblLsup)
- {/* we are in the safe region */
- dblR = dsqrts( (dblAbsReal + 1 )*(dblAbsReal + 1 ) + dblAbsImg*dblAbsImg);
- dblS = dsqrts( (dblAbsReal - 1 )*(dblAbsReal - 1 ) + dblAbsImg*dblAbsImg);
- dblA = 0.5 * ( dblR + dblS );
- dblB = dblAbsReal / dblA;
-
-
- /* compute the real part */
- if(dblB <= sdblBcross)
- _pdblReal = dacoss(dblB);
- else if( dblAbsReal <= 1)
- _pdblReal = datans(dsqrts(0.5 * (dblA + dblAbsReal) * (dblAbsImg*dblAbsImg / (dblR + (dblAbsReal + 1)) + (dblS + (1 - dblAbsReal)))) / dblAbsReal);
- else
- _pdblReal = datans((dblAbsImg * dsqrts(0.5 * ((dblA + dblAbsReal) / (dblR + (dblAbsReal + 1)) + (dblA + dblAbsReal) / (dblS + (dblAbsReal - 1))))) / dblAbsReal);
-
- /* compute the imaginary part */
- if(dblA <= sdblAcross)
- {
- double dblImg1 = 0;
-
- if(dblAbsReal < 1)
- /* Am1 = 0.5d0*((y**2)/(R+(x+1.d0))+(y**2)/(S+(1.d0-x))) */
- dblImg1 = 0.5 * (dblAbsImg*dblAbsImg / (dblR + (dblAbsReal + 1)) + dblAbsImg*dblAbsImg / (dblS + (1 - dblAbsReal)));
- else
- /* Am1 = 0.5d0*((y**2)/(R+(x+1.d0))+(S+(x-1.d0))) */
- dblImg1 = 0.5 * (dblAbsImg*dblAbsImg / (dblR + (dblAbsReal + 1)) + (dblS + (dblAbsReal - 1)));
- /* ai = logp1(Am1 + sqrt(Am1*(A+1.d0))) */
- dblTemp = dblImg1 + dsqrts(dblImg1 *( dblA + 1));
- _pdblImg = dlog1ps(dblTemp);
- }
- else
- /* ai = log(A + sqrt(A**2 - 1.d0)) */
- _pdblImg = dlogs(dblA + dsqrts(dblA*dblA - 1));
- }
- else
- {/* evaluation in the special regions ... */
- if(dblAbsImg <= dblEpsm * dabss(dblAbsReal - 1))
- {
- if(dblAbsReal < 1)
- {
- _pdblReal = dacoss(dblAbsReal);
- _pdblImg = dblAbsImg / dsqrts((1 + dblAbsReal) * (1 - dblAbsReal));
- }
- else
- {
- _pdblReal = 0;
- if(dblAbsReal <= dblLsup)
- {
- dblTemp = (dblAbsReal - 1) + dsqrts((dblAbsReal - 1) * (dblAbsReal + 1));
- _pdblImg = dlog1ps(dblTemp);
- }
- else
- _pdblImg = sdblLn2 + dlogs(dblAbsReal);
- }
- }
- else if(dblAbsImg < dblLinf)
- {
- _pdblReal = dsqrts(dblAbsImg);
- _pdblImg = _pdblReal;
- }
- else if((dblEpsm * dblAbsImg - 1 >= dblAbsReal))
- {
- _pdblReal = sdblPi_2;
- _pdblImg = sdblLn2 + dlogs(dblAbsImg);
- }
- else if(dblAbsReal > 1)
- {
- _pdblReal = datans(dblAbsImg / dblAbsReal);
- dblTemp = (dblAbsReal / dblAbsImg)*(dblAbsReal / dblAbsImg);
- _pdblImg = sdblLn2 + dlogs(dblAbsImg) + 0.5 * dlog1ps(dblTemp);
- }
- else
- {
- double dblTemp2 = dsqrts(1 + dblAbsImg*dblAbsImg);
- _pdblReal = sdblPi_2;
- dblTemp = 2 * dblAbsImg * (dblAbsImg + dblTemp2);
- _pdblImg = 0.5 * dlog1ps(dblTemp);
- }
- }
- if(dblSignReal < 0)
- _pdblReal = sdblPi - _pdblReal;
-
- if(dblAbsImg != 0 || dblSignReal < 0)
- _pdblImg = - dblSignImg * _pdblImg;
-
- return DoubleComplex(_pdblReal, _pdblImg);
-}
+/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2007-2008 - INRIA - Bruno JOFRET + * Copyright (C) Bruno Pincon + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + +/* + * This fonction is a translation of fortran wacos write by Bruno Pincon <Bruno.Pincon@iecn.u-nancy.fr> + * REFERENCE + * This is a Fortran-77 translation of an algorithm by + * T.E. Hull, T. F. Fairgrieve and P.T.P. Tang which + * appears in their article : + * "Implementing the Complex Arcsine and Arccosine + * Functions Using Exception Handling", ACM, TOMS, + * Vol 23, No. 3, Sept 1997, p. 299-335 + */ + +#include "acos.h" +#include "atan.h" +#include "log.h" +#include "log1p.h" +#include "sqrt.h" +#include "abs.h" +#include "lapack.h" +#include "min.h" +#include "max.h" + +#define localSign(x) (x>0 ? 1 : -1) + +doubleComplex zacoss(doubleComplex z) { + static double sdblPi = 3.1415926535897932384626433; + static double sdblPi_2 = 1.5707963267948966192313216; + static double sdblLn2 = 0.6931471805599453094172321; + static double sdblAcross = 1.5; + static double sdblBcross = 0.6417; + + double dblLsup = dsqrts(getOverflowThreshold())/8.0; + double dblLinf = 4.0 * dsqrts(getUnderflowThreshold()); + double dblEpsm = dsqrts(getRelativeMachinePrecision()); + + double dblAbsReal = dabss(zreals(z)); + double dblAbsImg = dabss(zimags(z)); + double dblSignReal = localSign(zreals(z)); + double dblSignImg = localSign(zimags(z)); + + double dblR = 0, dblS = 0, dblA = 0, dblB = 0; + + double dblTemp = 0; + + double _pdblReal = 0; + double _pdblImg = 0; + + if( min(dblAbsReal, dblAbsImg) > dblLinf && max(dblAbsReal, dblAbsImg) <= dblLsup) + {/* we are in the safe region */ + dblR = dsqrts( (dblAbsReal + 1 )*(dblAbsReal + 1 ) + dblAbsImg*dblAbsImg); + dblS = dsqrts( (dblAbsReal - 1 )*(dblAbsReal - 1 ) + dblAbsImg*dblAbsImg); + dblA = 0.5 * ( dblR + dblS ); + dblB = dblAbsReal / dblA; + + + /* compute the real part */ + if(dblB <= sdblBcross) + _pdblReal = dacoss(dblB); + else if( dblAbsReal <= 1) + _pdblReal = datans(dsqrts(0.5 * (dblA + dblAbsReal) * (dblAbsImg*dblAbsImg / (dblR + (dblAbsReal + 1)) + (dblS + (1 - dblAbsReal)))) / dblAbsReal); + else + _pdblReal = datans((dblAbsImg * dsqrts(0.5 * ((dblA + dblAbsReal) / (dblR + (dblAbsReal + 1)) + (dblA + dblAbsReal) / (dblS + (dblAbsReal - 1))))) / dblAbsReal); + + /* compute the imaginary part */ + if(dblA <= sdblAcross) + { + double dblImg1 = 0; + + if(dblAbsReal < 1) + /* Am1 = 0.5d0*((y**2)/(R+(x+1.d0))+(y**2)/(S+(1.d0-x))) */ + dblImg1 = 0.5 * (dblAbsImg*dblAbsImg / (dblR + (dblAbsReal + 1)) + dblAbsImg*dblAbsImg / (dblS + (1 - dblAbsReal))); + else + /* Am1 = 0.5d0*((y**2)/(R+(x+1.d0))+(S+(x-1.d0))) */ + dblImg1 = 0.5 * (dblAbsImg*dblAbsImg / (dblR + (dblAbsReal + 1)) + (dblS + (dblAbsReal - 1))); + /* ai = logp1(Am1 + sqrt(Am1*(A+1.d0))) */ + dblTemp = dblImg1 + dsqrts(dblImg1 *( dblA + 1)); + _pdblImg = dlog1ps(dblTemp); + } + else + /* ai = log(A + sqrt(A**2 - 1.d0)) */ + _pdblImg = dlogs(dblA + dsqrts(dblA*dblA - 1)); + } + else + {/* evaluation in the special regions ... */ + if(dblAbsImg <= dblEpsm * dabss(dblAbsReal - 1)) + { + if(dblAbsReal < 1) + { + _pdblReal = dacoss(dblAbsReal); + _pdblImg = dblAbsImg / dsqrts((1 + dblAbsReal) * (1 - dblAbsReal)); + } + else + { + _pdblReal = 0; + if(dblAbsReal <= dblLsup) + { + dblTemp = (dblAbsReal - 1) + dsqrts((dblAbsReal - 1) * (dblAbsReal + 1)); + _pdblImg = dlog1ps(dblTemp); + } + else + _pdblImg = sdblLn2 + dlogs(dblAbsReal); + } + } + else if(dblAbsImg < dblLinf) + { + _pdblReal = dsqrts(dblAbsImg); + _pdblImg = _pdblReal; + } + else if((dblEpsm * dblAbsImg - 1 >= dblAbsReal)) + { + _pdblReal = sdblPi_2; + _pdblImg = sdblLn2 + dlogs(dblAbsImg); + } + else if(dblAbsReal > 1) + { + _pdblReal = datans(dblAbsImg / dblAbsReal); + dblTemp = (dblAbsReal / dblAbsImg)*(dblAbsReal / dblAbsImg); + _pdblImg = sdblLn2 + dlogs(dblAbsImg) + 0.5 * dlog1ps(dblTemp); + } + else + { + double dblTemp2 = dsqrts(1 + dblAbsImg*dblAbsImg); + _pdblReal = sdblPi_2; + dblTemp = 2 * dblAbsImg * (dblAbsImg + dblTemp2); + _pdblImg = 0.5 * dlog1ps(dblTemp); + } + } + if(dblSignReal < 0) + _pdblReal = sdblPi - _pdblReal; + + if(dblAbsImg != 0 || dblSignReal < 0) + _pdblImg = - dblSignImg * _pdblImg; + + return DoubleComplex(_pdblReal, _pdblImg); +} diff --git a/src/c/elementaryFunctions/acosd/cacoss.c b/src/c/elementaryFunctions/acosd/cacoss.c index 97420313..6e12ed8a 100644 --- a/src/c/elementaryFunctions/acosd/cacoss.c +++ b/src/c/elementaryFunctions/acosd/cacoss.c @@ -1,147 +1,147 @@ -/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2007-2008 - INRIA - Bruno JOFRET
- * Copyright (C) Bruno Pincon
- *
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
-
-/*
- * This fonction is a translation of fortran wacos write by Bruno Pincon <Bruno.Pincon@iecn.u-nancy.fr>
- * REFERENCE
- * This is a Fortran-77 translation of an algorithm by
- * T.E. Hull, T. F. Fairgrieve and P.T.P. Tang which
- * appears in their article :
- * "Implementing the Complex Arcsine and Arccosine
- * Functions Using Exception Handling", ACM, TOMS,
- * Vol 23, No. 3, Sept 1997, p. 299-335
- */
-
-#include "acos.h"
-#include "atan.h"
-#include "log.h"
-#include "log1p.h"
-#include "sqrt.h"
-#include "abs.h"
-#include "lapack.h"
-#include "min.h"
-#include "max.h"
-
-#define localSign(x) (x>0 ? 1.0f : -1.0f)
-
-floatComplex cacoss(floatComplex z) {
- static float sfltPi = 3.1415926535897932384626433f;
- static float sfltPi_2 = 1.5707963267948966192313216f;
- static float sfltLn2 = 0.6931471805599453094172321f;
- static float sfltAcross = 1.5f;
- static float sfltBcross = 0.6417f;
-
- float fltLsup = ssqrts((float) getOverflowThreshold())/8.0f;
- float fltLinf = 4.0f * ssqrts((float) getUnderflowThreshold());
- float fltEpsm = ssqrts((float) getRelativeMachinePrecision());
-
- float fltAbsReal = sabss(creals(z));
- float fltAbsImg = sabss(cimags(z));
- float fltSignReal = localSign(creals(z));
- float fltSignImg = localSign(cimags(z));
-
- float fltR = 0, fltS = 0, fltA = 0, fltB = 0;
-
- float fltTemp = 0;
-
- float _pfltReal = 0;
- float _pfltImg = 0;
-
- if( min(fltAbsReal, fltAbsImg) > fltLinf && max(fltAbsReal, fltAbsImg) <= fltLsup)
- {/* we are in the safe region */
- fltR = ssqrts( (fltAbsReal + 1 )*(fltAbsReal + 1 ) + fltAbsImg*fltAbsImg);
- fltS = ssqrts( (fltAbsReal - 1 )*(fltAbsReal - 1 ) + fltAbsImg*fltAbsImg);
- fltA = 0.5f * ( fltR + fltS );
- fltB = fltAbsReal / fltA;
-
-
- /* compute the real part */
- if(fltB <= sfltBcross)
- _pfltReal = sacoss(fltB);
- else if( fltAbsReal <= 1)
- _pfltReal = satans(ssqrts(0.5f * (fltA + fltAbsReal) * (fltAbsImg*fltAbsImg / (fltR + (fltAbsReal + 1)) + (fltS + (1 - fltAbsReal)))) / fltAbsReal);
- else
- _pfltReal = satans((fltAbsImg * ssqrts(0.5f * ((fltA + fltAbsReal) / (fltR + (fltAbsReal + 1)) + (fltA + fltAbsReal) / (fltS + (fltAbsReal - 1))))) / fltAbsReal);
-
- /* compute the imaginary part */
- if(fltA <= sfltAcross)
- {
- float fltImg1 = 0;
-
- if(fltAbsReal < 1)
- /* Am1 = 0.5d0*((y**2)/(R+(x+1.d0))+(y**2)/(S+(1.d0-x))) */
- fltImg1 = 0.5f * (fltAbsImg*fltAbsImg / (fltR + (fltAbsReal + 1)) + fltAbsImg*fltAbsImg / (fltS + (1 - fltAbsReal)));
- else
- /* Am1 = 0.5d0*((y**2)/(R+(x+1.d0))+(S+(x-1.d0))) */
- fltImg1 = 0.5f * (fltAbsImg*fltAbsImg / (fltR + (fltAbsReal + 1)) + (fltS + (fltAbsReal - 1)));
- /* ai = logp1(Am1 + sqrt(Am1*(A+1.d0))) */
- fltTemp = fltImg1 + ssqrts(fltImg1 *( fltA + 1));
- _pfltImg = slog1ps(fltTemp);
- }
- else
- /* ai = log(A + sqrt(A**2 - 1.d0)) */
- _pfltImg = slogs(fltA + ssqrts(fltA*fltA - 1));
- }
- else
- {/* evaluation in the special regions ... */
- if(fltAbsImg <= fltEpsm * sabss(fltAbsReal - 1))
- {
- if(fltAbsReal < 1)
- {
- _pfltReal = sacoss(fltAbsReal);
- _pfltImg = fltAbsImg / ssqrts((1 + fltAbsReal) * (1 - fltAbsReal));
- }
- else
- {
- _pfltReal = 0;
- if(fltAbsReal <= fltLsup)
- {
- fltTemp = (fltAbsReal - 1) + ssqrts((fltAbsReal - 1) * (fltAbsReal + 1));
- _pfltImg = slog1ps(fltTemp);
- }
- else
- _pfltImg = sfltLn2 + slogs(fltAbsReal);
- }
- }
- else if(fltAbsImg < fltLinf)
- {
- _pfltReal = ssqrts(fltAbsImg);
- _pfltImg = _pfltReal;
- }
- else if((fltEpsm * fltAbsImg - 1 >= fltAbsReal))
- {
- _pfltReal = sfltPi_2;
- _pfltImg = sfltLn2 + slogs(fltAbsImg);
- }
- else if(fltAbsReal > 1)
- {
- _pfltReal = satans(fltAbsImg / fltAbsReal);
- fltTemp = (fltAbsReal / fltAbsImg)*(fltAbsReal / fltAbsImg);
- _pfltImg = sfltLn2 + slogs(fltAbsImg) + 0.5f * slog1ps(fltTemp);
- }
- else
- {
- float fltTemp2 = ssqrts(1 + fltAbsImg*fltAbsImg);
- _pfltReal = sfltPi_2;
- fltTemp = 2 * fltAbsImg * (fltAbsImg + fltTemp2);
- _pfltImg = 0.5f * slog1ps(fltTemp);
- }
- }
- if(fltSignReal < 0)
- _pfltReal = sfltPi - _pfltReal;
-
- if(fltAbsImg != 0 || fltSignReal < 0)
- _pfltImg = - fltSignImg * _pfltImg;
-
- return FloatComplex(_pfltReal, _pfltImg);
-}
+/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2007-2008 - INRIA - Bruno JOFRET + * Copyright (C) Bruno Pincon + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + +/* + * This fonction is a translation of fortran wacos write by Bruno Pincon <Bruno.Pincon@iecn.u-nancy.fr> + * REFERENCE + * This is a Fortran-77 translation of an algorithm by + * T.E. Hull, T. F. Fairgrieve and P.T.P. Tang which + * appears in their article : + * "Implementing the Complex Arcsine and Arccosine + * Functions Using Exception Handling", ACM, TOMS, + * Vol 23, No. 3, Sept 1997, p. 299-335 + */ + +#include "acos.h" +#include "atan.h" +#include "log.h" +#include "log1p.h" +#include "sqrt.h" +#include "abs.h" +#include "lapack.h" +#include "min.h" +#include "max.h" + +#define localSign(x) (x>0 ? 1.0f : -1.0f) + +floatComplex cacoss(floatComplex z) { + static float sfltPi = 3.1415926535897932384626433f; + static float sfltPi_2 = 1.5707963267948966192313216f; + static float sfltLn2 = 0.6931471805599453094172321f; + static float sfltAcross = 1.5f; + static float sfltBcross = 0.6417f; + + float fltLsup = ssqrts((float) getOverflowThreshold())/8.0f; + float fltLinf = 4.0f * ssqrts((float) getUnderflowThreshold()); + float fltEpsm = ssqrts((float) getRelativeMachinePrecision()); + + float fltAbsReal = sabss(creals(z)); + float fltAbsImg = sabss(cimags(z)); + float fltSignReal = localSign(creals(z)); + float fltSignImg = localSign(cimags(z)); + + float fltR = 0, fltS = 0, fltA = 0, fltB = 0; + + float fltTemp = 0; + + float _pfltReal = 0; + float _pfltImg = 0; + + if( min(fltAbsReal, fltAbsImg) > fltLinf && max(fltAbsReal, fltAbsImg) <= fltLsup) + {/* we are in the safe region */ + fltR = ssqrts( (fltAbsReal + 1 )*(fltAbsReal + 1 ) + fltAbsImg*fltAbsImg); + fltS = ssqrts( (fltAbsReal - 1 )*(fltAbsReal - 1 ) + fltAbsImg*fltAbsImg); + fltA = 0.5f * ( fltR + fltS ); + fltB = fltAbsReal / fltA; + + + /* compute the real part */ + if(fltB <= sfltBcross) + _pfltReal = sacoss(fltB); + else if( fltAbsReal <= 1) + _pfltReal = satans(ssqrts(0.5f * (fltA + fltAbsReal) * (fltAbsImg*fltAbsImg / (fltR + (fltAbsReal + 1)) + (fltS + (1 - fltAbsReal)))) / fltAbsReal); + else + _pfltReal = satans((fltAbsImg * ssqrts(0.5f * ((fltA + fltAbsReal) / (fltR + (fltAbsReal + 1)) + (fltA + fltAbsReal) / (fltS + (fltAbsReal - 1))))) / fltAbsReal); + + /* compute the imaginary part */ + if(fltA <= sfltAcross) + { + float fltImg1 = 0; + + if(fltAbsReal < 1) + /* Am1 = 0.5d0*((y**2)/(R+(x+1.d0))+(y**2)/(S+(1.d0-x))) */ + fltImg1 = 0.5f * (fltAbsImg*fltAbsImg / (fltR + (fltAbsReal + 1)) + fltAbsImg*fltAbsImg / (fltS + (1 - fltAbsReal))); + else + /* Am1 = 0.5d0*((y**2)/(R+(x+1.d0))+(S+(x-1.d0))) */ + fltImg1 = 0.5f * (fltAbsImg*fltAbsImg / (fltR + (fltAbsReal + 1)) + (fltS + (fltAbsReal - 1))); + /* ai = logp1(Am1 + sqrt(Am1*(A+1.d0))) */ + fltTemp = fltImg1 + ssqrts(fltImg1 *( fltA + 1)); + _pfltImg = slog1ps(fltTemp); + } + else + /* ai = log(A + sqrt(A**2 - 1.d0)) */ + _pfltImg = slogs(fltA + ssqrts(fltA*fltA - 1)); + } + else + {/* evaluation in the special regions ... */ + if(fltAbsImg <= fltEpsm * sabss(fltAbsReal - 1)) + { + if(fltAbsReal < 1) + { + _pfltReal = sacoss(fltAbsReal); + _pfltImg = fltAbsImg / ssqrts((1 + fltAbsReal) * (1 - fltAbsReal)); + } + else + { + _pfltReal = 0; + if(fltAbsReal <= fltLsup) + { + fltTemp = (fltAbsReal - 1) + ssqrts((fltAbsReal - 1) * (fltAbsReal + 1)); + _pfltImg = slog1ps(fltTemp); + } + else + _pfltImg = sfltLn2 + slogs(fltAbsReal); + } + } + else if(fltAbsImg < fltLinf) + { + _pfltReal = ssqrts(fltAbsImg); + _pfltImg = _pfltReal; + } + else if((fltEpsm * fltAbsImg - 1 >= fltAbsReal)) + { + _pfltReal = sfltPi_2; + _pfltImg = sfltLn2 + slogs(fltAbsImg); + } + else if(fltAbsReal > 1) + { + _pfltReal = satans(fltAbsImg / fltAbsReal); + fltTemp = (fltAbsReal / fltAbsImg)*(fltAbsReal / fltAbsImg); + _pfltImg = sfltLn2 + slogs(fltAbsImg) + 0.5f * slog1ps(fltTemp); + } + else + { + float fltTemp2 = ssqrts(1 + fltAbsImg*fltAbsImg); + _pfltReal = sfltPi_2; + fltTemp = 2 * fltAbsImg * (fltAbsImg + fltTemp2); + _pfltImg = 0.5f * slog1ps(fltTemp); + } + } + if(fltSignReal < 0) + _pfltReal = sfltPi - _pfltReal; + + if(fltAbsImg != 0 || fltSignReal < 0) + _pfltImg = - fltSignImg * _pfltImg; + + return FloatComplex(_pfltReal, _pfltImg); +} diff --git a/src/c/elementaryFunctions/acosh/dacoshs.c b/src/c/elementaryFunctions/acosh/dacoshs.c index a5c13c8b..78825eab 100644 --- a/src/c/elementaryFunctions/acosh/dacoshs.c +++ b/src/c/elementaryFunctions/acosh/dacoshs.c @@ -14,10 +14,10 @@ #include "acosh.h" #ifdef _MSC_VER -double acosh(double x)
-{
- return log(x + sqrt(x * x - 1));
-}
+double acosh(double x) +{ + return log(x + sqrt(x * x - 1)); +} #endif double dacoshs(double x) { diff --git a/src/c/elementaryFunctions/acosh/sacoshs.c b/src/c/elementaryFunctions/acosh/sacoshs.c index d2a9ae53..875897d1 100644 --- a/src/c/elementaryFunctions/acosh/sacoshs.c +++ b/src/c/elementaryFunctions/acosh/sacoshs.c @@ -14,11 +14,11 @@ #include "acosh.h" #ifdef _MSC_VER -float acoshf (float x)
-{
- return (float) log(x + sqrt(x * x - 1));
-}
-#endif
+float acoshf (float x) +{ + return (float) log(x + sqrt(x * x - 1)); +} +#endif float sacoshs(float x) { return (acoshf(x)); diff --git a/src/c/elementaryFunctions/acosh/testDoubleAcosh.c b/src/c/elementaryFunctions/acosh/testDoubleAcosh.c index 60a041db..d9cdf3ee 100644 --- a/src/c/elementaryFunctions/acosh/testDoubleAcosh.c +++ b/src/c/elementaryFunctions/acosh/testDoubleAcosh.c @@ -14,9 +14,9 @@ #include "isnan.h" #include "testAcosh.h" -#ifdef _MSC_VER
-#include <float.h>
-#define isnan(x) _isnan((double)x)
+#ifdef _MSC_VER +#include <float.h> +#define isnan(x) _isnan((double)x) #endif diff --git a/src/c/elementaryFunctions/acosh/testFloatAcosh.c b/src/c/elementaryFunctions/acosh/testFloatAcosh.c index aa14a308..67627792 100644 --- a/src/c/elementaryFunctions/acosh/testFloatAcosh.c +++ b/src/c/elementaryFunctions/acosh/testFloatAcosh.c @@ -1,510 +1,510 @@ -/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2006-2008 - INRIA - Bruno JOFRET
- *
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
-
-#include "testAcosh.h"
-#include "isnan.h"
-
-#ifdef _MSC_VER
-#include <float.h>
-#define isnan(x) _isnan((double)x)
-#endif
-
-#define IN {38.746443623676896095276f,39.8779044859111309052f,99.6399083640426397324f,\
-93.207842670381069183350f,6.8147667217999696731567f,71.874653641134500503540f,\
-65.928971720859408378601f,43.781969323754310607910f,95.70061699487268924713f,\
-39.777786191552877426147f,54.149620747193694114685f,14.754852838814258575439f,\
-91.972588421776890754700f,41.853474546223878860474f,90.448315022513270378113f,\
-32.027477025985717773438f,57.482325518503785133362f,75.726259034126996994019f,\
-32.547289272770285606384f,50.125551037490367889404f,26.862081931903958320618f,\
-11.706684622913599014282f,36.675705714151263237000f,87.538864836096763610840f,\
-52.483216533437371253967f,76.861125137656927108765f,82.899243896827101707458f,\
-64.99033216387033462524f,56.250627012923359870911f,21.698794979602098464966f,\
-93.22312804870307445526f,93.5097210109233856201f,97.608120972290635108948f,\
-91.35094834491610527039f,26.843591919168829917908f,9.1870715841650962829590f,\
-17.129724519327282905579f,73.117265943437814712524f,86.922781122848391532898f,\
-1.4808017760515213012695f,65.071928361430764198303f,42.254429217427968978882f,\
-23.262092983350157737732f,31.955500133335590362549f,74.261871399357914924622f,\
-77.881882060319185256958f,65.248953877016901969910f,90.324406325817108154297f,\
-86.69646182097494602203f,70.879780035465955734253f,69.452034076675772666931f,\
-84.671579115092754364014f,93.227435695007443428040f,95.654127094894647598267f,\
-16.239900095388293266296f,12.728751823306083679199f,95.707353064790368080139f,\
-67.644099798053503036499f,39.798104530200362205505f,11.081875301897525787354f,\
-50.97153154201805591583f,58.446559030562639236450f,25.919713405892252922058f,\
-29.182348400354385375977f,6.0309174004942178726196f,90.43274922296404838562f,\
-61.944271018728613853455f,25.037935934960842132568f,83.850894169881939888000f,\
-82.732185069471597671509f,73.220202280208468437195f,29.458374157547950744629f,\
-29.091028729453682899475f,70.458725746721029281616f,30.465652560815215110779f,\
-75.730663724243640899658f,73.18075490184128284454f,69.053836632519960403442f,\
-62.402765033766627311707f,41.599050164222717285156f,28.105994546785950660706f,\
-5.6220385245978832244873f,58.040395518764853477478f,0.4246918484568595886230f,\
-68.2817161548882722855f,89.133544359356164932251f,92.980264825746417045593f,\
-28.40001545846462249756f,9.885430941358208656311f,41.369083430618047714233f,\
-64.121548598632216453552f,64.692758955061435699463f,47.02662643976509571075f,\
-60.481913108378648757935f,67.138904659077525138855f,71.394702047109603881836f,\
-54.127137595787644386292f,39.052018057554960250854f,1.1089378502219915390015f,\
-90.150084160268306732178f,13.887455360963940620422f,8.5074969567358493804932f,\
-34.66010238043963909149f,42.338709905743598937988f,80.213972786441445351f,\
-31.7881367169320583344f,18.021041667088866233826f,69.688742049038410186768f,\
-35.482168616726994514465f,16.12617420032620429993f,75.34236568026244640350f,\
-62.194181978702545166016f,51.510728383436799049377f,67.819245439022779464722f,\
-61.666865786537528038025f,70.212037675082683563232f,13.621602999046444892883f,\
-60.870522353798151016235f,18.923167092725634574890f,47.614179179072380065918f,\
-17.161004850640892982483f,41.371036972850561141968f,15.31781828962266445160f,\
-22.868881560862064361572f,95.856341393664479255676f,39.499193150550127029419f,\
-2.500818995758891106f,44.927055388689041137695f,91.384086245670914649963f,\
-11.012465786188840866089f,74.87958460114896297455f,0.7881646975874900817871f,\
-23.523587780073285102844f,80.106287542730569839478f,65.456348611041903495789f,\
-51.620832458138465881348f,70.271815219894051551819f,5.5151230655610561370850f,\
-62.56400248967111110687f,84.313133545219898223877f,17.294042231515049934387f,\
-41.730730701237916946411f,81.875373004004359245300f,25.327575206756591796875f,\
-86.085468018427491188049f,17.212611716240644454956f,78.060937067493796348572f,\
-13.735765032470226287842f,0.2187759149819612503052f,1.4656470157206058502197f,\
-30.469974083825945854187f,80.307766422629356384277f,99.052629480138421058655f,\
-82.85992136225104331970f,87.21015579067170619965f,29.531141556799411773682f,\
-58.27610609121620655060f,29.06773509457707405090f,2.0005736034363508224f,\
-71.4346818625926971436f,26.664068037644028663635f,51.992803346365690231323f,\
-48.17320345900952816010f,0.0918259844183921813965f,38.418471114709973335266f,\
-49.06664276495575904846f,44.197808159515261650085f,65.678765252232551574707f,\
-10.470610717311501502991f,42.787145730108022689819f,75.105277216061949729919f,\
-36.962236650288105010986f,84.119305433705449104309f,90.374342072755098342896f,\
-44.184404192492365837097f,1.0920032858848571777344f,20.380018139258027076721f,\
-85.418348293751478195190f,39.327101549133658409119f,97.573022358119487762451f,\
-8.4199145901948213577271f,23.39450428262352943420f,48.397052986547350883484f,\
-33.292300626635551452637f,96.453859517350792884827f,52.920697536319494247437f,\
-7.9968032892793416976929f,75.475437380373477935791f,4.476350219920277596f,\
-84.631874877959489822388f,20.008285669609904289246f,69.44785490632057189941f,\
-28.204387659206986427307f,79.546741675585508346558f,20.281786611303687095642f,\
-78.075716458261013031006f,93.606285052374005317688f,88.801648560911417007446f,\
-33.848348213359713554382f,89.761531725525856018066f}
-
-#define RESULT {4.3500195892822599574856f,4.378812333443298676627f,5.2946847693089331698957f,\
-5.2279502699832844925254f,2.6068118507181217147206f,4.968022463585481496295f,\
-4.8816676362403299549442f,4.4722388068202851840738f,5.2543446283333992141706f,\
-4.3762977630646631155287f,4.6848128785767624293612f,3.3835688928264802122214f,\
-5.2146082054939908445590f,4.4271792498758397726988f,5.1978952030053422461719f,\
-4.159497560939560578674f,4.7445490293632399669832f,5.0202285648475850621253f,\
-4.1756051841813626168687f,4.6075785448582253778227f,3.9835162329116351465075f,\
-3.1514779837977200394050f,4.2950758361772223281605f,5.165197419194649697261f,\
-4.653549840642725143880f,5.035105083560019956224f,5.1107367420045859418565f,\
-4.8673265089936572636020f,4.7228853485288873059744f,3.7698725167565876326137f,\
-5.2281142583800894740875f,5.2311839874435639430317f,5.2740816359097371091025f,\
-5.2078258853539018957690f,3.982827186610214287299f,2.9079691610609703644741f,\
-3.5331093207527803912171f,4.9851649496034715625115f,5.1581342419725935144470f,\
-0.9450506373811344840163f,4.8685813827251553931319f,4.4367163112396088564537f,\
-3.8395099847061766595857f,4.1572465837028591550961f,5.0006994941965512424531f,\
-5.0482993082581542054754f,4.8712984679982609392823f,5.1965242406243383754827f,\
-5.1555269912574592794385f,4.954082618091184997411f,4.9337317049920867972901f,\
-5.1318923054243690273779f,5.228160467885317963521f,5.2538586990129676479455f,\
-3.4796690893012534040452f,3.2354639460120244720542f,5.2544150166005954005755f,\
-4.9073526741507107473694f,4.3768085901327413722584f,3.0964161555968114925008f,\
-4.6243182142058252281913f,4.7611868033967539304285f,3.9477786701409951497510f,\
-4.0664175090632737052943f,2.4831009250018341028010f,5.1977230816033159754852f,\
-4.8193171469932529760172f,3.9131402651137854320496f,5.1221517738388655516246f,\
-5.1087193584020944570057f,4.98657191625376672306f,4.0758371911626332106948f,\
-4.0632814774108050315249f,4.9481239065017428302440f,4.1094776238806378643176f,\
-5.0202867341820684998766f,4.9860329708595516606806f,4.9279811897230469952547f,\
-4.8266925606060153697285f,4.421080015153528108840f,4.0288134359166507536543f,\
-2.4118364183807097234080f,4.7542122019999739634954f,0,\
-4.9167355873994562642793f,5.1832514554357551617159f,5.2255055264178071894321f,\
-4.0392267678246307482937f,2.9816410740582028893186f,4.4155348942144980739499f,\
-4.8538668500531736427206f,4.8627367182462748473881f,4.5437480774189333843083f,\
-4.7954231948046981415246f,4.8998553915953095838631f,4.9613217960209823331752f,\
-4.6843975172654603866818f,4.3578777660333960497496f,0.4626347638559775710121f,\
-5.1945923008314265345575f,3.3228343258666956927527f,2.830622803369744922009f,\
-4.238528249750794785200f,4.438709481897562980635f,5.077806047884725337838f,\
-4.1519928438683244564800f,3.5839165427001460351164f,4.9371344840241793150426f,\
-4.2619788264190443527468f,3.4726281293145686568380f,5.0151457380383783757338f,\
-4.8233440014012511909414f,4.6348430510092004652734f,4.9099388325030934865367f,\
-4.81482819845952114690f,4.9446162371720561168331f,3.3034540778469194677314f,\
-4.8018287252966844746993f,3.6328352359975357721567f,4.556167488561304601546f,\
-3.5349368514717505185274f,4.41558212917596915048f,3.4210967363570983224008f,\
-3.8224459155669441301484f,5.2559705982049909067655f,4.3692671498839636967659f,\
-1.5671566063449566819088f,4.4980634827120455909721f,5.2081885950679547292452f,\
-3.0901072205487807309510f,5.0089838747007107144782f,0,\
-3.850698741029123794988f,5.076462566530570263978f,4.8744723131002718474747f,\
-4.6369786693462113902342f,4.9454673471881154256380f,2.3923187222394570738970f,\
-4.8292733779221936885051f,5.127649658742538640865f,3.5426723072020398497273f,\
-4.424241396092424949416f,5.0983081346685077406278f,3.9246509637740216724922f,\
-5.1484540607983912963164f,3.537944651477085589164f,5.0505959169093319616195f,\
-3.3118225003889145696689f,0,0.9310418690232507010762f,\
-4.1096195393026562214800f,5.0789747485012091132717f,5.2887730188734272118722f,\
-5.1102622536361952398920f,5.1614350980940946200803f,4.0783057415377843568649f,\
-4.7582657239633334711471f,4.0624799671967695147146f,1.3172890037212539038336f,\
-4.9618816771260449982606f,3.9761122565887623281f,4.64415999832871140285f,\
-4.5678423566873336270078f,0,4.3415161209508754680542f,\
-4.5862227542495350718355f,4.481694375737592217490f,4.8778648861550966131517f,\
-3.0394313734202933474648f,4.4492483198356360674097f,5.0119936831694982259933f,\
-4.3028609023006350042806f,5.1253479422290126876760f,5.1970769705972195140475f,\
-4.4813909798397162376205f,0.4257373352329655857851f,3.7070996451820255046528f,\
-5.1406738437618608728030f,4.3648993866947414232982f,5.2737219653314042489001f,\
-2.820201721217977297584f,3.8451912168199942065883f,4.5724793527790357217100f,\
-4.1982477070823893683382f,5.2621850617105074832125f,4.661852422144622920541f,\
-2.7682565538529817494862f,5.0169105620070073570105f,2.1792385497944919414692f,\
-5.131423242241443638534f,3.6886685835548016498819f,4.9336715234659216378077f,\
-4.032310316197459165721f,5.0694524637856641646749f,3.7022621441401133424165f,\
-5.0507852459760567143121f,5.2322161767096924123166f,5.1795206909289932539764f,\
-4.2148191048546337356129f,5.19027265701442619417f}
-
-#define CRIN {0.1483933464623987674713f,0.5565875237807631492615f,0.4628333351574838161469f,\
-0.9158247429877519607544f,0.0444016349501907825470f,0.8175177471712231636047f,\
-0.5320580708794295787811f,0.2989391684532165527344f,0.5029047676362097263336f,\
-0.4266923693940043449402f,0.3965902938507497310638f,0.7440190296620130538940f,\
-0.7921002809889614582062f,0.5715918401256203651428f,0.4155966262333095073700f,\
-0.2953372262418270111084f,0.1075767637230455875397f,0.7572548976168036460876f,\
-0.93660886352881789207f,0.7694978956133127212524f,0.0902581927366554737091f,\
-0.4731486858800053596497f,0.4765542480163276195526f,0.6361737176775932312012f,\
-0.5064576440490782260895f,0.9049607468768954277039f,0.6742701171897351741791f,\
-0.3656400945037603378296f,0.6837903787381947040558f,0.4100628877058625221252f,\
-0.3582529271952807903290f,0.7118562050163745880127f,0.7966963038779795169830f,\
-0.9753969227895140647888f,0.5733916512690484523773f,0.8998429346829652786255f,\
-0.5953218084760010242462f,0.3765322910621762275696f,0.9104355531744658946991f,\
-0.1861076802015304565430f,0.6715109744109213352203f,0.2566455481573939323425f,\
-0.9819463356398046016693f,0.7608660291880369186401f,0.8556561623699963092804f,\
-0.8441717335954308509827f,0.3884846637956798076630f,0.4608103148639202117920f,\
-0.8381579727865755558014f,0.5278776129707694053650f,0.0187810636125504970551f,\
-0.2611750457435846328735f,0.6092445817776024341583f,0.0081067951396107673645f,\
-0.0276411953382194042206f,0.0158492103219032287598f,0.8109004520811140537262f,\
-0.2429467244073748588562f,0.3353355019353330135345f,0.4142854567617177963257f,\
-0.5946544189937412738800f,0.9080675477162003517151f,0.992223232518881559372f,\
-0.6239561475813388824463f,0.0789771513082087039948f,0.5889828568324446678162f,\
-0.2523608407936990261078f,0.5871062893420457839966f,0.0000379872508347034454f,\
-0.4244823055341839790344f,0.69984475849196314812f,0.4405533373355865478516f,\
-0.6495711454190313816071f,0.4199861017987132072449f,0.2716385438106954097748f,\
-0.0272838752716779708862f,0.6936013107188045978546f,0.1495713749900460243f,\
-0.5206344048492610454559f,0.9685971699655055999756f,0.9657785953022539615631f,\
-0.0654204180464148521423f,0.9626990980468690395355f,0.2655456010252237319946f,\
-0.8290728745050728321075f,0.1334408046677708625793f,0.8514542016200721263885f,\
-0.8984219655394554138184f,0.1995774977840483188629f,0.0138073815032839775085f,\
-0.2245407640002667903900f,0.3930436577647924423218f,0.8261723746545612812042f,\
-0.5051761353388428688049f,0.5651183272711932659149f,0.822583723813295364380f,\
-0.9197964356280863285065f,0.4713199352845549583435f,0.9223483256064355373383f,\
-0.2136987913399934768677f,0.7260794681496918201447f,0.9689361499622464179993f,\
-0.8346118587069213390350f,0.8257038742303848266602f,0.1350833275355398654938f,\
-0.7953761396929621696472f,0.8992118402384221553802f,0.2715440522879362106323f,\
-0.9219025229103863239288f,0.1750466236844658851624f,0.3323095212690532207489f,\
-0.9493130259215831756592f,0.7118741781450808048248f,0.8032329222187399864197f,\
-0.3628453887067735195160f,0.7530685458332300186157f,0.2641473677940666675568f,\
-0.9660940738394856452942f,0.8041944387368857860565f,0.5316947177052497863770f,\
-0.1673618280328810214996f,0.955579827539622783661f,0.6473058252595365047455f,\
-0.2645611818879842758179f,0.5411860425956547260284f,0.4980195099487900733948f,\
-0.0190768833272159099579f,0.4227291680872440338135f,0.8374647037126123905182f,\
-0.4151327675208449363708f,0.3497115275822579860687f,0.4844544250518083572388f,\
-0.3347255480475723743439f,0.2362121837213635444641f,0.0928130256943404674530f,\
-0.0737370252609252929688f,0.4197955676354467868805f,0.9802277712151408195496f,\
-0.8419611467979848384857f,0.6906680446118116378784f,0.2502765958197414875031f,\
-0.8266033390536904335022f,0.1875236849300563335419f,0.5023231171071529388428f,\
-0.8916302681900560855865f,0.8934147348627448081970f,0.1574523574672639369965f,\
-0.1629528645426034927368f,0.5226223585195839405060f,0.8417599620297551155090f,\
-0.5858130785636603832245f,0.1322202011942863464355f,0.8028764897026121616364f,\
-0.5250511718913912773132f,0.2528006075881421566010f,0.4602345135062932968140f,\
-0.996287219692021608353f,0.4019785309210419654846f,0.1399875725619494915009f,\
-0.5081327147781848907471f,0.9440425024367868900299f,0.9318959629163146018982f,\
-0.6445578685961663722992f,0.5729571748524904251099f,0.4810055238194763660431f,\
-0.6713787661865353584290f,0.0962744313292205333710f,0.8855805248022079467773f,\
-0.3892059125937521457672f,0.2907031057402491569519f,0.4209313853643834590912f,\
-0.9504273366183042526245f,0.482190326321870088577f,0.2289973804727196693420f,\
-0.2940405677072703838348f,0.6957426778972148895264f,0.9139824123121798038483f,\
-0.2068154653534293174744f,0.6285024262033402919769f,0.4031575415283441543579f,\
-0.3064021435566246509552f,0.3148818286135792732239f,0.7400112929753959178925f,\
-0.8853011503815650939941f,0.788494529668241739273f,0.8977585239335894584656f,\
-0.0339450328610837459564f,0.8802101369947195053101f,0.5418177028186619281769f,\
-0.9511840576305985450745f,0.5574890668503940105438f,0.1312845982611179351807f,\
-0.9453403786756098270416f,0.2518341308459639549255f,0.2607447705231606960297f,\
-0.1215410251170396804810f,0.9136986923404037952423f,0.9382542567327618598938f,\
-0.3105722474865615367889f,0.9309121072292327880859f}
-
-#define CIIN {0.5225624092854559421539f,0.7617142526432871818542f,0.3009174778126180171967f,\
-0.1853434126824140548706f,0.5148605112917721271515f,0.7257346073165535926819f,\
-0.7033738414756953716278f,0.5664369426667690277100f,0.7816161573864519596100f,\
-0.3330347230657935142517f,0.4017280167900025844574f,0.8503915611654520034790f,\
-0.41114101978018879890f,0.1586530329659581184387f,0.6542402538470923900604f,\
-0.9449902996420860290527f,0.400338994804769754410f,0.9679889930412173271179f,\
-0.32740902295336127281f,0.8933845367282629013062f,0.6218692888505756855011f,\
-0.0985169494524598121643f,0.7449700380675494670868f,0.3134250529110431671143f,\
-0.1409188793040812015533f,0.3239218806847929954529f,0.9958796552382409572601f,\
-0.2412899602204561233521f,0.4753343504853546619415f,0.9194070147350430488586f,\
-0.0450326460413634777069f,0.8481595069169998168945f,0.8928631045855581760406f,\
-0.1469233212992548942566f,0.4904643460176885128021f,0.9986877571791410446167f,\
-0.3392539476044476032257f,0.8790708789601922035217f,0.3107871781103312969208f,\
-0.1200211457908153533936f,0.0909670502878725528717f,0.5804221173748373985291f,\
-0.446611551102250814438f,0.3501139078289270401001f,0.7262432840652763843536f,\
-0.3650169344618916511536f,0.5597011330537497997284f,0.434090383350849151611f,\
-0.5082829319871962070465f,0.3487796885892748832703f,0.8136124997399747371674f,\
-0.337404197081923484802f,0.7742837746627628803253f,0.0156080657616257667542f,\
-0.0195691580884158611298f,0.0445443131029605865479f,0.4240885511972010135651f,\
-0.8158838218078017234802f,0.9913199446164071559906f,0.5120379645377397537231f,\
-0.1021917951293289661407f,0.7161553995683789253235f,0.4527317988686263561249f,\
-0.2445004582405090332031f,0.1668560453690588474274f,0.9187424210831522941589f,\
-0.3418669118545949459076f,0.4624818544834852218628f,0.0400874321348965167999f,\
-0.4700120547786355018616f,0.8552942494861781597137f,0.3308605216443538665771f,\
-0.0322206378914415836334f,0.9760772576555609703064f,0.0763854510150849819183f,\
-0.2165335658937692642212f,0.2348632332868874073029f,0.1446668924763798713684f,\
-0.5313451024703681468964f,0.4441541358828544616699f,0.5759493880905210971832f,\
-0.3719177199527621269226f,0.5167253850959241390228f,0.5186656024307012557983f,\
-0.6306529571302235126495f,0.0928382659330964088440f,0.5421750987879931926727f,\
-0.2833826132118701934814f,0.2819099412299692630768f,0.1141945635899901390076f,\
-0.7321730605326592922211f,0.9823690224438905715942f,0.8243003231473267078400f,\
-0.6485677706077694892883f,0.5304958778433501720428f,0.6958626955747604370117f,\
-0.6050392785109579563141f,0.2683336613699793815613f,0.5511700971983373165131f,\
-0.1174971889704465866089f,0.7958277617581188678741f,0.4983139941468834877014f,\
-0.9196587274782359600067f,0.1420703046023845672607f,0.389312467072159051895f,\
-0.2658497532829642295837f,0.9480321384035050868988f,0.2326095197349786758423f,\
-0.0139051643200218677521f,0.9270462663844227790833f,0.4878733339719474315643f,\
-0.0354842916131019592285f,0.6607114099897444248199f,0.0879401965066790580750f,\
-0.8046676008962094783783f,0.212315237149596214294f,0.9163186331279575824738f,\
-0.9393384093418717384338f,0.3174265320412814617157f,0.9574301876127719879150f,\
-0.7951935962773859500885f,0.3240787154063582420349f,0.0472964248619973659515f,\
-0.1696171183139085769653f,0.7654392314143478870392f,0.2554624872282147407532f,\
-0.1189010548405349254608f,0.7469239532947540283203f,0.0616608508862555027008f,\
-0.1056091515347361564636f,0.1581688239239156246185f,0.9732552450150251388550f,\
-0.8786917333491146564484f,0.1824825564399361610413f,0.9303942839615046977997f,\
-0.4655157290399074554443f,0.5399280847050249576569f,0.9143392136320471763611f,\
-0.0622840351425111293793f,0.6500507537275552749634f,0.2340233740396797657013f,\
-0.3603484155610203742981f,0.1917369994334876537323f,0.2371335849165916442871f,\
-0.4136920445598661899567f,0.2661342276260256767273f,0.3891090690158307552338f,\
-0.6622495856136083602905f,0.4503725995309650897980f,0.3829893553629517555237f,\
-0.1937121297232806682587f,0.9629272706806659698486f,0.6385000632144510746002f,\
-0.2695108866319060325623f,0.1092974594794213771820f,0.0598662365227937698364f,\
-0.1431378168053925037384f,0.2944079088047146797180f,0.9022735017351806163788f,\
-0.9111119657754898071289f,0.9847188093699514865875f,0.0592310009524226188660f,\
-0.5464080139063298702240f,0.5080275069922208786011f,0.6546461437828838825226f,\
-0.9597736010327935218811f,0.1577645908109843730927f,0.1818120293319225311279f,\
-0.4555030376650393009186f,0.1048952480778098106384f,0.7636235631071031093597f,\
-0.1893162522464990615845f,0.1596221593208611011505f,0.3115166993811726570129f,\
-0.2491372707299888134003f,0.0469047501683235168457f,0.0797643386758863925934f,\
-0.3945369226858019828796f,0.3254697113297879695892f,0.5811151321977376937866f,\
-0.1456566532142460346222f,0.4704219633713364601135f,0.8631705637089908123016f,\
-0.1648640967905521392822f,0.0801398889161646366119f,0.4932156866416335105896f,\
-0.4345335862599313259125f,0.1079503614455461502075f,0.2686753761954605579376f,\
-0.7417223947122693061829f,0.4086893904022872447968f,0.6706044673919677734375f,\
-0.4159612008370459079742f,0.4766113189980387687683f,0.4431825890205800533295f,\
-0.6688354592770338058472f,0.5834077899344265460968f,0.4861929873004555702209f,\
-0.715783319901674985886f,0.1403244398534297943115f}
-
-#define CRRESULT {0.5053397031743451783825f,0.7650083608446867078356f,0.3289296819323739295982f,\
-0.3563456766158749622342f,0.4948207655225617118688f,0.8169593462846268527855f,\
-0.7132198900639351579755f,0.5570137230416445373038f,0.7685376318852206178889f,\
-0.3559803193123551312560f,0.4189790595413633300659f,0.8813522345691391368661f,\
-0.5405451162482487470484f,0.1905551975849387180695f,0.6493731034151291048317f,\
-0.8578709195697519218626f,0.3922142862720902067863f,0.9642946930057294530059f,\
-0.5389615746319644795648f,0.9186094888728127960675f,0.5890418064066422765279f,\
-0.1113977102429560134267f,0.7345860770241963155769f,0.3799876579856086289411f,\
-0.1619970506356118999935f,0.51382943864194075001f,0.9605702232101991366875f,\
-0.2552214504374311077051f,0.5588288246069162967800f,0.8545155572742579863643f,\
-0.0482073009402987154304f,0.8701819105023789191478f,0.9267094766915666692597f,\
-0.3583874762657675017152f,0.5394241582016752190043f,1.0267057888096897677599f,\
-0.3962322220487046187110f,0.8200372580795054489045f,0.5035682683774097556650f,\
-0.1218215489911998739014f,0.1217295472085216101465f,0.5645974853924803360528f,\
-0.6787204142960019392916f,0.4641409785094591788912f,0.8320374579652175528466f,\
-0.5202648072575078996849f,0.5635084163999081185992f,0.4608376215542885900867f,\
-0.6521335567127740651117f,0.3901559225476997627702f,0.7433295520896158192770f,\
-0.3414853587252406064145f,0.7876437052847802267053f,0.0156079448330699189357f,\
-0.0195753850507095344957f,0.0445351746116087257588f,0.5619901990592348628439f,\
-0.7563216032216260042986f,0.8953230010983072029163f,0.5250759023565449989945f,\
-0.1262270783291525866332f,0.8463340938014771719367f,0.6903512283163251161966f,\
-0.3002023271844543317322f,0.1665929038330317135674f,0.8881085995755062523216f,\
-0.3450945758035259824936f,0.5168125326109850314893f,0.0400767031552608649081f,\
-0.4881659313644853837033f,0.8717577944100705078512f,0.3559191435167290418207f,\
-0.0423384874325624382951f,0.8962569818869624560520f,0.0792669980362326609402f,\
-0.2149514867261388406661f,0.3084002596083564862184f,0.1457610223920582370738f,\
-0.5638322964331675679617f,0.6681928703809085767773f,0.7715309042125101379739f,\
-0.3644939000586688848671f,0.7241095709372292743566f,0.5109856481565466790329f,\
-0.7492592023075983487246f,0.0935322123614654998836f,0.6873609600399674945947f,\
-0.4653574362777189166174f,0.2834338708350941926639f,0.1139584955905696417311f,\
-0.6886187601911135658384f,0.8966624572124947123442f,0.8901159605244814976288f,\
-0.6621780758434868685569f,0.5739364819547106977282f,0.7967040377802739881119f,\
-0.7702556784014074064970f,0.2963495189276508789966f,0.729639913718978516677f,\
-0.1199467917211827494572f,0.8369585267706058928638f,0.7130151705637984838049f,\
-0.9564173315765011063050f,0.2362741844905166255231f,0.3829952297292640861492f,\
-0.3854654409071321952140f,0.9956878617898979877410f,0.2388852521695121466916f,\
-0.0357548125472270175718f,0.8344528446849692748799f,0.4908081134490644426016f,\
-0.1072298401775326898155f,0.7292248632489435333781f,0.1444440063075330404896f,\
-0.7618560442692507983509f,0.3014073074948313002430f,0.8338433864005018181231f,\
-1.013809216729007589564f,0.4488437286282063176657f,0.9028988520348978363828f,\
-0.7342748763980897486192f,0.5492704923146081164020f,0.0619250478958671968233f,\
-0.1747947745500638971894f,0.7643392221916658346714f,0.2869233753851287982428f,\
-0.1186438529044472750540f,0.7261517086175122148717f,0.1110167797262640587697f,\
-0.1156665104854840142590f,0.1677179018762894047168f,0.9049771869312485117476f,\
-0.8140692858573190804350f,0.1865250841653489921601f,0.8328626043313867022277f,\
-0.4511026850510220786994f,0.5511713324178673101272f,1.0040394102716723168101f,\
-0.1134432764930088655131f,0.7136163206069113806862f,0.2389915016256592694699f,\
-0.5061510239067475991348f,0.1938531425179492451161f,0.267912781705172242663f,\
-0.594520593176991907214f,0.4421595740617755287971f,0.3838580911610497414799f,\
-0.6265966551277006857390f,0.4892019455111443759776f,0.5371648663643865395656f,\
-0.2336644699290637006150f,0.8580649693764487162539f,0.7447932141471096390006f,\
-0.30664577808112553070f,0.1126796888171682081703f,0.0673404850217956818526f,\
-0.3780061914448271664924f,0.3135468248495265064513f,0.8141814149801622768621f,\
-0.8656800272972641208113f,1.0330415543607425199468f,0.1517147576472806791426f,\
-0.6107832692276639052764f,0.5555300503019462432519f,0.6621194316643849164805f,\
-0.9359383537376269046604f,0.1578266511911156633197f,0.3288869400610432980336f,\
-0.4688911283964798393242f,0.1093517544178844447256f,0.7390278072154514710235f,\
-0.3915656081630794482784f,0.1803516698292359499156f,0.3140185989593758941751f,\
-0.2570435038916802361619f,0.0651252572213311814453f,0.1812803236410877871787f,\
-0.3918987512324060840108f,0.3907169202420177067658f,0.5847178774812699098007f,\
-0.1522469534945809221949f,0.4726351219523636792985f,0.8890284419930043480207f,\
-0.3043305148205690535690f,0.1282404489119809976039f,0.6689999411776240689775f,\
-0.4220981761434796641907f,0.2107039270298768085521f,0.3089304668962193911597f,\
-0.8825265124364938262858f,0.4570764804119011315287f,0.6317437032300170507426f,\
-0.6289949625530589782940f,0.4716158816756069738219f,0.4417016096894970100806f,\
-0.6297964082740089564183f,0.7506329678118981441060f,0.6853639001045995771122f,\
-0.6844909750084481325771f,0.3028385676048351293765f}
-
-#define CIRESULT {1.4391441245686327210507f,1.130955515640670316913f,1.1164484564631134144719f,\
-0.5343429881094952094145f,1.5313159234681512632648f,0.9218282568507811802760f,\
-1.1368031918334591257036f,1.309961324172885133166f,1.1768313149474189938104f,\
-1.1581725732800560724201f,1.198068547194847122128f,1.0167778558643913999759f,\
-0.8107284978807606234952f,0.9747572654361357225028f,1.2226962809307837520834f,\
-1.356863284326968122073f,1.4708283871101888173882f,1.0424189614104724110888f,\
-0.6175483783889722522176f,1.012434899444895508580f,1.4941377955828787360559f,\
-1.081247186686038253001f,1.189977918876721885155f,0.9361970185325101390106f,\
-1.0473314366303878575337f,0.6478815708564551467674f,1.103880390282215628872f,\
-1.208902068619972958174f,0.9405460211534443226711f,1.2708555309086870810376f,\
-1.2048457921815343141247f,1.0386992340805454304586f,0.9940470159552662332558f,\
-0.4129471251607437776165f,1.0483368304459323994138f,0.9626808065085141752348f,\
-0.9866797451792658213421f,1.2893127532844186333705f,0.6333368050416610106623f,\
-1.3849939050391590900091f,0.8412033774271403530065f,1.3484185557182311043789f,\
-0.6561721869869621137639f,0.8152667302376208624537f,0.8942162872449925803409f,\
-0.7354476761871528989190f,1.2302184692777484720239f,1.1419032200306009627866f,\
-0.8136425490751511002685f,1.0585917357001826122342f,1.5562281161680697749716f,\
-1.3215709464122720184776f,1.0936282246933759498830f,1.562690430228121041267f,\
-1.5431569076078051061529f,1.5549621593607869662890f,0.7985043985204253180754f,\
-1.3827954341839958640747f,1.3338048203354757603734f,1.1992311317991326546917f,\
-0.9398015526727905299964f,0.8526323846859752420002f,0.6516084904889641871151f,\
-0.9312161189612270240090f,1.4928235928235611407189f,1.1434135639085114544145f,\
-1.3304436504678796016066f,1.0279557218905930326969f,1.5707583700301124274290f,\
-1.18264027414866035315f,1.049240570305455033662f,1.1438977350867394200407f,\
-0.8645410048697405036577f,1.272544314036070156604f,1.2965854453389789036066f,\
-1.5441276936419627840991f,0.8474785980812834518261f,1.4222542688372477037717f,\
-1.1067340541491283989473f,0.6658230283826037654293f,0.7440600810961385258580f,\
-1.509454955782236762474f,0.7139904083352976993382f,1.3343109319103572119047f,\
-0.8754276015708571945240f,1.4375430902494801266300f,0.8182153660902479197503f,\
-0.6279916190243797213810f,1.3777792247900606525945f,1.5570776874524723254467f,\
-1.3896877170114805277734f,1.292290381577097857502f,0.9513544490495031702437f,\
-1.146595322853661613749f,1.0663673649265974496814f,0.9066444651210990857138f,\
-0.7936124351430207113367f,1.1025133400691302654195f,0.7646931356316959416120f,\
-1.3570006423237950254901f,1.0127507430242304042878f,0.6984070724030820853656f,\
-0.9777377069899801931285f,0.6381815285628557044006f,1.4447151619316793702552f,\
-0.7381184252357657626931f,0.9463444174447509515957f,1.3036540993301888313738f,\
-0.3993509460349408124458f,1.4425649666003559357108f,1.2703537792660923866350f,\
-0.3366052452908819825339f,0.9799364183556658058905f,0.6519110571169279833015f,\
-1.288935099739083156578f,0.766834829952783847418f,1.3765235555687964641436f,\
-0.9026821267000586512808f,0.7532458865053713870097f,1.1915253215495016370085f,\
-1.4398661339551832583084f,0.5960292480319858698934f,0.8683763627836410536887f,\
-1.307183356265154250409f,1.1437419441048803925298f,1.0721920855425228769064f,\
-1.5518517938677236500666f,1.2329687641584510249260f,0.5874976025749066854686f,\
-1.1457409989520814797004f,1.2187173974473419768572f,1.2272326680013900812583f,\
-1.3202499364548996307889f,1.3364966855772182352524f,1.5028659601895917319325f,\
-1.5039244799556488185743f,1.199080874147727016066f,0.8850027352965960103504f,\
-0.5797999065603636204003f,0.9935513093218836244702f,1.3250345117052622079257f,\
-0.7510747251416685088543f,1.3856864393507652977178f,1.0646397833458374204696f,\
-0.7161423103150551527918f,0.6220745390646167383153f,1.4237426982899421545881f,\
-1.4349026977530163762253f,1.0862935323189089054097f,0.7475103036060971595234f,\
-0.9640755596017442918821f,1.4756182374730877349123f,0.8992686396344509169865f,\
-1.0456992348735927311765f,1.316872193719026640224f,1.0937098269572853581622f,\
-0.3787889502350130777053f,1.1777575502770252224849f,1.466927792635024818679f,\
-1.198998549247170863907f,0.9317214709279717510526f,0.3994553068013038665818f,\
-0.9996993047110468433303f,1.0533682169916682713762f,1.1680862767422879322510f,\
-1.0968093743281353003027f,1.475564759332087749755f,0.5739680940616843640711f,\
-1.2132055498728515630091f,1.277641763762892734846f,1.2372616699165408515881f,\
-0.4908185034943345348424f,1.0764535824324550361553f,1.3508749145869605179371f,\
-1.282220574891209663448f,0.8033914160655766245611f,0.4529330910646225394345f,\
-1.3777085436870080137339f,0.9478851551815749010288f,1.2208388985822435923723f,\
-1.263077873207383738929f,1.284175149159334061721f,1.023436357706823729430f,\
-0.5626793926847969418148f,0.6728398111486185717567f,0.7545922256887819257187f,\
-1.5396608871785673056110f,0.5335122401588628937574f,1.0275094129340511805992f,\
-0.8338356239168208672297f,1.0426578447465559840168f,1.4617456602888381222982f,\
-0.6682797094798482717692f,1.3426136823908161321839f,1.3312882615539098907220f,\
-1.4697575902556172522395f,0.7877417380659905710161f,0.7165102522491650915981f,\
-1.3183788402186256139004f,0.4738958779540429211430f}
-
-
-void sacoshsTest(void) {
- float In[]=IN;
- float Res[]=RESULT;
- float out;
- int i = 0;
-
- for (i=0;i<200;i++){
- if (In[i]<1) assert(1);
- else {
- out = sacoshs(In[i]);
- assert ( ( fabs(out-Res[i]) / fabs(out) ) <1e-6);
- }
- }
-}
-
-void cacoshsTest(void) {
- float InR[]=CRIN;
- float InI[]=CIIN;
- float ResR[]=CRRESULT;
- float ResI[]=CIRESULT;
- int i=0;
- floatComplex in,out;
-
- for (i=0;i<200;i++){
- in=FloatComplex(InR[i],InI[i]);
- out=cacoshs(in);
- assert( ( fabs(creals(out)-ResR[i]) / fabs(creals(out)) ) <1e-6);
- assert( ( fabs(cimags(out)-ResI[i]) / fabs(cimags(out)) ) <1e-6);
- }
-}
-
-void sacoshaTest(void) {
- float In[]=IN;
- float Res[]=RESULT;
- float out[200],in[200];
- int i = 0;
-
- for (i=0;i<200;i++){
- in[i]=In[i];
- }
-
- sacosha(in,200,out);
- for (i=0;i<200;i++){
- if (isnan(out[i])) assert(1);
- else{
- assert ( ( fabs(out[i]-Res[i]) / fabs(out[i]) ) <1e-6);
- }
- }
-}
-
-void cacoshaTest(void) {
- float InR[]=CRIN;
- float InI[]=CIIN;
- float ResR[]=CRRESULT;
- float ResI[]=CIRESULT;
- int i=0;
- floatComplex in[200],out[200];
-
- for (i=0;i<200;i++){
- in[i]=FloatComplex(InR[i],InI[i]);
- }
- cacosha(in,200,out);
- for (i=0;i<200;i++){
- assert( ( fabs(creals(out[i])-ResR[i]) / fabs(creals(out[i])) ) <1e-6);
- assert( ( fabs(cimags(out[i])-ResI[i]) / fabs(cimags(out[i])) ) <1e-6);
- }
-}
-
-int testAcosh(void) {
- printf("\n>>>> Float Hyperbolic ArcCosine Tests\n");
- sacoshsTest();
- cacoshsTest();
- sacoshaTest();
- cacoshaTest();
- return 0;
-}
-
-int main(void) {
- assert(testAcosh() == 0);
- return 0;
-}
+/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2006-2008 - INRIA - Bruno JOFRET + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + +#include "testAcosh.h" +#include "isnan.h" + +#ifdef _MSC_VER +#include <float.h> +#define isnan(x) _isnan((double)x) +#endif + +#define IN {38.746443623676896095276f,39.8779044859111309052f,99.6399083640426397324f,\ +93.207842670381069183350f,6.8147667217999696731567f,71.874653641134500503540f,\ +65.928971720859408378601f,43.781969323754310607910f,95.70061699487268924713f,\ +39.777786191552877426147f,54.149620747193694114685f,14.754852838814258575439f,\ +91.972588421776890754700f,41.853474546223878860474f,90.448315022513270378113f,\ +32.027477025985717773438f,57.482325518503785133362f,75.726259034126996994019f,\ +32.547289272770285606384f,50.125551037490367889404f,26.862081931903958320618f,\ +11.706684622913599014282f,36.675705714151263237000f,87.538864836096763610840f,\ +52.483216533437371253967f,76.861125137656927108765f,82.899243896827101707458f,\ +64.99033216387033462524f,56.250627012923359870911f,21.698794979602098464966f,\ +93.22312804870307445526f,93.5097210109233856201f,97.608120972290635108948f,\ +91.35094834491610527039f,26.843591919168829917908f,9.1870715841650962829590f,\ +17.129724519327282905579f,73.117265943437814712524f,86.922781122848391532898f,\ +1.4808017760515213012695f,65.071928361430764198303f,42.254429217427968978882f,\ +23.262092983350157737732f,31.955500133335590362549f,74.261871399357914924622f,\ +77.881882060319185256958f,65.248953877016901969910f,90.324406325817108154297f,\ +86.69646182097494602203f,70.879780035465955734253f,69.452034076675772666931f,\ +84.671579115092754364014f,93.227435695007443428040f,95.654127094894647598267f,\ +16.239900095388293266296f,12.728751823306083679199f,95.707353064790368080139f,\ +67.644099798053503036499f,39.798104530200362205505f,11.081875301897525787354f,\ +50.97153154201805591583f,58.446559030562639236450f,25.919713405892252922058f,\ +29.182348400354385375977f,6.0309174004942178726196f,90.43274922296404838562f,\ +61.944271018728613853455f,25.037935934960842132568f,83.850894169881939888000f,\ +82.732185069471597671509f,73.220202280208468437195f,29.458374157547950744629f,\ +29.091028729453682899475f,70.458725746721029281616f,30.465652560815215110779f,\ +75.730663724243640899658f,73.18075490184128284454f,69.053836632519960403442f,\ +62.402765033766627311707f,41.599050164222717285156f,28.105994546785950660706f,\ +5.6220385245978832244873f,58.040395518764853477478f,0.4246918484568595886230f,\ +68.2817161548882722855f,89.133544359356164932251f,92.980264825746417045593f,\ +28.40001545846462249756f,9.885430941358208656311f,41.369083430618047714233f,\ +64.121548598632216453552f,64.692758955061435699463f,47.02662643976509571075f,\ +60.481913108378648757935f,67.138904659077525138855f,71.394702047109603881836f,\ +54.127137595787644386292f,39.052018057554960250854f,1.1089378502219915390015f,\ +90.150084160268306732178f,13.887455360963940620422f,8.5074969567358493804932f,\ +34.66010238043963909149f,42.338709905743598937988f,80.213972786441445351f,\ +31.7881367169320583344f,18.021041667088866233826f,69.688742049038410186768f,\ +35.482168616726994514465f,16.12617420032620429993f,75.34236568026244640350f,\ +62.194181978702545166016f,51.510728383436799049377f,67.819245439022779464722f,\ +61.666865786537528038025f,70.212037675082683563232f,13.621602999046444892883f,\ +60.870522353798151016235f,18.923167092725634574890f,47.614179179072380065918f,\ +17.161004850640892982483f,41.371036972850561141968f,15.31781828962266445160f,\ +22.868881560862064361572f,95.856341393664479255676f,39.499193150550127029419f,\ +2.500818995758891106f,44.927055388689041137695f,91.384086245670914649963f,\ +11.012465786188840866089f,74.87958460114896297455f,0.7881646975874900817871f,\ +23.523587780073285102844f,80.106287542730569839478f,65.456348611041903495789f,\ +51.620832458138465881348f,70.271815219894051551819f,5.5151230655610561370850f,\ +62.56400248967111110687f,84.313133545219898223877f,17.294042231515049934387f,\ +41.730730701237916946411f,81.875373004004359245300f,25.327575206756591796875f,\ +86.085468018427491188049f,17.212611716240644454956f,78.060937067493796348572f,\ +13.735765032470226287842f,0.2187759149819612503052f,1.4656470157206058502197f,\ +30.469974083825945854187f,80.307766422629356384277f,99.052629480138421058655f,\ +82.85992136225104331970f,87.21015579067170619965f,29.531141556799411773682f,\ +58.27610609121620655060f,29.06773509457707405090f,2.0005736034363508224f,\ +71.4346818625926971436f,26.664068037644028663635f,51.992803346365690231323f,\ +48.17320345900952816010f,0.0918259844183921813965f,38.418471114709973335266f,\ +49.06664276495575904846f,44.197808159515261650085f,65.678765252232551574707f,\ +10.470610717311501502991f,42.787145730108022689819f,75.105277216061949729919f,\ +36.962236650288105010986f,84.119305433705449104309f,90.374342072755098342896f,\ +44.184404192492365837097f,1.0920032858848571777344f,20.380018139258027076721f,\ +85.418348293751478195190f,39.327101549133658409119f,97.573022358119487762451f,\ +8.4199145901948213577271f,23.39450428262352943420f,48.397052986547350883484f,\ +33.292300626635551452637f,96.453859517350792884827f,52.920697536319494247437f,\ +7.9968032892793416976929f,75.475437380373477935791f,4.476350219920277596f,\ +84.631874877959489822388f,20.008285669609904289246f,69.44785490632057189941f,\ +28.204387659206986427307f,79.546741675585508346558f,20.281786611303687095642f,\ +78.075716458261013031006f,93.606285052374005317688f,88.801648560911417007446f,\ +33.848348213359713554382f,89.761531725525856018066f} + +#define RESULT {4.3500195892822599574856f,4.378812333443298676627f,5.2946847693089331698957f,\ +5.2279502699832844925254f,2.6068118507181217147206f,4.968022463585481496295f,\ +4.8816676362403299549442f,4.4722388068202851840738f,5.2543446283333992141706f,\ +4.3762977630646631155287f,4.6848128785767624293612f,3.3835688928264802122214f,\ +5.2146082054939908445590f,4.4271792498758397726988f,5.1978952030053422461719f,\ +4.159497560939560578674f,4.7445490293632399669832f,5.0202285648475850621253f,\ +4.1756051841813626168687f,4.6075785448582253778227f,3.9835162329116351465075f,\ +3.1514779837977200394050f,4.2950758361772223281605f,5.165197419194649697261f,\ +4.653549840642725143880f,5.035105083560019956224f,5.1107367420045859418565f,\ +4.8673265089936572636020f,4.7228853485288873059744f,3.7698725167565876326137f,\ +5.2281142583800894740875f,5.2311839874435639430317f,5.2740816359097371091025f,\ +5.2078258853539018957690f,3.982827186610214287299f,2.9079691610609703644741f,\ +3.5331093207527803912171f,4.9851649496034715625115f,5.1581342419725935144470f,\ +0.9450506373811344840163f,4.8685813827251553931319f,4.4367163112396088564537f,\ +3.8395099847061766595857f,4.1572465837028591550961f,5.0006994941965512424531f,\ +5.0482993082581542054754f,4.8712984679982609392823f,5.1965242406243383754827f,\ +5.1555269912574592794385f,4.954082618091184997411f,4.9337317049920867972901f,\ +5.1318923054243690273779f,5.228160467885317963521f,5.2538586990129676479455f,\ +3.4796690893012534040452f,3.2354639460120244720542f,5.2544150166005954005755f,\ +4.9073526741507107473694f,4.3768085901327413722584f,3.0964161555968114925008f,\ +4.6243182142058252281913f,4.7611868033967539304285f,3.9477786701409951497510f,\ +4.0664175090632737052943f,2.4831009250018341028010f,5.1977230816033159754852f,\ +4.8193171469932529760172f,3.9131402651137854320496f,5.1221517738388655516246f,\ +5.1087193584020944570057f,4.98657191625376672306f,4.0758371911626332106948f,\ +4.0632814774108050315249f,4.9481239065017428302440f,4.1094776238806378643176f,\ +5.0202867341820684998766f,4.9860329708595516606806f,4.9279811897230469952547f,\ +4.8266925606060153697285f,4.421080015153528108840f,4.0288134359166507536543f,\ +2.4118364183807097234080f,4.7542122019999739634954f,0,\ +4.9167355873994562642793f,5.1832514554357551617159f,5.2255055264178071894321f,\ +4.0392267678246307482937f,2.9816410740582028893186f,4.4155348942144980739499f,\ +4.8538668500531736427206f,4.8627367182462748473881f,4.5437480774189333843083f,\ +4.7954231948046981415246f,4.8998553915953095838631f,4.9613217960209823331752f,\ +4.6843975172654603866818f,4.3578777660333960497496f,0.4626347638559775710121f,\ +5.1945923008314265345575f,3.3228343258666956927527f,2.830622803369744922009f,\ +4.238528249750794785200f,4.438709481897562980635f,5.077806047884725337838f,\ +4.1519928438683244564800f,3.5839165427001460351164f,4.9371344840241793150426f,\ +4.2619788264190443527468f,3.4726281293145686568380f,5.0151457380383783757338f,\ +4.8233440014012511909414f,4.6348430510092004652734f,4.9099388325030934865367f,\ +4.81482819845952114690f,4.9446162371720561168331f,3.3034540778469194677314f,\ +4.8018287252966844746993f,3.6328352359975357721567f,4.556167488561304601546f,\ +3.5349368514717505185274f,4.41558212917596915048f,3.4210967363570983224008f,\ +3.8224459155669441301484f,5.2559705982049909067655f,4.3692671498839636967659f,\ +1.5671566063449566819088f,4.4980634827120455909721f,5.2081885950679547292452f,\ +3.0901072205487807309510f,5.0089838747007107144782f,0,\ +3.850698741029123794988f,5.076462566530570263978f,4.8744723131002718474747f,\ +4.6369786693462113902342f,4.9454673471881154256380f,2.3923187222394570738970f,\ +4.8292733779221936885051f,5.127649658742538640865f,3.5426723072020398497273f,\ +4.424241396092424949416f,5.0983081346685077406278f,3.9246509637740216724922f,\ +5.1484540607983912963164f,3.537944651477085589164f,5.0505959169093319616195f,\ +3.3118225003889145696689f,0,0.9310418690232507010762f,\ +4.1096195393026562214800f,5.0789747485012091132717f,5.2887730188734272118722f,\ +5.1102622536361952398920f,5.1614350980940946200803f,4.0783057415377843568649f,\ +4.7582657239633334711471f,4.0624799671967695147146f,1.3172890037212539038336f,\ +4.9618816771260449982606f,3.9761122565887623281f,4.64415999832871140285f,\ +4.5678423566873336270078f,0,4.3415161209508754680542f,\ +4.5862227542495350718355f,4.481694375737592217490f,4.8778648861550966131517f,\ +3.0394313734202933474648f,4.4492483198356360674097f,5.0119936831694982259933f,\ +4.3028609023006350042806f,5.1253479422290126876760f,5.1970769705972195140475f,\ +4.4813909798397162376205f,0.4257373352329655857851f,3.7070996451820255046528f,\ +5.1406738437618608728030f,4.3648993866947414232982f,5.2737219653314042489001f,\ +2.820201721217977297584f,3.8451912168199942065883f,4.5724793527790357217100f,\ +4.1982477070823893683382f,5.2621850617105074832125f,4.661852422144622920541f,\ +2.7682565538529817494862f,5.0169105620070073570105f,2.1792385497944919414692f,\ +5.131423242241443638534f,3.6886685835548016498819f,4.9336715234659216378077f,\ +4.032310316197459165721f,5.0694524637856641646749f,3.7022621441401133424165f,\ +5.0507852459760567143121f,5.2322161767096924123166f,5.1795206909289932539764f,\ +4.2148191048546337356129f,5.19027265701442619417f} + +#define CRIN {0.1483933464623987674713f,0.5565875237807631492615f,0.4628333351574838161469f,\ +0.9158247429877519607544f,0.0444016349501907825470f,0.8175177471712231636047f,\ +0.5320580708794295787811f,0.2989391684532165527344f,0.5029047676362097263336f,\ +0.4266923693940043449402f,0.3965902938507497310638f,0.7440190296620130538940f,\ +0.7921002809889614582062f,0.5715918401256203651428f,0.4155966262333095073700f,\ +0.2953372262418270111084f,0.1075767637230455875397f,0.7572548976168036460876f,\ +0.93660886352881789207f,0.7694978956133127212524f,0.0902581927366554737091f,\ +0.4731486858800053596497f,0.4765542480163276195526f,0.6361737176775932312012f,\ +0.5064576440490782260895f,0.9049607468768954277039f,0.6742701171897351741791f,\ +0.3656400945037603378296f,0.6837903787381947040558f,0.4100628877058625221252f,\ +0.3582529271952807903290f,0.7118562050163745880127f,0.7966963038779795169830f,\ +0.9753969227895140647888f,0.5733916512690484523773f,0.8998429346829652786255f,\ +0.5953218084760010242462f,0.3765322910621762275696f,0.9104355531744658946991f,\ +0.1861076802015304565430f,0.6715109744109213352203f,0.2566455481573939323425f,\ +0.9819463356398046016693f,0.7608660291880369186401f,0.8556561623699963092804f,\ +0.8441717335954308509827f,0.3884846637956798076630f,0.4608103148639202117920f,\ +0.8381579727865755558014f,0.5278776129707694053650f,0.0187810636125504970551f,\ +0.2611750457435846328735f,0.6092445817776024341583f,0.0081067951396107673645f,\ +0.0276411953382194042206f,0.0158492103219032287598f,0.8109004520811140537262f,\ +0.2429467244073748588562f,0.3353355019353330135345f,0.4142854567617177963257f,\ +0.5946544189937412738800f,0.9080675477162003517151f,0.992223232518881559372f,\ +0.6239561475813388824463f,0.0789771513082087039948f,0.5889828568324446678162f,\ +0.2523608407936990261078f,0.5871062893420457839966f,0.0000379872508347034454f,\ +0.4244823055341839790344f,0.69984475849196314812f,0.4405533373355865478516f,\ +0.6495711454190313816071f,0.4199861017987132072449f,0.2716385438106954097748f,\ +0.0272838752716779708862f,0.6936013107188045978546f,0.1495713749900460243f,\ +0.5206344048492610454559f,0.9685971699655055999756f,0.9657785953022539615631f,\ +0.0654204180464148521423f,0.9626990980468690395355f,0.2655456010252237319946f,\ +0.8290728745050728321075f,0.1334408046677708625793f,0.8514542016200721263885f,\ +0.8984219655394554138184f,0.1995774977840483188629f,0.0138073815032839775085f,\ +0.2245407640002667903900f,0.3930436577647924423218f,0.8261723746545612812042f,\ +0.5051761353388428688049f,0.5651183272711932659149f,0.822583723813295364380f,\ +0.9197964356280863285065f,0.4713199352845549583435f,0.9223483256064355373383f,\ +0.2136987913399934768677f,0.7260794681496918201447f,0.9689361499622464179993f,\ +0.8346118587069213390350f,0.8257038742303848266602f,0.1350833275355398654938f,\ +0.7953761396929621696472f,0.8992118402384221553802f,0.2715440522879362106323f,\ +0.9219025229103863239288f,0.1750466236844658851624f,0.3323095212690532207489f,\ +0.9493130259215831756592f,0.7118741781450808048248f,0.8032329222187399864197f,\ +0.3628453887067735195160f,0.7530685458332300186157f,0.2641473677940666675568f,\ +0.9660940738394856452942f,0.8041944387368857860565f,0.5316947177052497863770f,\ +0.1673618280328810214996f,0.955579827539622783661f,0.6473058252595365047455f,\ +0.2645611818879842758179f,0.5411860425956547260284f,0.4980195099487900733948f,\ +0.0190768833272159099579f,0.4227291680872440338135f,0.8374647037126123905182f,\ +0.4151327675208449363708f,0.3497115275822579860687f,0.4844544250518083572388f,\ +0.3347255480475723743439f,0.2362121837213635444641f,0.0928130256943404674530f,\ +0.0737370252609252929688f,0.4197955676354467868805f,0.9802277712151408195496f,\ +0.8419611467979848384857f,0.6906680446118116378784f,0.2502765958197414875031f,\ +0.8266033390536904335022f,0.1875236849300563335419f,0.5023231171071529388428f,\ +0.8916302681900560855865f,0.8934147348627448081970f,0.1574523574672639369965f,\ +0.1629528645426034927368f,0.5226223585195839405060f,0.8417599620297551155090f,\ +0.5858130785636603832245f,0.1322202011942863464355f,0.8028764897026121616364f,\ +0.5250511718913912773132f,0.2528006075881421566010f,0.4602345135062932968140f,\ +0.996287219692021608353f,0.4019785309210419654846f,0.1399875725619494915009f,\ +0.5081327147781848907471f,0.9440425024367868900299f,0.9318959629163146018982f,\ +0.6445578685961663722992f,0.5729571748524904251099f,0.4810055238194763660431f,\ +0.6713787661865353584290f,0.0962744313292205333710f,0.8855805248022079467773f,\ +0.3892059125937521457672f,0.2907031057402491569519f,0.4209313853643834590912f,\ +0.9504273366183042526245f,0.482190326321870088577f,0.2289973804727196693420f,\ +0.2940405677072703838348f,0.6957426778972148895264f,0.9139824123121798038483f,\ +0.2068154653534293174744f,0.6285024262033402919769f,0.4031575415283441543579f,\ +0.3064021435566246509552f,0.3148818286135792732239f,0.7400112929753959178925f,\ +0.8853011503815650939941f,0.788494529668241739273f,0.8977585239335894584656f,\ +0.0339450328610837459564f,0.8802101369947195053101f,0.5418177028186619281769f,\ +0.9511840576305985450745f,0.5574890668503940105438f,0.1312845982611179351807f,\ +0.9453403786756098270416f,0.2518341308459639549255f,0.2607447705231606960297f,\ +0.1215410251170396804810f,0.9136986923404037952423f,0.9382542567327618598938f,\ +0.3105722474865615367889f,0.9309121072292327880859f} + +#define CIIN {0.5225624092854559421539f,0.7617142526432871818542f,0.3009174778126180171967f,\ +0.1853434126824140548706f,0.5148605112917721271515f,0.7257346073165535926819f,\ +0.7033738414756953716278f,0.5664369426667690277100f,0.7816161573864519596100f,\ +0.3330347230657935142517f,0.4017280167900025844574f,0.8503915611654520034790f,\ +0.41114101978018879890f,0.1586530329659581184387f,0.6542402538470923900604f,\ +0.9449902996420860290527f,0.400338994804769754410f,0.9679889930412173271179f,\ +0.32740902295336127281f,0.8933845367282629013062f,0.6218692888505756855011f,\ +0.0985169494524598121643f,0.7449700380675494670868f,0.3134250529110431671143f,\ +0.1409188793040812015533f,0.3239218806847929954529f,0.9958796552382409572601f,\ +0.2412899602204561233521f,0.4753343504853546619415f,0.9194070147350430488586f,\ +0.0450326460413634777069f,0.8481595069169998168945f,0.8928631045855581760406f,\ +0.1469233212992548942566f,0.4904643460176885128021f,0.9986877571791410446167f,\ +0.3392539476044476032257f,0.8790708789601922035217f,0.3107871781103312969208f,\ +0.1200211457908153533936f,0.0909670502878725528717f,0.5804221173748373985291f,\ +0.446611551102250814438f,0.3501139078289270401001f,0.7262432840652763843536f,\ +0.3650169344618916511536f,0.5597011330537497997284f,0.434090383350849151611f,\ +0.5082829319871962070465f,0.3487796885892748832703f,0.8136124997399747371674f,\ +0.337404197081923484802f,0.7742837746627628803253f,0.0156080657616257667542f,\ +0.0195691580884158611298f,0.0445443131029605865479f,0.4240885511972010135651f,\ +0.8158838218078017234802f,0.9913199446164071559906f,0.5120379645377397537231f,\ +0.1021917951293289661407f,0.7161553995683789253235f,0.4527317988686263561249f,\ +0.2445004582405090332031f,0.1668560453690588474274f,0.9187424210831522941589f,\ +0.3418669118545949459076f,0.4624818544834852218628f,0.0400874321348965167999f,\ +0.4700120547786355018616f,0.8552942494861781597137f,0.3308605216443538665771f,\ +0.0322206378914415836334f,0.9760772576555609703064f,0.0763854510150849819183f,\ +0.2165335658937692642212f,0.2348632332868874073029f,0.1446668924763798713684f,\ +0.5313451024703681468964f,0.4441541358828544616699f,0.5759493880905210971832f,\ +0.3719177199527621269226f,0.5167253850959241390228f,0.5186656024307012557983f,\ +0.6306529571302235126495f,0.0928382659330964088440f,0.5421750987879931926727f,\ +0.2833826132118701934814f,0.2819099412299692630768f,0.1141945635899901390076f,\ +0.7321730605326592922211f,0.9823690224438905715942f,0.8243003231473267078400f,\ +0.6485677706077694892883f,0.5304958778433501720428f,0.6958626955747604370117f,\ +0.6050392785109579563141f,0.2683336613699793815613f,0.5511700971983373165131f,\ +0.1174971889704465866089f,0.7958277617581188678741f,0.4983139941468834877014f,\ +0.9196587274782359600067f,0.1420703046023845672607f,0.389312467072159051895f,\ +0.2658497532829642295837f,0.9480321384035050868988f,0.2326095197349786758423f,\ +0.0139051643200218677521f,0.9270462663844227790833f,0.4878733339719474315643f,\ +0.0354842916131019592285f,0.6607114099897444248199f,0.0879401965066790580750f,\ +0.8046676008962094783783f,0.212315237149596214294f,0.9163186331279575824738f,\ +0.9393384093418717384338f,0.3174265320412814617157f,0.9574301876127719879150f,\ +0.7951935962773859500885f,0.3240787154063582420349f,0.0472964248619973659515f,\ +0.1696171183139085769653f,0.7654392314143478870392f,0.2554624872282147407532f,\ +0.1189010548405349254608f,0.7469239532947540283203f,0.0616608508862555027008f,\ +0.1056091515347361564636f,0.1581688239239156246185f,0.9732552450150251388550f,\ +0.8786917333491146564484f,0.1824825564399361610413f,0.9303942839615046977997f,\ +0.4655157290399074554443f,0.5399280847050249576569f,0.9143392136320471763611f,\ +0.0622840351425111293793f,0.6500507537275552749634f,0.2340233740396797657013f,\ +0.3603484155610203742981f,0.1917369994334876537323f,0.2371335849165916442871f,\ +0.4136920445598661899567f,0.2661342276260256767273f,0.3891090690158307552338f,\ +0.6622495856136083602905f,0.4503725995309650897980f,0.3829893553629517555237f,\ +0.1937121297232806682587f,0.9629272706806659698486f,0.6385000632144510746002f,\ +0.2695108866319060325623f,0.1092974594794213771820f,0.0598662365227937698364f,\ +0.1431378168053925037384f,0.2944079088047146797180f,0.9022735017351806163788f,\ +0.9111119657754898071289f,0.9847188093699514865875f,0.0592310009524226188660f,\ +0.5464080139063298702240f,0.5080275069922208786011f,0.6546461437828838825226f,\ +0.9597736010327935218811f,0.1577645908109843730927f,0.1818120293319225311279f,\ +0.4555030376650393009186f,0.1048952480778098106384f,0.7636235631071031093597f,\ +0.1893162522464990615845f,0.1596221593208611011505f,0.3115166993811726570129f,\ +0.2491372707299888134003f,0.0469047501683235168457f,0.0797643386758863925934f,\ +0.3945369226858019828796f,0.3254697113297879695892f,0.5811151321977376937866f,\ +0.1456566532142460346222f,0.4704219633713364601135f,0.8631705637089908123016f,\ +0.1648640967905521392822f,0.0801398889161646366119f,0.4932156866416335105896f,\ +0.4345335862599313259125f,0.1079503614455461502075f,0.2686753761954605579376f,\ +0.7417223947122693061829f,0.4086893904022872447968f,0.6706044673919677734375f,\ +0.4159612008370459079742f,0.4766113189980387687683f,0.4431825890205800533295f,\ +0.6688354592770338058472f,0.5834077899344265460968f,0.4861929873004555702209f,\ +0.715783319901674985886f,0.1403244398534297943115f} + +#define CRRESULT {0.5053397031743451783825f,0.7650083608446867078356f,0.3289296819323739295982f,\ +0.3563456766158749622342f,0.4948207655225617118688f,0.8169593462846268527855f,\ +0.7132198900639351579755f,0.5570137230416445373038f,0.7685376318852206178889f,\ +0.3559803193123551312560f,0.4189790595413633300659f,0.8813522345691391368661f,\ +0.5405451162482487470484f,0.1905551975849387180695f,0.6493731034151291048317f,\ +0.8578709195697519218626f,0.3922142862720902067863f,0.9642946930057294530059f,\ +0.5389615746319644795648f,0.9186094888728127960675f,0.5890418064066422765279f,\ +0.1113977102429560134267f,0.7345860770241963155769f,0.3799876579856086289411f,\ +0.1619970506356118999935f,0.51382943864194075001f,0.9605702232101991366875f,\ +0.2552214504374311077051f,0.5588288246069162967800f,0.8545155572742579863643f,\ +0.0482073009402987154304f,0.8701819105023789191478f,0.9267094766915666692597f,\ +0.3583874762657675017152f,0.5394241582016752190043f,1.0267057888096897677599f,\ +0.3962322220487046187110f,0.8200372580795054489045f,0.5035682683774097556650f,\ +0.1218215489911998739014f,0.1217295472085216101465f,0.5645974853924803360528f,\ +0.6787204142960019392916f,0.4641409785094591788912f,0.8320374579652175528466f,\ +0.5202648072575078996849f,0.5635084163999081185992f,0.4608376215542885900867f,\ +0.6521335567127740651117f,0.3901559225476997627702f,0.7433295520896158192770f,\ +0.3414853587252406064145f,0.7876437052847802267053f,0.0156079448330699189357f,\ +0.0195753850507095344957f,0.0445351746116087257588f,0.5619901990592348628439f,\ +0.7563216032216260042986f,0.8953230010983072029163f,0.5250759023565449989945f,\ +0.1262270783291525866332f,0.8463340938014771719367f,0.6903512283163251161966f,\ +0.3002023271844543317322f,0.1665929038330317135674f,0.8881085995755062523216f,\ +0.3450945758035259824936f,0.5168125326109850314893f,0.0400767031552608649081f,\ +0.4881659313644853837033f,0.8717577944100705078512f,0.3559191435167290418207f,\ +0.0423384874325624382951f,0.8962569818869624560520f,0.0792669980362326609402f,\ +0.2149514867261388406661f,0.3084002596083564862184f,0.1457610223920582370738f,\ +0.5638322964331675679617f,0.6681928703809085767773f,0.7715309042125101379739f,\ +0.3644939000586688848671f,0.7241095709372292743566f,0.5109856481565466790329f,\ +0.7492592023075983487246f,0.0935322123614654998836f,0.6873609600399674945947f,\ +0.4653574362777189166174f,0.2834338708350941926639f,0.1139584955905696417311f,\ +0.6886187601911135658384f,0.8966624572124947123442f,0.8901159605244814976288f,\ +0.6621780758434868685569f,0.5739364819547106977282f,0.7967040377802739881119f,\ +0.7702556784014074064970f,0.2963495189276508789966f,0.729639913718978516677f,\ +0.1199467917211827494572f,0.8369585267706058928638f,0.7130151705637984838049f,\ +0.9564173315765011063050f,0.2362741844905166255231f,0.3829952297292640861492f,\ +0.3854654409071321952140f,0.9956878617898979877410f,0.2388852521695121466916f,\ +0.0357548125472270175718f,0.8344528446849692748799f,0.4908081134490644426016f,\ +0.1072298401775326898155f,0.7292248632489435333781f,0.1444440063075330404896f,\ +0.7618560442692507983509f,0.3014073074948313002430f,0.8338433864005018181231f,\ +1.013809216729007589564f,0.4488437286282063176657f,0.9028988520348978363828f,\ +0.7342748763980897486192f,0.5492704923146081164020f,0.0619250478958671968233f,\ +0.1747947745500638971894f,0.7643392221916658346714f,0.2869233753851287982428f,\ +0.1186438529044472750540f,0.7261517086175122148717f,0.1110167797262640587697f,\ +0.1156665104854840142590f,0.1677179018762894047168f,0.9049771869312485117476f,\ +0.8140692858573190804350f,0.1865250841653489921601f,0.8328626043313867022277f,\ +0.4511026850510220786994f,0.5511713324178673101272f,1.0040394102716723168101f,\ +0.1134432764930088655131f,0.7136163206069113806862f,0.2389915016256592694699f,\ +0.5061510239067475991348f,0.1938531425179492451161f,0.267912781705172242663f,\ +0.594520593176991907214f,0.4421595740617755287971f,0.3838580911610497414799f,\ +0.6265966551277006857390f,0.4892019455111443759776f,0.5371648663643865395656f,\ +0.2336644699290637006150f,0.8580649693764487162539f,0.7447932141471096390006f,\ +0.30664577808112553070f,0.1126796888171682081703f,0.0673404850217956818526f,\ +0.3780061914448271664924f,0.3135468248495265064513f,0.8141814149801622768621f,\ +0.8656800272972641208113f,1.0330415543607425199468f,0.1517147576472806791426f,\ +0.6107832692276639052764f,0.5555300503019462432519f,0.6621194316643849164805f,\ +0.9359383537376269046604f,0.1578266511911156633197f,0.3288869400610432980336f,\ +0.4688911283964798393242f,0.1093517544178844447256f,0.7390278072154514710235f,\ +0.3915656081630794482784f,0.1803516698292359499156f,0.3140185989593758941751f,\ +0.2570435038916802361619f,0.0651252572213311814453f,0.1812803236410877871787f,\ +0.3918987512324060840108f,0.3907169202420177067658f,0.5847178774812699098007f,\ +0.1522469534945809221949f,0.4726351219523636792985f,0.8890284419930043480207f,\ +0.3043305148205690535690f,0.1282404489119809976039f,0.6689999411776240689775f,\ +0.4220981761434796641907f,0.2107039270298768085521f,0.3089304668962193911597f,\ +0.8825265124364938262858f,0.4570764804119011315287f,0.6317437032300170507426f,\ +0.6289949625530589782940f,0.4716158816756069738219f,0.4417016096894970100806f,\ +0.6297964082740089564183f,0.7506329678118981441060f,0.6853639001045995771122f,\ +0.6844909750084481325771f,0.3028385676048351293765f} + +#define CIRESULT {1.4391441245686327210507f,1.130955515640670316913f,1.1164484564631134144719f,\ +0.5343429881094952094145f,1.5313159234681512632648f,0.9218282568507811802760f,\ +1.1368031918334591257036f,1.309961324172885133166f,1.1768313149474189938104f,\ +1.1581725732800560724201f,1.198068547194847122128f,1.0167778558643913999759f,\ +0.8107284978807606234952f,0.9747572654361357225028f,1.2226962809307837520834f,\ +1.356863284326968122073f,1.4708283871101888173882f,1.0424189614104724110888f,\ +0.6175483783889722522176f,1.012434899444895508580f,1.4941377955828787360559f,\ +1.081247186686038253001f,1.189977918876721885155f,0.9361970185325101390106f,\ +1.0473314366303878575337f,0.6478815708564551467674f,1.103880390282215628872f,\ +1.208902068619972958174f,0.9405460211534443226711f,1.2708555309086870810376f,\ +1.2048457921815343141247f,1.0386992340805454304586f,0.9940470159552662332558f,\ +0.4129471251607437776165f,1.0483368304459323994138f,0.9626808065085141752348f,\ +0.9866797451792658213421f,1.2893127532844186333705f,0.6333368050416610106623f,\ +1.3849939050391590900091f,0.8412033774271403530065f,1.3484185557182311043789f,\ +0.6561721869869621137639f,0.8152667302376208624537f,0.8942162872449925803409f,\ +0.7354476761871528989190f,1.2302184692777484720239f,1.1419032200306009627866f,\ +0.8136425490751511002685f,1.0585917357001826122342f,1.5562281161680697749716f,\ +1.3215709464122720184776f,1.0936282246933759498830f,1.562690430228121041267f,\ +1.5431569076078051061529f,1.5549621593607869662890f,0.7985043985204253180754f,\ +1.3827954341839958640747f,1.3338048203354757603734f,1.1992311317991326546917f,\ +0.9398015526727905299964f,0.8526323846859752420002f,0.6516084904889641871151f,\ +0.9312161189612270240090f,1.4928235928235611407189f,1.1434135639085114544145f,\ +1.3304436504678796016066f,1.0279557218905930326969f,1.5707583700301124274290f,\ +1.18264027414866035315f,1.049240570305455033662f,1.1438977350867394200407f,\ +0.8645410048697405036577f,1.272544314036070156604f,1.2965854453389789036066f,\ +1.5441276936419627840991f,0.8474785980812834518261f,1.4222542688372477037717f,\ +1.1067340541491283989473f,0.6658230283826037654293f,0.7440600810961385258580f,\ +1.509454955782236762474f,0.7139904083352976993382f,1.3343109319103572119047f,\ +0.8754276015708571945240f,1.4375430902494801266300f,0.8182153660902479197503f,\ +0.6279916190243797213810f,1.3777792247900606525945f,1.5570776874524723254467f,\ +1.3896877170114805277734f,1.292290381577097857502f,0.9513544490495031702437f,\ +1.146595322853661613749f,1.0663673649265974496814f,0.9066444651210990857138f,\ +0.7936124351430207113367f,1.1025133400691302654195f,0.7646931356316959416120f,\ +1.3570006423237950254901f,1.0127507430242304042878f,0.6984070724030820853656f,\ +0.9777377069899801931285f,0.6381815285628557044006f,1.4447151619316793702552f,\ +0.7381184252357657626931f,0.9463444174447509515957f,1.3036540993301888313738f,\ +0.3993509460349408124458f,1.4425649666003559357108f,1.2703537792660923866350f,\ +0.3366052452908819825339f,0.9799364183556658058905f,0.6519110571169279833015f,\ +1.288935099739083156578f,0.766834829952783847418f,1.3765235555687964641436f,\ +0.9026821267000586512808f,0.7532458865053713870097f,1.1915253215495016370085f,\ +1.4398661339551832583084f,0.5960292480319858698934f,0.8683763627836410536887f,\ +1.307183356265154250409f,1.1437419441048803925298f,1.0721920855425228769064f,\ +1.5518517938677236500666f,1.2329687641584510249260f,0.5874976025749066854686f,\ +1.1457409989520814797004f,1.2187173974473419768572f,1.2272326680013900812583f,\ +1.3202499364548996307889f,1.3364966855772182352524f,1.5028659601895917319325f,\ +1.5039244799556488185743f,1.199080874147727016066f,0.8850027352965960103504f,\ +0.5797999065603636204003f,0.9935513093218836244702f,1.3250345117052622079257f,\ +0.7510747251416685088543f,1.3856864393507652977178f,1.0646397833458374204696f,\ +0.7161423103150551527918f,0.6220745390646167383153f,1.4237426982899421545881f,\ +1.4349026977530163762253f,1.0862935323189089054097f,0.7475103036060971595234f,\ +0.9640755596017442918821f,1.4756182374730877349123f,0.8992686396344509169865f,\ +1.0456992348735927311765f,1.316872193719026640224f,1.0937098269572853581622f,\ +0.3787889502350130777053f,1.1777575502770252224849f,1.466927792635024818679f,\ +1.198998549247170863907f,0.9317214709279717510526f,0.3994553068013038665818f,\ +0.9996993047110468433303f,1.0533682169916682713762f,1.1680862767422879322510f,\ +1.0968093743281353003027f,1.475564759332087749755f,0.5739680940616843640711f,\ +1.2132055498728515630091f,1.277641763762892734846f,1.2372616699165408515881f,\ +0.4908185034943345348424f,1.0764535824324550361553f,1.3508749145869605179371f,\ +1.282220574891209663448f,0.8033914160655766245611f,0.4529330910646225394345f,\ +1.3777085436870080137339f,0.9478851551815749010288f,1.2208388985822435923723f,\ +1.263077873207383738929f,1.284175149159334061721f,1.023436357706823729430f,\ +0.5626793926847969418148f,0.6728398111486185717567f,0.7545922256887819257187f,\ +1.5396608871785673056110f,0.5335122401588628937574f,1.0275094129340511805992f,\ +0.8338356239168208672297f,1.0426578447465559840168f,1.4617456602888381222982f,\ +0.6682797094798482717692f,1.3426136823908161321839f,1.3312882615539098907220f,\ +1.4697575902556172522395f,0.7877417380659905710161f,0.7165102522491650915981f,\ +1.3183788402186256139004f,0.4738958779540429211430f} + + +void sacoshsTest(void) { + float In[]=IN; + float Res[]=RESULT; + float out; + int i = 0; + + for (i=0;i<200;i++){ + if (In[i]<1) assert(1); + else { + out = sacoshs(In[i]); + assert ( ( fabs(out-Res[i]) / fabs(out) ) <1e-6); + } + } +} + +void cacoshsTest(void) { + float InR[]=CRIN; + float InI[]=CIIN; + float ResR[]=CRRESULT; + float ResI[]=CIRESULT; + int i=0; + floatComplex in,out; + + for (i=0;i<200;i++){ + in=FloatComplex(InR[i],InI[i]); + out=cacoshs(in); + assert( ( fabs(creals(out)-ResR[i]) / fabs(creals(out)) ) <1e-6); + assert( ( fabs(cimags(out)-ResI[i]) / fabs(cimags(out)) ) <1e-6); + } +} + +void sacoshaTest(void) { + float In[]=IN; + float Res[]=RESULT; + float out[200],in[200]; + int i = 0; + + for (i=0;i<200;i++){ + in[i]=In[i]; + } + + sacosha(in,200,out); + for (i=0;i<200;i++){ + if (isnan(out[i])) assert(1); + else{ + assert ( ( fabs(out[i]-Res[i]) / fabs(out[i]) ) <1e-6); + } + } +} + +void cacoshaTest(void) { + float InR[]=CRIN; + float InI[]=CIIN; + float ResR[]=CRRESULT; + float ResI[]=CIRESULT; + int i=0; + floatComplex in[200],out[200]; + + for (i=0;i<200;i++){ + in[i]=FloatComplex(InR[i],InI[i]); + } + cacosha(in,200,out); + for (i=0;i<200;i++){ + assert( ( fabs(creals(out[i])-ResR[i]) / fabs(creals(out[i])) ) <1e-6); + assert( ( fabs(cimags(out[i])-ResI[i]) / fabs(cimags(out[i])) ) <1e-6); + } +} + +int testAcosh(void) { + printf("\n>>>> Float Hyperbolic ArcCosine Tests\n"); + sacoshsTest(); + cacoshsTest(); + sacoshaTest(); + cacoshaTest(); + return 0; +} + +int main(void) { + assert(testAcosh() == 0); + return 0; +} diff --git a/src/c/elementaryFunctions/asin/casins.c b/src/c/elementaryFunctions/asin/casins.c index 35a4a8d8..caed038e 100644 --- a/src/c/elementaryFunctions/asin/casins.c +++ b/src/c/elementaryFunctions/asin/casins.c @@ -1,146 +1,146 @@ -/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2008-2008 - INRIA - Bruno JOFRET
- * Copyright (C) Bruno Pincon
- *
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
-
-/*
- * REFERENCE
- * This is a Fortran-77 translation of an algorithm by
- * T.E. Hull, T. F. Fairgrieve and P.T.P. Tang which
- * appears in their article :
- * "Implementing the Complex Arcsine and Arccosine
- * Functions Using Exception Handling", ACM, TOMS,
- * Vol 23, No. 3, Sept 1997, p. 299-335
- * Thanks to Tom Fairgrieve
- */
-
-#include "lapack.h"
-#include "asin.h"
-#include "atan.h"
-#include "sqrt.h"
-#include "abs.h"
-#include "log.h"
-#include "log1p.h"
-#include "min.h"
-#include "max.h"
-
-floatComplex casins(floatComplex z) {
- static float sdblPi_2 = 1.5707963267948966192313216f;
- static float sdblLn2 = 0.6931471805599453094172321f;
- static float sdblAcross = 1.5f;
- static float sdblBcross = 0.6417f;
-
- float dblLsup = ssqrts((float) getOverflowThreshold())/ 8.0f;
- float dblLinf = 4.0f * ssqrts((float) getUnderflowThreshold());
- float dblEpsm = ssqrts((float) getRelativeMachinePrecision());
-
- float _dblReal = creals(z);
- float _dblImg = cimags(z);
-
- float dblAbsReal = sabss(_dblReal);
- float dblAbsImg = sabss(_dblImg);
- float iSignReal = _dblReal < 0 ? -1.0f : 1.0f;
- float iSignImg = _dblImg < 0 ? -1.0f : 1.0f;
-
- float dblR = 0, dblS = 0, dblA = 0, dblB = 0;
-
- float dblTemp = 0;
-
- float _pdblReal = 0;
- float _pdblImg = 0;
-
- if( min(dblAbsReal, dblAbsImg) > dblLinf && max(dblAbsReal, dblAbsImg) <= dblLsup)
- {
- /* we are in the safe region */
- dblR = ssqrts( (dblAbsReal + 1) * (dblAbsReal + 1) + dblAbsImg * dblAbsImg);
- dblS = ssqrts( (dblAbsReal - 1) * (dblAbsReal - 1) + dblAbsImg * dblAbsImg);
- dblA = (float) 0.5 * ( dblR + dblS );
- dblB = dblAbsReal / dblA;
-
-
- /* compute the real part */
- if(dblB <= sdblBcross)
- _pdblReal = sasins(dblB);
- else if( dblAbsReal <= 1)
- _pdblReal = satans(dblAbsReal / ssqrts( 0.5f * (dblA + dblAbsReal) * ( (dblAbsImg * dblAbsImg) / (dblR + (dblAbsReal + 1)) + (dblS + (1 - dblAbsReal)))));
- else
- _pdblReal = satans(dblAbsReal / (dblAbsImg * ssqrts( 0.5f * ((dblA + dblAbsReal) / (dblR + (dblAbsReal + 1)) + (dblA + dblAbsReal) / (dblS + (dblAbsReal-1))))));
-
- /* compute the imaginary part */
- if(dblA <= sdblAcross)
- {
- float dblImg1 = 0;
-
- if(dblAbsReal < 1)
- /* Am1 = 0.5d0*((y**2)/(R+(x+1.d0))+(y**2)/(S+(1.d0-x))) */
- dblImg1 = 0.5f * (dblAbsImg * dblAbsImg / (dblR + (dblAbsReal + 1)) + dblAbsImg * dblAbsImg / (dblS + (1 - dblAbsReal)));
- else
- /* Am1 = 0.5d0*((y**2)/(R+(x+1.d0))+(S+(x-1.d0))) */
- dblImg1 = 0.5f * (dblAbsImg * dblAbsImg / (dblR + (dblAbsReal + 1)) + (dblS + (dblAbsReal - 1)));
- /* ai = logp1(Am1 + sqrt(Am1*(A+1.d0))) */
- dblTemp = dblImg1 + ssqrts(dblImg1 * (dblA + 1));
- _pdblImg = slog1ps(dblTemp);
- }
- else
- /* ai = log(A + sqrt(A**2 - 1.d0)) */
- _pdblImg = slogs(dblA + ssqrts(dblA * dblA - (float) 1.0));
- }
- else
- {
- /* evaluation in the special regions ... */
- if(dblAbsImg <= dblEpsm * dabss(dblAbsReal - 1))
- {
- if(dblAbsReal < 1)
- {
- _pdblReal = sasins(dblAbsReal);
- _pdblImg = dblAbsImg / ssqrts((1 + dblAbsReal) * (1 - dblAbsReal));
- }
- else
- {
- _pdblReal = sdblPi_2;
- if(dblAbsReal <= dblLsup)
- {
- dblTemp = (dblAbsReal - 1) + ssqrts((dblAbsReal - 1) * (dblAbsReal + 1));
- _pdblImg = slog1ps(dblTemp);
- }
- else
- _pdblImg = sdblLn2 + slogs(dblAbsReal);
- }
- }
- else if(dblAbsImg < dblLinf)
- {
- _pdblReal = sdblPi_2 - ssqrts(dblAbsImg);
- _pdblImg = ssqrts(dblAbsImg);
- }
- else if((dblEpsm * dblAbsImg - 1 >= dblAbsReal))
- {
- _pdblReal = dblAbsReal * dblAbsImg;
- _pdblImg = sdblLn2 + slogs(dblAbsReal);
- }
- else if(dblAbsReal > 1)
- {
- _pdblReal = satans(dblAbsReal / dblAbsImg);
- dblTemp = (dblAbsReal / dblAbsImg) * (dblAbsReal / dblAbsImg);
- _pdblImg = sdblLn2 + slogs(dblAbsReal) + 0.5f * slog1ps(dblTemp);
- }
- else
- {
- float dblTemp2 = ssqrts(1 + dblAbsImg * dblAbsImg);
- _pdblReal = dblAbsReal / dblTemp2;
- dblTemp = 2.0f * dblAbsImg * (dblAbsImg + dblTemp2);
- _pdblImg = 0.5f * slog1ps(dblTemp);
- }
- }
- _pdblReal *= iSignReal;
- _pdblImg *= iSignImg;
-
- return (FloatComplex(_pdblReal, _pdblImg));
-}
+/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2008-2008 - INRIA - Bruno JOFRET + * Copyright (C) Bruno Pincon + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + +/* + * REFERENCE + * This is a Fortran-77 translation of an algorithm by + * T.E. Hull, T. F. Fairgrieve and P.T.P. Tang which + * appears in their article : + * "Implementing the Complex Arcsine and Arccosine + * Functions Using Exception Handling", ACM, TOMS, + * Vol 23, No. 3, Sept 1997, p. 299-335 + * Thanks to Tom Fairgrieve + */ + +#include "lapack.h" +#include "asin.h" +#include "atan.h" +#include "sqrt.h" +#include "abs.h" +#include "log.h" +#include "log1p.h" +#include "min.h" +#include "max.h" + +floatComplex casins(floatComplex z) { + static float sdblPi_2 = 1.5707963267948966192313216f; + static float sdblLn2 = 0.6931471805599453094172321f; + static float sdblAcross = 1.5f; + static float sdblBcross = 0.6417f; + + float dblLsup = ssqrts((float) getOverflowThreshold())/ 8.0f; + float dblLinf = 4.0f * ssqrts((float) getUnderflowThreshold()); + float dblEpsm = ssqrts((float) getRelativeMachinePrecision()); + + float _dblReal = creals(z); + float _dblImg = cimags(z); + + float dblAbsReal = sabss(_dblReal); + float dblAbsImg = sabss(_dblImg); + float iSignReal = _dblReal < 0 ? -1.0f : 1.0f; + float iSignImg = _dblImg < 0 ? -1.0f : 1.0f; + + float dblR = 0, dblS = 0, dblA = 0, dblB = 0; + + float dblTemp = 0; + + float _pdblReal = 0; + float _pdblImg = 0; + + if( min(dblAbsReal, dblAbsImg) > dblLinf && max(dblAbsReal, dblAbsImg) <= dblLsup) + { + /* we are in the safe region */ + dblR = ssqrts( (dblAbsReal + 1) * (dblAbsReal + 1) + dblAbsImg * dblAbsImg); + dblS = ssqrts( (dblAbsReal - 1) * (dblAbsReal - 1) + dblAbsImg * dblAbsImg); + dblA = (float) 0.5 * ( dblR + dblS ); + dblB = dblAbsReal / dblA; + + + /* compute the real part */ + if(dblB <= sdblBcross) + _pdblReal = sasins(dblB); + else if( dblAbsReal <= 1) + _pdblReal = satans(dblAbsReal / ssqrts( 0.5f * (dblA + dblAbsReal) * ( (dblAbsImg * dblAbsImg) / (dblR + (dblAbsReal + 1)) + (dblS + (1 - dblAbsReal))))); + else + _pdblReal = satans(dblAbsReal / (dblAbsImg * ssqrts( 0.5f * ((dblA + dblAbsReal) / (dblR + (dblAbsReal + 1)) + (dblA + dblAbsReal) / (dblS + (dblAbsReal-1)))))); + + /* compute the imaginary part */ + if(dblA <= sdblAcross) + { + float dblImg1 = 0; + + if(dblAbsReal < 1) + /* Am1 = 0.5d0*((y**2)/(R+(x+1.d0))+(y**2)/(S+(1.d0-x))) */ + dblImg1 = 0.5f * (dblAbsImg * dblAbsImg / (dblR + (dblAbsReal + 1)) + dblAbsImg * dblAbsImg / (dblS + (1 - dblAbsReal))); + else + /* Am1 = 0.5d0*((y**2)/(R+(x+1.d0))+(S+(x-1.d0))) */ + dblImg1 = 0.5f * (dblAbsImg * dblAbsImg / (dblR + (dblAbsReal + 1)) + (dblS + (dblAbsReal - 1))); + /* ai = logp1(Am1 + sqrt(Am1*(A+1.d0))) */ + dblTemp = dblImg1 + ssqrts(dblImg1 * (dblA + 1)); + _pdblImg = slog1ps(dblTemp); + } + else + /* ai = log(A + sqrt(A**2 - 1.d0)) */ + _pdblImg = slogs(dblA + ssqrts(dblA * dblA - (float) 1.0)); + } + else + { + /* evaluation in the special regions ... */ + if(dblAbsImg <= dblEpsm * dabss(dblAbsReal - 1)) + { + if(dblAbsReal < 1) + { + _pdblReal = sasins(dblAbsReal); + _pdblImg = dblAbsImg / ssqrts((1 + dblAbsReal) * (1 - dblAbsReal)); + } + else + { + _pdblReal = sdblPi_2; + if(dblAbsReal <= dblLsup) + { + dblTemp = (dblAbsReal - 1) + ssqrts((dblAbsReal - 1) * (dblAbsReal + 1)); + _pdblImg = slog1ps(dblTemp); + } + else + _pdblImg = sdblLn2 + slogs(dblAbsReal); + } + } + else if(dblAbsImg < dblLinf) + { + _pdblReal = sdblPi_2 - ssqrts(dblAbsImg); + _pdblImg = ssqrts(dblAbsImg); + } + else if((dblEpsm * dblAbsImg - 1 >= dblAbsReal)) + { + _pdblReal = dblAbsReal * dblAbsImg; + _pdblImg = sdblLn2 + slogs(dblAbsReal); + } + else if(dblAbsReal > 1) + { + _pdblReal = satans(dblAbsReal / dblAbsImg); + dblTemp = (dblAbsReal / dblAbsImg) * (dblAbsReal / dblAbsImg); + _pdblImg = sdblLn2 + slogs(dblAbsReal) + 0.5f * slog1ps(dblTemp); + } + else + { + float dblTemp2 = ssqrts(1 + dblAbsImg * dblAbsImg); + _pdblReal = dblAbsReal / dblTemp2; + dblTemp = 2.0f * dblAbsImg * (dblAbsImg + dblTemp2); + _pdblImg = 0.5f * slog1ps(dblTemp); + } + } + _pdblReal *= iSignReal; + _pdblImg *= iSignImg; + + return (FloatComplex(_pdblReal, _pdblImg)); +} diff --git a/src/c/elementaryFunctions/asin/zasins.c b/src/c/elementaryFunctions/asin/zasins.c index 5bd586a8..a0042e15 100644 --- a/src/c/elementaryFunctions/asin/zasins.c +++ b/src/c/elementaryFunctions/asin/zasins.c @@ -1,146 +1,146 @@ -/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2007-2008 - INRIA - Bruno JOFRET
- * Copyright (C) Bruno Pincon
- *
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
-
-/*
- * REFERENCE
- * This is a Fortran-77 translation of an algorithm by
- * T.E. Hull, T. F. Fairgrieve and P.T.P. Tang which
- * appears in their article :
- * "Implementing the Complex Arcsine and Arccosine
- * Functions Using Exception Handling", ACM, TOMS,
- * Vol 23, No. 3, Sept 1997, p. 299-335
- * Thanks to Tom Fairgrieve
- */
-
-#include "lapack.h"
-#include "asin.h"
-#include "atan.h"
-#include "sqrt.h"
-#include "abs.h"
-#include "log.h"
-#include "log1p.h"
-#include "min.h"
-#include "max.h"
-
-doubleComplex zasins(doubleComplex z) {
- static double sdblPi_2 = 1.5707963267948966192313216;
- static double sdblLn2 = 0.6931471805599453094172321;
- static double sdblAcross = 1.5;
- static double sdblBcross = 0.6417;
-
- double dblLsup = dsqrts(getOverflowThreshold())/8.0;
- double dblLinf = 4 * dsqrts(getUnderflowThreshold());
- double dblEpsm = dsqrts(getRelativeMachinePrecision());
-
- double _dblReal = zreals(z);
- double _dblImg = zimags(z);
-
- double dblAbsReal = dabss(_dblReal);
- double dblAbsImg = dabss(_dblImg);
- int iSignReal = _dblReal < 0 ? -1 : 1;
- int iSignImg = _dblImg < 0 ? -1 : 1;
-
- double dblR = 0, dblS = 0, dblA = 0, dblB = 0;
-
- double dblTemp = 0;
-
- double _pdblReal = 0;
- double _pdblImg = 0;
-
- if( min(dblAbsReal, dblAbsImg) > dblLinf && max(dblAbsReal, dblAbsImg) <= dblLsup)
- {
- /* we are in the safe region */
- dblR = dsqrts( (dblAbsReal + 1) * (dblAbsReal + 1) + dblAbsImg * dblAbsImg);
- dblS = dsqrts( (dblAbsReal - 1) * (dblAbsReal - 1) + dblAbsImg * dblAbsImg);
- dblA = 0.5 * ( dblR + dblS );
- dblB = dblAbsReal / dblA;
-
-
- /* compute the real part */
- if(dblB <= sdblBcross)
- _pdblReal = dasins(dblB);
- else if( dblAbsReal <= 1)
- _pdblReal = datans(dblAbsReal / dsqrts( 0.5 * (dblA + dblAbsReal) * ( (dblAbsImg * dblAbsImg) / (dblR + (dblAbsReal + 1)) + (dblS + (1 - dblAbsReal)))));
- else
- _pdblReal = datans(dblAbsReal / (dblAbsImg * dsqrts(0.5 * ((dblA + dblAbsReal) / (dblR + (dblAbsReal + 1)) + (dblA + dblAbsReal) / (dblS + (dblAbsReal-1))))));
-
- /* compute the imaginary part */
- if(dblA <= sdblAcross)
- {
- double dblImg1 = 0;
-
- if(dblAbsReal < 1)
- /* Am1 = 0.5d0*((y**2)/(R+(x+1.d0))+(y**2)/(S+(1.d0-x))) */
- dblImg1 = 0.5 * (dblAbsImg * dblAbsImg / (dblR + (dblAbsReal + 1)) + dblAbsImg * dblAbsImg / (dblS + (1 - dblAbsReal)));
- else
- /* Am1 = 0.5d0*((y**2)/(R+(x+1.d0))+(S+(x-1.d0))) */
- dblImg1 = 0.5 * (dblAbsImg * dblAbsImg / (dblR + (dblAbsReal + 1)) + (dblS + (dblAbsReal - 1)));
- /* ai = logp1(Am1 + sqrt(Am1*(A+1.d0))) */
- dblTemp = dblImg1 + dsqrts(dblImg1 * (dblA + 1));
- _pdblImg = dlog1ps(dblTemp);
- }
- else
- /* ai = log(A + sqrt(A**2 - 1.d0)) */
- _pdblImg = dlogs(dblA + dsqrts(dblA * dblA - 1));
- }
- else
- {
- /* evaluation in the special regions ... */
- if(dblAbsImg <= dblEpsm * dabss(dblAbsReal - 1))
- {
- if(dblAbsReal < 1)
- {
- _pdblReal = dasins(dblAbsReal);
- _pdblImg = dblAbsImg / dsqrts((1 + dblAbsReal) * (1 - dblAbsReal));
- }
- else
- {
- _pdblReal = sdblPi_2;
- if(dblAbsReal <= dblLsup)
- {
- dblTemp = (dblAbsReal - 1) + dsqrts((dblAbsReal - 1) * (dblAbsReal + 1));
- _pdblImg = dlog1ps(dblTemp);
- }
- else
- _pdblImg = sdblLn2 + dlogs(dblAbsReal);
- }
- }
- else if(dblAbsImg < dblLinf)
- {
- _pdblReal = sdblPi_2 - dsqrts(dblAbsImg);
- _pdblImg = dsqrts(dblAbsImg);
- }
- else if((dblEpsm * dblAbsImg - 1 >= dblAbsReal))
- {
- _pdblReal = dblAbsReal * dblAbsImg;
- _pdblImg = sdblLn2 + dlogs(dblAbsReal);
- }
- else if(dblAbsReal > 1)
- {
- _pdblReal = datans(dblAbsReal / dblAbsImg);
- dblTemp = (dblAbsReal / dblAbsImg) * (dblAbsReal / dblAbsImg);
- _pdblImg = sdblLn2 + dlogs(dblAbsReal) + 0.5 * dlog1ps(dblTemp);
- }
- else
- {
- double dblTemp2 = dsqrts(1 + dblAbsImg * dblAbsImg);
- _pdblReal = dblAbsReal / dblTemp2;
- dblTemp = 2 * dblAbsImg * (dblAbsImg + dblTemp2);
- _pdblImg = 0.5 * dlog1ps(dblTemp);
- }
- }
- _pdblReal *= iSignReal;
- _pdblImg *= iSignImg;
-
- return (DoubleComplex(_pdblReal, _pdblImg));
-}
+/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2007-2008 - INRIA - Bruno JOFRET + * Copyright (C) Bruno Pincon + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + +/* + * REFERENCE + * This is a Fortran-77 translation of an algorithm by + * T.E. Hull, T. F. Fairgrieve and P.T.P. Tang which + * appears in their article : + * "Implementing the Complex Arcsine and Arccosine + * Functions Using Exception Handling", ACM, TOMS, + * Vol 23, No. 3, Sept 1997, p. 299-335 + * Thanks to Tom Fairgrieve + */ + +#include "lapack.h" +#include "asin.h" +#include "atan.h" +#include "sqrt.h" +#include "abs.h" +#include "log.h" +#include "log1p.h" +#include "min.h" +#include "max.h" + +doubleComplex zasins(doubleComplex z) { + static double sdblPi_2 = 1.5707963267948966192313216; + static double sdblLn2 = 0.6931471805599453094172321; + static double sdblAcross = 1.5; + static double sdblBcross = 0.6417; + + double dblLsup = dsqrts(getOverflowThreshold())/8.0; + double dblLinf = 4 * dsqrts(getUnderflowThreshold()); + double dblEpsm = dsqrts(getRelativeMachinePrecision()); + + double _dblReal = zreals(z); + double _dblImg = zimags(z); + + double dblAbsReal = dabss(_dblReal); + double dblAbsImg = dabss(_dblImg); + int iSignReal = _dblReal < 0 ? -1 : 1; + int iSignImg = _dblImg < 0 ? -1 : 1; + + double dblR = 0, dblS = 0, dblA = 0, dblB = 0; + + double dblTemp = 0; + + double _pdblReal = 0; + double _pdblImg = 0; + + if( min(dblAbsReal, dblAbsImg) > dblLinf && max(dblAbsReal, dblAbsImg) <= dblLsup) + { + /* we are in the safe region */ + dblR = dsqrts( (dblAbsReal + 1) * (dblAbsReal + 1) + dblAbsImg * dblAbsImg); + dblS = dsqrts( (dblAbsReal - 1) * (dblAbsReal - 1) + dblAbsImg * dblAbsImg); + dblA = 0.5 * ( dblR + dblS ); + dblB = dblAbsReal / dblA; + + + /* compute the real part */ + if(dblB <= sdblBcross) + _pdblReal = dasins(dblB); + else if( dblAbsReal <= 1) + _pdblReal = datans(dblAbsReal / dsqrts( 0.5 * (dblA + dblAbsReal) * ( (dblAbsImg * dblAbsImg) / (dblR + (dblAbsReal + 1)) + (dblS + (1 - dblAbsReal))))); + else + _pdblReal = datans(dblAbsReal / (dblAbsImg * dsqrts(0.5 * ((dblA + dblAbsReal) / (dblR + (dblAbsReal + 1)) + (dblA + dblAbsReal) / (dblS + (dblAbsReal-1)))))); + + /* compute the imaginary part */ + if(dblA <= sdblAcross) + { + double dblImg1 = 0; + + if(dblAbsReal < 1) + /* Am1 = 0.5d0*((y**2)/(R+(x+1.d0))+(y**2)/(S+(1.d0-x))) */ + dblImg1 = 0.5 * (dblAbsImg * dblAbsImg / (dblR + (dblAbsReal + 1)) + dblAbsImg * dblAbsImg / (dblS + (1 - dblAbsReal))); + else + /* Am1 = 0.5d0*((y**2)/(R+(x+1.d0))+(S+(x-1.d0))) */ + dblImg1 = 0.5 * (dblAbsImg * dblAbsImg / (dblR + (dblAbsReal + 1)) + (dblS + (dblAbsReal - 1))); + /* ai = logp1(Am1 + sqrt(Am1*(A+1.d0))) */ + dblTemp = dblImg1 + dsqrts(dblImg1 * (dblA + 1)); + _pdblImg = dlog1ps(dblTemp); + } + else + /* ai = log(A + sqrt(A**2 - 1.d0)) */ + _pdblImg = dlogs(dblA + dsqrts(dblA * dblA - 1)); + } + else + { + /* evaluation in the special regions ... */ + if(dblAbsImg <= dblEpsm * dabss(dblAbsReal - 1)) + { + if(dblAbsReal < 1) + { + _pdblReal = dasins(dblAbsReal); + _pdblImg = dblAbsImg / dsqrts((1 + dblAbsReal) * (1 - dblAbsReal)); + } + else + { + _pdblReal = sdblPi_2; + if(dblAbsReal <= dblLsup) + { + dblTemp = (dblAbsReal - 1) + dsqrts((dblAbsReal - 1) * (dblAbsReal + 1)); + _pdblImg = dlog1ps(dblTemp); + } + else + _pdblImg = sdblLn2 + dlogs(dblAbsReal); + } + } + else if(dblAbsImg < dblLinf) + { + _pdblReal = sdblPi_2 - dsqrts(dblAbsImg); + _pdblImg = dsqrts(dblAbsImg); + } + else if((dblEpsm * dblAbsImg - 1 >= dblAbsReal)) + { + _pdblReal = dblAbsReal * dblAbsImg; + _pdblImg = sdblLn2 + dlogs(dblAbsReal); + } + else if(dblAbsReal > 1) + { + _pdblReal = datans(dblAbsReal / dblAbsImg); + dblTemp = (dblAbsReal / dblAbsImg) * (dblAbsReal / dblAbsImg); + _pdblImg = sdblLn2 + dlogs(dblAbsReal) + 0.5 * dlog1ps(dblTemp); + } + else + { + double dblTemp2 = dsqrts(1 + dblAbsImg * dblAbsImg); + _pdblReal = dblAbsReal / dblTemp2; + dblTemp = 2 * dblAbsImg * (dblAbsImg + dblTemp2); + _pdblImg = 0.5 * dlog1ps(dblTemp); + } + } + _pdblReal *= iSignReal; + _pdblImg *= iSignImg; + + return (DoubleComplex(_pdblReal, _pdblImg)); +} diff --git a/src/c/elementaryFunctions/atan/catans.c b/src/c/elementaryFunctions/atan/catans.c index d2081181..50694c45 100644 --- a/src/c/elementaryFunctions/atan/catans.c +++ b/src/c/elementaryFunctions/atan/catans.c @@ -1,249 +1,249 @@ -/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2006-2008 - INRIA - Bruno JOFRET
- * Copyright (C) Bruno Pincon
- *
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
-
-/*
- PURPOSE
- watan compute the arctangent of a complex number
- y = yr + i yi = atan(x), x = xr + i xi
-
- CALLING LIST / PARAMETERS
- subroutine watan(xr,xi,yr,yi)
- double precision xr,xi,yr,yi
-
- xr,xi: real and imaginary parts of the complex number
- yr,yi: real and imaginary parts of the result
- yr,yi may have the same memory cases than xr et xi
-
- COPYRIGHT (C) 2001 Bruno Pincon and Lydia van Dijk
- Written by Bruno Pincon <Bruno.Pincon@iecn.u-nancy.fr> so
- as to get more precision. Also to fix the
- behavior at the singular points and at the branch cuts.
- Polished by Lydia van Dijk
- <lvandijk@hammersmith-consulting.com>
-
- CHANGES : - (Bruno on 2001 May 22) for ysptrk use a
- minimax polynome to enlarge the special
- evaluation zone |s| < SLIM. Also rename
- this function as lnp1m1.
- - (Bruno on 2001 June 7) better handling
- of spurious over/underflow ; remove
- the call to pythag ; better accuracy
- in the real part for z near +-i
-
- EXTERNALS FUNCTIONS
- dlamch
- lnp1m1 (at the end of this file)
-
- ALGORITHM : noting z = a + i*b, we have:
- Z = yr + yi*b = arctan(z) = (i/2) * log( (i+z)/(i-z) )
-
- This function has two branch points at +i and -i and the
- chosen branch cuts are the two half-straight lines
- D1 = [i, i*oo) and D2 = (-i*oo, i]. The function is then
- analytic in C \ (D1 U D2)).
-
- From the definition it follows that:
-
- yr = 0.5 Arg ( (i+z)/(i-z) ) (1)
- yi = 0.5 log (|(i+z)/(i-z)|) (2)
-
- so lim (z -> +- i) yr = undefined (and Nan is logical)
- lim (z -> +i) yi = +oo
- lim (z -> -i) yi = -oo
-
- The real part of arctan(z) is discontinuous across D1 and D2
- and we impose the following definitions:
- if imag(z) > 1 then
- Arg(arctan(z)) = pi/2 (=lim real(z) -> 0+)
- if imag(z) < 1 then
- Arg(arctan(z)) = -pi/2 (=lim real(z) -> 0-)
-
-
- Basic evaluation: if we write (i+z)/(i-z) using
- z = a + i*b, we get:
-
- i+z 1-(a**2+b**2) + i*(2a)
- --- = ----------------------
- i-z a**2 + (1-b)**2
-
- then, with r2 = |z|^2 = a**2 + b**2 :
-
- yr = 0.5 * Arg(1-r2 + (2*a)*i)
- = 0.5 * atan2(2a, (1-r2)) (3)
-
- This formula is changed when r2 > RMAX (max pos float)
- and also when |1-r2| and |a| are near 0 (see comments
- in the code).
-
- After some math:
-
- yi = 0.25 * log( (a**2 + (b + 1)**2) /
- (a**2 + (b - 1)**2) ) (4)
-
- Evaluation for "big" |z|
- ------------------------
-
- If |z| is "big", the direct evaluation of yi by (4) may
- suffer of innaccuracies and of spurious overflow. Noting
- that s = 2 b / (1 + |z|**2), we have:
-
- yi = 0.25 log ( (1 + s)/(1 - s) ) (5)
-
- 3 5
- yi = 0.25*( 2 * ( s + 1/3 s + 1/5 s + ... ))
-
- yi = 0.25 * lnp1m1(s) if |s| < SLIM
-
- So if |s| is less than SLIM we switch to a special
- evaluation done by the function lnp1m1. The
- threshold value SLIM is choosen by experiment
- (with the Pari-gp software). For |s|
- "very small" we used a truncated taylor dvp,
- else a minimax polynome (see lnp1m1).
-
- To avoid spurious overflows (which result in spurious
- underflows for s) in computing s with s= 2 b / (1 + |z|**2)
- when |z|^2 > RMAX (max positive float) we use :
-
- s = 2d0 / ( (a/b)*a + b )
-
- but if |b| = Inf this formula leads to NaN when
- |a| is also Inf. As we have :
-
- |s| <= 2 / |b|
-
- we impose simply : s = 0 when |b| = Inf
-
- Evaluation for z very near to i or -i:
- --------------------------------------
- Floating point numbers of the form a+i or a-i with 0 <
- a**2 < tiny (approximately 1d-308) may lead to underflow
- (i.e., a**2 = 0) and the logarithm will break formula (4).
- So we switch to the following formulas:
-
- If b = +-1 and |a| < sqrt(tiny) approximately 1d-150 (say)
- then (by using that a**2 + 4 = 4 in machine for such a):
-
- yi = 0.5 * log( 2/|a| ) for b=1
-
- yi = 0.5 * log( |a|/2 ) for b=-1
-
- finally: yi = 0.5 * sign(b) * log( 2/|a| )
- yi = 0.5 * sign(b) * (log(2) - log(|a|)) (6)
-
- The last trick is to avoid overflow for |a|=tiny! In fact
- this formula may be used until a**2 + 4 = 4 so that the
- threshold value may be larger.
-*/
-
-#include <math.h>
-#include "atan.h"
-#include "abs.h"
-#include "lnp1m1.h"
-#include "lapack.h"
-
-#define _sign(a, b) b >=0 ? a : -a
-
-floatComplex catans(floatComplex z) {
- static float sSlim = 0.2f;
- /* .
- ** / \ WARNING : this algorithm was based on double precision
- ** / ! \ using float truncate the value to 0.
- ** `----'
- **
- ** static float sAlim = 1E-150f;
- */
- static float sAlim = 0.0f;
- static float sTol = 0.3f;
- static float sLn2 = 0.6931471805599453094172321f;
-
- float RMax = (float) getOverflowThreshold();
- float Pi_2 = 2.0f * satans(1);
-
- float _inReal = creals(z);
- float _inImg = cimags(z);
- float _outReal = 0;
- float _outImg = 0;
-
- /* Temporary variables */
- float R2 = 0;
- float S = 0;
-
-
- if(_inImg == 0)
- {
- _outReal = satans(_inReal);
- _outImg = 0;
- }
- else
- {
- R2 = _inReal * _inReal + _inImg * _inImg; /* Oo */
- if(R2 > RMax)
- {
- if( dabss(_inImg) > RMax)
- S = 0;
- else
- S = 1.0f / (((0.5f * _inReal) / _inImg) * _inReal + 0.5f * _inImg );
- }
- else
- S = (2 * _inImg) / (1+R2);
-
- if(dabss(S) < sSlim)
- {
- /*
- s is small: |s| < SLIM <=> |z| outside the following disks:
- D+ = D(center = [0; 1/slim], radius = sqrt(1/slim**2 - 1)) if b > 0
- D- = D(center = [0; -1/slim], radius = sqrt(1/slim**2 - 1)) if b < 0
- use the special evaluation of log((1+s)/(1-s)) (5)
- */
- _outImg = slnp1m1s(S) * 0.25f;
- }
- else
- {
- if(sabss(S) == 1 && sabss(_inReal) <= sAlim)
- {
- /* |s| >= SLIM => |z| is inside D+ or D- */
- _outImg = _sign(0.5f,_inImg) * ( sLn2 - logf(sabss(_inReal)));
- }
- else
- {
- _outImg = 0.25f * logf((powf(_inReal,2) + powf((_inImg + 1.0f),2)) / (powf(_inReal,2) + powf((_inImg - 1.0f),2)));
- }
- }
- if(_inReal == 0)
- {/* z is purely imaginary */
- if( dabss(_inImg) > 1)
- {/* got sign(b) * pi/2 */
- _outReal = _sign(1, _inImg) * Pi_2;
- }
- else if( dabss(_inImg) == 1)
- {/* got a Nan with 0/0 */
- _outReal = (_inReal - _inReal) / (_inReal - _inReal); /* Oo */
- }
- else
- _outReal = 0;
- }
- else if(R2 > RMax)
- {/* _outImg is necessarily very near sign(a)* pi/2 */
- _outReal = _sign(1, _inReal) * Pi_2;
- }
- else if(sabss(1 - R2) + sabss(_inReal) <= sTol)
- {/* |b| is very near 1 (and a is near 0) some cancellation occur in the (next) generic formula */
- _outReal = 0.5f * atan2f(2.0f * _inReal, (1.0f - _inImg) * (1.0f + _inImg) - powf(_inReal,2.0f));
- }
- else
- _outReal = 0.5f * atan2f(2.0f * _inReal, 1.0f - R2);
- }
-
- return FloatComplex(_outReal, _outImg);
-}
+/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2006-2008 - INRIA - Bruno JOFRET + * Copyright (C) Bruno Pincon + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + +/* + PURPOSE + watan compute the arctangent of a complex number + y = yr + i yi = atan(x), x = xr + i xi + + CALLING LIST / PARAMETERS + subroutine watan(xr,xi,yr,yi) + double precision xr,xi,yr,yi + + xr,xi: real and imaginary parts of the complex number + yr,yi: real and imaginary parts of the result + yr,yi may have the same memory cases than xr et xi + + COPYRIGHT (C) 2001 Bruno Pincon and Lydia van Dijk + Written by Bruno Pincon <Bruno.Pincon@iecn.u-nancy.fr> so + as to get more precision. Also to fix the + behavior at the singular points and at the branch cuts. + Polished by Lydia van Dijk + <lvandijk@hammersmith-consulting.com> + + CHANGES : - (Bruno on 2001 May 22) for ysptrk use a + minimax polynome to enlarge the special + evaluation zone |s| < SLIM. Also rename + this function as lnp1m1. + - (Bruno on 2001 June 7) better handling + of spurious over/underflow ; remove + the call to pythag ; better accuracy + in the real part for z near +-i + + EXTERNALS FUNCTIONS + dlamch + lnp1m1 (at the end of this file) + + ALGORITHM : noting z = a + i*b, we have: + Z = yr + yi*b = arctan(z) = (i/2) * log( (i+z)/(i-z) ) + + This function has two branch points at +i and -i and the + chosen branch cuts are the two half-straight lines + D1 = [i, i*oo) and D2 = (-i*oo, i]. The function is then + analytic in C \ (D1 U D2)). + + From the definition it follows that: + + yr = 0.5 Arg ( (i+z)/(i-z) ) (1) + yi = 0.5 log (|(i+z)/(i-z)|) (2) + + so lim (z -> +- i) yr = undefined (and Nan is logical) + lim (z -> +i) yi = +oo + lim (z -> -i) yi = -oo + + The real part of arctan(z) is discontinuous across D1 and D2 + and we impose the following definitions: + if imag(z) > 1 then + Arg(arctan(z)) = pi/2 (=lim real(z) -> 0+) + if imag(z) < 1 then + Arg(arctan(z)) = -pi/2 (=lim real(z) -> 0-) + + + Basic evaluation: if we write (i+z)/(i-z) using + z = a + i*b, we get: + + i+z 1-(a**2+b**2) + i*(2a) + --- = ---------------------- + i-z a**2 + (1-b)**2 + + then, with r2 = |z|^2 = a**2 + b**2 : + + yr = 0.5 * Arg(1-r2 + (2*a)*i) + = 0.5 * atan2(2a, (1-r2)) (3) + + This formula is changed when r2 > RMAX (max pos float) + and also when |1-r2| and |a| are near 0 (see comments + in the code). + + After some math: + + yi = 0.25 * log( (a**2 + (b + 1)**2) / + (a**2 + (b - 1)**2) ) (4) + + Evaluation for "big" |z| + ------------------------ + + If |z| is "big", the direct evaluation of yi by (4) may + suffer of innaccuracies and of spurious overflow. Noting + that s = 2 b / (1 + |z|**2), we have: + + yi = 0.25 log ( (1 + s)/(1 - s) ) (5) + + 3 5 + yi = 0.25*( 2 * ( s + 1/3 s + 1/5 s + ... )) + + yi = 0.25 * lnp1m1(s) if |s| < SLIM + + So if |s| is less than SLIM we switch to a special + evaluation done by the function lnp1m1. The + threshold value SLIM is choosen by experiment + (with the Pari-gp software). For |s| + "very small" we used a truncated taylor dvp, + else a minimax polynome (see lnp1m1). + + To avoid spurious overflows (which result in spurious + underflows for s) in computing s with s= 2 b / (1 + |z|**2) + when |z|^2 > RMAX (max positive float) we use : + + s = 2d0 / ( (a/b)*a + b ) + + but if |b| = Inf this formula leads to NaN when + |a| is also Inf. As we have : + + |s| <= 2 / |b| + + we impose simply : s = 0 when |b| = Inf + + Evaluation for z very near to i or -i: + -------------------------------------- + Floating point numbers of the form a+i or a-i with 0 < + a**2 < tiny (approximately 1d-308) may lead to underflow + (i.e., a**2 = 0) and the logarithm will break formula (4). + So we switch to the following formulas: + + If b = +-1 and |a| < sqrt(tiny) approximately 1d-150 (say) + then (by using that a**2 + 4 = 4 in machine for such a): + + yi = 0.5 * log( 2/|a| ) for b=1 + + yi = 0.5 * log( |a|/2 ) for b=-1 + + finally: yi = 0.5 * sign(b) * log( 2/|a| ) + yi = 0.5 * sign(b) * (log(2) - log(|a|)) (6) + + The last trick is to avoid overflow for |a|=tiny! In fact + this formula may be used until a**2 + 4 = 4 so that the + threshold value may be larger. +*/ + +#include <math.h> +#include "atan.h" +#include "abs.h" +#include "lnp1m1.h" +#include "lapack.h" + +#define _sign(a, b) b >=0 ? a : -a + +floatComplex catans(floatComplex z) { + static float sSlim = 0.2f; + /* . + ** / \ WARNING : this algorithm was based on double precision + ** / ! \ using float truncate the value to 0. + ** `----' + ** + ** static float sAlim = 1E-150f; + */ + static float sAlim = 0.0f; + static float sTol = 0.3f; + static float sLn2 = 0.6931471805599453094172321f; + + float RMax = (float) getOverflowThreshold(); + float Pi_2 = 2.0f * satans(1); + + float _inReal = creals(z); + float _inImg = cimags(z); + float _outReal = 0; + float _outImg = 0; + + /* Temporary variables */ + float R2 = 0; + float S = 0; + + + if(_inImg == 0) + { + _outReal = satans(_inReal); + _outImg = 0; + } + else + { + R2 = _inReal * _inReal + _inImg * _inImg; /* Oo */ + if(R2 > RMax) + { + if( dabss(_inImg) > RMax) + S = 0; + else + S = 1.0f / (((0.5f * _inReal) / _inImg) * _inReal + 0.5f * _inImg ); + } + else + S = (2 * _inImg) / (1+R2); + + if(dabss(S) < sSlim) + { + /* + s is small: |s| < SLIM <=> |z| outside the following disks: + D+ = D(center = [0; 1/slim], radius = sqrt(1/slim**2 - 1)) if b > 0 + D- = D(center = [0; -1/slim], radius = sqrt(1/slim**2 - 1)) if b < 0 + use the special evaluation of log((1+s)/(1-s)) (5) + */ + _outImg = slnp1m1s(S) * 0.25f; + } + else + { + if(sabss(S) == 1 && sabss(_inReal) <= sAlim) + { + /* |s| >= SLIM => |z| is inside D+ or D- */ + _outImg = _sign(0.5f,_inImg) * ( sLn2 - logf(sabss(_inReal))); + } + else + { + _outImg = 0.25f * logf((powf(_inReal,2) + powf((_inImg + 1.0f),2)) / (powf(_inReal,2) + powf((_inImg - 1.0f),2))); + } + } + if(_inReal == 0) + {/* z is purely imaginary */ + if( dabss(_inImg) > 1) + {/* got sign(b) * pi/2 */ + _outReal = _sign(1, _inImg) * Pi_2; + } + else if( dabss(_inImg) == 1) + {/* got a Nan with 0/0 */ + _outReal = (_inReal - _inReal) / (_inReal - _inReal); /* Oo */ + } + else + _outReal = 0; + } + else if(R2 > RMax) + {/* _outImg is necessarily very near sign(a)* pi/2 */ + _outReal = _sign(1, _inReal) * Pi_2; + } + else if(sabss(1 - R2) + sabss(_inReal) <= sTol) + {/* |b| is very near 1 (and a is near 0) some cancellation occur in the (next) generic formula */ + _outReal = 0.5f * atan2f(2.0f * _inReal, (1.0f - _inImg) * (1.0f + _inImg) - powf(_inReal,2.0f)); + } + else + _outReal = 0.5f * atan2f(2.0f * _inReal, 1.0f - R2); + } + + return FloatComplex(_outReal, _outImg); +} diff --git a/src/c/elementaryFunctions/atan/zatans.c b/src/c/elementaryFunctions/atan/zatans.c index 4b8e9640..ab1354f7 100644 --- a/src/c/elementaryFunctions/atan/zatans.c +++ b/src/c/elementaryFunctions/atan/zatans.c @@ -1,242 +1,242 @@ -/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2006-2008 - INRIA - Bruno JOFRET
- * Copyright (C) Bruno Pincon
- *
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
-
-/*
- PURPOSE
- watan compute the arctangent of a complex number
- y = yr + i yi = atan(x), x = xr + i xi
-
- CALLING LIST / PARAMETERS
- subroutine watan(xr,xi,yr,yi)
- double precision xr,xi,yr,yi
-
- xr,xi: real and imaginary parts of the complex number
- yr,yi: real and imaginary parts of the result
- yr,yi may have the same memory cases than xr et xi
-
- COPYRIGHT (C) 2001 Bruno Pincon and Lydia van Dijk
- Written by Bruno Pincon <Bruno.Pincon@iecn.u-nancy.fr> so
- as to get more precision. Also to fix the
- behavior at the singular points and at the branch cuts.
- Polished by Lydia van Dijk
- <lvandijk@hammersmith-consulting.com>
-
- CHANGES : - (Bruno on 2001 May 22) for ysptrk use a
- minimax polynome to enlarge the special
- evaluation zone |s| < SLIM. Also rename
- this function as lnp1m1.
- - (Bruno on 2001 June 7) better handling
- of spurious over/underflow ; remove
- the call to pythag ; better accuracy
- in the real part for z near +-i
-
- EXTERNALS FUNCTIONS
- dlamch
- lnp1m1 (at the end of this file)
-
- ALGORITHM : noting z = a + i*b, we have:
- Z = yr + yi*b = arctan(z) = (i/2) * log( (i+z)/(i-z) )
-
- This function has two branch points at +i and -i and the
- chosen branch cuts are the two half-straight lines
- D1 = [i, i*oo) and D2 = (-i*oo, i]. The function is then
- analytic in C \ (D1 U D2)).
-
- From the definition it follows that:
-
- yr = 0.5 Arg ( (i+z)/(i-z) ) (1)
- yi = 0.5 log (|(i+z)/(i-z)|) (2)
-
- so lim (z -> +- i) yr = undefined (and Nan is logical)
- lim (z -> +i) yi = +oo
- lim (z -> -i) yi = -oo
-
- The real part of arctan(z) is discontinuous across D1 and D2
- and we impose the following definitions:
- if imag(z) > 1 then
- Arg(arctan(z)) = pi/2 (=lim real(z) -> 0+)
- if imag(z) < 1 then
- Arg(arctan(z)) = -pi/2 (=lim real(z) -> 0-)
-
-
- Basic evaluation: if we write (i+z)/(i-z) using
- z = a + i*b, we get:
-
- i+z 1-(a**2+b**2) + i*(2a)
- --- = ----------------------
- i-z a**2 + (1-b)**2
-
- then, with r2 = |z|^2 = a**2 + b**2 :
-
- yr = 0.5 * Arg(1-r2 + (2*a)*i)
- = 0.5 * atan2(2a, (1-r2)) (3)
-
- This formula is changed when r2 > RMAX (max pos float)
- and also when |1-r2| and |a| are near 0 (see comments
- in the code).
-
- After some math:
-
- yi = 0.25 * log( (a**2 + (b + 1)**2) /
- (a**2 + (b - 1)**2) ) (4)
-
- Evaluation for "big" |z|
- ------------------------
-
- If |z| is "big", the direct evaluation of yi by (4) may
- suffer of innaccuracies and of spurious overflow. Noting
- that s = 2 b / (1 + |z|**2), we have:
-
- yi = 0.25 log ( (1 + s)/(1 - s) ) (5)
-
- 3 5
- yi = 0.25*( 2 * ( s + 1/3 s + 1/5 s + ... ))
-
- yi = 0.25 * lnp1m1(s) if |s| < SLIM
-
- So if |s| is less than SLIM we switch to a special
- evaluation done by the function lnp1m1. The
- threshold value SLIM is choosen by experiment
- (with the Pari-gp software). For |s|
- "very small" we used a truncated taylor dvp,
- else a minimax polynome (see lnp1m1).
-
- To avoid spurious overflows (which result in spurious
- underflows for s) in computing s with s= 2 b / (1 + |z|**2)
- when |z|^2 > RMAX (max positive float) we use :
-
- s = 2d0 / ( (a/b)*a + b )
-
- but if |b| = Inf this formula leads to NaN when
- |a| is also Inf. As we have :
-
- |s| <= 2 / |b|
-
- we impose simply : s = 0 when |b| = Inf
-
- Evaluation for z very near to i or -i:
- --------------------------------------
- Floating point numbers of the form a+i or a-i with 0 <
- a**2 < tiny (approximately 1d-308) may lead to underflow
- (i.e., a**2 = 0) and the logarithm will break formula (4).
- So we switch to the following formulas:
-
- If b = +-1 and |a| < sqrt(tiny) approximately 1d-150 (say)
- then (by using that a**2 + 4 = 4 in machine for such a):
-
- yi = 0.5 * log( 2/|a| ) for b=1
-
- yi = 0.5 * log( |a|/2 ) for b=-1
-
- finally: yi = 0.5 * sign(b) * log( 2/|a| )
- yi = 0.5 * sign(b) * (log(2) - log(|a|)) (6)
-
- The last trick is to avoid overflow for |a|=tiny! In fact
- this formula may be used until a**2 + 4 = 4 so that the
- threshold value may be larger.
-*/
-
-#include <math.h>
-#include "lapack.h"
-#include "atan.h"
-#include "abs.h"
-#include "lnp1m1.h"
-
-#define _sign(a, b) b >=0 ? a : -a
-
-doubleComplex zatans(doubleComplex z) {
- static double sSlim = 0.2;
- static double sAlim = 1E-150;
- static double sTol = 0.3;
- static double sLn2 = 0.6931471805599453094172321;
-
- double RMax = getOverflowThreshold();
- double Pi_2 = 2.0 * datans(1);
-
- double _inReal = zreals(z);
- double _inImg = zimags(z);
- double _outReal = 0;
- double _outImg = 0;
-
- /* Temporary variables */
- double R2 = 0;
- double S = 0;
-
-
- if(_inImg == 0)
- {
- _outReal = datans(_inReal);
- _outImg = 0;
- }
- else
- {
- R2 = _inReal * _inReal + _inImg * _inImg; /* Oo */
- if(R2 > RMax)
- {
- if( dabss(_inImg) > RMax)
- S = 0;
- else
- S = 1 / (((0.5 * _inReal) / _inImg) * _inReal + 0.5 * _inImg );
- }
- else
- S = (2 * _inImg) / (1+R2);
-
- if(dabss(S) < sSlim)
- {
- /*
- s is small: |s| < SLIM <=> |z| outside the following disks:
- D+ = D(center = [0; 1/slim], radius = sqrt(1/slim**2 - 1)) if b > 0
- D- = D(center = [0; -1/slim], radius = sqrt(1/slim**2 - 1)) if b < 0
- use the special evaluation of log((1+s)/(1-s)) (5)
- */
- _outImg = dlnp1m1s(S) * 0.25;
- }
- else
- {
- if(dabss(S) == 1 && dabss(_inReal) <= sAlim)
- {
- /* |s| >= SLIM => |z| is inside D+ or D- */
- _outImg = _sign(0.5,_inImg) * ( sLn2 - log(dabss(_inReal)));
- }
- else
- {
- _outImg = 0.25 * log((pow(_inReal,2) + pow((_inImg + 1),2)) / (pow(_inReal,2) + pow((_inImg - 1),2)));
- }
- }
- if(_inReal == 0)
- {/* z is purely imaginary */
- if( dabss(_inImg) > 1)
- {/* got sign(b) * pi/2 */
- _outReal = _sign(1, _inImg) * Pi_2;
- }
- else if( dabss(_inImg) == 1)
- {/* got a Nan with 0/0 */
- _outReal = (_inReal - _inReal) / (_inReal - _inReal); /* Oo */
- }
- else
- _outReal = 0;
- }
- else if(R2 > RMax)
- {/* _outImg is necessarily very near sign(a)* pi/2 */
- _outReal = _sign(1, _inReal) * Pi_2;
- }
- else if(dabss(1 - R2) + dabss(_inReal) <= sTol)
- {/* |b| is very near 1 (and a is near 0) some cancellation occur in the (next) generic formula */
- _outReal = 0.5 * atan2(2 * _inReal, (1-_inImg) * (1 + _inImg) - pow(_inReal,2));
- }
- else
- _outReal = 0.5 * atan2(2 * _inReal, 1 - R2);
- }
-
- return DoubleComplex(_outReal, _outImg);
-}
+/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2006-2008 - INRIA - Bruno JOFRET + * Copyright (C) Bruno Pincon + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + +/* + PURPOSE + watan compute the arctangent of a complex number + y = yr + i yi = atan(x), x = xr + i xi + + CALLING LIST / PARAMETERS + subroutine watan(xr,xi,yr,yi) + double precision xr,xi,yr,yi + + xr,xi: real and imaginary parts of the complex number + yr,yi: real and imaginary parts of the result + yr,yi may have the same memory cases than xr et xi + + COPYRIGHT (C) 2001 Bruno Pincon and Lydia van Dijk + Written by Bruno Pincon <Bruno.Pincon@iecn.u-nancy.fr> so + as to get more precision. Also to fix the + behavior at the singular points and at the branch cuts. + Polished by Lydia van Dijk + <lvandijk@hammersmith-consulting.com> + + CHANGES : - (Bruno on 2001 May 22) for ysptrk use a + minimax polynome to enlarge the special + evaluation zone |s| < SLIM. Also rename + this function as lnp1m1. + - (Bruno on 2001 June 7) better handling + of spurious over/underflow ; remove + the call to pythag ; better accuracy + in the real part for z near +-i + + EXTERNALS FUNCTIONS + dlamch + lnp1m1 (at the end of this file) + + ALGORITHM : noting z = a + i*b, we have: + Z = yr + yi*b = arctan(z) = (i/2) * log( (i+z)/(i-z) ) + + This function has two branch points at +i and -i and the + chosen branch cuts are the two half-straight lines + D1 = [i, i*oo) and D2 = (-i*oo, i]. The function is then + analytic in C \ (D1 U D2)). + + From the definition it follows that: + + yr = 0.5 Arg ( (i+z)/(i-z) ) (1) + yi = 0.5 log (|(i+z)/(i-z)|) (2) + + so lim (z -> +- i) yr = undefined (and Nan is logical) + lim (z -> +i) yi = +oo + lim (z -> -i) yi = -oo + + The real part of arctan(z) is discontinuous across D1 and D2 + and we impose the following definitions: + if imag(z) > 1 then + Arg(arctan(z)) = pi/2 (=lim real(z) -> 0+) + if imag(z) < 1 then + Arg(arctan(z)) = -pi/2 (=lim real(z) -> 0-) + + + Basic evaluation: if we write (i+z)/(i-z) using + z = a + i*b, we get: + + i+z 1-(a**2+b**2) + i*(2a) + --- = ---------------------- + i-z a**2 + (1-b)**2 + + then, with r2 = |z|^2 = a**2 + b**2 : + + yr = 0.5 * Arg(1-r2 + (2*a)*i) + = 0.5 * atan2(2a, (1-r2)) (3) + + This formula is changed when r2 > RMAX (max pos float) + and also when |1-r2| and |a| are near 0 (see comments + in the code). + + After some math: + + yi = 0.25 * log( (a**2 + (b + 1)**2) / + (a**2 + (b - 1)**2) ) (4) + + Evaluation for "big" |z| + ------------------------ + + If |z| is "big", the direct evaluation of yi by (4) may + suffer of innaccuracies and of spurious overflow. Noting + that s = 2 b / (1 + |z|**2), we have: + + yi = 0.25 log ( (1 + s)/(1 - s) ) (5) + + 3 5 + yi = 0.25*( 2 * ( s + 1/3 s + 1/5 s + ... )) + + yi = 0.25 * lnp1m1(s) if |s| < SLIM + + So if |s| is less than SLIM we switch to a special + evaluation done by the function lnp1m1. The + threshold value SLIM is choosen by experiment + (with the Pari-gp software). For |s| + "very small" we used a truncated taylor dvp, + else a minimax polynome (see lnp1m1). + + To avoid spurious overflows (which result in spurious + underflows for s) in computing s with s= 2 b / (1 + |z|**2) + when |z|^2 > RMAX (max positive float) we use : + + s = 2d0 / ( (a/b)*a + b ) + + but if |b| = Inf this formula leads to NaN when + |a| is also Inf. As we have : + + |s| <= 2 / |b| + + we impose simply : s = 0 when |b| = Inf + + Evaluation for z very near to i or -i: + -------------------------------------- + Floating point numbers of the form a+i or a-i with 0 < + a**2 < tiny (approximately 1d-308) may lead to underflow + (i.e., a**2 = 0) and the logarithm will break formula (4). + So we switch to the following formulas: + + If b = +-1 and |a| < sqrt(tiny) approximately 1d-150 (say) + then (by using that a**2 + 4 = 4 in machine for such a): + + yi = 0.5 * log( 2/|a| ) for b=1 + + yi = 0.5 * log( |a|/2 ) for b=-1 + + finally: yi = 0.5 * sign(b) * log( 2/|a| ) + yi = 0.5 * sign(b) * (log(2) - log(|a|)) (6) + + The last trick is to avoid overflow for |a|=tiny! In fact + this formula may be used until a**2 + 4 = 4 so that the + threshold value may be larger. +*/ + +#include <math.h> +#include "lapack.h" +#include "atan.h" +#include "abs.h" +#include "lnp1m1.h" + +#define _sign(a, b) b >=0 ? a : -a + +doubleComplex zatans(doubleComplex z) { + static double sSlim = 0.2; + static double sAlim = 1E-150; + static double sTol = 0.3; + static double sLn2 = 0.6931471805599453094172321; + + double RMax = getOverflowThreshold(); + double Pi_2 = 2.0 * datans(1); + + double _inReal = zreals(z); + double _inImg = zimags(z); + double _outReal = 0; + double _outImg = 0; + + /* Temporary variables */ + double R2 = 0; + double S = 0; + + + if(_inImg == 0) + { + _outReal = datans(_inReal); + _outImg = 0; + } + else + { + R2 = _inReal * _inReal + _inImg * _inImg; /* Oo */ + if(R2 > RMax) + { + if( dabss(_inImg) > RMax) + S = 0; + else + S = 1 / (((0.5 * _inReal) / _inImg) * _inReal + 0.5 * _inImg ); + } + else + S = (2 * _inImg) / (1+R2); + + if(dabss(S) < sSlim) + { + /* + s is small: |s| < SLIM <=> |z| outside the following disks: + D+ = D(center = [0; 1/slim], radius = sqrt(1/slim**2 - 1)) if b > 0 + D- = D(center = [0; -1/slim], radius = sqrt(1/slim**2 - 1)) if b < 0 + use the special evaluation of log((1+s)/(1-s)) (5) + */ + _outImg = dlnp1m1s(S) * 0.25; + } + else + { + if(dabss(S) == 1 && dabss(_inReal) <= sAlim) + { + /* |s| >= SLIM => |z| is inside D+ or D- */ + _outImg = _sign(0.5,_inImg) * ( sLn2 - log(dabss(_inReal))); + } + else + { + _outImg = 0.25 * log((pow(_inReal,2) + pow((_inImg + 1),2)) / (pow(_inReal,2) + pow((_inImg - 1),2))); + } + } + if(_inReal == 0) + {/* z is purely imaginary */ + if( dabss(_inImg) > 1) + {/* got sign(b) * pi/2 */ + _outReal = _sign(1, _inImg) * Pi_2; + } + else if( dabss(_inImg) == 1) + {/* got a Nan with 0/0 */ + _outReal = (_inReal - _inReal) / (_inReal - _inReal); /* Oo */ + } + else + _outReal = 0; + } + else if(R2 > RMax) + {/* _outImg is necessarily very near sign(a)* pi/2 */ + _outReal = _sign(1, _inReal) * Pi_2; + } + else if(dabss(1 - R2) + dabss(_inReal) <= sTol) + {/* |b| is very near 1 (and a is near 0) some cancellation occur in the (next) generic formula */ + _outReal = 0.5 * atan2(2 * _inReal, (1-_inImg) * (1 + _inImg) - pow(_inReal,2)); + } + else + _outReal = 0.5 * atan2(2 * _inReal, 1 - R2); + } + + return DoubleComplex(_outReal, _outImg); +} diff --git a/src/c/elementaryFunctions/includes/dynlib_elementaryfunctions.h b/src/c/elementaryFunctions/includes/dynlib_elementaryfunctions.h index 5037696f..f3fed2c3 100644 --- a/src/c/elementaryFunctions/includes/dynlib_elementaryfunctions.h +++ b/src/c/elementaryFunctions/includes/dynlib_elementaryfunctions.h @@ -1,26 +1,26 @@ -/*
-* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-* Copyright (C) 2009 - DIGITEO - Allan CORNET
-*
-* This file must be used under the terms of the CeCILL.
-* This source file is licensed as described in the file COPYING, which
-* you should have received as part of this distribution. The terms
-* are also available at
-* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
-*
-*/
-
-#ifndef __DYNLIB_ELEMENTARYFUNCTIONS_H__
-#define __DYNLIB_ELEMENTARYFUNCTIONS_H__
-
-#if defined(_MSC_VER) && defined(_USRDLL)
- #if ELEMENTARYFUNCTIONS_EXPORTS
- #define EXTERN_ELEMFUNCT __declspec (dllexport)
- #else
- #define EXTERN_ELEMFUNCT __declspec (dllimport)
- #endif
-#else
- #define EXTERN_ELEMFUNCT
-#endif
-
-#endif /* __DYNLIB_ELEMENTARYFUNCTIONS_H__ */
+/* +* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +* Copyright (C) 2009 - DIGITEO - Allan CORNET +* +* This file must be used under the terms of the CeCILL. +* This source file is licensed as described in the file COPYING, which +* you should have received as part of this distribution. The terms +* are also available at +* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +* +*/ + +#ifndef __DYNLIB_ELEMENTARYFUNCTIONS_H__ +#define __DYNLIB_ELEMENTARYFUNCTIONS_H__ + +#if defined(_MSC_VER) && defined(_USRDLL) + #if ELEMENTARYFUNCTIONS_EXPORTS + #define EXTERN_ELEMFUNCT __declspec (dllexport) + #else + #define EXTERN_ELEMFUNCT __declspec (dllimport) + #endif +#else + #define EXTERN_ELEMFUNCT +#endif + +#endif /* __DYNLIB_ELEMENTARYFUNCTIONS_H__ */ diff --git a/src/c/elementaryFunctions/lnp1m1/dlnp1m1s.c b/src/c/elementaryFunctions/lnp1m1/dlnp1m1s.c index 7e1759be..af7ba9d5 100644 --- a/src/c/elementaryFunctions/lnp1m1/dlnp1m1s.c +++ b/src/c/elementaryFunctions/lnp1m1/dlnp1m1s.c @@ -1,77 +1,77 @@ -/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2008-2008 - INRIA - Bruno JOFRET
- * Copyright (C) Bruno Pincon
- *
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
-
-#include "lnp1m1.h"
-#include "abs.h"
-
-/*
- PURPOSE : Compute v = log ( (1 + s)/(1 - s) )
- for small s, this is for |s| < SLIM = 0.20
-
- ALGORITHM :
- 1/ if |s| is "very small" we use a truncated
- taylor dvp (by keeping 3 terms) from :
- 2 4 6
- t = 2 * s * ( 1 + 1/3 s + 1/5 s + [ 1/7 s + ....] )
- 2 4
- t = 2 * s * ( 1 + 1/3 s + 1/5 s + er)
-
- The limit E until we use this formula may be simply
- gotten so that the negliged part er is such that :
- 2 4
- (#) er <= epsm * ( 1 + 1/3 s + 1/5 s ) for all |s|<= E
-
- As er = 1/7 s^6 + 1/9 s^8 + ...
- er <= 1/7 * s^6 ( 1 + s^2 + s^4 + ...) = 1/7 s^6/(1-s^2)
-
- the inequality (#) is forced if :
-
- 1/7 s^6 / (1-s^2) <= epsm * ( 1 + 1/3 s^2 + 1/5 s^4 )
-
- s^6 <= 7 epsm * (1 - 2/3 s^2 - 3/15 s^4 - 1/5 s^6)
-
- So that E is very near (7 epsm)^(1/6) (approximately 3.032d-3):
-
- 2/ For larger |s| we used a minimax polynome :
-
- yi = s * (2 + d3 s^3 + d5 s^5 .... + d13 s^13 + d15 s^15)
-
- This polynome was computed (by some remes algorithm) following
- (*) the sin(x) example (p 39) of the book :
-
- "ELEMENTARY FUNCTIONS"
- "Algorithms and implementation"
- J.M. Muller (Birkhauser)
-
- (*) without the additionnal raffinement to get the first coefs
- very near floating point numbers)
-*/
-double dlnp1m1s(double Var)
-{
- static double D3 = 0.66666666666672679472;
- static double D5 = 0.39999999996176889299;
- static double D7 = 0.28571429392829380980;
- static double D9 = 0.22222138684562683797;
- static double D11 = 0.18186349187499222459;
- static double D13 = 0.15250315884469364710;
- static double D15 = 0.15367270224757008114;
- static double E = 3.032E-3;
- static double C3 = 2.0/3.0;
- static double C5 = 2.0/5.0;
-
- double S2 = Var * Var;
- if( dabss(Var) <= E)
- return Var * (2 + S2 * (C3 + C5 * S2));
- else
- return Var * (2 + S2 * (D3 + S2 * (D5 + S2 * (D7 + S2 * (D9 + S2 * (D11 + S2 * (D13 + S2 * D15)))))));
-}
+/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2008-2008 - INRIA - Bruno JOFRET + * Copyright (C) Bruno Pincon + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + +#include "lnp1m1.h" +#include "abs.h" + +/* + PURPOSE : Compute v = log ( (1 + s)/(1 - s) ) + for small s, this is for |s| < SLIM = 0.20 + + ALGORITHM : + 1/ if |s| is "very small" we use a truncated + taylor dvp (by keeping 3 terms) from : + 2 4 6 + t = 2 * s * ( 1 + 1/3 s + 1/5 s + [ 1/7 s + ....] ) + 2 4 + t = 2 * s * ( 1 + 1/3 s + 1/5 s + er) + + The limit E until we use this formula may be simply + gotten so that the negliged part er is such that : + 2 4 + (#) er <= epsm * ( 1 + 1/3 s + 1/5 s ) for all |s|<= E + + As er = 1/7 s^6 + 1/9 s^8 + ... + er <= 1/7 * s^6 ( 1 + s^2 + s^4 + ...) = 1/7 s^6/(1-s^2) + + the inequality (#) is forced if : + + 1/7 s^6 / (1-s^2) <= epsm * ( 1 + 1/3 s^2 + 1/5 s^4 ) + + s^6 <= 7 epsm * (1 - 2/3 s^2 - 3/15 s^4 - 1/5 s^6) + + So that E is very near (7 epsm)^(1/6) (approximately 3.032d-3): + + 2/ For larger |s| we used a minimax polynome : + + yi = s * (2 + d3 s^3 + d5 s^5 .... + d13 s^13 + d15 s^15) + + This polynome was computed (by some remes algorithm) following + (*) the sin(x) example (p 39) of the book : + + "ELEMENTARY FUNCTIONS" + "Algorithms and implementation" + J.M. Muller (Birkhauser) + + (*) without the additionnal raffinement to get the first coefs + very near floating point numbers) +*/ +double dlnp1m1s(double Var) +{ + static double D3 = 0.66666666666672679472; + static double D5 = 0.39999999996176889299; + static double D7 = 0.28571429392829380980; + static double D9 = 0.22222138684562683797; + static double D11 = 0.18186349187499222459; + static double D13 = 0.15250315884469364710; + static double D15 = 0.15367270224757008114; + static double E = 3.032E-3; + static double C3 = 2.0/3.0; + static double C5 = 2.0/5.0; + + double S2 = Var * Var; + if( dabss(Var) <= E) + return Var * (2 + S2 * (C3 + C5 * S2)); + else + return Var * (2 + S2 * (D3 + S2 * (D5 + S2 * (D7 + S2 * (D9 + S2 * (D11 + S2 * (D13 + S2 * D15))))))); +} diff --git a/src/c/elementaryFunctions/lnp1m1/slnp1m1s.c b/src/c/elementaryFunctions/lnp1m1/slnp1m1s.c index 9940810c..d03badcd 100644 --- a/src/c/elementaryFunctions/lnp1m1/slnp1m1s.c +++ b/src/c/elementaryFunctions/lnp1m1/slnp1m1s.c @@ -1,77 +1,77 @@ -/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2007-2008 - INRIA - Bruno JOFRET
- * Copyright (C) Bruno Pincon
- *
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
-
-#include "lnp1m1.h"
-#include "abs.h"
-
-/*
- PURPOSE : Compute v = log ( (1 + s)/(1 - s) )
- for small s, this is for |s| < SLIM = 0.20
-
- ALGORITHM :
- 1/ if |s| is "very small" we use a truncated
- taylor dvp (by keeping 3 terms) from :
- 2 4 6
- t = 2 * s * ( 1 + 1/3 s + 1/5 s + [ 1/7 s + ....] )
- 2 4
- t = 2 * s * ( 1 + 1/3 s + 1/5 s + er)
-
- The limit E until we use this formula may be simply
- gotten so that the negliged part er is such that :
- 2 4
- (#) er <= epsm * ( 1 + 1/3 s + 1/5 s ) for all |s|<= E
-
- As er = 1/7 s^6 + 1/9 s^8 + ...
- er <= 1/7 * s^6 ( 1 + s^2 + s^4 + ...) = 1/7 s^6/(1-s^2)
-
- the inequality (#) is forced if :
-
- 1/7 s^6 / (1-s^2) <= epsm * ( 1 + 1/3 s^2 + 1/5 s^4 )
-
- s^6 <= 7 epsm * (1 - 2/3 s^2 - 3/15 s^4 - 1/5 s^6)
-
- So that E is very near (7 epsm)^(1/6) (approximately 3.032d-3):
-
- 2/ For larger |s| we used a minimax polynome :
-
- yi = s * (2 + d3 s^3 + d5 s^5 .... + d13 s^13 + d15 s^15)
-
- This polynome was computed (by some remes algorithm) following
- (*) the sin(x) example (p 39) of the book :
-
- "ELEMENTARY FUNCTIONS"
- "Algorithms and implementation"
- J.M. Muller (Birkhauser)
-
- (*) without the additionnal raffinement to get the first coefs
- very near floating point numbers)
-*/
-float slnp1m1s(float Var)
-{
- static float D3 = 0.66666666666672679472f;
- static float D5 = 0.39999999996176889299f;
- static float D7 = 0.28571429392829380980f;
- static float D9 = 0.22222138684562683797f;
- static float D11 = 0.18186349187499222459f;
- static float D13 = 0.15250315884469364710f;
- static float D15 = 0.15367270224757008114f;
- static float E = 3.032E-3f;
- static float C3 = 2.0f/3.0f;
- static float C5 = 2.0f/5.0f;
-
- float S2 = Var * Var;
- if( sabss(Var) <= E)
- return Var * (2 + S2 * (C3 + C5 * S2));
- else
- return Var * (2 + S2 * (D3 + S2 * (D5 + S2 * (D7 + S2 * (D9 + S2 * (D11 + S2 * (D13 + S2 * D15)))))));
-}
+/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2007-2008 - INRIA - Bruno JOFRET + * Copyright (C) Bruno Pincon + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + +#include "lnp1m1.h" +#include "abs.h" + +/* + PURPOSE : Compute v = log ( (1 + s)/(1 - s) ) + for small s, this is for |s| < SLIM = 0.20 + + ALGORITHM : + 1/ if |s| is "very small" we use a truncated + taylor dvp (by keeping 3 terms) from : + 2 4 6 + t = 2 * s * ( 1 + 1/3 s + 1/5 s + [ 1/7 s + ....] ) + 2 4 + t = 2 * s * ( 1 + 1/3 s + 1/5 s + er) + + The limit E until we use this formula may be simply + gotten so that the negliged part er is such that : + 2 4 + (#) er <= epsm * ( 1 + 1/3 s + 1/5 s ) for all |s|<= E + + As er = 1/7 s^6 + 1/9 s^8 + ... + er <= 1/7 * s^6 ( 1 + s^2 + s^4 + ...) = 1/7 s^6/(1-s^2) + + the inequality (#) is forced if : + + 1/7 s^6 / (1-s^2) <= epsm * ( 1 + 1/3 s^2 + 1/5 s^4 ) + + s^6 <= 7 epsm * (1 - 2/3 s^2 - 3/15 s^4 - 1/5 s^6) + + So that E is very near (7 epsm)^(1/6) (approximately 3.032d-3): + + 2/ For larger |s| we used a minimax polynome : + + yi = s * (2 + d3 s^3 + d5 s^5 .... + d13 s^13 + d15 s^15) + + This polynome was computed (by some remes algorithm) following + (*) the sin(x) example (p 39) of the book : + + "ELEMENTARY FUNCTIONS" + "Algorithms and implementation" + J.M. Muller (Birkhauser) + + (*) without the additionnal raffinement to get the first coefs + very near floating point numbers) +*/ +float slnp1m1s(float Var) +{ + static float D3 = 0.66666666666672679472f; + static float D5 = 0.39999999996176889299f; + static float D7 = 0.28571429392829380980f; + static float D9 = 0.22222138684562683797f; + static float D11 = 0.18186349187499222459f; + static float D13 = 0.15250315884469364710f; + static float D15 = 0.15367270224757008114f; + static float E = 3.032E-3f; + static float C3 = 2.0f/3.0f; + static float C5 = 2.0f/5.0f; + + float S2 = Var * Var; + if( sabss(Var) <= E) + return Var * (2 + S2 * (C3 + C5 * S2)); + else + return Var * (2 + S2 * (D3 + S2 * (D5 + S2 * (D7 + S2 * (D9 + S2 * (D11 + S2 * (D13 + S2 * D15))))))); +} diff --git a/src/c/elementaryFunctions/log/clogs.c b/src/c/elementaryFunctions/log/clogs.c index 3b9f6911..c351cf3c 100644 --- a/src/c/elementaryFunctions/log/clogs.c +++ b/src/c/elementaryFunctions/log/clogs.c @@ -1,65 +1,65 @@ -/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2007-2008 - INRIA - Bruno JOFRET
- * Copyright (C) Bruno Pincon
- *
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
-
-#include <math.h>
-#include "log.h"
-#include "lapack.h"
-#include "log1p.h"
-#include "pythag.h"
-
-floatComplex clogs(floatComplex in) {
- static float sR2 = 1.41421356237309504f;
-
- float _RealIn = creals(in);
- float _ImgIn = cimags(in);
-
- float _RealOut = 0;
- float _ImgOut = 0;
-
- float RMax = (float) getOverflowThreshold();
- float LInf = sqrtf((float) getUnderflowThreshold());
- float LSup = sqrtf(0.5f * RMax);
-
- float AbsReal = fabsf(_RealIn);
- float AbsImg = fabsf(_ImgIn);
-
- _ImgOut = atan2f(_ImgIn, _RealIn);
-
- if(_ImgIn > _RealIn)
- {/* switch Real part and Imaginary part */
- float Temp = AbsReal;
- AbsReal = AbsImg;
- AbsImg = Temp;
- }
-
- if((0.5 <= AbsReal) && (AbsReal <= sR2))
- _RealOut = 0.5f * slog1ps((AbsReal - 1.0f) * (AbsReal + 1.0f) + AbsImg * AbsImg);
- else if(LInf < AbsImg && AbsReal < LSup)
- _RealOut = 0.5f * slogs(AbsReal * AbsReal + AbsImg * AbsImg);
- else if(AbsReal > RMax)
- _RealOut = AbsReal;
- else
- {
- float Temp = spythags(AbsReal, AbsImg);
- if(Temp <= RMax)
- {
- _RealOut = slogs(Temp);
- }
- else /* handle rare spurious overflow with : */
- {
- float Temp2 = AbsImg/AbsReal;
- _RealOut = slogs(AbsReal) + 0.5f * slog1ps(Temp2 * Temp2);
- }
- }
- return FloatComplex(_RealOut, _ImgOut);
-}
+/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2007-2008 - INRIA - Bruno JOFRET + * Copyright (C) Bruno Pincon + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + +#include <math.h> +#include "log.h" +#include "lapack.h" +#include "log1p.h" +#include "pythag.h" + +floatComplex clogs(floatComplex in) { + static float sR2 = 1.41421356237309504f; + + float _RealIn = creals(in); + float _ImgIn = cimags(in); + + float _RealOut = 0; + float _ImgOut = 0; + + float RMax = (float) getOverflowThreshold(); + float LInf = sqrtf((float) getUnderflowThreshold()); + float LSup = sqrtf(0.5f * RMax); + + float AbsReal = fabsf(_RealIn); + float AbsImg = fabsf(_ImgIn); + + _ImgOut = atan2f(_ImgIn, _RealIn); + + if(_ImgIn > _RealIn) + {/* switch Real part and Imaginary part */ + float Temp = AbsReal; + AbsReal = AbsImg; + AbsImg = Temp; + } + + if((0.5 <= AbsReal) && (AbsReal <= sR2)) + _RealOut = 0.5f * slog1ps((AbsReal - 1.0f) * (AbsReal + 1.0f) + AbsImg * AbsImg); + else if(LInf < AbsImg && AbsReal < LSup) + _RealOut = 0.5f * slogs(AbsReal * AbsReal + AbsImg * AbsImg); + else if(AbsReal > RMax) + _RealOut = AbsReal; + else + { + float Temp = spythags(AbsReal, AbsImg); + if(Temp <= RMax) + { + _RealOut = slogs(Temp); + } + else /* handle rare spurious overflow with : */ + { + float Temp2 = AbsImg/AbsReal; + _RealOut = slogs(AbsReal) + 0.5f * slog1ps(Temp2 * Temp2); + } + } + return FloatComplex(_RealOut, _ImgOut); +} diff --git a/src/c/elementaryFunctions/log/zlogs.c b/src/c/elementaryFunctions/log/zlogs.c index e5e9ded1..de947bf4 100644 --- a/src/c/elementaryFunctions/log/zlogs.c +++ b/src/c/elementaryFunctions/log/zlogs.c @@ -1,65 +1,65 @@ -/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2007-2008 - INRIA - Bruno JOFRET
- * Copyright (C) Bruno Pincon
- *
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
-
-#include <math.h>
-#include "log.h"
-#include "lapack.h"
-#include "log1p.h"
-#include "pythag.h"
-
-doubleComplex zlogs(doubleComplex in) {
- static double sR2 = 1.41421356237309504;
-
- double _RealIn = zreals(in);
- double _ImgIn = zimags(in);
-
- double _RealOut = 0;
- double _ImgOut = 0;
-
- double RMax = getOverflowThreshold();
- double LInf = sqrt(getUnderflowThreshold());
- double LSup = sqrt(0.5 * RMax);
-
- double AbsReal = fabs(_RealIn);
- double AbsImg = fabs(_ImgIn);
-
- _ImgOut = atan2(_ImgIn, _RealIn);
-
- if(_ImgIn > _RealIn)
- {/* switch Real part and Imaginary part */
- double Temp = AbsReal;
- AbsReal = AbsImg;
- AbsImg = Temp;
- }
-
- if((0.5 <= AbsReal) && (AbsReal <= sR2))
- _RealOut = 0.5 * dlog1ps((AbsReal - 1) * (AbsReal + 1) + AbsImg * AbsImg);
- else if(LInf < AbsImg && AbsReal < LSup)
- _RealOut = 0.5 * dlogs(AbsReal * AbsReal + AbsImg * AbsImg);
- else if(AbsReal > RMax)
- _RealOut = AbsReal;
- else
- {
- double Temp = dpythags(AbsReal, AbsImg);
- if(Temp <= RMax)
- {
- _RealOut = dlogs(Temp);
- }
- else /* handle rare spurious overflow with : */
- {
- double Temp2 = AbsImg/AbsReal;
- _RealOut = dlogs(AbsReal) + 0.5 * dlog1ps(Temp2 * Temp2);
- }
- }
- return DoubleComplex(_RealOut, _ImgOut);
-}
+/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2007-2008 - INRIA - Bruno JOFRET + * Copyright (C) Bruno Pincon + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + +#include <math.h> +#include "log.h" +#include "lapack.h" +#include "log1p.h" +#include "pythag.h" + +doubleComplex zlogs(doubleComplex in) { + static double sR2 = 1.41421356237309504; + + double _RealIn = zreals(in); + double _ImgIn = zimags(in); + + double _RealOut = 0; + double _ImgOut = 0; + + double RMax = getOverflowThreshold(); + double LInf = sqrt(getUnderflowThreshold()); + double LSup = sqrt(0.5 * RMax); + + double AbsReal = fabs(_RealIn); + double AbsImg = fabs(_ImgIn); + + _ImgOut = atan2(_ImgIn, _RealIn); + + if(_ImgIn > _RealIn) + {/* switch Real part and Imaginary part */ + double Temp = AbsReal; + AbsReal = AbsImg; + AbsImg = Temp; + } + + if((0.5 <= AbsReal) && (AbsReal <= sR2)) + _RealOut = 0.5 * dlog1ps((AbsReal - 1) * (AbsReal + 1) + AbsImg * AbsImg); + else if(LInf < AbsImg && AbsReal < LSup) + _RealOut = 0.5 * dlogs(AbsReal * AbsReal + AbsImg * AbsImg); + else if(AbsReal > RMax) + _RealOut = AbsReal; + else + { + double Temp = dpythags(AbsReal, AbsImg); + if(Temp <= RMax) + { + _RealOut = dlogs(Temp); + } + else /* handle rare spurious overflow with : */ + { + double Temp2 = AbsImg/AbsReal; + _RealOut = dlogs(AbsReal) + 0.5 * dlog1ps(Temp2 * Temp2); + } + } + return DoubleComplex(_RealOut, _ImgOut); +} diff --git a/src/c/elementaryFunctions/log1p/dlog1ps.c b/src/c/elementaryFunctions/log1p/dlog1ps.c index e75a05fd..20d75004 100644 --- a/src/c/elementaryFunctions/log1p/dlog1ps.c +++ b/src/c/elementaryFunctions/log1p/dlog1ps.c @@ -1,34 +1,34 @@ -/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2008-2008 - INRIA - Bruno JOFRET
- * Copyright (C) Bruno Pincon
- *
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
-
-#include "log1p.h"
-#include "log.h"
-#include "lnp1m1.h"
-
-double dlog1ps(double in) {
- static double A = -1.0/3.0;
- static double B = 0.5;
-
- if(in < -1)
- {/* got NaN */
- return (in - in) / (in - in); /* NaN */
- }
- else if(A <= in && in <= B)
- {/* use the function log((1+g)/(1-g)) with g = x/(x + 2) */
- return dlnp1m1s(in / (in + 2));
- }
- else
- {/* use the standard formula */
- return dlogs(in + 1);
- }
-}
+/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2008-2008 - INRIA - Bruno JOFRET + * Copyright (C) Bruno Pincon + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + +#include "log1p.h" +#include "log.h" +#include "lnp1m1.h" + +double dlog1ps(double in) { + static double A = -1.0/3.0; + static double B = 0.5; + + if(in < -1) + {/* got NaN */ + return (in - in) / (in - in); /* NaN */ + } + else if(A <= in && in <= B) + {/* use the function log((1+g)/(1-g)) with g = x/(x + 2) */ + return dlnp1m1s(in / (in + 2)); + } + else + {/* use the standard formula */ + return dlogs(in + 1); + } +} diff --git a/src/c/elementaryFunctions/log1p/slog1ps.c b/src/c/elementaryFunctions/log1p/slog1ps.c index 04786524..93ab4e73 100644 --- a/src/c/elementaryFunctions/log1p/slog1ps.c +++ b/src/c/elementaryFunctions/log1p/slog1ps.c @@ -1,35 +1,35 @@ -/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2008-2008 - INRIA - Bruno JOFRET
- * Copyright (C) Bruno Pincon
-
- *
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
-
-#include "log1p.h"
-#include "log.h"
-#include "lnp1m1.h"
-
-float slog1ps(float in) {
- static double A = -1.0/3.0;
- static double B = 0.5;
-
- if(in < -1)
- {/* got NaN */
- return (in - in) / (in - in); /* NaN */
- }
- else if(A <= in && in <= B)
- {/* use the function log((1+g)/(1-g)) with g = x/(x + 2) */
- return slnp1m1s(in / (in + 2));
- }
- else
- {/* use the standard formula */
- return slogs(in + 1);
- }
-}
+/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2008-2008 - INRIA - Bruno JOFRET + * Copyright (C) Bruno Pincon + + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + +#include "log1p.h" +#include "log.h" +#include "lnp1m1.h" + +float slog1ps(float in) { + static double A = -1.0/3.0; + static double B = 0.5; + + if(in < -1) + {/* got NaN */ + return (in - in) / (in - in); /* NaN */ + } + else if(A <= in && in <= B) + {/* use the function log((1+g)/(1-g)) with g = x/(x + 2) */ + return slnp1m1s(in / (in + 2)); + } + else + {/* use the standard formula */ + return slogs(in + 1); + } +} diff --git a/src/c/elementaryFunctions/sqrt/csqrts.c b/src/c/elementaryFunctions/sqrt/csqrts.c index a24f9558..07ef3bb0 100644 --- a/src/c/elementaryFunctions/sqrt/csqrts.c +++ b/src/c/elementaryFunctions/sqrt/csqrts.c @@ -1,111 +1,111 @@ -/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2008-2008 - INRIA - Bruno JOFRET
- * Copyright (C) Bruno Pincon
- *
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
-
-#include <math.h>
-#include "sqrt.h"
-#include "lapack.h"
-#include "abs.h"
-#include "sign.h"
-#include "pythag.h"
-
-#ifdef _MSC_VER
-#include <float.h>
-#define isnan(x) _isnan((double)x)
-#endif
-
-#define _sign(a, b) b >=0 ? a : -a
-
-floatComplex csqrts(floatComplex in) {
- float RMax = (float) getOverflowThreshold();
- float BRMin = 2.0f * (float) getUnderflowThreshold();
-
- float RealIn = creals(in);
- float ImgIn = cimags(in);
-
- float RealOut = 0;
- float ImgOut = 0;
-
- if(RealIn == 0)
- {/* pure imaginary case */
- if(dabss(ImgIn >= BRMin))
- RealOut = ssqrts(0.5f * sabss(ImgIn));
- else
- RealOut = ssqrts(sabss(ImgIn)) * ssqrts(0.5);
-
- ImgOut = _sign(1, ImgIn) * RealOut;
- }
- else if( sabss(RealIn) <= RMax && sabss(ImgIn) <= RMax)
- {/* standard case : a (not zero) and b are finite */
- float Temp = ssqrts(2.0f * (sabss(RealIn) + spythags(RealIn, ImgIn)));
- /* overflow test */
- if(Temp > RMax)
- {/* handle (spurious) overflow by scaling a and b */
- float RealTemp = RealIn / 16.0f;
- float ImgTemp = ImgIn / 16.0f;
- Temp = ssqrts(2.0f * (sabss(RealIn) + spythags(RealIn, ImgTemp)));
- if(RealTemp >= 0)
- {
- RealOut = 2 * Temp;
- ImgOut = 4 * ImgTemp / Temp;
- }
- else
- {
- RealOut = 4 * sabss(ImgIn) / Temp;
- ImgOut = _sign(2, ImgIn) * Temp;
- }
- }
- else if(RealIn >= 0) /* classic switch to get the stable formulas */
- {
- RealOut = 0.5f * Temp;
- ImgOut = ImgIn / Temp;
- }
- else
- {
- RealOut = sabss(ImgIn) / Temp;
- ImgOut = (_sign(0.5f, ImgIn)) * Temp;
- }
- }
- else
- {
- /*
- //Here we treat the special cases where a and b are +- 00 or NaN.
- //The following is the treatment recommended by the C99 standard
- //with the simplification of returning NaN + i NaN if the
- //the real part or the imaginary part is NaN (C99 recommends
- //something more complicated)
- */
-
- if(isnan(RealIn) == 1 || isnan(ImgIn) == 1)
- {/* got NaN + i NaN */
- RealOut = RealIn + ImgIn;
- ImgOut = RealOut;
- }
- else if( dabss(ImgIn) > RMax)
- {/* case a +- i oo -> result must be +oo +- i oo for all a (finite or not) */
- RealOut = sabss(ImgIn);
- ImgOut = ImgIn;
- }
- else if(RealIn < -RMax)
- {/* here a is -Inf and b is finite */
- RealOut = 0;
- ImgOut = _sign(1, ImgIn) * sabss(RealIn);
- }
- else
- {/* here a is +Inf and b is finite */
- RealOut = RealIn;
- ImgOut = 0;
- }
- }
-
- return FloatComplex(RealOut, ImgOut);
-}
+/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2008-2008 - INRIA - Bruno JOFRET + * Copyright (C) Bruno Pincon + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + +#include <math.h> +#include "sqrt.h" +#include "lapack.h" +#include "abs.h" +#include "sign.h" +#include "pythag.h" + +#ifdef _MSC_VER +#include <float.h> +#define isnan(x) _isnan((double)x) +#endif + +#define _sign(a, b) b >=0 ? a : -a + +floatComplex csqrts(floatComplex in) { + float RMax = (float) getOverflowThreshold(); + float BRMin = 2.0f * (float) getUnderflowThreshold(); + + float RealIn = creals(in); + float ImgIn = cimags(in); + + float RealOut = 0; + float ImgOut = 0; + + if(RealIn == 0) + {/* pure imaginary case */ + if(dabss(ImgIn >= BRMin)) + RealOut = ssqrts(0.5f * sabss(ImgIn)); + else + RealOut = ssqrts(sabss(ImgIn)) * ssqrts(0.5); + + ImgOut = _sign(1, ImgIn) * RealOut; + } + else if( sabss(RealIn) <= RMax && sabss(ImgIn) <= RMax) + {/* standard case : a (not zero) and b are finite */ + float Temp = ssqrts(2.0f * (sabss(RealIn) + spythags(RealIn, ImgIn))); + /* overflow test */ + if(Temp > RMax) + {/* handle (spurious) overflow by scaling a and b */ + float RealTemp = RealIn / 16.0f; + float ImgTemp = ImgIn / 16.0f; + Temp = ssqrts(2.0f * (sabss(RealIn) + spythags(RealIn, ImgTemp))); + if(RealTemp >= 0) + { + RealOut = 2 * Temp; + ImgOut = 4 * ImgTemp / Temp; + } + else + { + RealOut = 4 * sabss(ImgIn) / Temp; + ImgOut = _sign(2, ImgIn) * Temp; + } + } + else if(RealIn >= 0) /* classic switch to get the stable formulas */ + { + RealOut = 0.5f * Temp; + ImgOut = ImgIn / Temp; + } + else + { + RealOut = sabss(ImgIn) / Temp; + ImgOut = (_sign(0.5f, ImgIn)) * Temp; + } + } + else + { + /* + //Here we treat the special cases where a and b are +- 00 or NaN. + //The following is the treatment recommended by the C99 standard + //with the simplification of returning NaN + i NaN if the + //the real part or the imaginary part is NaN (C99 recommends + //something more complicated) + */ + + if(isnan(RealIn) == 1 || isnan(ImgIn) == 1) + {/* got NaN + i NaN */ + RealOut = RealIn + ImgIn; + ImgOut = RealOut; + } + else if( dabss(ImgIn) > RMax) + {/* case a +- i oo -> result must be +oo +- i oo for all a (finite or not) */ + RealOut = sabss(ImgIn); + ImgOut = ImgIn; + } + else if(RealIn < -RMax) + {/* here a is -Inf and b is finite */ + RealOut = 0; + ImgOut = _sign(1, ImgIn) * sabss(RealIn); + } + else + {/* here a is +Inf and b is finite */ + RealOut = RealIn; + ImgOut = 0; + } + } + + return FloatComplex(RealOut, ImgOut); +} diff --git a/src/c/elementaryFunctions/sqrt/zsqrts.c b/src/c/elementaryFunctions/sqrt/zsqrts.c index 3637ddd6..f8aac152 100644 --- a/src/c/elementaryFunctions/sqrt/zsqrts.c +++ b/src/c/elementaryFunctions/sqrt/zsqrts.c @@ -1,111 +1,111 @@ -/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2008-2008 - INRIA - Bruno JOFRET
- * Copyright (C) Bruno Pincon
- *
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
-#include <stdio.h>
-#include <math.h>
-#include "sqrt.h"
-#include "lapack.h"
-#include "abs.h"
-#include "sign.h"
-#include "pythag.h"
-
-#ifdef _MSC_VER
-#include <float.h>
-#define isnan(x) _isnan((double)x)
-#endif
-
-#define _sign(a, b) b >=0 ? a : -a
-
-doubleComplex zsqrts(doubleComplex in) {
- double RMax = getOverflowThreshold();
- double BRMin = 2 * getUnderflowThreshold();
-
- double RealIn = zreals(in);
- double ImgIn = zimags(in);
-
- double RealOut = 0;
- double ImgOut = 0;
-
- if(RealIn == 0)
- {/* pure imaginary case */
- if(dabss(ImgIn >= BRMin))
- RealOut = dsqrts(0.5 * dabss(ImgIn));
- else
- RealOut = dsqrts(dabss(ImgIn)) * dsqrts(0.5);
-
- ImgOut = _sign(1, ImgIn) * RealOut;
- }
- else if( dabss(RealIn) <= RMax && dabss(ImgIn) <= RMax)
- {/* standard case : a (not zero) and b are finite */
- double Temp = dsqrts(2 * (dabss(RealIn) + dpythags(RealIn, ImgIn)));
- /* overflow test */
- if(Temp > RMax)
- {/* handle (spurious) overflow by scaling a and b */
- double RealTemp = RealIn / 16;
- double ImgTemp = ImgIn / 16;
- Temp = dsqrts(2 * (dabss(RealIn) + dpythags(RealIn, ImgTemp)));
- if(RealTemp >= 0)
- {
- RealOut = 2 * Temp;
- ImgOut = 4 * ImgTemp / Temp;
- }
- else
- {
- RealOut = 4 * dabss(ImgIn) / Temp;
- ImgOut = _sign(2, ImgIn) * Temp;
- }
- }
- else if(RealIn >= 0) /* classic switch to get the stable formulas */
- {
- RealOut = 0.5 * Temp;
- ImgOut = ImgIn / Temp;
- }
- else
- {
- RealOut = dabss(ImgIn) / Temp;
- ImgOut = (_sign(0.5, ImgIn)) * Temp;
- }
- }
- else
- {
- /*
- //Here we treat the special cases where a and b are +- 00 or NaN.
- //The following is the treatment recommended by the C99 standard
- //with the simplification of returning NaN + i NaN if the
- //the real part or the imaginary part is NaN (C99 recommends
- //something more complicated)
- */
-
- if(isnan(RealIn) == 1 || isnan(ImgIn) == 1)
- {/* got NaN + i NaN */
- RealOut = RealIn + ImgIn;
- ImgOut = RealOut;
- }
- else if( dabss(ImgIn) > RMax)
- {/* case a +- i oo -> result must be +oo +- i oo for all a (finite or not) */
- RealOut = dabss(ImgIn);
- ImgOut = ImgIn;
- }
- else if(RealIn < -RMax)
- {/* here a is -Inf and b is finite */
- RealOut = 0;
- ImgOut = _sign(1, ImgIn) * dabss(RealIn);
- }
- else
- {/* here a is +Inf and b is finite */
- RealOut = RealIn;
- ImgOut = 0;
- }
- }
-
- return DoubleComplex(RealOut, ImgOut);
-}
+/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2008-2008 - INRIA - Bruno JOFRET + * Copyright (C) Bruno Pincon + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ +#include <stdio.h> +#include <math.h> +#include "sqrt.h" +#include "lapack.h" +#include "abs.h" +#include "sign.h" +#include "pythag.h" + +#ifdef _MSC_VER +#include <float.h> +#define isnan(x) _isnan((double)x) +#endif + +#define _sign(a, b) b >=0 ? a : -a + +doubleComplex zsqrts(doubleComplex in) { + double RMax = getOverflowThreshold(); + double BRMin = 2 * getUnderflowThreshold(); + + double RealIn = zreals(in); + double ImgIn = zimags(in); + + double RealOut = 0; + double ImgOut = 0; + + if(RealIn == 0) + {/* pure imaginary case */ + if(dabss(ImgIn >= BRMin)) + RealOut = dsqrts(0.5 * dabss(ImgIn)); + else + RealOut = dsqrts(dabss(ImgIn)) * dsqrts(0.5); + + ImgOut = _sign(1, ImgIn) * RealOut; + } + else if( dabss(RealIn) <= RMax && dabss(ImgIn) <= RMax) + {/* standard case : a (not zero) and b are finite */ + double Temp = dsqrts(2 * (dabss(RealIn) + dpythags(RealIn, ImgIn))); + /* overflow test */ + if(Temp > RMax) + {/* handle (spurious) overflow by scaling a and b */ + double RealTemp = RealIn / 16; + double ImgTemp = ImgIn / 16; + Temp = dsqrts(2 * (dabss(RealIn) + dpythags(RealIn, ImgTemp))); + if(RealTemp >= 0) + { + RealOut = 2 * Temp; + ImgOut = 4 * ImgTemp / Temp; + } + else + { + RealOut = 4 * dabss(ImgIn) / Temp; + ImgOut = _sign(2, ImgIn) * Temp; + } + } + else if(RealIn >= 0) /* classic switch to get the stable formulas */ + { + RealOut = 0.5 * Temp; + ImgOut = ImgIn / Temp; + } + else + { + RealOut = dabss(ImgIn) / Temp; + ImgOut = (_sign(0.5, ImgIn)) * Temp; + } + } + else + { + /* + //Here we treat the special cases where a and b are +- 00 or NaN. + //The following is the treatment recommended by the C99 standard + //with the simplification of returning NaN + i NaN if the + //the real part or the imaginary part is NaN (C99 recommends + //something more complicated) + */ + + if(isnan(RealIn) == 1 || isnan(ImgIn) == 1) + {/* got NaN + i NaN */ + RealOut = RealIn + ImgIn; + ImgOut = RealOut; + } + else if( dabss(ImgIn) > RMax) + {/* case a +- i oo -> result must be +oo +- i oo for all a (finite or not) */ + RealOut = dabss(ImgIn); + ImgOut = ImgIn; + } + else if(RealIn < -RMax) + {/* here a is -Inf and b is finite */ + RealOut = 0; + ImgOut = _sign(1, ImgIn) * dabss(RealIn); + } + else + {/* here a is +Inf and b is finite */ + RealOut = RealIn; + ImgOut = 0; + } + } + + return DoubleComplex(RealOut, ImgOut); +} diff --git a/src/c/elementaryFunctions/tan/ztans.c b/src/c/elementaryFunctions/tan/ztans.c index 761da36b..66e74cec 100644 --- a/src/c/elementaryFunctions/tan/ztans.c +++ b/src/c/elementaryFunctions/tan/ztans.c @@ -1,104 +1,104 @@ -/*
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2006-2008 - INRIA - Bruno JOFRET
- * Copyright (C) Bruno Pincon
- *
- * This file must be used under the terms of the CeCILL.
- * This source file is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at
- * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
- *
- */
-
-/*
- ALGORITHM
- based on the formula :
-
- 0.5 sin(2 xr) + i 0.5 sinh(2 xi)
- tan(xr + i xi) = ---------------------------------
- cos(xr)^2 + sinh(xi)^2
-
- noting d = cos(xr)^2 + sinh(xi)^2, we have :
-
- yr = 0.5 * sin(2 * xr) / d (1)
-
- yi = 0.5 * sinh(2 * xi) / d (2)
-
- to avoid spurious overflows in computing yi with
- formula (2) (which results in NaN for yi)
- we use also the following formula :
-
- yi = sign(xi) when |xi| > LIM (3)
-
- Explanations for (3) :
-
- we have d = sinh(xi)^2 ( 1 + (cos(xr)/sinh(xi))^2 ),
- so when :
-
- (cos(xr)/sinh(xi))^2 < epsm ( epsm = max relative error
- for coding a real in a f.p.
- number set F(b,p,emin,emax)
- epsm = 0.5 b^(1-p) )
- which is forced when :
-
- 1/sinh(xi)^2 < epsm (4)
- <=> |xi| > asinh(1/sqrt(epsm)) (= 19.06... in ieee 754 double)
-
- sinh(xi)^2 is a good approximation for d (relative to the f.p.
- arithmetic used) and then yr may be approximate with :
-
- yr = cosh(xi)/sinh(xi)
- = sign(xi) (1 + exp(-2 |xi|))/(1 - exp(-2|xi|))
- = sign(xi) (1 + 2 u + 2 u^2 + 2 u^3 + ...)
-
- with u = exp(-2 |xi|)). Now when :
-
- 2 exp(-2|xi|) < epsm (2)
- <=> |xi| > 0.5 * log(2/epsm) (= 18.71... in ieee 754 double)
-
- sign(xi) is a good approximation for yr.
-
- Constraint (1) is stronger than (2) and we take finaly
-
- LIM = 1 + log(2/sqrt(epsm))
-
- (log(2/sqrt(epsm)) being very near asinh(1/sqrt(epsm))
-
-AUTHOR
- Bruno Pincon <Bruno.Pincon@iecn.u-nancy.fr>
-*/
-
-#include <math.h>
-#include "lapack.h"
-#include "tan.h"
-#include "sqrt.h"
-#include "cos.h"
-#include "sinh.h"
-#include "sin.h"
-#include "log.h"
-#include "abs.h"
-
-#define localSign(x) x >= 0 ? 1.0 : -1.0
-
-doubleComplex ztans(doubleComplex z) {
- double Temp = 0;
- double Lim = 1 + dlogs(2.0 / dsqrts( getRelativeMachinePrecision()));
- double RealIn = zreals(z);
- double ImagIn = zimags(z);
- double RealOut = 0;
- double ImagOut = 0;
-
- Temp = pow(dcoss(RealIn), 2) + pow(dsinhs(ImagIn), 2);
- RealOut = 0.5 * dsins(2 * RealIn) / Temp;
- if(dabss(ImagIn) < Lim)
- {
- ImagOut = 0.5 * dsinhs(2 * ImagIn) / Temp;
- }
- else
- {
- ImagOut = localSign(ImagIn);
- }
-
- return DoubleComplex(RealOut, ImagOut);
-}
+/* + * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab + * Copyright (C) 2006-2008 - INRIA - Bruno JOFRET + * Copyright (C) Bruno Pincon + * + * This file must be used under the terms of the CeCILL. + * This source file is licensed as described in the file COPYING, which + * you should have received as part of this distribution. The terms + * are also available at + * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt + * + */ + +/* + ALGORITHM + based on the formula : + + 0.5 sin(2 xr) + i 0.5 sinh(2 xi) + tan(xr + i xi) = --------------------------------- + cos(xr)^2 + sinh(xi)^2 + + noting d = cos(xr)^2 + sinh(xi)^2, we have : + + yr = 0.5 * sin(2 * xr) / d (1) + + yi = 0.5 * sinh(2 * xi) / d (2) + + to avoid spurious overflows in computing yi with + formula (2) (which results in NaN for yi) + we use also the following formula : + + yi = sign(xi) when |xi| > LIM (3) + + Explanations for (3) : + + we have d = sinh(xi)^2 ( 1 + (cos(xr)/sinh(xi))^2 ), + so when : + + (cos(xr)/sinh(xi))^2 < epsm ( epsm = max relative error + for coding a real in a f.p. + number set F(b,p,emin,emax) + epsm = 0.5 b^(1-p) ) + which is forced when : + + 1/sinh(xi)^2 < epsm (4) + <=> |xi| > asinh(1/sqrt(epsm)) (= 19.06... in ieee 754 double) + + sinh(xi)^2 is a good approximation for d (relative to the f.p. + arithmetic used) and then yr may be approximate with : + + yr = cosh(xi)/sinh(xi) + = sign(xi) (1 + exp(-2 |xi|))/(1 - exp(-2|xi|)) + = sign(xi) (1 + 2 u + 2 u^2 + 2 u^3 + ...) + + with u = exp(-2 |xi|)). Now when : + + 2 exp(-2|xi|) < epsm (2) + <=> |xi| > 0.5 * log(2/epsm) (= 18.71... in ieee 754 double) + + sign(xi) is a good approximation for yr. + + Constraint (1) is stronger than (2) and we take finaly + + LIM = 1 + log(2/sqrt(epsm)) + + (log(2/sqrt(epsm)) being very near asinh(1/sqrt(epsm)) + +AUTHOR + Bruno Pincon <Bruno.Pincon@iecn.u-nancy.fr> +*/ + +#include <math.h> +#include "lapack.h" +#include "tan.h" +#include "sqrt.h" +#include "cos.h" +#include "sinh.h" +#include "sin.h" +#include "log.h" +#include "abs.h" + +#define localSign(x) x >= 0 ? 1.0 : -1.0 + +doubleComplex ztans(doubleComplex z) { + double Temp = 0; + double Lim = 1 + dlogs(2.0 / dsqrts( getRelativeMachinePrecision())); + double RealIn = zreals(z); + double ImagIn = zimags(z); + double RealOut = 0; + double ImagOut = 0; + + Temp = pow(dcoss(RealIn), 2) + pow(dsinhs(ImagIn), 2); + RealOut = 0.5 * dsins(2 * RealIn) / Temp; + if(dabss(ImagIn) < Lim) + { + ImagOut = 0.5 * dsinhs(2 * ImagIn) / Temp; + } + else + { + ImagOut = localSign(ImagIn); + } + + return DoubleComplex(RealOut, ImagOut); +} diff --git a/src/c/implicitList/dynlib_implicitlist.h b/src/c/implicitList/dynlib_implicitlist.h index 297c64b3..9fe60525 100644 --- a/src/c/implicitList/dynlib_implicitlist.h +++ b/src/c/implicitList/dynlib_implicitlist.h @@ -1,26 +1,26 @@ -/*
-* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-* Copyright (C) 2009 - DIGITEO - Allan CORNET
-*
-* This file must be used under the terms of the CeCILL.
-* This source file is licensed as described in the file COPYING, which
-* you should have received as part of this distribution. The terms
-* are also available at
-* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
-*
-*/
-
-#ifndef __DYNLIB_IMPLICITLIST_H__
-#define __DYNLIB_IMPLICITLIST_H__
-
-#if defined(_MSC_VER) && defined(_USRDLL)
- #if IMPLICITLIST_EXPORTS
- #define EXTERN_IMPLIST __declspec (dllexport)
- #else
- #define EXTERN_IMPLIST __declspec (dllimport)
- #endif
-#else
- #define EXTERN_IMPLIST
-#endif
-
-#endif /* __DYNLIB_IMPLICITLIST_H__ */
+/* +* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +* Copyright (C) 2009 - DIGITEO - Allan CORNET +* +* This file must be used under the terms of the CeCILL. +* This source file is licensed as described in the file COPYING, which +* you should have received as part of this distribution. The terms +* are also available at +* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +* +*/ + +#ifndef __DYNLIB_IMPLICITLIST_H__ +#define __DYNLIB_IMPLICITLIST_H__ + +#if defined(_MSC_VER) && defined(_USRDLL) + #if IMPLICITLIST_EXPORTS + #define EXTERN_IMPLIST __declspec (dllexport) + #else + #define EXTERN_IMPLIST __declspec (dllimport) + #endif +#else + #define EXTERN_IMPLIST +#endif + +#endif /* __DYNLIB_IMPLICITLIST_H__ */ diff --git a/src/c/matrixOperations/includes/dynlib_matrixoperations.h b/src/c/matrixOperations/includes/dynlib_matrixoperations.h index a0597a59..c357d981 100644 --- a/src/c/matrixOperations/includes/dynlib_matrixoperations.h +++ b/src/c/matrixOperations/includes/dynlib_matrixoperations.h @@ -1,26 +1,26 @@ -/*
-* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-* Copyright (C) 2009 - DIGITEO - Allan CORNET
-*
-* This file must be used under the terms of the CeCILL.
-* This source file is licensed as described in the file COPYING, which
-* you should have received as part of this distribution. The terms
-* are also available at
-* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
-*
-*/
-
-#ifndef __DYNLIB_MATRIXOPERATIONS_H__
-#define __DYNLIB_MATRIXOPERATIONS_H__
-
-#if defined(_MSC_VER) && defined(_USRDLL)
- #if MATRIXOPERATIONS_EXPORTS
- #define EXTERN_MATOPS __declspec (dllexport)
- #else
- #define EXTERN_MATOPS __declspec (dllimport)
- #endif
-#else
- #define EXTERN_MATOPS
-#endif
-
-#endif /* __DYNLIB_MATRIXOPERATIONS_H__ */
+/* +* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +* Copyright (C) 2009 - DIGITEO - Allan CORNET +* +* This file must be used under the terms of the CeCILL. +* This source file is licensed as described in the file COPYING, which +* you should have received as part of this distribution. The terms +* are also available at +* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +* +*/ + +#ifndef __DYNLIB_MATRIXOPERATIONS_H__ +#define __DYNLIB_MATRIXOPERATIONS_H__ + +#if defined(_MSC_VER) && defined(_USRDLL) + #if MATRIXOPERATIONS_EXPORTS + #define EXTERN_MATOPS __declspec (dllexport) + #else + #define EXTERN_MATOPS __declspec (dllimport) + #endif +#else + #define EXTERN_MATOPS +#endif + +#endif /* __DYNLIB_MATRIXOPERATIONS_H__ */ diff --git a/src/c/operations/includes/dynlib_operations.h b/src/c/operations/includes/dynlib_operations.h index e91f6322..f4a26e76 100644 --- a/src/c/operations/includes/dynlib_operations.h +++ b/src/c/operations/includes/dynlib_operations.h @@ -1,26 +1,26 @@ -/*
-* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-* Copyright (C) 2009 - DIGITEO - Allan CORNET
-*
-* This file must be used under the terms of the CeCILL.
-* This source file is licensed as described in the file COPYING, which
-* you should have received as part of this distribution. The terms
-* are also available at
-* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
-*
-*/
-
-#ifndef __DYNLIB_OPERATIONS_H__
-#define __DYNLIB_OPERATIONS_H__
-
-#if defined(_MSC_VER) && defined(_USRDLL)
- #if OPERATIONS_EXPORTS
- #define EXTERN_OPERATIONS __declspec (dllexport)
- #else
- #define EXTERN_OPERATIONS __declspec (dllimport)
- #endif
-#else
- #define EXTERN_OPERATIONS
-#endif
-
-#endif /* __DYNLIB_OPERATIONS_H__ */
+/* +* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +* Copyright (C) 2009 - DIGITEO - Allan CORNET +* +* This file must be used under the terms of the CeCILL. +* This source file is licensed as described in the file COPYING, which +* you should have received as part of this distribution. The terms +* are also available at +* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +* +*/ + +#ifndef __DYNLIB_OPERATIONS_H__ +#define __DYNLIB_OPERATIONS_H__ + +#if defined(_MSC_VER) && defined(_USRDLL) + #if OPERATIONS_EXPORTS + #define EXTERN_OPERATIONS __declspec (dllexport) + #else + #define EXTERN_OPERATIONS __declspec (dllimport) + #endif +#else + #define EXTERN_OPERATIONS +#endif + +#endif /* __DYNLIB_OPERATIONS_H__ */ diff --git a/src/c/signalProcessing/includes/dynlib_signalprocessing.h b/src/c/signalProcessing/includes/dynlib_signalprocessing.h index fcbe5800..478c1973 100644 --- a/src/c/signalProcessing/includes/dynlib_signalprocessing.h +++ b/src/c/signalProcessing/includes/dynlib_signalprocessing.h @@ -1,26 +1,26 @@ -/*
-* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-* Copyright (C) 2009 - DIGITEO - Allan CORNET
-*
-* This file must be used under the terms of the CeCILL.
-* This source file is licensed as described in the file COPYING, which
-* you should have received as part of this distribution. The terms
-* are also available at
-* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
-*
-*/
-
-#ifndef __DYNLIB_SIGNALPROCESSING_H__
-#define __DYNLIB_SIGNALPROCESSING_H__
-
-#if defined(_MSC_VER) && defined(_USRDLL)
- #if SIGNALPROCESSING_EXPORTS
- #define EXTERN_SIGPROC __declspec (dllexport)
- #else
- #define EXTERN_SIGPROC __declspec (dllimport)
- #endif
-#else
- #define EXTERN_SIGPROC
-#endif
-
-#endif /* __DYNLIB_SIGNALPROCESSING_H__ */
+/* +* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +* Copyright (C) 2009 - DIGITEO - Allan CORNET +* +* This file must be used under the terms of the CeCILL. +* This source file is licensed as described in the file COPYING, which +* you should have received as part of this distribution. The terms +* are also available at +* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +* +*/ + +#ifndef __DYNLIB_SIGNALPROCESSING_H__ +#define __DYNLIB_SIGNALPROCESSING_H__ + +#if defined(_MSC_VER) && defined(_USRDLL) + #if SIGNALPROCESSING_EXPORTS + #define EXTERN_SIGPROC __declspec (dllexport) + #else + #define EXTERN_SIGPROC __declspec (dllimport) + #endif +#else + #define EXTERN_SIGPROC +#endif + +#endif /* __DYNLIB_SIGNALPROCESSING_H__ */ diff --git a/src/c/statisticsFunctions/includes/dynlib_statisticsfunctions.h b/src/c/statisticsFunctions/includes/dynlib_statisticsfunctions.h index b6dab50f..fbfc0622 100644 --- a/src/c/statisticsFunctions/includes/dynlib_statisticsfunctions.h +++ b/src/c/statisticsFunctions/includes/dynlib_statisticsfunctions.h @@ -1,26 +1,26 @@ -/*
-* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-* Copyright (C) 2009 - DIGITEO - Allan CORNET
-*
-* This file must be used under the terms of the CeCILL.
-* This source file is licensed as described in the file COPYING, which
-* you should have received as part of this distribution. The terms
-* are also available at
-* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
-*
-*/
-
-#ifndef __DYNLIB_STATISTICSFUNCTIONS_H__
-#define __DYNLIB_STATISTICSFUNCTIONS_H__
-
-#if defined(_MSC_VER) && defined(_USRDLL)
- #if STATISTICSFUNCTIONS_EXPORTS
- #define EXTERN_STATFUNC __declspec (dllexport)
- #else
- #define EXTERN_STATFUNC __declspec (dllimport)
- #endif
-#else
- #define EXTERN_STATFUNC
-#endif
-
-#endif /* __DYNLIB_STATISTICSFUNCTIONS_H__ */
+/* +* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +* Copyright (C) 2009 - DIGITEO - Allan CORNET +* +* This file must be used under the terms of the CeCILL. +* This source file is licensed as described in the file COPYING, which +* you should have received as part of this distribution. The terms +* are also available at +* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +* +*/ + +#ifndef __DYNLIB_STATISTICSFUNCTIONS_H__ +#define __DYNLIB_STATISTICSFUNCTIONS_H__ + +#if defined(_MSC_VER) && defined(_USRDLL) + #if STATISTICSFUNCTIONS_EXPORTS + #define EXTERN_STATFUNC __declspec (dllexport) + #else + #define EXTERN_STATFUNC __declspec (dllimport) + #endif +#else + #define EXTERN_STATFUNC +#endif + +#endif /* __DYNLIB_STATISTICSFUNCTIONS_H__ */ diff --git a/src/c/string/disp/sdisps.c b/src/c/string/disp/sdisps.c index 98b04a6f..ddec56c3 100644 --- a/src/c/string/disp/sdisps.c +++ b/src/c/string/disp/sdisps.c @@ -13,6 +13,6 @@ #include "disp.h" double sdisps (float in) { - printf(" %f \n",in);
+ printf(" %f \n",in); return 0; } diff --git a/src/c/string/includes/dynlib_string.h b/src/c/string/includes/dynlib_string.h index ca11ce10..b8d4248d 100644 --- a/src/c/string/includes/dynlib_string.h +++ b/src/c/string/includes/dynlib_string.h @@ -1,27 +1,27 @@ -/*
-* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-* Copyright (C) 2009 - DIGITEO - Allan CORNET
-*
-* This file must be used under the terms of the CeCILL.
-* This source file is licensed as described in the file COPYING, which
-* you should have received as part of this distribution. The terms
-* are also available at
-* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
-*
-*/
-
-#ifndef __DYNLIB_STRING_H__
-#define __DYNLIB_STRING_H__
-
-#if defined(_MSC_VER) && defined(_USRDLL)
- #if STRING_EXPORTS
- #define EXTERN_STRING __declspec (dllexport)
- #else
- #define EXTERN_STRING __declspec (dllimport)
- #endif
-#else
- #define EXTERN_STRING
-#endif
-
-#endif /* __DYNLIB_STRING_H__ */
-
+/* +* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +* Copyright (C) 2009 - DIGITEO - Allan CORNET +* +* This file must be used under the terms of the CeCILL. +* This source file is licensed as described in the file COPYING, which +* you should have received as part of this distribution. The terms +* are also available at +* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +* +*/ + +#ifndef __DYNLIB_STRING_H__ +#define __DYNLIB_STRING_H__ + +#if defined(_MSC_VER) && defined(_USRDLL) + #if STRING_EXPORTS + #define EXTERN_STRING __declspec (dllexport) + #else + #define EXTERN_STRING __declspec (dllimport) + #endif +#else + #define EXTERN_STRING +#endif + +#endif /* __DYNLIB_STRING_H__ */ + diff --git a/src/c/type/dynlib_type.h b/src/c/type/dynlib_type.h index 35ae247f..b3471b98 100644 --- a/src/c/type/dynlib_type.h +++ b/src/c/type/dynlib_type.h @@ -1,26 +1,26 @@ -/*
-* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
-* Copyright (C) 2009 - DIGITEO - Allan CORNET
-*
-* This file must be used under the terms of the CeCILL.
-* This source file is licensed as described in the file COPYING, which
-* you should have received as part of this distribution. The terms
-* are also available at
-* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
-*
-*/
-
-#ifndef __DYNLIB_TYPE_H__
-#define __DYNLIB_TYPE_H__
-
-#if defined(_MSC_VER) && defined(_USRDLL)
- #if TYPE_EXPORTS
- #define EXTERN_TYPE __declspec (dllexport)
- #else
- #define EXTERN_TYPE __declspec (dllimport)
- #endif
-#else
- #define EXTERN_TYPE
-#endif
-
-#endif /* __DYNLIB_TYPE_H__ */
+/* +* Scilab ( http://www.scilab.org/ ) - This file is part of Scilab +* Copyright (C) 2009 - DIGITEO - Allan CORNET +* +* This file must be used under the terms of the CeCILL. +* This source file is licensed as described in the file COPYING, which +* you should have received as part of this distribution. The terms +* are also available at +* http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +* +*/ + +#ifndef __DYNLIB_TYPE_H__ +#define __DYNLIB_TYPE_H__ + +#if defined(_MSC_VER) && defined(_USRDLL) + #if TYPE_EXPORTS + #define EXTERN_TYPE __declspec (dllexport) + #else + #define EXTERN_TYPE __declspec (dllimport) + #endif +#else + #define EXTERN_TYPE +#endif + +#endif /* __DYNLIB_TYPE_H__ */ |