MCPcopy Create free account
hub / github.com/numpy/numpy / _do_init

Method _do_init

numpy/core/_machar.py:122–337  ·  view source on GitHub ↗
(self, float_conv, int_conv, float_to_float, float_to_str, title)

Source from the content-addressed store, hash-verified

120 self._do_init(float_conv, int_conv, float_to_float, float_to_str, title)
121
122 def _do_init(self, float_conv, int_conv, float_to_float, float_to_str, title):
123 max_iterN = 10000
124 msg = "Did not converge after %d tries with %s"
125 one = float_conv(1)
126 two = one + one
127 zero = one - one
128
129 # Do we really need to do this? Aren't they 2 and 2.0?
130 # Determine ibeta and beta
131 a = one
132 for _ in range(max_iterN):
133 a = a + a
134 temp = a + one
135 temp1 = temp - a
136 if any(temp1 - one != zero):
137 break
138 else:
139 raise RuntimeError(msg % (_, one.dtype))
140 b = one
141 for _ in range(max_iterN):
142 b = b + b
143 temp = a + b
144 itemp = int_conv(temp-a)
145 if any(itemp != 0):
146 break
147 else:
148 raise RuntimeError(msg % (_, one.dtype))
149 ibeta = itemp
150 beta = float_conv(ibeta)
151
152 # Determine it and irnd
153 it = -1
154 b = one
155 for _ in range(max_iterN):
156 it = it + 1
157 b = b * beta
158 temp = b + one
159 temp1 = temp - b
160 if any(temp1 - one != zero):
161 break
162 else:
163 raise RuntimeError(msg % (_, one.dtype))
164
165 betah = beta / two
166 a = one
167 for _ in range(max_iterN):
168 a = a + a
169 temp = a + one
170 temp1 = temp - a
171 if any(temp1 - one != zero):
172 break
173 else:
174 raise RuntimeError(msg % (_, one.dtype))
175 temp = a + betah
176 irnd = 0
177 if any(temp-a != zero):
178 irnd = 1
179 tempa = a + beta

Callers 1

__init__Method · 0.95

Calls 2

absFunction · 0.85
anyFunction · 0.70

Tested by

no test coverage detected