DoubleFloats plans for fft

Hi,
I would like to use fft’s under DoubleFloats. Is it possible to use plans to optimize the calculations?

Many thanks!

Jaime

Yes, it is possible to do so. DoubleFloat is called Float64:

julia> x = randn((10, 6))
10×6 Array{Float64,2}:
  0.677066  -0.751123   0.411206   -0.144039  -0.888348  -0.0769508
 -0.945243  -0.669601  -1.491      -0.544662   1.27262    0.136143
  0.28446   -0.723543  -0.160361    1.16289    0.23427   -0.607768
 -0.234152   0.384269  -2.07268    -0.403732  -1.13892    1.14722
 -0.521411  -0.25495   -0.491467    0.552317  -0.794891   1.13252
  2.64284   -1.41663   -0.889482    0.192952  -0.102239   0.285883
  0.433473   0.119091  -0.127861    0.107863   0.423339   0.575146
 -0.430365   2.01674    1.17148    -0.515649  -0.614735   0.778848
  0.414355   0.75615   -0.684232   -0.515438  -1.12986   -0.208387
 -0.945138  -1.38633   -0.0074715  -0.395333   0.229893  -0.182433

julia> using FFTW

julia> p = plan_fft(x)
FFTW forward plan for 10×6 array of Complex{Float64}
(dft-rank>=2/1
  (dft-direct-10-x6 "n2fv_10_avx2_128")
  (dft-direct-6-x10 "n1fv_6_avx2_128"))

julia> p * x
10×6 Array{Complex{Float64},2}:
 -4.92339+0.0im         5.83122+5.83627im   3.77128+2.66141im     -6.02632+0.0im       3.77128-2.66141im     5.83122-5.83627im
 -6.79686+3.87239im     1.81164+1.4843im   -3.80074-5.21342im      3.99578+3.07849im  -1.85259-2.79249im    -11.3733+2.56027im
 -0.34439-5.93107im   -0.623183+6.69577im   1.07565+4.31514im      9.26973-4.32148im   7.85852-1.60115im    -1.15141-3.45542im
  1.41788-0.469272im  0.0864065-5.51548im  -6.83544+5.2453im      -7.50708+4.00053im  -5.44799+0.380456im    3.21576+2.04184im
  2.65891+4.59058im      8.8873-9.56459im    3.1661+1.12184im      3.14579+3.08435im   9.54174-2.81019im     2.18611-1.65011im
  3.33042+0.0im        -2.41414-4.85566im   4.37983+2.13933im   -0.0617635+0.0im       4.37983-2.13933im    -2.41414+4.85566im
  2.65891-4.59058im     2.18611+1.65011im   9.54174+2.81019im      3.14579-3.08435im    3.1661-1.12184im      8.8873+9.56459im
  1.41788+0.469272im    3.21576-2.04184im  -5.44799-0.380456im    -7.50708-4.00053im  -6.83544-5.2453im    0.0864065+5.51548im
 -0.34439+5.93107im    -1.15141+3.45542im   7.85852+1.60115im      9.26973+4.32148im   1.07565-4.31514im   -0.623183-6.69577im
 -6.79686-3.87239im    -11.3733-2.56027im  -1.85259+2.79249im      3.99578-3.07849im  -3.80074+5.21342im     1.81164-1.4843im

I believe this answer was asking about https://github.com/JuliaMath/DoubleFloats.jl which lets you use 2 Float64 values to get 106 bits of precision.

2 Likes

Thanks to both for the quick responses. In fact, I’m interested in the extended precision of the DoubleFloats.jl package for intensive use of fft’s.

Ah, my bad :smile:

I did some digging and found this

julia> using FastTransforms
[ Info: Precompiling FastTransforms [057dd010-8810-581a-b7be-e3fc3b93f78c]

julia> y = randn(Double64, (10, 10))
10×10 Array{Double64,2}:
 -1.1292438537972538   -0.647511331823632   -0.2647247666637986    0.8267851456602784    1.3436907644238494   …   0.7870741156168397    -0.5287937843738052    -1.7250231675101182    0.22126096156067945
 -0.15273201413073784  -0.8364645453039026  -0.3183729145601668    0.1417536736000426    0.45278025346723316      0.024227483743503867  -1.8280541794695537     0.6832412686365034    2.6330390741383765
  0.5175505803284906   -0.7712969432337178   1.7893287272380964    0.20968617567882064  -0.8037639454510728      -0.8795971595690645     1.2002587197933383    -1.3769192958710266   -0.23218509952117508
  0.3420447623467037   -1.2947623508838697   0.9307795811697627    0.6930611601306795   -0.9575991427231448      -0.14592052089972013   -0.37164316683469606    1.21693888457782     -0.8967976966654317
  0.9704747983489629    1.8878756588207026   0.06305727124057722   0.9347732838576301    0.9292087926322615       0.6244744627146146    -0.046449033226453836  -0.540522799434064     0.7538986770485111
  0.23960443387373154  -0.422600572244826   -1.3726986665291663    0.7188112112995776    0.5217224731263702   …  -1.6025451241555402     1.2965817372108346     0.5117009222713786    1.1623435460649825
  0.3631076668323081   -0.7390915858991868  -0.3147547733945754   -0.1762223496000308   -0.07734824598088659     -0.2755406866796454     0.5123448164121102    -0.07455447431286513   0.7240734073223415
  0.260055557859319    -1.1021593352447352  -2.5449183044042556   -0.19074471493717693   1.6923292561435175       0.2735904232122618    -2.281275342839853      1.3632409182772423   -1.9103471623634534
 -0.5463619527005806    1.8161824155649817   1.1298995223938033    1.0542431660455265    0.9549014407743441       2.101138912912026      0.8617700339970756    -0.8200795498955755    0.7172978226782473
 -0.7380548662201147   -0.2868621636604453   1.0579940531814318   -0.9202852647999166   -0.8229624674270529      -0.04375364493708027    0.4492518422187647    -0.27399827842307145  -1.06797450208141

julia> fft(y)
ERROR: MethodError: no method matching generic_fft(::Array{Complex{Double64},2})
Closest candidates are:
  generic_fft(::Array{T,1}) where T<:Union{AbstractFloat, Complex{T} where T<:AbstractFloat} at /home/fxw/.julia/packages/FastTransforms/oQJQJ/src/fftBigFloat.jl:11
Stacktrace:
 [1] *(::FastTransforms.DummyFFTPlan{Complex{Double64},false}, ::Array{Complex{Double64},2}) at /home/fxw/.julia/packages/FastTransforms/oQJQJ/src/fftBigFloat.jl:198
 [2] fft(::Array{Complex{Double64},2}, ::UnitRange{Int64}) at /home/fxw/.julia/packages/AbstractFFTs/mhQvY/src/definitions.jl:51
 [3] fft(::Array{Double64,2}, ::UnitRange{Int64}) at /home/fxw/.julia/packages/AbstractFFTs/mhQvY/src/definitions.jl:198 (repeats 2 times)
 [4] top-level scope at REPL[22]:1
 [5] run_repl(::REPL.AbstractREPL, ::Any) at /build/julia/src/julia-1.5.3/usr/share/julia/stdlib/v1.5/REPL/src/REPL.jl:288

For some reason their latest package doesn’t support it anymore

If you take a slice it works:
julia> using FFTW, FastTransforms, DoubleFloats
julia> y = Double64.(randn(10,10));
julia> fft(y[:,1])
10-element Array{Complex{Double64},1}:
-0.5997902658636178 + 4.622231866529366e-33im
-3.925995047597333 + 0.4632874725753252im
-2.344821026447533 - 1.1174059973165642im
0.9948184949863303 + 1.5537872960816208im
-6.429590723078108 + 0.05469385542831158im
-2.2804314503074674 + 2.04107518113366e-33im
-6.429590723078108 - 0.05469385542831158im
0.9948184949863303 - 1.5537872960816208im
-2.344821026447533 + 1.1174059973165642im
-3.925995047597333 - 0.4632874725753252im

1 Like