intervals 0.3.56

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. data/VERSION.txt +1 -0
  2. data/ext/crlibm/AUTHORS +2 -0
  3. data/ext/crlibm/COPYING +504 -0
  4. data/ext/crlibm/ChangeLog +80 -0
  5. data/ext/crlibm/INSTALL +182 -0
  6. data/ext/crlibm/Makefile.am +84 -0
  7. data/ext/crlibm/Makefile.in +530 -0
  8. data/ext/crlibm/NEWS +0 -0
  9. data/ext/crlibm/README +31 -0
  10. data/ext/crlibm/TODO +47 -0
  11. data/ext/crlibm/VERSION +1 -0
  12. data/ext/crlibm/aclocal.m4 +989 -0
  13. data/ext/crlibm/atan-itanium.c +846 -0
  14. data/ext/crlibm/atan-pentium.c +261 -0
  15. data/ext/crlibm/atan_accurate.c +244 -0
  16. data/ext/crlibm/atan_accurate.h +191 -0
  17. data/ext/crlibm/atan_fast.c +324 -0
  18. data/ext/crlibm/atan_fast.h +678 -0
  19. data/ext/crlibm/config.guess +1461 -0
  20. data/ext/crlibm/config.sub +1566 -0
  21. data/ext/crlibm/configure +7517 -0
  22. data/ext/crlibm/configure.ac +364 -0
  23. data/ext/crlibm/crlibm.h +125 -0
  24. data/ext/crlibm/crlibm_config.h +149 -0
  25. data/ext/crlibm/crlibm_config.h.in +148 -0
  26. data/ext/crlibm/crlibm_private.c +293 -0
  27. data/ext/crlibm/crlibm_private.h +658 -0
  28. data/ext/crlibm/csh_fast.c +631 -0
  29. data/ext/crlibm/csh_fast.h +771 -0
  30. data/ext/crlibm/double-extended.h +496 -0
  31. data/ext/crlibm/exp-td.c +962 -0
  32. data/ext/crlibm/exp-td.h +685 -0
  33. data/ext/crlibm/exp_accurate.c +197 -0
  34. data/ext/crlibm/exp_accurate.h +85 -0
  35. data/ext/crlibm/gappa/log-de-E0-logir0.gappa +106 -0
  36. data/ext/crlibm/gappa/log-de-E0.gappa +79 -0
  37. data/ext/crlibm/gappa/log-de.gappa +81 -0
  38. data/ext/crlibm/gappa/log-td-E0-logir0.gappa +126 -0
  39. data/ext/crlibm/gappa/log-td-E0.gappa +143 -0
  40. data/ext/crlibm/gappa/log-td-accurate-E0-logir0.gappa +230 -0
  41. data/ext/crlibm/gappa/log-td-accurate-E0.gappa +213 -0
  42. data/ext/crlibm/gappa/log-td-accurate.gappa +217 -0
  43. data/ext/crlibm/gappa/log-td.gappa +156 -0
  44. data/ext/crlibm/gappa/trigoSinCosCase3.gappa +204 -0
  45. data/ext/crlibm/gappa/trigoTanCase2.gappa +73 -0
  46. data/ext/crlibm/install-sh +269 -0
  47. data/ext/crlibm/log-de.c +431 -0
  48. data/ext/crlibm/log-de.h +732 -0
  49. data/ext/crlibm/log-td.c +852 -0
  50. data/ext/crlibm/log-td.h +819 -0
  51. data/ext/crlibm/log10-td.c +906 -0
  52. data/ext/crlibm/log10-td.h +823 -0
  53. data/ext/crlibm/log2-td.c +935 -0
  54. data/ext/crlibm/log2-td.h +821 -0
  55. data/ext/crlibm/maple/atan.mpl +359 -0
  56. data/ext/crlibm/maple/common-procedures.mpl +997 -0
  57. data/ext/crlibm/maple/csh.mpl +446 -0
  58. data/ext/crlibm/maple/double-extended.mpl +151 -0
  59. data/ext/crlibm/maple/exp-td.mpl +195 -0
  60. data/ext/crlibm/maple/log-de.mpl +243 -0
  61. data/ext/crlibm/maple/log-td.mpl +316 -0
  62. data/ext/crlibm/maple/log10-td.mpl +345 -0
  63. data/ext/crlibm/maple/log2-td.mpl +334 -0
  64. data/ext/crlibm/maple/trigo.mpl +728 -0
  65. data/ext/crlibm/maple/triple-double.mpl +58 -0
  66. data/ext/crlibm/missing +198 -0
  67. data/ext/crlibm/mkinstalldirs +40 -0
  68. data/ext/crlibm/rem_pio2_accurate.c +219 -0
  69. data/ext/crlibm/rem_pio2_accurate.h +53 -0
  70. data/ext/crlibm/scs_lib/AUTHORS +3 -0
  71. data/ext/crlibm/scs_lib/COPYING +504 -0
  72. data/ext/crlibm/scs_lib/ChangeLog +16 -0
  73. data/ext/crlibm/scs_lib/INSTALL +215 -0
  74. data/ext/crlibm/scs_lib/Makefile.am +18 -0
  75. data/ext/crlibm/scs_lib/Makefile.in +328 -0
  76. data/ext/crlibm/scs_lib/NEWS +0 -0
  77. data/ext/crlibm/scs_lib/README +9 -0
  78. data/ext/crlibm/scs_lib/TODO +4 -0
  79. data/ext/crlibm/scs_lib/addition_scs.c +623 -0
  80. data/ext/crlibm/scs_lib/config.guess +1461 -0
  81. data/ext/crlibm/scs_lib/config.sub +1566 -0
  82. data/ext/crlibm/scs_lib/configure +6226 -0
  83. data/ext/crlibm/scs_lib/division_scs.c +110 -0
  84. data/ext/crlibm/scs_lib/double2scs.c +174 -0
  85. data/ext/crlibm/scs_lib/install-sh +269 -0
  86. data/ext/crlibm/scs_lib/missing +198 -0
  87. data/ext/crlibm/scs_lib/mkinstalldirs +40 -0
  88. data/ext/crlibm/scs_lib/multiplication_scs.c +456 -0
  89. data/ext/crlibm/scs_lib/poly_fct.c +112 -0
  90. data/ext/crlibm/scs_lib/print_scs.c +73 -0
  91. data/ext/crlibm/scs_lib/rand_scs.c +63 -0
  92. data/ext/crlibm/scs_lib/scs.h +353 -0
  93. data/ext/crlibm/scs_lib/scs2double.c +391 -0
  94. data/ext/crlibm/scs_lib/scs2mpf.c +58 -0
  95. data/ext/crlibm/scs_lib/scs2mpfr.c +61 -0
  96. data/ext/crlibm/scs_lib/scs_private.c +23 -0
  97. data/ext/crlibm/scs_lib/scs_private.h +133 -0
  98. data/ext/crlibm/scs_lib/tests/tbx_timing.h +102 -0
  99. data/ext/crlibm/scs_lib/wrapper_scs.h +486 -0
  100. data/ext/crlibm/scs_lib/zero_scs.c +52 -0
  101. data/ext/crlibm/stamp-h.in +1 -0
  102. data/ext/crlibm/tests/Makefile.am +43 -0
  103. data/ext/crlibm/tests/Makefile.in +396 -0
  104. data/ext/crlibm/tests/blind_test.c +148 -0
  105. data/ext/crlibm/tests/generate_test_vectors.c +258 -0
  106. data/ext/crlibm/tests/soak_test.c +334 -0
  107. data/ext/crlibm/tests/test_common.c +627 -0
  108. data/ext/crlibm/tests/test_common.h +28 -0
  109. data/ext/crlibm/tests/test_perf.c +570 -0
  110. data/ext/crlibm/tests/test_val.c +249 -0
  111. data/ext/crlibm/trigo_accurate.c +500 -0
  112. data/ext/crlibm/trigo_accurate.h +331 -0
  113. data/ext/crlibm/trigo_fast.c +1219 -0
  114. data/ext/crlibm/trigo_fast.h +639 -0
  115. data/ext/crlibm/triple-double.h +878 -0
  116. data/ext/extconf.rb +31 -0
  117. data/ext/fpu.c +107 -0
  118. data/ext/jamis-mod.rb +591 -0
  119. data/lib/fpu.rb +287 -0
  120. data/lib/interval.rb +1170 -0
  121. data/lib/intervals.rb +212 -0
  122. data/lib/struct_float.rb +133 -0
  123. data/test/data_atan.txt +360 -0
  124. data/test/data_cos.txt +346 -0
  125. data/test/data_cosh.txt +3322 -0
  126. data/test/data_exp.txt +3322 -0
  127. data/test/data_log.txt +141 -0
  128. data/test/data_sin.txt +140 -0
  129. data/test/data_sinh.txt +3322 -0
  130. data/test/data_tan.txt +342 -0
  131. metadata +186 -0
@@ -0,0 +1,198 @@
1
+ #! /bin/sh
2
+ # Common stub for a few missing GNU programs while installing.
3
+ # Copyright (C) 1996, 1997, 2001, 2002 Free Software Foundation, Inc.
4
+ # Franc,ois Pinard <pinard@iro.umontreal.ca>, 1996.
5
+
6
+ # This program is free software; you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation; either version 2, or (at your option)
9
+ # any later version.
10
+
11
+ # This program is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with this program; if not, write to the Free Software
18
+ # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19
+ # 02111-1307, USA.
20
+
21
+ if test $# -eq 0; then
22
+ echo 1>&2 "Try \`$0 --help' for more information"
23
+ exit 1
24
+ fi
25
+
26
+ # In the cases where this matters, `missing' is being run in the
27
+ # srcdir already.
28
+ if test -f configure.in; then
29
+ configure_ac=configure.ac
30
+ else
31
+ configure_ac=configure.in
32
+ fi
33
+
34
+ case "$1" in
35
+
36
+ -h|--h|--he|--hel|--help)
37
+ echo "\
38
+ $0 [OPTION]... PROGRAM [ARGUMENT]...
39
+
40
+ Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
41
+ error status if there is no known handling for PROGRAM.
42
+
43
+ Options:
44
+ -h, --help display this help and exit
45
+ -v, --version output version information and exit
46
+
47
+ Supported PROGRAM values:
48
+ aclocal touch file \`aclocal.m4'
49
+ autoconf touch file \`configure'
50
+ autoheader touch file \`config.h.in'
51
+ automake touch all \`Makefile.in' files
52
+ bison create \`y.tab.[ch]', if possible, from existing .[ch]
53
+ flex create \`lex.yy.c', if possible, from existing .c
54
+ lex create \`lex.yy.c', if possible, from existing .c
55
+ makeinfo touch the output file
56
+ yacc create \`y.tab.[ch]', if possible, from existing .[ch]"
57
+ ;;
58
+
59
+ -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
60
+ echo "missing - GNU libit 0.0"
61
+ ;;
62
+
63
+ -*)
64
+ echo 1>&2 "$0: Unknown \`$1' option"
65
+ echo 1>&2 "Try \`$0 --help' for more information"
66
+ exit 1
67
+ ;;
68
+
69
+ aclocal*)
70
+ echo 1>&2 "\
71
+ WARNING: \`$1' is missing on your system. You should only need it if
72
+ you modified \`acinclude.m4' or \`$configure_ac'. You might want
73
+ to install the \`Automake' and \`Perl' packages. Grab them from
74
+ any GNU archive site."
75
+ touch aclocal.m4
76
+ ;;
77
+
78
+ autoconf)
79
+ echo 1>&2 "\
80
+ WARNING: \`$1' is missing on your system. You should only need it if
81
+ you modified \`$configure_ac'. You might want to install the
82
+ \`Autoconf' and \`GNU m4' packages. Grab them from any GNU
83
+ archive site."
84
+ touch configure
85
+ ;;
86
+
87
+ autoheader)
88
+ echo 1>&2 "\
89
+ WARNING: \`$1' is missing on your system. You should only need it if
90
+ you modified \`acconfig.h' or \`$configure_ac'. You might want
91
+ to install the \`Autoconf' and \`GNU m4' packages. Grab them
92
+ from any GNU archive site."
93
+ files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' $configure_ac`
94
+ test -z "$files" && files="config.h"
95
+ touch_files=
96
+ for f in $files; do
97
+ case "$f" in
98
+ *:*) touch_files="$touch_files "`echo "$f" |
99
+ sed -e 's/^[^:]*://' -e 's/:.*//'`;;
100
+ *) touch_files="$touch_files $f.in";;
101
+ esac
102
+ done
103
+ touch $touch_files
104
+ ;;
105
+
106
+ automake*)
107
+ echo 1>&2 "\
108
+ WARNING: \`$1' is missing on your system. You should only need it if
109
+ you modified \`Makefile.am', \`acinclude.m4' or \`$configure_ac'.
110
+ You might want to install the \`Automake' and \`Perl' packages.
111
+ Grab them from any GNU archive site."
112
+ find . -type f -name Makefile.am -print |
113
+ sed 's/\.am$/.in/' |
114
+ while read f; do touch "$f"; done
115
+ ;;
116
+
117
+ bison|yacc)
118
+ echo 1>&2 "\
119
+ WARNING: \`$1' is missing on your system. You should only need it if
120
+ you modified a \`.y' file. You may need the \`Bison' package
121
+ in order for those modifications to take effect. You can get
122
+ \`Bison' from any GNU archive site."
123
+ rm -f y.tab.c y.tab.h
124
+ if [ $# -ne 1 ]; then
125
+ eval LASTARG="\${$#}"
126
+ case "$LASTARG" in
127
+ *.y)
128
+ SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
129
+ if [ -f "$SRCFILE" ]; then
130
+ cp "$SRCFILE" y.tab.c
131
+ fi
132
+ SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
133
+ if [ -f "$SRCFILE" ]; then
134
+ cp "$SRCFILE" y.tab.h
135
+ fi
136
+ ;;
137
+ esac
138
+ fi
139
+ if [ ! -f y.tab.h ]; then
140
+ echo >y.tab.h
141
+ fi
142
+ if [ ! -f y.tab.c ]; then
143
+ echo 'main() { return 0; }' >y.tab.c
144
+ fi
145
+ ;;
146
+
147
+ lex|flex)
148
+ echo 1>&2 "\
149
+ WARNING: \`$1' is missing on your system. You should only need it if
150
+ you modified a \`.l' file. You may need the \`Flex' package
151
+ in order for those modifications to take effect. You can get
152
+ \`Flex' from any GNU archive site."
153
+ rm -f lex.yy.c
154
+ if [ $# -ne 1 ]; then
155
+ eval LASTARG="\${$#}"
156
+ case "$LASTARG" in
157
+ *.l)
158
+ SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
159
+ if [ -f "$SRCFILE" ]; then
160
+ cp "$SRCFILE" lex.yy.c
161
+ fi
162
+ ;;
163
+ esac
164
+ fi
165
+ if [ ! -f lex.yy.c ]; then
166
+ echo 'main() { return 0; }' >lex.yy.c
167
+ fi
168
+ ;;
169
+
170
+ makeinfo)
171
+ echo 1>&2 "\
172
+ WARNING: \`$1' is missing on your system. You should only need it if
173
+ you modified a \`.texi' or \`.texinfo' file, or any other file
174
+ indirectly affecting the aspect of the manual. The spurious
175
+ call might also be the consequence of using a buggy \`make' (AIX,
176
+ DU, IRIX). You might want to install the \`Texinfo' package or
177
+ the \`GNU make' package. Grab either from any GNU archive site."
178
+ file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
179
+ if test -z "$file"; then
180
+ file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
181
+ file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
182
+ fi
183
+ touch $file
184
+ ;;
185
+
186
+ *)
187
+ echo 1>&2 "\
188
+ WARNING: \`$1' is needed, and you do not seem to have it handy on your
189
+ system. You might have modified some files without having the
190
+ proper tools for further handling them. Check the \`README' file,
191
+ it often tells you about the needed prerequirements for installing
192
+ this package. You may also peek at any GNU archive site, in case
193
+ some other package would contain this missing \`$1' program."
194
+ exit 1
195
+ ;;
196
+ esac
197
+
198
+ exit 0
@@ -0,0 +1,40 @@
1
+ #! /bin/sh
2
+ # mkinstalldirs --- make directory hierarchy
3
+ # Author: Noah Friedman <friedman@prep.ai.mit.edu>
4
+ # Created: 1993-05-16
5
+ # Public domain
6
+
7
+ # $Id: mkinstalldirs,v 1.13 1999/01/05 03:18:55 bje Exp $
8
+
9
+ errstatus=0
10
+
11
+ for file
12
+ do
13
+ set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
14
+ shift
15
+
16
+ pathcomp=
17
+ for d
18
+ do
19
+ pathcomp="$pathcomp$d"
20
+ case "$pathcomp" in
21
+ -* ) pathcomp=./$pathcomp ;;
22
+ esac
23
+
24
+ if test ! -d "$pathcomp"; then
25
+ echo "mkdir $pathcomp"
26
+
27
+ mkdir "$pathcomp" || lasterr=$?
28
+
29
+ if test ! -d "$pathcomp"; then
30
+ errstatus=$lasterr
31
+ fi
32
+ fi
33
+
34
+ pathcomp="$pathcomp/"
35
+ done
36
+ done
37
+
38
+ exit $errstatus
39
+
40
+ # mkinstalldirs ends here
@@ -0,0 +1,456 @@
1
+ /** Functions for SCS multiplication operations
2
+ @file multiplication_scs.c
3
+
4
+ @author Defour David David.Defour@ens-lyon.fr
5
+ @author Florent de Dinechin Florent.de.Dinechin@ens-lyon.fr
6
+
7
+ This file is part of the SCS library.
8
+ */
9
+
10
+ /*
11
+ Copyright (C) 2002 David Defour and Florent de Dinechin
12
+
13
+ This library is free software; you can redistribute it and/or
14
+ modify it under the terms of the GNU Lesser General Public
15
+ License as published by the Free Software Foundation; either
16
+ version 2.1 of the License, or (at your option) any later version.
17
+
18
+ This library is distributed in the hope that it will be useful,
19
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
20
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21
+ Lesser General Public License for more details.
22
+
23
+ You should have received a copy of the GNU Lesser General Public
24
+ License along with this library; if not, write to the Free Software
25
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
+
27
+ */
28
+
29
+ #include "scs.h"
30
+ #include "scs_private.h"
31
+
32
+ #if 0 /* used to help debugging */
33
+ void pr(char* s,double d) {
34
+ db_number x;
35
+ x.d=d;
36
+ printf(s);printf(" ");
37
+ printf("%8x%8x . 2^%d (%8f %8x %8x) \n",
38
+ (x.i[HI]&0x000FFFFF)+0x00100000,
39
+ x.i[LO],
40
+ (x.i[HI]>>20)-1023,
41
+ x.d,
42
+ x.i[HI],
43
+ x.i[LO]);
44
+ }
45
+ #endif
46
+
47
+
48
+
49
+ /* Compute the carry of r1, remove it from r1, and add it to r0 */
50
+ #define SCS_CARRY_PROPAGATE(r1,r0,tmp) \
51
+ {tmp = r1>>SCS_NB_BITS; r0 += tmp; r1 -= (tmp<<SCS_NB_BITS);}
52
+
53
+
54
+
55
+
56
+
57
+
58
+
59
+ /************************************************************/
60
+ /* We have unrolled the loops for SCS_NB_WORDS==4 or 8
61
+
62
+ We just wish gcc would do it for us ! There are option switches,
63
+ but they don't lead to any performance improvement. When they do,
64
+ this part of the source code will be removed.
65
+
66
+ In the meantime, feel free to unroll for other values. */
67
+
68
+
69
+ /***************************/
70
+ #if (SCS_NB_WORDS==4)
71
+ /***************************/
72
+ void scs_mul(scs_ptr result, scs_ptr x, scs_ptr y){
73
+ uint64_t val, tmp;
74
+ uint64_t r0,r1,r2,r3,r4;
75
+ uint64_t x0,x1,x2,x3;
76
+ int y0,y1,y2,y3;
77
+
78
+ R_EXP = X_EXP * Y_EXP;
79
+ R_SGN = X_SGN * Y_SGN;
80
+ R_IND = X_IND + Y_IND;
81
+
82
+ /* Partial products computation */
83
+ x3=X_HW[3]; y3=Y_HW[3]; x2=X_HW[2]; y2=Y_HW[2];
84
+ x1=X_HW[1]; y1=Y_HW[1]; x0=X_HW[0]; y0=Y_HW[0];
85
+
86
+ r4 = x3*y1 + x2*y2 + x1*y3;
87
+ r3 = x3*y0 + x2*y1 + x1*y2 + x0*y3;
88
+ r2 = x2*y0 + x1*y1 + x0*y2;
89
+ r1 = x1*y0 + x0*y1 ;
90
+ r0 = x0*y0;
91
+
92
+ val= 0;
93
+ /* Carry Propagate */
94
+ SCS_CARRY_PROPAGATE(r4,r3,tmp)
95
+ SCS_CARRY_PROPAGATE(r3,r2,tmp)
96
+ SCS_CARRY_PROPAGATE(r2,r1,tmp)
97
+ SCS_CARRY_PROPAGATE(r1,r0,tmp)
98
+ SCS_CARRY_PROPAGATE(r0,val,tmp)
99
+
100
+ if(val != 0){
101
+ /* shift all the digits ! */
102
+ R_HW[0] = val; R_HW[1] = r0; R_HW[2] = r1; R_HW[3] = r2;
103
+ R_IND += 1;
104
+ }
105
+ else {
106
+ R_HW[0] = r0; R_HW[1] = r1; R_HW[2] = r2; R_HW[3] = r3;
107
+ }
108
+
109
+ }
110
+
111
+
112
+ void scs_square(scs_ptr result, scs_ptr x){
113
+ uint64_t r0,r1,r2,r3,r4;
114
+ uint64_t x0,x1,x2,x3;
115
+ uint64_t val, tmp;
116
+
117
+
118
+ R_EXP = X_EXP * X_EXP;
119
+ R_IND = X_IND + X_IND;
120
+ R_SGN = 1;
121
+
122
+ /*
123
+ * Calcul des PP
124
+ */
125
+ x3=X_HW[3]; x2=X_HW[2]; x1=X_HW[1]; x0=X_HW[0];
126
+
127
+ r0 = x0*x0;
128
+ r1 = (x0*x1)* 2 ;
129
+ r2 = x1*x1 + (x0*x2*2);
130
+ r3 = (x1*x2 + x0*x3)* 2;
131
+ r4 = x2*x2 + (x1*x3)* 2;
132
+
133
+ val= 0;
134
+ /* Propagation des retenues */
135
+ SCS_CARRY_PROPAGATE(r4,r3,tmp)
136
+ SCS_CARRY_PROPAGATE(r3,r2,tmp)
137
+ SCS_CARRY_PROPAGATE(r2,r1,tmp)
138
+ SCS_CARRY_PROPAGATE(r1,r0,tmp)
139
+ SCS_CARRY_PROPAGATE(r0,val,tmp)
140
+
141
+ if(val != 0){
142
+ /* shift all the digits ! */
143
+ R_HW[0] = val; R_HW[1] = r0; R_HW[2] = r1; R_HW[3] = r2;
144
+ R_IND += 1;
145
+ }
146
+ else {
147
+ R_HW[0] = r0; R_HW[1] = r1; R_HW[2] = r2; R_HW[3] = r3;
148
+ }
149
+
150
+ }
151
+
152
+
153
+
154
+
155
+
156
+
157
+
158
+ /***************************/
159
+ #elif (SCS_NB_WORDS==8)
160
+ /***************************/
161
+ void scs_mul(scs_ptr result, scs_ptr x, scs_ptr y){
162
+ uint64_t val, tmp;
163
+ uint64_t r0,r1,r2,r3,r4,r5,r6,r7,r8;
164
+ uint64_t x0,x1,x2,x3,x4,x5,x6,x7;
165
+ int y0,y1,y2,y3,y4,y5,y6,y7;
166
+
167
+ R_EXP = X_EXP * Y_EXP;
168
+ R_SGN = X_SGN * Y_SGN;
169
+ R_IND = X_IND + Y_IND;
170
+
171
+ /* Partial products computation */
172
+ x7=X_HW[7]; y7=Y_HW[7]; x6=X_HW[6]; y6=Y_HW[6];
173
+ x5=X_HW[5]; y5=Y_HW[5]; x4=X_HW[4]; y4=Y_HW[4];
174
+ x3=X_HW[3]; y3=Y_HW[3]; x2=X_HW[2]; y2=Y_HW[2];
175
+ x1=X_HW[1]; y1=Y_HW[1]; x0=X_HW[0]; y0=Y_HW[0];
176
+
177
+ r8 = x7*y1 + x6*y2 + x5*y3 + x4*y4 + x3*y5 + x2*y6 + x1*y7;
178
+ r7 = x7*y0 + x6*y1 + x5*y2 + x4*y3 + x3*y4 + x2*y5 + x1*y6 + x0*y7;
179
+ r6 = x6*y0 + x5*y1 + x4*y2 + x3*y3 + x2*y4 + x1*y5 + x0*y6;
180
+ r5 = x5*y0 + x4*y1 + x3*y2 + x2*y3 + x1*y4 + x0*y5;
181
+ r4 = x4*y0 + x3*y1 + x2*y2 + x1*y3 + x0*y4 ;
182
+ r3 = x3*y0 + x2*y1 + x1*y2 + x0*y3;
183
+ r2 = x2*y0 + x1*y1 + x0*y2;
184
+ r1 = x1*y0 + x0*y1 ;
185
+ r0 = x0*y0 ;
186
+
187
+ val= 0;
188
+ /* Carry Propagate */
189
+ SCS_CARRY_PROPAGATE(r8,r7,tmp)
190
+ SCS_CARRY_PROPAGATE(r7,r6,tmp)
191
+ SCS_CARRY_PROPAGATE(r6,r5,tmp)
192
+ SCS_CARRY_PROPAGATE(r5,r4,tmp)
193
+ SCS_CARRY_PROPAGATE(r4,r3,tmp)
194
+ SCS_CARRY_PROPAGATE(r3,r2,tmp)
195
+ SCS_CARRY_PROPAGATE(r2,r1,tmp)
196
+ SCS_CARRY_PROPAGATE(r1,r0,tmp)
197
+ SCS_CARRY_PROPAGATE(r0,val,tmp)
198
+
199
+ if(val != 0){
200
+ /* shift all the digits ! */
201
+ R_HW[0] = val; R_HW[1] = r0; R_HW[2] = r1; R_HW[3] = r2;
202
+ R_HW[4] = r3; R_HW[5] = r4; R_HW[6] = r5; R_HW[7] = r6;
203
+ R_IND += 1;
204
+ }
205
+ else {
206
+ R_HW[0] = r0; R_HW[1] = r1; R_HW[2] = r2; R_HW[3] = r3;
207
+ R_HW[4] = r4; R_HW[5] = r5; R_HW[6] = r6; R_HW[7] = r7;
208
+ }
209
+
210
+ }
211
+
212
+
213
+ void scs_square(scs_ptr result, scs_ptr x){
214
+ uint64_t r0,r1,r2,r3,r4,r5,r6,r7,r8;
215
+ uint64_t x0,x1,x2,x3,x4,x5,x6,x7;
216
+ uint64_t val, tmp;
217
+
218
+
219
+ R_EXP = X_EXP * X_EXP;
220
+ R_IND = X_IND + X_IND;
221
+ R_SGN = 1;
222
+
223
+ /*
224
+ * Partial products
225
+ */
226
+ x7=X_HW[7]; x6=X_HW[6]; x5=X_HW[5]; x4=X_HW[4];
227
+ x3=X_HW[3]; x2=X_HW[2]; x1=X_HW[1]; x0=X_HW[0];
228
+
229
+ r0 = x0*x0;
230
+ r1 = (x0*x1)* 2 ;
231
+ r2 = x1*x1 + (x0*x2*2);
232
+ r3 = (x1*x2 + x0*x3)* 2;
233
+ r4 = x2*x2 + (x1*x3 + x0*x4)* 2;
234
+ r5 = (x2*x3 + x1*x4 + x0*x5)* 2;
235
+ r6 = x3*x3 + (x2*x4 + x1*x5 + x0*x6)* 2;
236
+ r7 = (x3*x4 + x2*x5 + x1*x6 + x0*x7)* 2;
237
+ r8 = x4*x4 + (x3*x5 + x2*x6 + x1*x7)* 2;
238
+
239
+ val= 0;
240
+ /* Carry propagation */
241
+ SCS_CARRY_PROPAGATE(r8,r7,tmp)
242
+ SCS_CARRY_PROPAGATE(r7,r6,tmp)
243
+ SCS_CARRY_PROPAGATE(r6,r5,tmp)
244
+ SCS_CARRY_PROPAGATE(r5,r4,tmp)
245
+ SCS_CARRY_PROPAGATE(r4,r3,tmp)
246
+ SCS_CARRY_PROPAGATE(r3,r2,tmp)
247
+ SCS_CARRY_PROPAGATE(r2,r1,tmp)
248
+ SCS_CARRY_PROPAGATE(r1,r0,tmp)
249
+ SCS_CARRY_PROPAGATE(r0,val,tmp)
250
+
251
+ if(val != 0){
252
+ /* shift all the digits ! */
253
+ R_HW[0] = val; R_HW[1] = r0; R_HW[2] = r1; R_HW[3] = r2;
254
+ R_HW[4] = r3; R_HW[5] = r4; R_HW[6] = r5; R_HW[7] = r6;
255
+ R_IND += 1;
256
+ }
257
+ else {
258
+ R_HW[0] = r0; R_HW[1] = r1; R_HW[2] = r2; R_HW[3] = r3;
259
+ R_HW[4] = r4; R_HW[5] = r5; R_HW[6] = r6; R_HW[7] = r7;
260
+ }
261
+
262
+ }
263
+
264
+
265
+
266
+ /***************************/
267
+ #else
268
+ /***************************/
269
+ /* From there on, the normal, unrolled case */
270
+
271
+
272
+ void scs_mul(scs_ptr result, scs_ptr x, scs_ptr y){
273
+ uint64_t RES[SCS_NB_WORDS+1];
274
+ uint64_t val, tmp;
275
+ int i, j;
276
+
277
+ R_EXP = X_EXP * Y_EXP;
278
+ R_SGN = X_SGN * Y_SGN;
279
+ R_IND = X_IND + Y_IND;
280
+
281
+ for(i=0; i<=SCS_NB_WORDS; i++)
282
+ RES[i]=0;
283
+
284
+ /* Compute only the first half of the partial product. See the
285
+ unrolled code for an example of what we compute */
286
+
287
+ #ifdef CRLIBM_TYPECPU_X86
288
+ /* This is the only place where there is assembly code to force 64-bit
289
+ arithmetic. Someday gcc will catch up here, too.
290
+ */
291
+ {
292
+ db_number t;
293
+ /* i=0 */
294
+ for(j=0; j<(SCS_NB_WORDS); j++) {
295
+ __asm__ volatile("mull %3"
296
+ : "=a" (t.i[LO]), "=d" (t.i[HI])
297
+ : "a" (X_HW[0]) , "g" (Y_HW[j]));
298
+ RES[j] += t.l;
299
+ }
300
+ /* i = 1..SCS_NB_WORDS-1 */
301
+ for(i=1 ; i<SCS_NB_WORDS; i++){
302
+ for(j=0; j<(SCS_NB_WORDS-i); j++){
303
+ __asm__ volatile("mull %3"
304
+ : "=a" (t.i[LO]), "=d" (t.i[HI])
305
+ : "a" (X_HW[i]) , "g" (Y_HW[j]));
306
+ RES[i+j] += t.l;
307
+ }
308
+ __asm__ volatile("mull %3"
309
+ : "=a" (t.i[LO]), "=d" (t.i[HI])
310
+ : "a" (X_HW[i]) , "g" (Y_HW[j]));
311
+ /* here j==SCS_NB_WORDS-i */
312
+ RES[SCS_NB_WORDS] += t.l;
313
+ }
314
+ }
315
+
316
+ #else /* other architectures */
317
+
318
+ /* i=0 */
319
+ tmp = X_HW[0];
320
+ for(j=0; j<(SCS_NB_WORDS); j++)
321
+ RES[j] += tmp * Y_HW[j];
322
+ /* i = 1..SCS_NB_WORDS-1 */
323
+ for(i=1 ; i<SCS_NB_WORDS; i++){
324
+ tmp = X_HW[i];
325
+ for(j=0; j<(SCS_NB_WORDS-i); j++)
326
+ RES[i+j] += tmp * Y_HW[j];
327
+ RES[SCS_NB_WORDS] += tmp * Y_HW[j]; /* here j==SCS_NB_WORDS-i */
328
+ }
329
+ #endif/* SCS_TYPECPU_X86 */
330
+
331
+ val = 0;
332
+
333
+ /* Carry propagate */
334
+ for(i=SCS_NB_WORDS; i>0; i--)
335
+ SCS_CARRY_PROPAGATE(RES[i],RES[i-1],tmp)
336
+ SCS_CARRY_PROPAGATE(RES[0],val,tmp)
337
+
338
+
339
+ /* Store the result */
340
+ if(val != 0){
341
+ /* shift all the digits ! */
342
+ R_HW[0] = val;
343
+ for(i=1; i<SCS_NB_WORDS; i++)
344
+ R_HW[i] = RES[i-1];
345
+
346
+ R_IND += 1;
347
+ }else {
348
+ for(i=0; i<SCS_NB_WORDS; i++)
349
+ R_HW[i] = RES[i];
350
+ }
351
+ }
352
+
353
+
354
+
355
+
356
+
357
+
358
+
359
+ void scs_square(scs_ptr result, scs_ptr x){
360
+ uint64_t RES[SCS_NB_WORDS+1];
361
+ uint64_t val, tmp;
362
+ int i, j;
363
+
364
+
365
+ R_EXP = X_EXP * X_EXP;
366
+ R_SGN = 1;
367
+ R_IND = X_IND + X_IND;
368
+
369
+ /* Set to 0 intermediate register */
370
+ for(i=0; i<=SCS_NB_WORDS; i++)
371
+ RES[i] = 0;
372
+
373
+ /* Compute all the double partial products: 2 x_i * x_j, i!=j */
374
+ tmp = (uint64_t)X_HW[0];
375
+ for(j=1; j<SCS_NB_WORDS; j++)
376
+ RES[j] += tmp * X_HW[j];
377
+ for(i=1 ; i<(SCS_NB_WORDS+1)/2; i++){
378
+ tmp = (uint64_t)X_HW[i];
379
+ for(j=i+1; j<(SCS_NB_WORDS-i); j++)
380
+ RES[i+j] += tmp * X_HW[j];
381
+ RES[SCS_NB_WORDS] += tmp * X_HW[SCS_NB_WORDS-i];
382
+ }
383
+
384
+ /* All these partial products are double */
385
+ for(i=0; i<=SCS_NB_WORDS; i++)
386
+ RES[i] *=2;
387
+
388
+ /* Add partial product of the form x_i^2 */
389
+ for(i=0, j=0; i<=SCS_NB_WORDS; i+=2, j++){
390
+ RES[i] += (uint64_t)X_HW[j] * X_HW[j];
391
+ }
392
+
393
+ val = 0;
394
+ /* Carry propagate */
395
+ for(i=SCS_NB_WORDS; i>0; i--)
396
+ SCS_CARRY_PROPAGATE(RES[i],RES[i-1],tmp)
397
+
398
+ SCS_CARRY_PROPAGATE(RES[0],val,tmp)
399
+
400
+
401
+ /* Store the result */
402
+ if(val != 0){
403
+ /* shift all the digits ! */
404
+ R_HW[0] = val;
405
+ for(i=1; i<SCS_NB_WORDS; i++)
406
+ R_HW[i] = RES[i-1];
407
+
408
+ R_IND += 1;
409
+ }else {
410
+ for(i=0; i<SCS_NB_WORDS; i++)
411
+ R_HW[i] = RES[i];
412
+ }
413
+
414
+ }
415
+
416
+
417
+ /*
418
+ * #endif corresponding to the test #if (SCS_NB_WORDS==8)
419
+ */
420
+ #endif
421
+
422
+
423
+ /*
424
+ Multiply x by an integer val; result is returned in x.
425
+ */
426
+ void scs_mul_ui(scs_ptr x, unsigned int val_int){
427
+ uint64_t val, tmp, vald, rr;
428
+ int i;
429
+
430
+ if (val_int == 0)
431
+ X_EXP = 0;
432
+
433
+ vald = val_int;
434
+
435
+ val = 0;
436
+ rr = 0;
437
+ for(i=(SCS_NB_WORDS-1); i>=0; i--){
438
+ val += vald * X_HW[i];
439
+ SCS_CARRY_PROPAGATE(val, rr, tmp)
440
+ X_HW[i] = val;
441
+ val = rr;
442
+ rr = 0;
443
+ }
444
+
445
+ if(val != 0){
446
+ /* shift all the digits ! */
447
+ for(i=(SCS_NB_WORDS-1); i>0; i--)
448
+ X_HW[i] = X_HW[i-1];
449
+
450
+ X_HW[0] = (unsigned int)val;
451
+ X_IND += 1;
452
+ }
453
+
454
+ return;
455
+ }
456
+