NO

Author Topic: Fork of QD (2.3.17) dll  (Read 1254 times)

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 1642
Fork of QD (2.3.17) dll
« on: August 12, 2017, 09:23:20 am »
Fork of QD (2.3.17) dll
c_test.c from it & QD.dll & QD.lib import library.

EDIT: missing headers and libs added.
EDIT  QDSSE.dll for 32-bit.
« Last Edit: August 13, 2017, 08:56:17 am by TimoVJL »
May the source be with you

Offline jj2007

  • Member
  • *
  • Posts: 471
Re: Fork of QD (2.3.17) dll
« Reply #1 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?

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 1642
Re: Fork of QD (2.3.17) dll
« Reply #2 on: August 12, 2017, 05:11:32 pm »
Because it is C++ code, dll is obvious choice.
May the source be with you

Offline jack

  • Member
  • *
  • Posts: 59
Re: Fork of QD (2.3.17) dll
« Reply #3 on: August 13, 2017, 01:43:39 am »
thanks you :)

Offline jack

  • Member
  • *
  • Posts: 59
Re: Fork of QD (2.3.17) dll
« Reply #4 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.
« Last Edit: August 13, 2017, 08:57:52 am by jack »

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 1642
Re: Fork of QD (2.3.17) dll
« Reply #5 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.
May the source be with you

Offline jack

  • Member
  • *
  • Posts: 59
Re: Fork of QD (2.3.17) dll
« Reply #6 on: August 13, 2017, 12:23:45 pm »
unfortunately it's still using the fpu.
« Last Edit: August 13, 2017, 12:39:25 pm by jack »

Offline jack

  • Member
  • *
  • Posts: 59
Re: Fork of QD (2.3.17) dll
« Reply #7 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.

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 1642
Re: Fork of QD (2.3.17) dll
« Reply #8 on: August 13, 2017, 03:31:30 pm »
No.
build cmd attached.
May the source be with you

Offline jack

  • Member
  • *
  • Posts: 59
Re: Fork of QD (2.3.17) dll
« Reply #9 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.

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 1642
Re: Fork of QD (2.3.17) dll
« Reply #10 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
May the source be with you

Offline jack

  • Member
  • *
  • Posts: 59
Re: Fork of QD (2.3.17) dll
« Reply #11 on: August 13, 2017, 07:55:56 pm »
you are the man  :)
works like a charm, thank you.

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 1642
Re: Fork of QD (2.3.17) dd to PellesC
« Reply #12 on: August 22, 2017, 07:50:03 pm »
Only dd part is partially converted to PellesC, still a lot of errors.
This is for someone who want to develop it further and fix bugs.

WARNING: functions are not tested properly :(

Example:
Code: [Select]
#include "c_dd.h"
#pragma comment(lib, "c_dd.lib")

int printf(const char * restrict format, ...);
int puts(const char *string);
// user msg
void c_dd_error(char* msg) { puts(msg); }

int main(void)
{
char buf[200];
double dd[2]; // double-double
c_dd_read("1.234567890", dd);
c_dd_swrite(dd, 10, buf, sizeof(buf));
puts(buf);
return 0;
}

I don't use this code, just test how to convert QD to C

EDIT 2017-08-24: asin and acos added.
EDIT 2017-08-25: fix to c_dd_write/c_dd_swrite
EDIT 2017-08-26: another fix to c_dd_write/c_dd_swrite at to c_dd_exp
EDIT 2017-08-31: fix for sin / cos / tan functions.
EDIT 2017-09-01: fixes for Pellesc, avoid using qd_quick_two_sum(), possible bug with it.
EDIT 2017-09-05: fix for two_sum / two_diff and c_dd_write / dd_to_string
            dd_cos_taylor sinh / cosh / tanh
EDIT 2017-09-06: fix for exp / sinh / tanh
EDIT 2017-09-07: fix for asinh / acosh
Code: [Select]
#include <stdio.h>
#include "c_dd.h"

#if __POCC_TARGET__ >= 3
#pragma comment(lib, "c_dd64.lib")
#else
#pragma comment(lib, "c_dd.lib")
#endif

// user msg
void c_dd_error(char* msg) { puts(msg); }

int main(void)
{
double dd[2]; // double-double
c_dd_pi(dd);
c_dd_write(dd);
double dd1[2], dd2[2], dd3[2];
c_dd_copy_d(1.0, dd1);
c_dd_copy_d(2.0, dd2);
c_dd_add(dd1, dd2, dd3);
c_dd_write(dd3);
c_dd_sub(dd1, dd2, dd3);
c_dd_write(dd3);
c_dd_mul(dd1, dd2, dd3);
c_dd_write(dd3);
c_dd_div(dd1, dd2, dd3);
c_dd_write(dd3);
return 0;
}

EDIT 2017-08-26: dll with stdcall undecorated functions for others languages.
« Last Edit: September 08, 2017, 01:54:13 pm by TimoVJL »
May the source be with you

Offline jack

  • Member
  • *
  • Posts: 59
Re: Fork of QD (2.3.17) dll
« Reply #13 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.

Offline jack

  • Member
  • *
  • Posts: 59
Re: Fork of QD (2.3.17) dll
« Reply #14 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'
« Last Edit: August 27, 2017, 05:25:14 am by jack »