Added type template to interpolate function and added test for interpolate

This commit is contained in:
ovainola
2015-06-25 19:13:28 +03:00
parent 8c182e45bb
commit bf8e4cf030
2 changed files with 3 additions and 2 deletions
+2 -2
View File
@@ -25,11 +25,11 @@ basis :: Function
ip :: Array{Number, 1}
Point to interpolate
""" ->
function interpolate(field::Array{Float64,1}, basis::Function, ip)
function interpolate{T<:Real}(field::Array{T,1}, basis::Function, ip)
result = dot(field, basis(ip))
return result
end
function interpolate(field::Array{Float64,2}, basis::Function, ip)
function interpolate{T<:Real}(field::Array{T,2}, basis::Function, ip)
m, n = size(field)
bip = basis(ip)
tmp = size(bip)
+1
View File
@@ -154,6 +154,7 @@ facts("test interpolation of different field variables") do
F3 = F2'
F4 = [0.0 0.0; 10.0 0.0; 10.0 1.0; 0.0 1.0]'
F5 = F4'
F6 = [36, 36, 36, 36]
@fact interpolate(F1, N, [0.0, 0.0]) => 36.0
@fact interpolate(F2, N, [0.0, 0.0]) => 36.0