for i in range(len(array1)):
array1[i] *= sqrt(2)
i += 1
print(amplitudes_array)
import math
def getAmplitudesArray(array):
amplitudesArray = []
multiplier = 2
for item in array:
amplitudesArray.append(float(item * math.sqrt(multiplier)))
multiplier *= 2
return amplitudesArray
array = [1] * 10
print(getAmplitudesArray(array))
>>> [1.4142135623730951,
2.0,
2.8284271247461903,
4.0, 5.656854249492381,
8.0, 11.313708498984761,
16.0,
22.627416997969522,
32.0]
from math import sqrt
array = [1] * 10
for i in range(len(array)):
array[i] *= sqrt(2) ** (i + 1)
print(array)
import numpy as np
array = np.ones(10, dtype='int32')
for i in range(len(array)):
array[i] *= np.sqrt(2) ** (i + 1)
print(array)
import numpy as np
array = np.ones(10, dtype='f4')
for i in range(len(array)):
array[i] *= np.sqrt(2) ** (i + 1)
print(array)
>>> def gen():
... a, b = 2 ** 0.5, 2
... while True:
... yield a
... yield b
... a *= 2
... b *= 2
...
>>> lst = [1] * 10
>>> out = [i * j for i, j in zip(lst, gen())]
>>> out
[1.4142135623730951, 2, 2.8284271247461903, 4, 5.656854249492381, 8, 11.313708498984761, 16, 22.627416997969522, 32]
>>>
arr = [1 for x in range(10)]
print arr
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
from math import sqrt
map(lambda(x,y): y * (sqrt(2) ** (x + 1)), enumerate(arr))
[1.4142135623730951, 2.0000000000000004, 2.8284271247461907, 4.000000000000001, 5.656854249492382, 8.000000000000004, 11.313708498984766, 16.000000000000007, 22.627416997969533, 32.00000000000002]