Ian Jauslin
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools.jl')
-rw-r--r--src/tools.jl22
1 files changed, 17 insertions, 5 deletions
diff --git a/src/tools.jl b/src/tools.jl
index 0d3dc7f..5d1678d 100644
--- a/src/tools.jl
+++ b/src/tools.jl
@@ -1,4 +1,4 @@
-## Copyright 2021 Ian Jauslin
+## Copyright 2021-2023 Ian Jauslin
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
@@ -13,7 +13,9 @@
## limitations under the License.
# \Phi(x)=2*(1-sqrt(1-x))/x
-@everywhere function Phi(x)
+@everywhere function Phi(
+ x::Float64
+)
if abs(x)>1e-5
return 2*(1-sqrt(abs(1-x)))/x
else
@@ -21,7 +23,9 @@
end
end
# \partial\Phi
-@everywhere function dPhi(x)
+@everywhere function dPhi(
+ x::Float64
+)
#if abs(x-1)<1e-5
# @printf(stderr,"warning: dPhi is singular at 1, and evaluating it at (% .8e+i% .8e)\n",real(x),imag(x))
#end
@@ -33,17 +37,25 @@ end
end
# apply Phi to every element of a vector
-@everywhere function dotPhi(v)
+@everywhere function dotPhi(
+ v::Array{Float64,1}
+)
out=zeros(Float64,length(v))
for i in 1:length(v)
out[i]=Phi(v[i])
end
return out
end
-@everywhere function dotdPhi(v)
+@everywhere function dotdPhi(
+ v::Array{Float64,1}
+)
out=zeros(Float64,length(v))
for i in 1:length(v)
out[i]=dPhi(v[i])
end
return out
end
+
+@everywhere function sinc(x::Float64)
+ return (x == 0 ? 1 : sin(x)/x)
+end