For a (binary) floating point system of the form $(1.s_1s_2s_3)_2 2p$ that has an exponent range from $−128$ to $127$ and that uses three bits to store the significand s, what is the difference between 1 and the smallest representable number greater than one?
In [44]:
import numpy as np
A = {0: {2: 17, 3: 31}, 1: {3: 5}, 3: {1: 14}}
x = np.array([1,2,4,5])
shape=(4,4)
import numpy as np
def sparse_mv_mult(A, x, shape):
Ax = np.zeros((shape[1],1))
for k in list(A.keys()):
sparse_row = A[k]
sparse_sum = 0
for j in list(sparse_row.keys()):
sparse_sum += sparse_row[j]*x[j]
Ax[k] = sparse_sum
return Ax
Ax = sparse_mv_mult(A,x,shape)
In [45]:
Ax
Out[45]:
In [39]:
def no_change(a):
k = 1
a = float(a)
while a != a + 10**-k:
k += 1
else:
return(k)
k = no_change(a)
In [42]:
f = (5,5)
f[1]
Out[42]:
In [7]:
subset[1:10]
Out[7]:
In [9]:
fp_numbers[f
In [ ]: