Commit bae2f0f3 authored by Alejandro Saez's avatar Alejandro Saez

add concat_data!

parent 46a92fa4
......@@ -520,4 +520,59 @@ function truncate_data!(data::Vector{Vector{CData}}, nc::Vector{Int64})
end
end
return nothing
end
@doc raw"""
concat_data!(data1::Vector{CData}, data2::Vector{CData})
concat_data!(data1::Vector{Vector{CData}}, data2::Vector{Vector{CData}})
Concatenates the output of 2 calls to `read_mesons` over configurations.
Both data must have the same number of replicas and correlators.
The output is saved in the first argument, so if you want to concatenate
3 data sets: `concat_data!(data1, data2); concat_data!(data1, data3)`
Examples:
```@example
#Single replica
dat = read_mesons(path, "G5", "G5")
dat2 = read_mesons(path2, "G5", "G5")
concat_data!(dat, dat2)
#Two replicas
dat = read_mesons([path1, path2], "G5", "G5")
dat2 = read_mesons([path3, path4], "G5", "G5")
concat_data!(dat, dat2)
```
"""
function concat_data!(data1::Vector{CData}, data2::Vector{CData})
N = length(data1)
if length(data1) != length(data2)
error("number of correlators do not match")
end
for k = 1:N
data1[k].vcfg = vcat(data1[k].vcfg, data2[k].vcfg)
data1[k].re_data = vcat(data1[k].re_data, data2[k].re_data)
data1[k].im_data = vcat(data1[k].im_data, data2[k].im_data)
end
return nothing
end
function concat_data!(data1::Vector{Vector{CData}}, data2::Vector{Vector{CData}})
N = length(data1)
if length(data1) != length(data2)
error("number of correlators do not match")
end
R = length(data1[1])
if length(data1[1]) != length(data2[1])
error("number of replicas do not match")
end
for k = 1:N
for r = 1:R
data1[k][r].vcfg = vcat(data1[k][r].vcfg, data2[k][r].vcfg)
data1[k][r].re_data = vcat(data1[k][r].re_data, data2[k][r].re_data)
data1[k][r].im_data = vcat(data1[k][r].im_data, data2[k][r].im_data)
end
end
return nothing
end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment