QDouble.st
author Claus Gittinger <cg@exept.de>
Wed, 14 Jun 2017 11:48:49 +0200
changeset 4388 742f099741bf
parent 4387 879309cae427
child 4389 54ec85aa8943
permissions -rw-r--r--
*** empty log message ***
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 2017 by eXept Software AG
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
     3
	      All Rights Reserved
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libbasic2' }"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
"{ NameSpace: Smalltalk }"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
LimitedPrecisionReal variableByteSubclass:#QDouble
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
	instanceVariableNames:''
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
	classVariableNames:'DefaultPrintFormat QDoubleZero QDoubleOne Pi E Ln2 Ln10 Epsilon'
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
	poolDictionaries:''
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
	category:'Magnitude-Numbers'
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
!QDouble primitiveDefinitions!
4385
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
    24
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
%{
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
#include <stdio.h>
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
#include <errno.h>
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
#define __USE_ISOC9X 1
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
#define __USE_ISOC99 1
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
#include <math.h>
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
/*
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
 * on some systems, errno is a macro ... check for it here
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
 */
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
#ifndef errno
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
 extern errno;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
#endif
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
#if !defined (__win32__)
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
# include <locale.h>
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
#endif
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
#if defined (__aix__)
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
# include <float.h>
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
#endif
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
#if defined(__irix__) || defined(__solaris__) || defined(__sunos__)
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
# include <nan.h>
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
#endif
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
#if defined(__linux__)
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
# ifndef NAN
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
#  include <bits/nan.h>
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
# endif
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
#endif
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
4387
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
    58
#if defined(__x86__) || defined(__x86_64__)
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
    59
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
    60
# ifndef _FPU_EXTENDED
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
    61
#  define _FPU_EXTENDED 0x0300
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
    62
# endif
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
    63
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
    64
# ifndef _FPU_DOUBLE
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
    65
#  define _FPU_DOUBLE 0x0200
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
    66
# endif
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
    67
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
    68
# if defined( __win32__ ) && (defined( __BORLANDC__ ) || defined( __VISUALC__ ))
4387
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
    69
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
    70
#  define fpu_fix_start(old_cw_ptr)\
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
    71
    {\
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
    72
	*old_cw_ptr = _control87(0, 0); \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
    73
	_control87(_FPU_DOUBLE, _FPU_EXTENDED);\
4387
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
    74
    }
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
    75
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
    76
#  define fpu_fix_end(old_cw_ptr)\
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
    77
    {\
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
    78
	_control87(*old_cw_ptr, _FPU_EXTENDED);\
4387
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
    79
    }
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
    80
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
    81
# else // assume MINGW, GCC or CLANG
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
    82
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
    83
#  ifndef _FPU_GETCW
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
    84
#   define _FPU_GETCW(x) asm volatile ("fnstcw %0":"=m" (x));
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
    85
#  endif
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
    86
#  ifndef _FPU_SETCW
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
    87
#   define _FPU_SETCW(x) asm volatile ("fldcw %0": :"m" (x));
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
    88
#  endif
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
    89
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
    90
#  define fpu_fix_start(old_cw_ptr)\
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
    91
    {\
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
    92
	volatile unsigned short cw, new_cw;\
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
    93
	_FPU_GETCW(cw);\
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
    94
	new_cw = (cw & ~_FPU_EXTENDED) | _FPU_DOUBLE;\
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
    95
	_FPU_SETCW(new_cw);\
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
    96
	*old_cw_ptr = cw;\
4387
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
    97
    }
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
    98
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
    99
#  define fpu_fix_end(old_cw_ptr)\
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
   100
    {\
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   101
	volatile unsigned short cw = *old_cw_ptr;\
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   102
	_FPU_SETCW(cw);\
4387
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
   103
    }
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
   104
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
   105
# endif
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
   106
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
   107
#endif
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
   108
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
   109
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
struct qd_real {
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
    double x[4];    /* The Components. */
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
};
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
struct __quadDoubleStruct {
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   115
	STX_OBJ_HEADER
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
#ifdef __NEED_DOUBLE_ALIGN
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   117
	__FILLTYPE_DOUBLE f_filler;
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
#endif
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   119
	double d_quadDoubleValue[4];
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
};
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
#define __QuadDoubleInstPtr(obj)      ((struct __quadDoubleStruct *)(__objPtr(obj)))
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
#ifndef __isQuadDouble
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
# define __isQuadDouble(o) \
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   126
	(__Class(o) == @global(QuadDouble))
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
#endif
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
#ifndef __qIsQuadDouble
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   130
# define __qIsQuadDouble(o) \
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   131
	(__qClass(o) == @global(QuadDouble))
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
#endif
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
#define __qNew_qdReal(newQD, d0,d1,d2,d3) { \
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
    __qNew(newQD, sizeof(struct __quadDoubleStruct)); \
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
    __stx_setClass(newQD, QDouble);                \
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
    __QuadDoubleInstPtr(newQD)->d_quadDoubleValue[0] = d0;   \
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
    __QuadDoubleInstPtr(newQD)->d_quadDoubleValue[1] = d1;   \
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
    __QuadDoubleInstPtr(newQD)->d_quadDoubleValue[2] = d2;   \
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
    __QuadDoubleInstPtr(newQD)->d_quadDoubleValue[3] = d3;   \
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
// qd_real(c0, c1, c2, c3);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
#define _QD_SPLITTER 134217729.0               // = 2^27 + 1
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
#define _QD_SPLIT_THRESH 6.69692879491417e+299 // = 2^996
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
#define m_quick_two_sum(rslt, a, b, err) {\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
  double s = a + b;\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
  err = b - (s - a);\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
  rslt = s; \
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   152
}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
4387
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
   154
#define m_quick_two_diff(rslt, a, b, err) {\
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
   155
  double s = a - b;\
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
   156
  err = (a - s) - b;\
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
   157
  rslt = s;\
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
   158
}
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
   159
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   160
#define m_two_sum(rslt, a, b, err) {\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   161
  double s = a + b;\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   162
  double bb = s - a;\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   163
  err = (a - (s - bb)) + (b - bb);\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   164
  rslt = s;\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
4387
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
   167
/* Computes fl(a-b) and err(a-b).  */
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
   168
#define m_two_diff(rslt, a, b, err) {\
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
   169
  double s = a - b;\
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
   170
  double bb = s - a;\
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
   171
  err = (a - (s - bb)) - (b + bb);\
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
   172
  rslt = s;\
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
   173
}
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
   174
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   175
#define m_three_sum(a, b, c) { \
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   176
  double t1, t2, t3; \
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   177
  m_two_sum(t1, a, b, t2); \
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   178
  m_two_sum(a, c, t1, t3); \
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   179
  m_two_sum(b, t2, t3, c); \
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   180
}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   181
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   182
#define m_three_sum2(a, b, c) {\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   183
  double t1, t2, t3;\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   184
  m_two_sum(t1, a, b, t2);\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   185
  m_two_sum(a, c, t1, t3);\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   186
  b = t2 + t3;\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   187
}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   188
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   189
#ifndef QD_FMS
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   190
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   191
/* Computes high word and lo word of a */
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   192
#define m_split(a, hi, lo) {\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   193
  double temp;\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
  if (a > _QD_SPLIT_THRESH || a < -_QD_SPLIT_THRESH) {\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
    a *= 3.7252902984619140625e-09;\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
    temp = _QD_SPLITTER * a;\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
    hi = temp - (temp - a);\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
    lo = a - hi;\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   199
    hi *= 268435456.0;\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
    lo *= 268435456.0;\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
  } else {\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
    temp = _QD_SPLITTER * a;\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
    hi = temp - (temp - a);\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
    lo = a - hi;\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
  }\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
#endif
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
#ifdef QD_FMS
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
/* Computes fl(a*b) and err(a*b). */
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
#define m_two_prod(rslt, a, b, err) {\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
  double p = a * b;\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
  err = QD_FMS(a, b, p);\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
  rslt = p; \
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
#else
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
#define m_two_prod(rslt, a, b, err) {\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
  double a_hi, a_lo, b_hi, b_lo;\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
  double p = a * b;\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
  m_split(a, a_hi, a_lo);\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
  m_split(b, b_hi, b_lo);\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
  err = ((a_hi * b_hi - p) + a_hi * b_lo + a_lo * b_hi) + a_lo * b_lo;\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
  rslt = p; \
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
#endif
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
#ifdef QD_FMS
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
#define m_two_sqr(rslt, a, err) {\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
  double p = a * a;\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   238
  err = QD_FMS(a, a, p);\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   239
  rslt = p;\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
#else
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
#define m_two_sqr(rslt, a, err) {\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
  double hi, lo;\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
  double q = a * a;\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
  m_split(a, hi, lo);\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
  err = ((hi * hi - q) + 2.0 * hi * lo) + lo * lo;\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
  rslt = q;\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
#endif
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
#define m_renorm4(c0, c1, c2, c3) {\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   255
  double s0, s1, s2 = 0.0, s3 = 0.0;\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   256
\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   257
    if (! isinf(c0)) { \
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   258
\
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   259
	m_quick_two_sum(s0, c2, c3, c3);\
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   260
	m_quick_two_sum(s0, c1, s0, c2);\
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   261
	m_quick_two_sum(c0, c0, s0, c1);\
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
\
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   263
	s0 = c0;\
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   264
	s1 = c1;\
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   265
	if (s1 != 0.0) {\
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   266
	     m_quick_two_sum(s1, s1, c2, s2);\
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   267
	    if (s2 != 0.0) {\
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   268
		 m_quick_two_sum(s2, s2, c3, s3);\
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   269
	    } else {\
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   270
		 m_quick_two_sum(s1, s1, c3, s2);\
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   271
	    }\
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   272
	} else {\
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   273
	    m_quick_two_sum(s0, s0, c2, s1);\
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   274
	    if (s1 != 0.0) {\
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   275
		 m_quick_two_sum(s1, s1, c3, s2);\
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   276
	    } else {\
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   277
		 m_quick_two_sum(s0, s0, c3, s1);\
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   278
	    }\
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   279
	}\
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
\
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   281
	c0 = s0;\
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   282
	c1 = s1;\
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   283
	c2 = s2;\
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   284
	c3 = s3;\
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
    }\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
#define m_renorm5(c0, c1, c2, c3, c4) { \
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
    double s0, s1, s2 = 0.0, s3 = 0.0; \
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
\
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
    if (! isinf(c0)) { \
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   292
	m_two_sum(s0, c3, c4, c4); \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   293
	m_quick_two_sum(s0, c2, s0, c3); \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   294
	m_quick_two_sum(s0, c1, s0, c2); \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   295
	m_quick_two_sum(c0, c0, s0, c1); \
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
\
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   297
	s0 = c0; \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   298
	s1 = c1; \
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
\
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   300
	m_two_sum(s0, c0, c1, s1); \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   301
	if (s1 != 0.0) { \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   302
	    m_quick_two_sum(s1, s1, c2, s2); \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   303
	    if (s2 != 0.0) { \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   304
		m_quick_two_sum(s2 ,s2, c3, s3); \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   305
		if (s3 != 0.0) {\
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   306
		    s3 += c4; \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   307
		} else {\
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   308
		    s2 += c4;\
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   309
		}\
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   310
	    } else { \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   311
		m_quick_two_sum(s1, s1, c3, s2); \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   312
		if (s2 != 0.0) {\
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   313
		    m_quick_two_sum(s2, s2, c4, s3); \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   314
		} else { \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   315
		    m_quick_two_sum(s1, s1, c4, s2); \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   316
		} \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   317
	    } \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   318
	} else { \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   319
	    m_quick_two_sum(s0,s0, c2, s1); \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   320
	    if (s1 != 0.0) { \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   321
		m_quick_two_sum(s1,s1, c3, s2); \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   322
		if (s2 != 0.0) {\
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   323
		    m_quick_two_sum(s2,s2, c4, s3); \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   324
		} else { \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   325
		    m_quick_two_sum(s1 ,s1, c4, s2); \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   326
		} \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   327
	    } else { \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   328
		m_quick_two_sum(s0,s0, c3, s1); \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   329
		if (s1 != 0.0) { \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   330
		    m_quick_two_sum(s1,s1, c4, s2); \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   331
		} else { \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   332
		    m_quick_two_sum(s0,s0, c4, s1); \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   333
		} \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   334
	    } \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   335
	} \
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   336
 \
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   337
	c0 = s0; \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   338
	c1 = s1; \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   339
	c2 = s2; \
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   340
	c3 = s3; \
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   341
    } \
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   342
}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   343
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   344
%}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   345
! !
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   346
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   347
!QDouble primitiveFunctions!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   348
%{
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   349
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   350
/*********** Basic Functions ************/
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   351
/* Computes fl(a+b) and err(a+b).  Assumes |a| >= |b|. */
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   352
inline double
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   353
quick_two_sum(double a, double b, double *errPtr) {
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   354
  double s = a + b;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   355
  *errPtr = b - (s - a);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   356
  return s;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   357
}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   358
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   359
/* Computes fl(a-b) and err(a-b).  Assumes |a| >= |b| */
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   360
inline double
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   361
quick_two_diff(double a, double b, double *errPtr) {
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   362
  double s = a - b;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   363
  *errPtr = (a - s) - b;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   364
  return s;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   365
}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   366
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   367
/* Computes fl(a+b) and err(a+b).  */
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   368
inline double
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   369
two_sum(double a, double b, double *errPtr) {
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   370
  double s = a + b;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   371
  double bb = s - a;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   372
  *errPtr = (a - (s - bb)) + (b - bb);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   373
  return s;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   374
}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   375
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   376
/* Computes fl(a-b) and err(a-b).  */
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   377
inline double
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   378
two_diff(double a, double b, double *errPtr) {
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   379
  double s = a - b;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   380
  double bb = s - a;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   381
  *errPtr = (a - (s - bb)) - (b + bb);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   382
  return s;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   383
}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   384
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   385
#ifndef QD_FMS
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   386
/* Computes high word and lo word of a */
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   387
inline void
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   388
split(double a, double *hiPtr, double *loPtr) {
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   389
  double temp;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   390
  if (a > _QD_SPLIT_THRESH || a < -_QD_SPLIT_THRESH) {
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   391
    a *= 3.7252902984619140625e-09;  // 2^-28
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   392
    temp = _QD_SPLITTER * a;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   393
    *hiPtr = temp - (temp - a);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   394
    *loPtr = a - *hiPtr;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   395
    *hiPtr *= 268435456.0;          // 2^28
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   396
    *loPtr *= 268435456.0;          // 2^28
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   397
  } else {
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   398
    temp = _QD_SPLITTER * a;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   399
    *hiPtr = temp - (temp - a);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   400
    *loPtr = a - *hiPtr;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   401
  }
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   402
}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   403
#endif
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   404
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   405
/* Computes fl(a*b) and err(a*b). */
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   406
inline double
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   407
two_prod(double a, double b, double *errPtr) {
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   408
#ifdef QD_FMS
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   409
  double p = a * b;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   410
  *errPtr = QD_FMS(a, b, p);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   411
  return p;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   412
#else
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   413
  double a_hi, a_lo, b_hi, b_lo;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   414
  double p = a * b;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   415
  split(a, &a_hi, &a_lo);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   416
  split(b, &b_hi, &b_lo);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   417
  *errPtr = ((a_hi * b_hi - p) + a_hi * b_lo + a_lo * b_hi) + a_lo * b_lo;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   418
  return p;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   419
#endif
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   420
}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   421
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   422
/* Computes fl(a*a) and err(a*a).  Faster than the above method. */
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   423
inline double
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   424
two_sqr(double a, double *errPtr) {
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   425
#ifdef QD_FMS
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   426
  double p = a * a;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   427
  *errPtr = QD_FMS(a, a, p);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   428
  return p;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   429
#else
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   430
  double hi, lo;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   431
  double q = a * a;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   432
  split(a, &hi, &lo);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   433
  *errPtr = ((hi * hi - q) + 2.0 * hi * lo) + lo * lo;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   434
  return q;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   435
#endif
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   436
}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   437
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   438
/* Computes the nearest integer to d. */
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   439
inline double
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   440
nint(double d) {
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   441
  if (d == floor(d))
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   442
    return d;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   443
  return floor(d + 0.5);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   444
}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   445
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   446
/* Computes the truncated integer. */
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   447
inline double
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   448
aint(double d) {
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   449
  return (d >= 0.0) ? floor(d) : ceil(d);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   450
}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   451
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   452
inline void
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   453
renorm4(double *c0Ptr, double *c1Ptr, double *c2Ptr, double *c3Ptr) {
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   454
  double s0, s1, s2 = 0.0, s3 = 0.0;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   455
  double c0 = *c0Ptr;
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   456
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   457
  if (isinf(c0)) return;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   458
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   459
  s0 = quick_two_sum(*c2Ptr, *c3Ptr, c3Ptr);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   460
  s0 = quick_two_sum(*c1Ptr, s0, c2Ptr);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   461
  c0 = quick_two_sum(c0, s0, c1Ptr);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   462
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   463
  s0 = c0;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   464
  s1 = *c1Ptr;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   465
  if (s1 != 0.0) {
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   466
    s1 = quick_two_sum(s1, *c2Ptr, &s2);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   467
    if (s2 != 0.0)
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   468
      s2 = quick_two_sum(s2, *c3Ptr, &s3);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   469
    else
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   470
      s1 = quick_two_sum(s1, *c3Ptr, &s2);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   471
  } else {
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   472
    s0 = quick_two_sum(s0, *c2Ptr, &s1);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   473
    if (s1 != 0.0)
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   474
      s1 = quick_two_sum(s1, *c3Ptr, &s2);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   475
    else
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   476
      s0 = quick_two_sum(s0, *c3Ptr, &s1);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   477
  }
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   478
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   479
  *c0Ptr = s0;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   480
  *c1Ptr = s1;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   481
  *c2Ptr = s2;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   482
  *c3Ptr = s3;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   483
}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   484
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   485
inline void
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   486
renorm5(double *c0Ptr, double *c1Ptr, double *c2Ptr, double *c3Ptr, double *c4Ptr) {
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   487
  double s0, s1, s2 = 0.0, s3 = 0.0;
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   488
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   489
  if (isinf(*c0Ptr)) return;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   490
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   491
  s0 = quick_two_sum(*c3Ptr, *c4Ptr, c4Ptr);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   492
  s0 = quick_two_sum(*c2Ptr, s0, c3Ptr);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   493
  s0 = quick_two_sum(*c1Ptr, s0, c2Ptr);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   494
  *c0Ptr = quick_two_sum(*c0Ptr, s0, c1Ptr);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   495
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   496
  s0 = *c0Ptr;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   497
  s1 = *c1Ptr;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   498
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   499
  s0 = quick_two_sum(*c0Ptr, *c1Ptr, &s1);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   500
  if (s1 != 0.0) {
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   501
    s1 = quick_two_sum(s1, *c2Ptr, &s2);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   502
    if (s2 != 0.0) {
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   503
      s2 =quick_two_sum(s2, *c3Ptr, &s3);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   504
      if (s3 != 0.0)
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   505
	s3 += *c4Ptr;
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   506
      else
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   507
	s2 += *c4Ptr;
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   508
    } else {
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   509
      s1 = quick_two_sum(s1, *c3Ptr, &s2);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   510
      if (s2 != 0.0)
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   511
	s2 = quick_two_sum(s2, *c4Ptr, &s3);
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   512
      else
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   513
	s1 = quick_two_sum(s1, *c4Ptr, &s2);
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   514
    }
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   515
  } else {
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   516
    s0 = quick_two_sum(s0, *c2Ptr, &s1);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   517
    if (s1 != 0.0) {
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   518
      s1 = quick_two_sum(s1, *c3Ptr, &s2);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   519
      if (s2 != 0.0)
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   520
	s2 = quick_two_sum(s2, *c4Ptr, &s3);
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   521
      else
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   522
	s1 = quick_two_sum(s1, *c4Ptr, &s2);
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   523
    } else {
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   524
      s0 = quick_two_sum(s0, *c3Ptr, &s1);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   525
      if (s1 != 0.0)
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   526
	s1 = quick_two_sum(s1, *c4Ptr, &s2);
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   527
      else
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   528
	s0 = quick_two_sum(s0, *c4Ptr, &s1);
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   529
    }
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   530
  }
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   531
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   532
  *c0Ptr = s0;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   533
  *c1Ptr = s1;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   534
  *c2Ptr = s2;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   535
  *c3Ptr = s3;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   536
}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   537
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   538
inline void
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   539
three_sum(double *aPtr, double *bPtr, double *cPtr) {
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   540
  double t1, t2, t3;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   541
  t1 = two_sum(*aPtr, *bPtr, &t2);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   542
  *aPtr  = two_sum(*cPtr, t1, &t3);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   543
  *bPtr  = two_sum(t2, t3, cPtr);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   544
}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   545
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   546
inline void three_sum2(double *aPtr, double *bPtr, double *cPtr) {
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   547
  double t1, t2, t3;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   548
  t1 = two_sum(*aPtr, *bPtr, &t2);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   549
  *aPtr  = two_sum(*cPtr, t1, &t3);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   550
  *bPtr = t2 + t3;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   551
}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   552
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   553
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   554
#if 0
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   555
/* These are provided to give consistent
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   556
   interface for double with double-double and quad-double. */
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   557
inline void
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   558
sincosh(double t, double &sinh_t, double &cosh_t) {
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   559
  sinh_t = sinh(t);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   560
  cosh_t = cosh(t);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   561
}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   562
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   563
inline double
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   564
sqr(double t) {
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   565
  return t * t;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   566
}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   567
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   568
inline double
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   569
to_double(double a) {
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   570
    return a;
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   571
}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   572
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   573
inline int
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   574
to_int(double a)    {
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   575
    return static_cast<int>(a);
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   576
}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   577
#endif
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   578
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   579
%}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   580
! !
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   581
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   582
!QDouble class methodsFor:'documentation'!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   583
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   584
copyright
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   585
"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   586
 COPYRIGHT (c) 2017 by eXept Software AG
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   587
	      All Rights Reserved
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   588
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   589
 This software is furnished under a license and may be used
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   590
 only in accordance with the terms of that license and with the
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   591
 inclusion of the above copyright notice.   This software may not
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   592
 be provided or otherwise made available to, or used by, any
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   593
 other person.  No title to or ownership of the software is
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   594
 hereby transferred.
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   595
"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   596
!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   597
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   598
documentation
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   599
"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   600
    QDoubles represent rational numbers with extended, but still limited precision.
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   601
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   602
    In contrast to Floats (which use the C-compilers native 64bit 'double' format),
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   603
    QDoubles give you 212 bit or approx. 64 decimal digits of precision.
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   604
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   605
    Representation:
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   606
	QDoubles use 4 IEEE doubles, each keeping 53 bits of precision.
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   607
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   608
    Range and Precision of Storage Formats: see LimitedPrecisionReal >> documentation
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   609
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   610
    [author:]
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   611
	Claus Gittinger
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   612
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   613
    [see also:]
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   614
	Number
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   615
	Float ShortFloat Fraction FixedPoint Integer Complex
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   616
	FloatArray DoubleArray
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   617
"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   618
! !
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   619
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   620
!QDouble class methodsFor:'instance creation'!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   621
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   622
basicNew
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   623
    "return a new quad-precision double - here we return 0.0
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   624
     Notice that numbers are usually NOT created this way ...
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   625
     It's implemented here to allow things like binary store & load
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   626
     of floats. (but even this support will go away eventually, it's not
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   627
     a good idea to store the bits of a float - the reader might have a
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   628
     totally different representation - so floats should be
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   629
     binary stored in a device independent format."
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   630
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   631
%{  /* NOCONTEXT */
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   632
#ifdef __SCHTEAM__
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   633
    ERROR("trying to instantiate a quad double");
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   634
#else
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   635
    OBJ newFloat;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   636
printf("xxx\n");
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   637
    __qNew(newFloat, sizeof(struct __quadDoubleStruct));
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   638
    __stx_setClass(newFloat, QDouble);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   639
    __QuadDoubleInstPtr(newFloat)->d_quadDoubleValue[0] = 0.0;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   640
    __QuadDoubleInstPtr(newFloat)->d_quadDoubleValue[1] = 0.0;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   641
    __QuadDoubleInstPtr(newFloat)->d_quadDoubleValue[2] = 0.0;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   642
    __QuadDoubleInstPtr(newFloat)->d_quadDoubleValue[3] = 0.0;
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   643
    RETURN (newFloat);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   644
#endif /* not SCHTEAM */
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   645
%}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   646
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   647
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   648
     self basicNew
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   649
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   650
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   651
    "Created: / 12-06-2017 / 16:00:38 / cg"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   652
!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   653
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   654
d0:d0 d1:d1 d2:d2 d3:d3
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   655
    "return a new quad-precision double from individual double components"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   656
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   657
%{  /* NOCONTEXT */
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   658
#ifdef __SCHTEAM__
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   659
    ERROR("trying to instantiate a quad double");
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   660
#else
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   661
    OBJ newQD;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   662
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   663
    if (__isFloatLike(d0)
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   664
     && __isFloatLike(d1)
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   665
     && __isFloatLike(d2)
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   666
     && __isFloatLike(d3)) {
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   667
	__qNew_qdReal(newQD, __floatVal(d0), __floatVal(d1),
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   668
			     __floatVal(d2), __floatVal(d3));
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   669
	RETURN (newQD);
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   670
    }
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   671
#endif
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   672
%}.
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   673
    self error:'invalid argument'
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   674
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   675
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   676
     self d0: 3.141592653589793116e+00
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   677
	  d1: 1.224646799147353207e-16
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   678
	  d2: -2.994769809718339666e-33
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   679
	  d3: 1.112454220863365282e-49
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   680
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   681
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   682
    "Created: / 12-06-2017 / 20:17:14 / cg"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   683
!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   684
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   685
fromDoubleArray:aDoubleArray
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   686
    "return a new quad-precision double from coercing a double array"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   687
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   688
%{  /* NOCONTEXT */
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   689
#ifdef __SCHTEAM__
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   690
    ERROR("trying to instantiate a quad double");
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   691
#else
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   692
    OBJ newQD;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   693
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   694
    if (__isDoubleArray(aDoubleArray)) {
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   695
	__qNew_qdReal(newQD,
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   696
		    __DoubleArrayInstPtr(aDoubleArray)->d_element[0],
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   697
		    __DoubleArrayInstPtr(aDoubleArray)->d_element[1],
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   698
		    __DoubleArrayInstPtr(aDoubleArray)->d_element[2],
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   699
		    __DoubleArrayInstPtr(aDoubleArray)->d_element[3]);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   700
	RETURN (newQD);
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   701
    }
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   702
#endif
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   703
%}.
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   704
    self error:'invalid argument'
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   705
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   706
    "
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   707
     self fromDoubleArray(DoubleArray
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   708
				with: 3.141592653589793116e+00
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   709
				with: 1.224646799147353207e-16
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   710
				with: -2.994769809718339666e-33
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   711
				with: 1.112454220863365282e-49)
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   712
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   713
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   714
    "Created: / 12-06-2017 / 18:25:32 / cg"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   715
!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   716
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   717
fromFloat:aFloat
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   718
    "return a new quad-precision double from coercing aFloat"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   719
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   720
%{  /* NOCONTEXT */
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   721
#ifdef __SCHTEAM__
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   722
    ERROR("trying to instantiate a quad double");
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   723
#else
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   724
    double dVal;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   725
    OBJ newFloat;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   726
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   727
    if (__isFloatLike(aFloat)) {
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   728
	dVal = __floatVal(aFloat);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   729
    } else if (__isShortFloat(aFloat)) {
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   730
	dVal = __shortFloatVal(aFloat);
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   731
    } else {
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   732
	goto badArg;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   733
    }
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   734
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   735
    __qNew(newFloat, sizeof(struct __quadDoubleStruct));
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   736
    __stx_setClass(newFloat, QDouble);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   737
    __QuadDoubleInstPtr(newFloat)->d_quadDoubleValue[0] = dVal;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   738
    __QuadDoubleInstPtr(newFloat)->d_quadDoubleValue[1] = 0.0;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   739
    __QuadDoubleInstPtr(newFloat)->d_quadDoubleValue[2] = 0.0;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   740
    __QuadDoubleInstPtr(newFloat)->d_quadDoubleValue[3] = 0.0;
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   741
    RETURN (newFloat);
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   742
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   743
badArg: ;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   744
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   745
#endif
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   746
%}.
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   747
    self error:'invalid argument'
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   748
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   749
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   750
     self fromFloat:1.0
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   751
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   752
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   753
    "Created: / 12-06-2017 / 16:06:54 / cg"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   754
!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   755
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   756
fromInteger:anInteger
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   757
    "return a new quad-precision double from coercing anInteger"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   758
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   759
%{  /* NOCONTEXT */
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   760
#ifndef __SCHTEAM__
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   761
    OBJ newFloat;
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   762
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   763
    if (__isSmallInteger(anInteger)) {
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   764
	__qNew(newFloat, sizeof(struct __quadDoubleStruct));
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   765
	__stx_setClass(newFloat, QDouble);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   766
	__QuadDoubleInstPtr(newFloat)->d_quadDoubleValue[0] = (double)(__smallIntegerVal(anInteger));
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   767
	__QuadDoubleInstPtr(newFloat)->d_quadDoubleValue[1] = 0.0;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   768
	__QuadDoubleInstPtr(newFloat)->d_quadDoubleValue[2] = 0.0;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   769
	__QuadDoubleInstPtr(newFloat)->d_quadDoubleValue[3] = 0.0;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   770
	RETURN (newFloat);
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   771
    }
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   772
#endif
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   773
%}.
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   774
    ^ super fromInteger:anInteger
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   775
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   776
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   777
     self fromInteger:2
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   778
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   779
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   780
    "Created: / 12-06-2017 / 16:10:10 / cg"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   781
! !
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   782
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   783
!QDouble class methodsFor:'constants'!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   784
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   785
e
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   786
    "return the constant e as quad precision double.
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   787
     (returns approx. 212 bits of precision)"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   788
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   789
    E isNil ifTrue:[
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   790
	E := self fromDoubleArray:(DoubleArray
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   791
				    with: 2.718281828459045091e+00
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   792
				    with: 1.445646891729250158e-16
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   793
				    with: -2.127717108038176765e-33
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   794
				    with: 1.515630159841218954e-49)
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   795
    ].
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   796
    ^ E
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   797
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   798
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   799
     self e
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   800
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   801
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   802
    "Created: / 12-06-2017 / 18:29:36 / cg"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   803
!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   804
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   805
ln10
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   806
    "return the constant e as quad precision double.
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   807
     (returns approx. 212 bits of precision)"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   808
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   809
    Ln10 isNil ifTrue:[
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   810
	Ln10 := self fromDoubleArray:(DoubleArray
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   811
				    with: 2.302585092994045901e+00
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   812
				    with: -2.170756223382249351e-16
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   813
				    with: -9.984262454465776570e-33
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   814
				    with: -4.023357454450206379e-49)
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   815
    ].
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   816
    ^ Ln10
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   817
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   818
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   819
     self ln10
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   820
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   821
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   822
    "Created: / 12-06-2017 / 18:32:29 / cg"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   823
!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   824
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   825
ln2
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   826
    "return the constant e as quad precision double.
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   827
     (returns approx. 212 bits of precision)"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   828
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   829
    Ln2 isNil ifTrue:[
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   830
	Ln2 := self fromDoubleArray:(DoubleArray
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   831
				    with: 6.931471805599452862e-01
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   832
				    with: 2.319046813846299558e-17
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   833
				    with: 5.707708438416212066e-34
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   834
				    with: -3.582432210601811423e-50)
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   835
    ].
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   836
    ^ Ln2
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   837
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   838
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   839
     self ln2
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   840
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   841
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   842
    "Created: / 12-06-2017 / 18:31:34 / cg"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   843
!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   844
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   845
pi
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   846
    "return the constant pi as quad precision double.
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   847
     (returns approx. 212 bits of precision)"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   848
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   849
    Pi isNil ifTrue:[
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   850
	Pi := self fromDoubleArray:(DoubleArray
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   851
				    with: 3.141592653589793116e+00
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   852
				    with: 1.224646799147353207e-16
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   853
				    with: -2.994769809718339666e-33
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   854
				    with: 1.112454220863365282e-49)
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   855
    ].
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   856
    ^ Pi
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   857
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   858
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   859
     self pi
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   860
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   861
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   862
    "Created: / 12-06-2017 / 18:27:13 / cg"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   863
! !
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   864
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   865
!QDouble class methodsFor:'queries'!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   866
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   867
epsilon
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   868
    "return the maximum relative spacing of instances of mySelf
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   869
     (i.e. the value-delta of the least significant bit)"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   870
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   871
    ^ Float epsilon
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   872
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   873
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   874
     Float epsilon
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   875
     ShortFloat epsilon
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   876
     QDouble epsilon
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   877
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   878
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   879
    "Created: / 12-06-2017 / 18:52:44 / cg"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   880
!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   881
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   882
numBitsInExponent
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   883
    "answer the number of bits in the exponent"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   884
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   885
    ^ Float numBitsInExponent
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   886
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   887
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   888
     1.0 asQDouble class numBitsInExponent
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   889
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   890
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   891
    "Created: / 12-06-2017 / 11:11:04 / cg"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   892
!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   893
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   894
numBitsInMantissa
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   895
    "answer the number of bits in the mantissa"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   896
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   897
    ^ Float precision * 4
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   898
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   899
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   900
     1.0 class numBitsInMantissa
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   901
     1.0 asShortFloat class numBitsInMantissa
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   902
     1.0 asLongFloat class numBitsInMantissa
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   903
     1.0 asDDouble class numBitsInMantissa
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   904
     1.0 asQDouble class numBitsInMantissa
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   905
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   906
     Float numBitsInMantissa
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   907
     ShortFloat numBitsInMantissa
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   908
     QDouble numBitsInMantissa
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   909
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   910
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   911
    "Created: / 12-06-2017 / 11:13:44 / cg"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   912
    "Modified: / 12-06-2017 / 18:48:48 / cg"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   913
!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   914
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   915
precision
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   916
    "answer the number of bits in the mantissa"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   917
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   918
    ^ Float precision * 4
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
   919
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   920
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   921
     1.0 class numBitsInMantissa
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   922
     1.0 asShortFloat class numBitsInMantissa
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   923
     1.0 asLongFloat class numBitsInMantissa
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   924
     1.0 asDDouble class numBitsInMantissa
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   925
     1.0 asQDouble class numBitsInMantissa
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   926
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   927
     Float numBitsInMantissa
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   928
     ShortFloat numBitsInMantissa
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   929
     QDouble numBitsInMantissa
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   930
     QDouble precision
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   931
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   932
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   933
    "Created: / 12-06-2017 / 18:49:11 / cg"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   934
!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   935
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   936
radix
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   937
    "answer the radix of a Floats exponent
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   938
     This is an IEEE float, which is represented as binary"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   939
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   940
    ^ Float radix
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   941
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   942
    "Created: / 12-06-2017 / 18:50:04 / cg"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   943
! !
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   944
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   945
!QDouble methodsFor:'arithmetic'!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   946
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   947
* aNumber
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   948
    "return the product of the receiver and the argument, aNumber"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   949
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   950
    ^ aNumber productFromQDouble:self
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   951
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   952
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   953
     ((QDouble fromFloat:1e20) + (QDouble fromFloat:1.0)) asDoubleArray
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   954
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   955
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   956
    "Created: / 13-06-2017 / 01:00:47 / cg"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   957
!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   958
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   959
+ aNumber
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   960
    "return the sum of the receiver and the argument, aNumber"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   961
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   962
    ^ aNumber sumFromQDouble:self
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   963
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   964
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   965
     ((QDouble fromFloat:1e20) + (QDouble fromFloat:1.0)) asDoubleArray
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   966
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   967
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   968
    "Created: / 12-06-2017 / 16:17:46 / cg"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   969
    "Modified: / 12-06-2017 / 23:06:22 / cg"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   970
!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   971
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   972
- aNumber
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   973
    "return the sum of the receiver and the argument, aNumber"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   974
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   975
    ^ (aNumber negated) sumFromQDouble:self
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   976
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   977
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   978
     (QDouble fromFloat:1e20) asDoubleArray
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   979
     ((QDouble fromFloat:1e20) - (QDouble fromFloat:1.0)) asDoubleArray
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   980
     (QDouble fromFloat:1e-20) asDoubleArray
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   981
     ((QDouble fromFloat:1e-20) - (QDouble fromFloat:1.0)) asDoubleArray
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   982
     ((QDouble fromFloat:2.0) - (QDouble fromFloat:1.0)) asDoubleArray
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   983
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   984
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   985
    "Created: / 12-06-2017 / 23:41:39 / cg"
4386
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   986
!
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   987
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   988
/ aNumber
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   989
    "return the quotient of the receiver and the argument, aNumber"
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   990
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   991
    ^ aNumber quotientFromQDouble:self
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   992
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   993
    "
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   994
     ((QDouble fromFloat:1e20) / (QDouble fromFloat:2.0)) asDoubleArray
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   995
    "
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   996
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
   997
    "Created: / 13-06-2017 / 17:59:09 / cg"
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   998
! !
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   999
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1000
!QDouble methodsFor:'coercing & converting'!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1001
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1002
asDoubleArray
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1003
    ^ DoubleArray
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1004
	    with:self d0
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1005
	    with:self d1
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1006
	    with:self d2
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1007
	    with:self d3.
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1008
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1009
    "
4386
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1010
     (QDouble fromFloat:1.0) asDoubleArray
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1011
     (QDouble fromFloat:2.0) asDoubleArray
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1012
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1013
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1014
    "Created: / 12-06-2017 / 18:19:19 / cg"
4386
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1015
    "Modified (comment): / 13-06-2017 / 17:58:09 / cg"
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1016
!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1017
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1018
asFloat
4386
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1019
    ^ self d0
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1020
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1021
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1022
     (QDouble fromFloat:1.0) asFloat
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1023
     (QDouble fromFloat:2.0) asFloat
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1024
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1025
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1026
    "Created: / 12-06-2017 / 18:15:27 / cg"
4386
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1027
    "Modified: / 13-06-2017 / 17:56:50 / cg"
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1028
!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1029
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1030
coerce:aNumber
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1031
    "convert the argument aNumber into an instance of the receiver's class and return it."
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1032
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1033
    ^ aNumber asQDouble
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1034
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1035
    "Created: / 12-06-2017 / 17:13:47 / cg"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1036
    "Modified: / 12-06-2017 / 21:09:06 / cg"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1037
!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1038
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1039
generality
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1040
    "return the generality value - see ArithmeticValue>>retry:coercing:"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1041
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1042
    ^ 95
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1043
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1044
    "Created: / 12-06-2017 / 17:13:14 / cg"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1045
!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1046
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1047
negative
4386
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1048
    ^ self d0 negative
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1049
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1050
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1051
     (QDouble fromFloat:0.0) negative
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1052
     (QDouble fromFloat:1.0) negative
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1053
     (QDouble fromFloat:-1.0) negative
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1054
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1055
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1056
    "Created: / 13-06-2017 / 01:57:39 / cg"
4386
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1057
    "Modified: / 13-06-2017 / 17:58:26 / cg"
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1058
!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1059
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1060
positive
4386
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1061
    ^ self d0 positive
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1062
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1063
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1064
     (QDouble fromFloat:1.0) positive
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1065
     (QDouble fromFloat:-1.0) positive
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1066
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1067
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1068
    "Created: / 13-06-2017 / 01:56:53 / cg"
4386
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1069
    "Modified: / 13-06-2017 / 17:58:41 / cg"
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1070
! !
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1071
4385
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1072
!QDouble methodsFor:'comparing'!
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1073
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1074
< aNumber
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1075
    "return true, if the argument, aNumber is greater than the receiver"
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1076
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1077
    ^ aNumber lessFromQDouble:self
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1078
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1079
    "Created: / 13-06-2017 / 16:58:53 / cg"
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1080
!
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1081
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1082
= aNumber
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1083
    "return true, if the argument, aNumber has the same value as than the receiver"
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1084
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1085
    ^ aNumber equalFromQDouble:self
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1086
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1087
    "Created: / 13-06-2017 / 17:12:09 / cg"
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1088
! !
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1089
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1090
!QDouble methodsFor:'double dispatching'!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1091
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1092
differenceFromFloat:aFloat
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1093
    "aFloat - self"
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1094
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1095
    ^ aFloat + (self negated)
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1096
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1097
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1098
     1.0 - (QDouble fromFloat:1.0)
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1099
     1e20 - (QDouble fromFloat:1.0)
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1100
     (1.0 - (QDouble fromFloat:1.0)) asFloat
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1101
     (1e20 - (QDouble fromFloat:1.0)) asFloat
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1102
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1103
     (1.0 - (QDouble fromFloat:1.0)) asDoubleArray
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1104
     (1e20 - (QDouble fromFloat:1.0)) asDoubleArray
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1105
     (1e20 - (QDouble fromFloat:1.0) + 1e-20) asDoubleArray
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1106
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1107
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1108
    "Created: / 12-06-2017 / 23:38:05 / cg"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1109
!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1110
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1111
differenceFromQDouble:aQDouble
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1112
    "aQDouble - self"
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1113
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1114
    ^ aQDouble + (self negated)
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1115
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1116
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1117
     1.0 - (QDouble fromFloat:1.0)
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1118
     1e20 - (QDouble fromFloat:1.0)
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1119
     (1.0 - (QDouble fromFloat:1.0)) asFloat
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1120
     (1e20 - (QDouble fromFloat:1.0)) asFloat
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1121
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1122
     (1.0 - (QDouble fromFloat:1.0)) asDoubleArray
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1123
     (1e20 - (QDouble fromFloat:1.0)) asDoubleArray
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1124
     (1e20 - (QDouble fromFloat:1.0) + 1e-20) asDoubleArray
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1125
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1126
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1127
    "Created: / 12-06-2017 / 23:38:19 / cg"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1128
!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1129
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1130
equalFromQDouble:aQDouble
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1131
%{
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1132
    if (__Class(aQDouble) == QDouble) {
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1133
	double *a = __QuadDoubleInstPtr(self)->d_quadDoubleValue;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1134
	double *b = __QuadDoubleInstPtr(aQDouble)->d_quadDoubleValue;
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1135
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1136
	RETURN ((a[0] == b[0]
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1137
		&& a[1] == b[1]
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1138
		&& a[2] == b[2]
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1139
		&& a[3] == b[3]) ? true : false);
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1140
    }
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1141
%}.
4386
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1142
    ^ (aQDouble d0 = self d0)
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1143
    and:[ (aQDouble d1 = self d1)
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1144
    and:[ (aQDouble d2 = self d2)
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1145
    and:[ (aQDouble d3 = self d3) ]]]
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1146
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1147
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1148
     (QDouble fromFloat:1.0) = (QDouble fromFloat:1.0)
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1149
     (QDouble fromFloat:1.0) = 1.0
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1150
     1.0 = (QDouble fromFloat:1.0)
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1151
   "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1152
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1153
    "Created: / 13-06-2017 / 03:01:19 / cg"
4386
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1154
    "Modified: / 13-06-2017 / 18:01:52 / cg"
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1155
!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1156
4385
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1157
lessFromQDouble:aQDouble
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1158
    "sent when aQDouble does not know how to compare to the receiver..
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1159
     Return true if aQDouble < self"
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1160
4385
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1161
%{
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1162
    if (__Class(aQDouble) == QDouble) {
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1163
	double *a = __QuadDoubleInstPtr(aQDouble)->d_quadDoubleValue;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1164
	double *b = __QuadDoubleInstPtr(self)->d_quadDoubleValue;
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1165
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1166
	// now compare if a < b!
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1167
	RETURN
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1168
	    ((a[0] < b[0] ||
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1169
	      (a[0] == b[0] && (a[1] < b[1] ||
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1170
		(a[1] == b[1] && (a[2] < b[2] ||
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1171
		  (a[2] == b[2] && a[3] < b[3])))))) ? true : false);
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1172
    }
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1173
%}.
4385
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1174
    ^ super lessFromQDouble:aQDouble
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1175
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1176
    "
4385
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1177
     (1.0 + 1e-40) > 1.0
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1178
     ((QDouble fromFloat:1.0) + (QDouble fromFloat:1e-40)) > (QDouble fromFloat:1.0)
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1179
4385
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1180
     (QDouble fromFloat:1.0) > (QDouble fromFloat:1.0)
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1181
     (QDouble fromFloat:1.1) > (QDouble fromFloat:1.0)
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1182
     (QDouble fromFloat:1.0) > 1.0
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1183
     (QDouble fromFloat:1.1) > 1.0
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1184
     1.0 > (QDouble fromFloat:1.0)
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1185
   "
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1186
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1187
    "Created: / 13-06-2017 / 17:07:47 / cg"
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1188
!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1189
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1190
productFromFloat:aFloat
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1191
%{
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1192
    if (__isFloatLike(aFloat)) {
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1193
	double *a = __QuadDoubleInstPtr(self)->d_quadDoubleValue;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1194
	double b = __floatVal(aFloat);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1195
	double p0, p1, p2, p3;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1196
	double q0, q1, q2;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1197
	double s0, s1, s2, s3, s4;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1198
	OBJ newQD;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1199
	int savedCV;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1200
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1201
	fpu_fix_start(&savedCV);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1202
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1203
	m_two_prod(p0, a[0], b, q0);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1204
	m_two_prod(p1, a[1], b, q1);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1205
	m_two_prod(p2, a[2], b, q2);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1206
	p3 = a[3] * b;
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1207
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1208
	s0 = p0;
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1209
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1210
	m_two_sum(s1, q0, p1, s2);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1211
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1212
	m_three_sum(s2, q1, p2);
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1213
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1214
	m_three_sum2(q1, q2, p3);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1215
	s3 = q1;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1216
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1217
	s4 = q2 + p2;
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1218
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1219
	m_renorm5(s0, s1, s2, s3, s4);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1220
	fpu_fix_end(&savedCV);
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1221
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1222
	__qNew_qdReal(newQD, s0, s1, s2, s3);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1223
	RETURN( newQD );
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1224
    }
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1225
%}.
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1226
    ^ super productFromFloat:aFloat.
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1227
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1228
    "
4387
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
  1229
     (QDouble fromFloat:1.0) productFromFloat:2.0
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
  1230
     ((QDouble fromFloat:1e20) + (QDouble fromFloat:1.0)) productFromFloat:2.0
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
  1231
     ((QDouble fromFloat:1e20) + (QDouble fromFloat:1.0)) productFromFloat:2e20
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
  1232
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1233
     2.0 * (QDouble fromFloat:1.0)
4387
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
  1234
     2.0 * (QDouble fromFloat:3.0)
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1235
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1236
     2.0 * ((QDouble fromFloat:1e20) + (QDouble fromFloat:1.0))
4387
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
  1237
     (2.0 * ((QDouble fromFloat:1e20) + (QDouble fromFloat:1.0))) - (QDouble fromFloat:1e20) - (QDouble fromFloat:1e20)
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
  1238
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1239
     (2.0 * (QDouble fromFloat:1.0)) asFloat
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1240
     (1e20 * (QDouble fromFloat:1.0)) asFloat
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1241
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1242
     (1e20 * (QDouble fromFloat:1.0) * 1e-20) asDoubleArray
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1243
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1244
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1245
    "Created: / 13-06-2017 / 00:58:56 / cg"
4387
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
  1246
    "Modified: / 14-06-2017 / 11:42:57 / cg"
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1247
!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1248
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1249
productFromQDouble:aQDouble
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1250
%{
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1251
    if (__Class(aQDouble) == QDouble) {
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1252
	double *a = __QuadDoubleInstPtr(self)->d_quadDoubleValue;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1253
	double *b = __QuadDoubleInstPtr(aQDouble)->d_quadDoubleValue;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1254
	OBJ newQD;
4387
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
  1255
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1256
	// sloppy
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1257
	double p0, p1, p2, p3, p4, p5;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1258
	double q0, q1, q2, q3, q4, q5;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1259
	double t0, t1;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1260
	double s0, s1, s2;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1261
	int savedCV;
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1262
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1263
	fpu_fix_start(&savedCV);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1264
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1265
	m_two_prod(p0, a[0], b[0], q0);
4387
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
  1266
fprintf(stderr, "%f * %f -> %f, %f\n", a[0], b[0], p0, q0);
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1267
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1268
	m_two_prod(p1, a[0], b[1], q1);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1269
	m_two_prod(p2, a[1], b[0], q2);
4387
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
  1270
fprintf(stderr, "%f * %f -> %f, %f\n", a[0], b[1], p1, q1);
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
  1271
fprintf(stderr, "%f * %f -> %f, %f\n", a[1], b[0], p2, q2);
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1272
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1273
	m_two_prod(p3, a[0], b[2], q3);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1274
	m_two_prod(p4, a[1], b[1], q4);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1275
	m_two_prod(p5, a[2], b[0], q5);
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1276
4387
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
  1277
fprintf(stderr, "%f * %f -> %f, %f\n", a[0], b[2], p3, q3);
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
  1278
fprintf(stderr, "%f * %f -> %f, %f\n", a[1], b[1], p4, q4);
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
  1279
fprintf(stderr, "%f * %f -> %f, %f\n", a[2], b[0], p5, q5);
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
  1280
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1281
	/* Start Accumulation */
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1282
	m_three_sum(p1, p2, q0);
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1283
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1284
	/* Six-Three Sum  of p2, q1, q2, p3, p4, p5. */
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1285
	m_three_sum(p2, q1, q2);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1286
	m_three_sum(p3, p4, p5);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1287
	/* compute (s0, s1, s2) = (p2, q1, q2) + (p3, p4, p5). */
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1288
	m_two_sum(s0, p2, p3, t0);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1289
	m_two_sum(s1, q1, p4, t1);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1290
	s2 = q2 + p5;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1291
	m_two_sum(s1, s1, t0, t0);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1292
	s2 += (t0 + t1);
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1293
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1294
	/* O(eps^3) order terms */
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1295
	s1 += a[0]*b[3] + a[1]*b[2] + a[2]*b[1] + a[3]*b[0] + q0 + q3 + q4 + q5;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1296
	m_renorm5(p0, p1, s0, s1, s2);
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1297
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1298
	fpu_fix_end(&savedCV);
4387
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
  1299
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1300
	__qNew_qdReal(newQD, p0, p1, s0, s1);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1301
	RETURN( newQD );
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1302
    }
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1303
%}.
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1304
    ^ super productFromQDouble:aQDouble.
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1305
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1306
    "
4387
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
  1307
     (QDouble fromFloat:1.0) * 2.0
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1308
     2.0 * (QDouble fromFloat:1.0)
4387
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
  1309
     (QDouble fromFloat:1.0) * (QDouble fromFloat:2.0)
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
  1310
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1311
     1e20 * (QDouble fromFloat:1.0)
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1312
     (2.0 * (QDouble fromFloat:1.0)) asFloat
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1313
     (1e20 * (QDouble fromFloat:1.0)) asFloat
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1314
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1315
     (1e20 * (QDouble fromFloat:1.0) * 1e-20) asDoubleArray
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1316
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1317
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1318
    "Created: / 13-06-2017 / 01:06:22 / cg"
4387
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
  1319
    "Modified: / 14-06-2017 / 11:43:28 / cg"
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1320
!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1321
4385
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1322
quotientFromQDouble:aQDouble
4386
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1323
    "sloppy"
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1324
4385
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1325
    |q0 q1 q2 q3 r|
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1326
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1327
    q0 := self d0 / aQDouble d0.
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1328
    r := self - (aQDouble * q0).
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1329
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1330
    q1 := r d0 / aQDouble d0.
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1331
    r := r - (aQDouble * q1).
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1332
4385
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1333
    q2 := r d0 / aQDouble d0.
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1334
    r := r - (aQDouble * q2).
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1335
4385
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1336
    q3 := r d0 / aQDouble d0.
4386
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1337
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1338
    r := self class d0:q0 d1:q1 d2:q2 d3:q3.
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1339
    r renorm.
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1340
    ^ r
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1341
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1342
    "
4385
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1343
     2.0 / (QDouble fromFloat:2.0)
4387
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
  1344
     2.0 / (QDouble fromFloat:1.0)
4385
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1345
     1e20 / (QDouble fromFloat:1.0)
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1346
     (2.0 / (QDouble fromFloat:1.0)) asFloat
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1347
     (1e20 / (QDouble fromFloat:1.0)) asFloat
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1348
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1349
     (QDouble fromFloat:2.0) / 2.0
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1350
     (QDouble fromFloat:1e20) / 2.0
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1351
     ((QDouble fromFloat:1.0) / 2.0) asFloat
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1352
     ((QDouble fromFloat:1e20 / 2.0)) asFloat
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1353
4385
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1354
     ((1e20 + (QDouble fromFloat:1.0) + 1e-20) / 2.0) asDoubleArray
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1355
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1356
4385
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1357
    "Created: / 13-06-2017 / 17:50:35 / cg"
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1358
!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1359
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1360
sumFromFloat:aFloat
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1361
%{
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1362
    if (__isFloatLike(aFloat)) {
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1363
	double *a = __QuadDoubleInstPtr(self)->d_quadDoubleValue;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1364
	double b = __floatVal(aFloat);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1365
	double c0, c1, c2, c3;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1366
	double e;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1367
	OBJ newQD;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1368
	int savedCV;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1369
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1370
	fpu_fix_start(&savedCV);
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1371
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1372
	m_two_sum(c0, a[0], b, e);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1373
	m_two_sum(c1 ,a[1], e, e);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1374
	m_two_sum(c2, a[2], e, e);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1375
	m_two_sum(c3, a[3], e, e);
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1376
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1377
	m_renorm5(c0, c1, c2, c3, e);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1378
	fpu_fix_end(&savedCV);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1379
	__qNew_qdReal(newQD, c0, c1, c2, c3);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1380
	RETURN( newQD );
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1381
    }
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1382
%}.
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1383
    ^ super sumFromFloat:aFloat.
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1384
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1385
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1386
     1.0 + (QDouble fromFloat:1.0)
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1387
     1e20 + (QDouble fromFloat:1.0)
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1388
     (1.0 + (QDouble fromFloat:1.0)) asFloat
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1389
     (1e20 + (QDouble fromFloat:1.0)) asFloat
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1390
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1391
     (1.0 + (QDouble fromFloat:1.0)) asDoubleArray
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1392
     (1e20 + (QDouble fromFloat:1.0)) asDoubleArray
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1393
     (1e20 + (QDouble fromFloat:1.0) + 1e-20) asDoubleArray
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1394
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1395
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1396
    "Created: / 12-06-2017 / 17:16:41 / cg"
4387
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
  1397
    "Modified: / 14-06-2017 / 11:43:47 / cg"
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1398
!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1399
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1400
sumFromQDouble:aQDouble
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1401
%{
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1402
    if (__Class(aQDouble) == QDouble) {
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1403
	double *a = __QuadDoubleInstPtr(self)->d_quadDoubleValue;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1404
	double *b = __QuadDoubleInstPtr(aQDouble)->d_quadDoubleValue;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1405
	OBJ newQD;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1406
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1407
#ifndef QD_IEEE_ADD
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1408
	// sloppy_add...
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1409
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1410
	/*
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1411
	double s0, s1, s2, s3;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1412
	double t0, t1, t2, t3;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1413
	int savedCV;
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1414
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1415
	fpu_fix_start(&savedCV);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1416
	m_two_sum(s0, a[0], b[0], t0);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1417
	m_two_sum(s1, a[1], b[1], t1);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1418
	m_two_sum(s2, a[2], b[2], t2);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1419
	m_two_sum(s3, a[3], b[3], t3);
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1420
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1421
	m_two_sum(s1, s1, t0, t0);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1422
	m_three_sum(s2, t0, t1);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1423
	m_three_sum2(s3, t0, t2);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1424
	t0 = t0 + t1 + t3;
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1425
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1426
	fpu_fix_end(&savedCV);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1427
	m_renorm5(s0, s1, s2, s3, t0);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1428
	return qd_real(s0, s1, s2, s3, t0);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1429
	*/
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1430
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1431
	/* Same as above, but addition re-organized to minimize
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1432
	   data dependency ... unfortunately some compilers are
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1433
	   not very smart to do this automatically */
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1434
	double s0, s1, s2, s3;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1435
	double t0, t1, t2, t3;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1436
	double v0, v1, v2, v3;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1437
	double u0, u1, u2, u3;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1438
	double w0, w1, w2, w3;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1439
	int savedCV;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1440
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1441
	fpu_fix_start(&savedCV);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1442
	s0 = a[0] + b[0];
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1443
	s1 = a[1] + b[1];
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1444
	s2 = a[2] + b[2];
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1445
	s3 = a[3] + b[3];
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1446
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1447
	v0 = s0 - a[0];
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1448
	v1 = s1 - a[1];
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1449
	v2 = s2 - a[2];
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1450
	v3 = s3 - a[3];
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1451
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1452
	u0 = s0 - v0;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1453
	u1 = s1 - v1;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1454
	u2 = s2 - v2;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1455
	u3 = s3 - v3;
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1456
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1457
	w0 = a[0] - u0;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1458
	w1 = a[1] - u1;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1459
	w2 = a[2] - u2;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1460
	w3 = a[3] - u3;
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1461
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1462
	u0 = b[0] - v0;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1463
	u1 = b[1] - v1;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1464
	u2 = b[2] - v2;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1465
	u3 = b[3] - v3;
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1466
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1467
	t0 = w0 + u0;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1468
	t1 = w1 + u1;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1469
	t2 = w2 + u2;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1470
	t3 = w3 + u3;
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1471
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1472
	m_two_sum(s1, s1, t0, t0);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1473
	m_three_sum(s2, t0, t1);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1474
	m_three_sum2(s3, t0, t2);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1475
	t0 = t0 + t1 + t3;
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1476
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1477
	/* renormalize */
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1478
	m_renorm5(s0, s1, s2, s3, t0);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1479
	fpu_fix_end(&savedCV);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1480
	__qNew_qdReal(newQD, s0, s1, s2, s3);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1481
	RETURN(newQD);
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1482
#else
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1483
	// ieee_add...
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1484
	int i, j, k;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1485
	double s, t;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1486
	double u, v;   /* double-length accumulator */
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1487
	double x[4] = {0.0, 0.0, 0.0, 0.0};
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1488
	int savedCV;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1489
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1490
	fpu_fix_start(&savedCV);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1491
	i = j = k = 0;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1492
	if (abs(a[i]) > abs(b[j]))
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1493
	  u = a[i++];
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1494
	else
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1495
	  u = b[j++];
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1496
	if (abs(a[i]) > abs(b[j]))
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1497
	  v = a[i++];
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1498
	else
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1499
	  v = b[j++];
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1500
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1501
	u = quick_two_sum(u, v, v);
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1502
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1503
	while (k < 4) {
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1504
	  if (i >= 4 && j >= 4) {
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1505
	    x[k] = u;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1506
	    if (k < 3)
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1507
	      x[++k] = v;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1508
	    break;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1509
	  }
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1510
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1511
	  if (i >= 4)
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1512
	    t = b[j++];
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1513
	  else if (j >= 4)
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1514
	    t = a[i++];
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1515
	  else if (abs(a[i]) > abs(b[j])) {
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1516
	    t = a[i++];
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1517
	  } else
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1518
	    t = b[j++];
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1519
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1520
	  s = quick_three_accum(u, v, t);
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1521
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1522
	  if (s != 0.0) {
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1523
	    x[k++] = s;
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1524
	  }
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1525
	}
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1526
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1527
	/* add the rest. */
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1528
	for (k = i; k < 4; k++)
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1529
	  x[3] += a[k];
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1530
	for (k = j; k < 4; k++)
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1531
	  x[3] += b[k];
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1532
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1533
	m_renorm4(x[0], x[1], x[2], x[3]);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1534
	fpu_fix_end(&savedCV);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1535
	__qNew_qdReal(newQD, x[0], x[1], x[2], x[3]);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1536
	RETURN(newQD);
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1537
#endif
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1538
    }
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1539
%}.
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1540
    ^ super sumFromQDouble:aQDouble
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1541
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1542
    "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1543
     (QDouble fromFloat:1.0) + (QDouble fromFloat:1.0)
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1544
     (QDouble fromFloat:1.0) + 1.0
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1545
     1.0 + (QDouble fromFloat:1.0)
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1546
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1547
     ((QDouble fromFloat:1.0) + (QDouble fromFloat:1.0)) asDoubleArray
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1548
     ((QDouble fromFloat:1.0) + 1.0) asDoubleArray
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1549
     (1.0 + (QDouble fromFloat:1.0)) asDoubleArray
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1550
     (1e-20 + (QDouble fromFloat:1.0)) asDoubleArray
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1551
     (1e20 + (QDouble fromFloat:1.0)) asDoubleArray
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1552
   "
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1553
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1554
    "Created: / 12-06-2017 / 21:15:43 / cg"
4387
879309cae427 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4386
diff changeset
  1555
    "Modified: / 14-06-2017 / 11:44:53 / cg"
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1556
! !
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1557
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1558
!QDouble methodsFor:'inspecting'!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1559
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1560
inspectorExtraAttributes
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1561
    "extra (pseudo instvar) entries to be shown in an inspector."
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1562
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1563
    ^ super inspectorExtraAttributes
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1564
	add:'-{doubles}' ->
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1565
	    [
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1566
		self asDoubleArray printString
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1567
	    ];
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1568
	yourself
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1569
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1570
    "Created: / 12-06-2017 / 23:43:05 / cg"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1571
! !
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1572
4385
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1573
!QDouble methodsFor:'mathematical functions'!
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1574
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1575
floor
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1576
    "return the receiver truncated towards negative infinity"
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1577
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1578
%{
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1579
    double *a = __QuadDoubleInstPtr(self)->d_quadDoubleValue;
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1580
    OBJ newQD;
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1581
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1582
    double x0, x1, x2, x3;
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1583
    x1 = x2 = x3 = 0.0;
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1584
    x0 =floor(a[0]);
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1585
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1586
    if (x0 == a[0]) {
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1587
	x1 = floor(a[1]);
4385
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1588
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1589
	if (x1 == a[1]) {
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1590
	    x2 = floor(a[2]);
4385
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1591
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1592
	    if (x2 == a[2]) {
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1593
		x3 = floor(a[3]);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1594
	    }
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1595
	}
4385
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1596
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1597
	m_renorm4(x0, x1, x2, x3);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1598
	__qNew_qdReal(newQD, x0, x1, x2, x3);
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1599
	RETURN( newQD );
4385
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1600
    }
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1601
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1602
    __qNew_qdReal(newQD, x0, x1, x2, x3);
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1603
    RETURN( newQD );
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1604
%}.
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1605
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1606
    "
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1607
     (QDouble fromFloat:4.0) floor
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1608
     (QDouble fromFloat:4.1) floor
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1609
     (QDouble fromFloat:0.1) floor
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1610
     (0.1 + (QDouble fromFloat:1.0)) floor
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1611
     (1e20 + (QDouble fromFloat:1.0)) floor
4385
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1612
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1613
     (QDouble fromFloat:1.5) floor
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1614
     (QDouble fromFloat:0.5) floor
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1615
     (QDouble fromFloat:-0.5) floor
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1616
     (QDouble fromFloat:-1.5) floor
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1617
    "
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1618
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1619
    "Created: / 13-06-2017 / 01:52:44 / cg"
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1620
    "Modified (comment): / 13-06-2017 / 17:33:19 / cg"
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1621
!
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1622
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1623
negated
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1624
    ^ self class
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1625
	d0:(self d0) negated
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1626
	d1:(self d1) negated
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1627
	d2:(self d2) negated
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1628
	d3:(self d3) negated
4385
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1629
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1630
    "
4385
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1631
     (QDouble fromFloat:1.0) negated
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1632
     ((QDouble fromFloat:1e20) + (QDouble fromFloat:1.0)) negated asDoubleArray
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1633
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1634
     (((QDouble fromFloat:1e20) + (QDouble fromFloat:1.0))
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1635
     + ((QDouble fromFloat:1e20) + (QDouble fromFloat:1.0))) asDoubleArray
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1636
    "
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1637
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1638
    "Created: / 12-06-2017 / 20:14:55 / cg"
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1639
    "Modified (comment): / 12-06-2017 / 23:46:57 / cg"
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1640
!
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1641
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1642
squared
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1643
%{
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1644
    double *a = __QuadDoubleInstPtr(self)->d_quadDoubleValue;
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1645
    double p0, p1, p2, p3, p4, p5;
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1646
    double q0, q1, q2, q3;
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1647
    double s0, s1;
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1648
    double t0, t1;
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1649
    double t;
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1650
    OBJ newQD;
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1651
4385
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1652
    m_two_sqr(p0, a[0], q0);
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1653
    t = 2.0 * a[0];
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1654
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1655
    m_two_prod(p1, t, a[1], q1);
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1656
    m_two_prod(p2, t, a[2], q2);
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1657
    m_two_sqr(p3, a[1], q3);
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1658
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1659
    m_two_sum(p1, q0, p1, q0);
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1660
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1661
    m_two_sum(q0, q0, q1, q1);
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1662
    m_two_sum(p2, p2, p3, p3);
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1663
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1664
    m_two_sum(s0, q0, p2, t0);
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1665
    m_two_sum(s1, q1, p3, t1);
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1666
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1667
    m_two_sum(s1, s1, t0, t0);
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1668
    t0 += t1;
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1669
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1670
    m_quick_two_sum(s1, s1, t0, t0);
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1671
    m_quick_two_sum(p2, s0, s1, t1);
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1672
    m_quick_two_sum(p3, t1, t0, q0);
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1673
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1674
    p4 = 2.0 * a[0] * a[3];
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1675
    p5 = 2.0 * a[1] * a[2];
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1676
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1677
    m_two_sum(p4, p4, p5, p5);
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1678
    m_two_sum(q2, q2, q3, q3);
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1679
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1680
    m_two_sum(t0, p4, q2, t1);
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1681
    t1 = t1 + p5 + q3;
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1682
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1683
    m_two_sum(p3, p3, t0, p4);
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1684
    p4 = p4 + q0 + t1;
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1685
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1686
    m_renorm5(p0, p1, p2, p3, p4);
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1687
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1688
    __qNew_qdReal(newQD, p0, p1, s0, s1);
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1689
    RETURN( newQD );
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1690
%}.
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1691
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1692
    "
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1693
     (QDouble fromFloat:4.0) squared
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1694
     (1e20 + (QDouble fromFloat:1.0)) squared
4385
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1695
    "
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1696
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1697
    "Created: / 13-06-2017 / 01:27:58 / cg"
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1698
! !
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1699
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1700
!QDouble methodsFor:'printing & storing'!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1701
4385
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1702
printDigitsOn:outStream precision:precision exponentInto:expn
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1703
    |numDigits r e i d|
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1704
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1705
    numDigits := precision+1. "/ number of digits
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1706
    r := self abs.
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1707
    self d0 = 0.0 ifTrue:[
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1708
	expn value:0.
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1709
	precision timesRepeat:[ outStream nextPut:$0 ].
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1710
	^ self.
4385
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1711
    ].
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1712
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1713
    "/ determine approx. exponent
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1714
    e := self d0 abs log10 floor.
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1715
    self halt.
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1716
    e < -300 ifTrue:[
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1717
	r := r * (10.0 raisedToInteger:300).
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1718
	r := r / (10.0 raisedToInteger:(e+300)).
4385
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1719
    ] ifFalse:[
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1720
	e > 300 ifTrue:[
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1721
	] ifFalse:[
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1722
	]
4385
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1723
    ].
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1724
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1725
4385
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1726
    "
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1727
     1.2345 asQDouble printDigitsOn:Transcript precision:5 exponentInto:[:e |]
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1728
    "
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1729
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1730
    "Created: / 13-06-2017 / 17:28:08 / cg"
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1731
!
3bfafdde1cb5 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4380
diff changeset
  1732
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1733
printString
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1734
    "return a printed representation of the receiver"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1735
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1736
    self d1 = 0.0 ifTrue:[
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1737
	^ self d0 printString
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1738
    ].
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1739
    ^ self d0 printString , '...'
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1740
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1741
    "Created: / 12-06-2017 / 23:41:04 / cg"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1742
! !
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1743
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1744
!QDouble methodsFor:'private accessing'!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1745
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1746
d0
4386
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1747
    "the most significant (and highest valued) 53 bits of precision"
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1748
%{
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1749
    RETURN ( __MKFLOAT(__QuadDoubleInstPtr(self)->d_quadDoubleValue[0]) );
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1750
%}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1751
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1752
    "Created: / 12-06-2017 / 20:15:12 / cg"
4386
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1753
    "Modified (comment): / 13-06-2017 / 17:59:47 / cg"
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1754
!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1755
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1756
d1
4386
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1757
    "the next most significant (and next highest valued) 53 bits of precision"
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1758
%{
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1759
    RETURN ( __MKFLOAT(__QuadDoubleInstPtr(self)->d_quadDoubleValue[1]) );
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1760
%}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1761
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1762
    "Created: / 12-06-2017 / 20:15:12 / cg"
4386
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1763
    "Modified (comment): / 13-06-2017 / 18:00:00 / cg"
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1764
!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1765
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1766
d2
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1767
%{
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1768
    RETURN ( __MKFLOAT(__QuadDoubleInstPtr(self)->d_quadDoubleValue[2]) );
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1769
%}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1770
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1771
    "Created: / 12-06-2017 / 20:15:29 / cg"
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1772
!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1773
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1774
d3
4386
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1775
    "the least significant (and smallest valued) 53 bits of precision"
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1776
%{
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1777
    RETURN ( __MKFLOAT(__QuadDoubleInstPtr(self)->d_quadDoubleValue[3]) );
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1778
%}
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1779
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1780
    "Created: / 12-06-2017 / 20:15:32 / cg"
4386
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1781
    "Modified (comment): / 13-06-2017 / 18:00:18 / cg"
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1782
!
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1783
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1784
renorm
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1785
%{
4388
742f099741bf *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 4387
diff changeset
  1786
    double *a = __QuadDoubleInstPtr(self)->d_quadDoubleValue;
4386
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1787
    double c0, c1, c2, c3;
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1788
    OBJ newQD;
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1789
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1790
    c0 = a[0];
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1791
    c1 = a[1];
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1792
    c2 = a[2];
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1793
    c3 = a[3];
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1794
    m_renorm4(c0, c1, c2, c3);
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1795
    a[0] = c0;
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1796
    a[1] = c1;
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1797
    a[2] = c2;
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1798
    a[3] = c3;
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1799
    RETURN( self );
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1800
%}.
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1801
    ^ self error.
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1802
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1803
    "
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1804
     (QDouble fromFloat:1.0) renorm
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1805
    "
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1806
0a320155d78a #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 4385
diff changeset
  1807
    "Created: / 13-06-2017 / 18:05:33 / cg"
4380
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1808
! !
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1809
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1810
!QDouble class methodsFor:'documentation'!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1811
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1812
version
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1813
    ^ '$Header$'
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1814
!
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1815
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1816
version_CVS
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1817
    ^ '$Header$'
1f4fe7f1c1d3 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1818
! !