Pelles C forum

C language => Tips & tricks => Topic started by: TimoVJL on August 12, 2017, 09:23:20 AM

Title: Fork of QD (2.3.17) dll
Post by: TimoVJL on August 12, 2017, 09:23:20 AM
Fork of QD (2.3.17) (https://github.com/scibuilder/QD) dll
c_test.c from it & QD.dll & QD.lib import library.

EDIT: missing headers and libs added.
EDIT  QDSSE.dll for 32-bit.
Title: Re: Fork of QD (2.3.17) dll
Post by: jj2007 on August 12, 2017, 05:07:04 PM
That looks very interesting, thanks ;-)

The *.lib files are just import libs. How useful is that, if you need the DLL anyway?
Title: Re: Fork of QD (2.3.17) dll
Post by: TimoVJL on August 12, 2017, 05:11:32 PM
Because it is C++ code, dll is obvious choice.
Title: Re: Fork of QD (2.3.17) dll
Post by: jack on August 13, 2017, 01:43:39 AM
thanks you :)
Title: Re: Fork of QD (2.3.17) dll
Post by: jack on August 13, 2017, 02:20:36 AM
hello TimoVJL
is there a way for you to compile the 32-bit version using sse?,  then you won't have to worry about fpu_fix_start/fpu_fix_end.
I edited the makefile in QD-master\src and added -mfpmath=sse -msse2 to CPPFLAGS = -O2 -mfpmath=sse -msse2
but that's when using gcc, not sure how you would do that in PellesC.
btw, that's a very small-sized dll, only 115k, mine compiled with gcc was 1.2 meg even after stripping.
Title: Re: Fork of QD (2.3.17) dll
Post by: TimoVJL on August 13, 2017, 09:01:16 AM
It was compiled with msvc 2010 with dynamic dlls.
It uses msvcp100.dll.

I added SSE version, with cl option -arch:SSE too.
Title: Re: Fork of QD (2.3.17) dll
Post by: jack on August 13, 2017, 12:23:45 PM
unfortunately it's still using the fpu.
Title: Re: Fork of QD (2.3.17) dll
Post by: jack on August 13, 2017, 02:50:22 PM
TimoVJL, did you have to edit any of the source files in order for vs to compile the project?
I have visual studio 2013-pro and also later community editions but am not able to setup a dll project that will compile
I have an older project, qd-2.3.7 and the 32-bit version compiles ok but if I replace the source files with the newer version then I have problems, something like max is not defined in the namespace std and can't convert qd_read to int.
Title: Re: Fork of QD (2.3.17) dll
Post by: TimoVJL on August 13, 2017, 03:31:30 PM
No.
build cmd attached.
Title: Re: Fork of QD (2.3.17) dll
Post by: jack on August 13, 2017, 04:54:44 PM
thank you
but still the same problem when using vs-2013
Quote
src\qd_real.cpp(446) : error C2039: 'max' : is not a member of 'std'
src\qd_real.cpp(446) : error C2440: '=' : cannot convert from 'qd_real' to 'int'
I have vs-2010 somewhere.
Title: Re: Fork of QD (2.3.17) dll
Post by: TimoVJL on August 13, 2017, 07:27:29 PM
so you have to add
Code: [Select]
#if _MSC_VER >= 18
#include <algorithm>
#endif
to dd_real.cpp and qd_real.cpp
Title: Re: Fork of QD (2.3.17) dll
Post by: jack on August 13, 2017, 07:55:56 PM
you are the man  :)
works like a charm, thank you.
Title: Re: Fork of QD (2.3.17) dll
Post by: jack on August 24, 2017, 01:37:17 PM
tank you TimoVJL  :)
having a C version means we can have a static lib instead of a dll, will keep an eye on your progress.
Title: Re: Fork of QD (2.3.17) dll
Post by: jack on August 27, 2017, 05:22:13 AM
hello TimoVJL :)
just for fun I tried to compile the source files with gcc and there are no complaints, however if I try to compile to dll then there are three errors
undefined reference to `c_dd_error'
undefined reference to `c_dd_div_d_dd'
undefined reference to `dd_real_eps'
Title: Re: Fork of QD (2.3.17) dll
Post by: jack on August 27, 2017, 12:35:03 PM
thank you
Title: Re: Fork of QD (2.3.17) dll
Post by: jack on August 29, 2017, 06:56:27 PM
hello TimoVJL
I tested c_dd_dll_ms and here's what I found
c_dd_add   ok
c_dd_sub   ok
c_dd_mul   ok
c_dd_div   ok
c_dd_sqr   ok
c_dd_sqrt   ok
c_dd_write   ok
c_dd_read   ok
the trig, log and exp functions give wrong results, c_dd_atan gives right result only for arg=1, c_dd_tan is missing.
sorry for the bad report, I just thought that you might like to have some feedback. :)
Title: Re: Fork of QD (2.3.17) dll
Post by: jack on August 29, 2017, 08:49:35 PM
hello TimoVJL
I didn't think about this earlier, but this type of arithmetic is sensitive to the FPU setting, remember that in the original code there were two functions to set the FPU flags, I bet that's where the problem is, or if you can coerce the compiler to use sse2 instructions then you should be ok.
Title: Re: Fork of QD (2.3.17) dll
Post by: jj2007 on August 30, 2017, 05:26:48 PM
this type of arithmetic is sensitive to the FPU setting, remember that in the original code there were two functions to set the FPU flags, I bet that's where the problem is, or if you can coerce the compiler to use sse2 instructions then you should be ok.

But don't forget LDMXCSR ;)
Title: Re: Fork of QD (2.3.17) dll
Post by: jack on September 05, 2017, 01:47:22 PM
hello TimoVJL
you are getting close, however there's a bug in dd_to_digits, if dd_variable.x[0] = 0.1 and dd_variable.x[1] = -5.551115123125983e-018 then you get an error and crash.
Quote
(dd_to_digits): can't compute exponent.
the trigs seem to be ok, but only made a very simple test.
Title: Re: Fork of QD (2.3.17) dll
Post by: jack on September 05, 2017, 04:41:07 PM
there's a problem with dd_cos, if dd_x = 1/n , n=11, 12, 13 ... then dd_cos fails, for dd_x=1/11 the result is
Quote
                                   dd_x.x[0]                               dd_x[1]
cos(1/11)            0.9958706137005629          0.9958706137005629
it should be something like
Quote
cos(1/11)            0.9958706137005629         -4.772639498746044e-017
[edit] dd_log is not working
Title: Re: Fork of QD (2.3.17) dll
Post by: jack on September 05, 2017, 07:57:36 PM
I did a loop from -70 to 70 and used mpfr for verification, for log/exp the loop was from 1 to 70
sin, cos, tan, atan, log and exp are ok, not sure about the hyperbolic functions.
Title: Re: Fork of QD (2.3.17) dll
Post by: jack on September 05, 2017, 08:10:05 PM
dd_atanh(dd_tanh(x)) from 1 to 19 ok, above 19 dd_atanh says "Argument out of domain."
Title: Re: Fork of QD (2.3.17) dll
Post by: jack on September 05, 2017, 09:13:35 PM
we really need a good test suite to check the functions in the supported range, the hyperbolic functions are trickier to check.
Title: Re: Fork of QD (2.3.17) dll
Post by: jack on September 06, 2017, 12:11:46 AM
I made a small test and the trigs -not including hyperbolic- , log and exp seem to be ok
I have been doing my testing in freebasic because I am more familiar with it than C.