Hi, in order to use fwht() function from Hadamard.jl package, I have to resize the input vector A into a vector tempA of a length that can be write as a power of two. I am doing this in the srht() function below at row 2. Also ispow2() checks if size(A)[1] is a power of 2 and n2p(size(A)[1]) returns the next upper power of 2 interger from the input interger.
function srht(to::TimerOutput, A::Array{<:AbstractFloat,1}, D::Array{Int}, R::Array{Int}, l::Int)::Array{<:AbstractFloat,1}
@timeit to "vcat" tempA = (ispow2(size(A)[1])) ? A : vcat(A,zeros(eltype(A), n2p(size(A)[1])-size(A)[1], 1))
#@assert l <= size(tempA)[1]
scale::AbstractFloat = (size(tempA)[1]/sqrt(l))
@timeit to "D.*tempA" view(tempA,:,1).*=D
copyto!(tempA,@timeit to "fwht" fwht(tempA))
return @timeit to "lmul!" lmul!(scale, tempA[R])
end
Without this resize/recast step, the fwht() function exits with an error (like input size isn’t a power of two). Is it possible to avoid this time and memory comsuming step, tagged with “vcat” in plot below ?
(see only RGS or GAUSS process, “vcat” is in blue shade, time is ~60-120 sec, Matrix size is 5E6x300)