You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
n =round(Int, log2(N)) # no. of qubits that can encodes signal
18
+
N >0||throw(ArgumentError("_array_to_tensor: Input signal must be non-empty."))
19
+
n =ceil(Int, log2(N)) # no. of qubits that can encode signal
20
+
padded_length =2^n
19
21
20
22
ITensors.disable_warn_order()
21
23
try
22
-
# If signal is not a power of 2, fill with 0s upto length 2^n with a warning
23
-
if N <2^n
24
-
@warn"_array_to_tensor: Input signal length $N is not a power of 2. Filling with zeros upto length $(2^n). We recommend providing signals of length power-of-2 for best performance."
25
-
x_filled =zeros(2^n)
24
+
# If signal is not a power of 2, fill with 0s up to the next power of 2 with a warning.
25
+
if N != padded_length
26
+
@warn"_array_to_tensor: Input signal length $N is not a power of 2. Filling with zeros upto length $(padded_length). We recommend providing signals of length power-of-2 for best performance."
27
+
x_filled =zeros(eltype(x), padded_length)
26
28
x_filled[1:N] .= x
27
29
x = x_filled
28
30
end
29
-
@assertlength(x) ==2^n||
31
+
@assertlength(x) ==padded_length||
30
32
"_array_to_tensor: Length of signal vector must be a power of 2"
31
33
if sites === undef
32
34
sites = [Index(2; tags=@sprintf("site-%d", i)) for i in1:n]
0 commit comments