116
116
#include < math.h>
117
117
#include < stdio.h>
118
118
#include < stdlib.h>
119
- // #include <sys/time.h >
119
+ #include < random >
120
120
121
- #if defined(_MSC_VER)
122
- int random () { return rand (); }
123
- #endif
121
+ // #if defined(_MSC_VER)
122
+ // long random() { return rand(); }
123
+ // #endif
124
124
125
125
126
126
/* On some machines, the exact arithmetic routines might be defeated by the */
@@ -518,23 +518,23 @@ double *e;
518
518
/* */
519
519
/* ****************************************************************************/
520
520
521
- double doublerand () {
522
- double result;
523
- double expo;
524
- long a, b, c;
525
- long i;
526
-
527
- a = random ();
528
- b = random ();
529
- c = random ();
530
- result = (double )(a - 1073741824 ) * 8388608.0 + (double )(b >> 8 );
531
- for (i = 512 , expo = 2 ; i <= 131072 ; i *= 2 , expo = expo * expo) {
532
- if (c & i) {
533
- result *= expo;
534
- }
535
- }
536
- return result;
537
- }
521
+ // double doublerand() {
522
+ // double result;
523
+ // double expo;
524
+ // long a, b, c;
525
+ // long i;
526
+ //
527
+ // a = random();
528
+ // b = random();
529
+ // c = random();
530
+ // result = (double)(a - 1073741824) * 8388608.0 + (double)(b >> 8);
531
+ // for (i = 512, expo = 2; i <= 131072; i *= 2, expo = expo * expo) {
532
+ // if (c & i) {
533
+ // result *= expo;
534
+ // }
535
+ // }
536
+ // return result;
537
+ // }
538
538
539
539
/* ****************************************************************************/
540
540
/* */
@@ -543,39 +543,39 @@ double doublerand() {
543
543
/* */
544
544
/* ****************************************************************************/
545
545
546
- double narrowdoublerand () {
547
- double result;
548
- double expo;
549
- long a, b, c;
550
- long i;
551
-
552
- a = random ();
553
- b = random ();
554
- c = random ();
555
- result = (double )(a - 1073741824 ) * 8388608.0 + (double )(b >> 8 );
556
- for (i = 512 , expo = 2 ; i <= 2048 ; i *= 2 , expo = expo * expo) {
557
- if (c & i) {
558
- result *= expo;
559
- }
560
- }
561
- return result;
562
- }
546
+ // double narrowdoublerand() {
547
+ // double result;
548
+ // double expo;
549
+ // long a, b, c;
550
+ // long i;
551
+ //
552
+ // a = random();
553
+ // b = random();
554
+ // c = random();
555
+ // result = (double)(a - 1073741824) * 8388608.0 + (double)(b >> 8);
556
+ // for (i = 512, expo = 2; i <= 2048; i *= 2, expo = expo * expo) {
557
+ // if (c & i) {
558
+ // result *= expo;
559
+ // }
560
+ // }
561
+ // return result;
562
+ // }
563
563
564
564
/* ****************************************************************************/
565
565
/* */
566
566
/* uniformdoublerand() Generate a double with random 53-bit significand. */
567
567
/* */
568
568
/* ****************************************************************************/
569
-
570
- double uniformdoublerand () {
571
- double result;
572
- long a, b;
573
-
574
- a = random ();
575
- b = random ();
576
- result = (double )(a - 1073741824 ) * 8388608.0 + (double )(b >> 8 );
577
- return result;
578
- }
569
+ //
570
+ // double uniformdoublerand() {
571
+ // double result;
572
+ // long a, b;
573
+ //
574
+ // a = random();
575
+ // b = random();
576
+ // result = (double)(a - 1073741824) * 8388608.0 + (double)(b >> 8);
577
+ // return result;
578
+ // }
579
579
580
580
/* ****************************************************************************/
581
581
/* */
@@ -590,24 +590,23 @@ double uniformdoublerand() {
590
590
/* */
591
591
/* ****************************************************************************/
592
592
593
- int grow_expansion (int elen, double * e, double b,
594
- double * h) /* e and h can be the same. */
593
+ int grow_expansion (int elen, double * e, double b, double * h) /* e and h can be the same. */
595
594
{
596
- double Q;
597
- INEXACT double Qnew;
598
- int eindex;
599
- double enow;
600
- INEXACT double bvirt;
601
- double avirt, bround, around;
602
-
603
- Q = b;
604
- for (eindex = 0 ; eindex < elen; eindex++) {
605
- enow = e[eindex];
606
- Two_Sum (Q, enow, Qnew, h[eindex]);
607
- Q = Qnew;
608
- }
609
- h[eindex] = Q;
610
- return eindex + 1 ;
595
+ double Q;
596
+ INEXACT double Qnew;
597
+ int eindex;
598
+ double enow;
599
+ INEXACT double bvirt;
600
+ double avirt, bround, around;
601
+
602
+ Q = b;
603
+ for (eindex = 0 ; eindex < elen; eindex++) {
604
+ enow = e[eindex];
605
+ Two_Sum (Q, enow, Qnew, h[eindex]);
606
+ Q = Qnew;
607
+ }
608
+ h[eindex] = Q;
609
+ return eindex + 1 ;
611
610
}
612
611
613
612
/* ****************************************************************************/
0 commit comments