为了跟进我已经问过的一个问题,就我得到问题的答案而言,我已经解决了一个问题,尽管事实上一个新问题是从已解决的问题中产生的:
使用Complex API的问题是它无法识别NMatrix API 中的 shape 方法:
因此,当我在编译的 C 扩展上运行以下规范代码时:
it "Creates a new FFTW.r2c object and takes an a 1D NMatrix as its argument" do
n = NMatrix.new([4], [3.10, 1.73, 1.04, 2.83])
r = FFTW.Z(n)
i = FFTW.Z(FFTW.r2c_one(r))
#expect(fftw).to eq(fftw)
end
由于 shape 属于 nmatrix 类,因此存在错误。
FFTW Creates a new FFTW.r2c object and takes an a 1D NMatrix as its argument
Failure/Error: i = FFTW.Z(FFTW.r2c_one(r))
NoMethodError:
undefined method `shape' for NMatrix:Class
# ./spec/fftw_spec.rb:26:in `r2c_one'
# ./spec/fftw_spec.rb:26:in `block (2 levels) in <top (required)>'
Shape 是从 nmatrix 类中调用的,所以我可以理解为什么会发生这种情况,但不知道如何绕过它。
的结果
it "Creates a new FFTW.r2c object and takes an a 1D NMatrix as its argument" do
n = NMatrix.new([4], [3.10, 1.73, 1.04, 2.83])
fftw = FFTW.Z(n)
expect(fftw).to eq(fftw)
end
是
/home/magpie/.rvm/rubies/ruby-2.1.2/bin/ruby -I/home/magpie/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/lib:/home/magpie/.rvm/gems/ruby-2.1.2/gems/rspec-support-3.0.4/lib -S /home/magpie/.rvm/gems/ruby-2.1.2/gems/rspec-core-3.0.4/exe/rspec ./spec/fftw_spec.rb
./lib/fftw/fftw.so found!
FFTW
creates an NMatrix object
Fills dense with individual assignments
Creates a new FFTW.r2c object and takes an a 1D NMatrix as its argument
Finished in 0.00091 seconds (files took 0.07199 seconds to load)
3 examples, 0 failures