PortAudio.jl/test/testhelpers.jl

23 lines
534 B
Julia
Raw Normal View History

2014-07-01 03:24:29 +02:00
# convenience function to calculate the mean-squared error
2014-08-12 00:09:51 +02:00
function mse(arr1::AbstractArray, arr2::AbstractArray)
2014-07-01 03:24:29 +02:00
@assert length(arr1) == length(arr2)
N = length(arr1)
err = 0.0
for i in 1:N
err += (arr2[i] - arr1[i])^2
end
err /= N
end
2014-08-12 00:09:51 +02:00
mse(X::AbstractArray, thresh=1e-8) = Y::AbstractArray -> begin
if size(X) != size(Y)
return false
end
return mse(X, Y) < thresh
end
2014-07-01 03:24:29 +02:00
issubtype(T::Type) = x -> typeof(x) <: T
lessthan(rhs) = lhs -> lhs < rhs
greaterthan(rhs) = lhs -> lhs > rhs