Commit 6b00acc5 authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

code compiles; warning: first index should be sample index because to column major order

This is a legacy commit from before 2015-03-01.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.

SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/branches/libfourier
SVN Revision: 3947
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent c629ba69
......@@ -40,6 +40,7 @@
#include <fourier/fftwaffar.h>
#include <fourier/error.h>
#include <aff/Carray.h>
namespace fourier {
......@@ -47,8 +48,8 @@ namespace fourier {
DRFFTWAFFArrayEngine::DRFFTWAFFArrayEngine(const int& nseis,
const int& nsamp)
: Mseriesarray(TAseries(nseis,nsamp)),
Mspectrumarray(TAspectrum(nseis,DRFFTWAFFArrayEngine::ncoeff(nsamp))),
: Mseriesarray(TAseries(nsamp,nseis)),
Mspectrumarray(TAspectrum(DRFFTWAFFArrayEngine::ncoeff(nsamp)),nseis),
Mplanr2c(0), Mplanc2r(0)
{
this->checkconsistency();
......@@ -97,11 +98,11 @@ namespace fourier {
void DRFFTWAFFArrayEngine::checkconsistency()
{
FOURIER_assert(Mseriesarray.size(0)==
DRFFTWAFFArrayEngine::ncoeff(Mspectrumarray.size(0)),
"ERROR: sample size inconsistent");
FOURIER_assert(Mseriesarray.size(1)==Mspectrumarray.size(1),
FOURIER_assert(Mseriesarray.size(0)==Mspectrumarray.size(0),
"ERROR: inconsistent number of signals");
FOURIER_assert(Mseriesarray.size(1)==
DRFFTWAFFArrayEngine::ncoeff(Mspectrumarray.size(1)),
"ERROR: sample size inconsistent");
FOURIER_assert(((Mseriesarray.size(2)==1) && (Mspectrumarray.size(2)==1)),
"ERROR: two-dimensional arrays only");
FOURIER_assert(((Mseriesarray.size(3)==1) && (Mspectrumarray.size(3)==1)),
......@@ -127,37 +128,27 @@ namespace fourier {
// input array
// -----------
aff::CArray<TAseries::Tvalue> Cseriesarray(Mseriesarray);
// one-dimensional transform: use default
int* inembed=0;
// distance to next sample
const int istride=Mseriesarray.stride(0);
const int istride=Cseriesarray.stride(0);
// distance to next signal
const int idist=Mseriesarray.stride(1);
// reference to memory
TAseries::Trepresentation irep=Mseriesarray.representation();
// offset in array representation
aff::Tsubscript ioffset=Mseriesarray.first_offset();
// pointer to first array element in memory
TAseries::Trepresentation::Tpointer ipointer=&irep[ioffset];
const int idist=Cseriesarray.stride(1);
// casted pointer
double* in=aff::SizeCheckedCast<TAseries::Tvalue,double>::cast(ipointer);
double* in=Cseriesarray.castedpointer<double>();
// output array
// ------------
aff::CArray<TAspectrum::Tvalue> Cspectrumarray(Mspectrumarray);
// one-dimensional transform: use default
int* onembed=0;
// distance to next sample
const int ostride=Mspectrumarray.stride(0);
const int ostride=Cspectrumarray.stride(0);
// distance to next signal
const int odist=Mspectrumarray.stride(1);
// reference to memory
TAspectrum::Trepresentation orep=Mspectrumarray.representation();
// offset in array representation
aff::Tsubscript ooffset=Mspectrumarray.first_offset();
// pointer to first array element in memory
TAspectrum::Trepresentation::Tpointer opointer=&orep[ooffset];
const int odist=Cspectrumarray.stride(1);
// casted pointer
fftw_complex* out=aff::SizeCheckedCast<TAspectrum::Tvalue,fftw_complex>::cast(opointer);
fftw_complex* out=Cspectrumarray.castedpointer<fftw_complex>();
// create plan
Mplanr2c=fftw_plan_many_dft_r2c(rank, &n, howmany,
......@@ -187,37 +178,27 @@ namespace fourier {
// input array
// -----------
aff::CArray<TAspectrum::Tvalue> Cspectrumarray(Mspectrumarray);
// one-dimensional transform: use default
int* inembed=0;
// distance to next sample
const int istride=Mspectrumarray.stride(0);
const int istride=Cspectrumarray.stride(0);
// distance to next signal
const int idist=Mspectrumarray.stride(1);
// reference to memory
TAspectrum::Trepresentation irep=Mspectrumarray.representation();
// offset in array representation
aff::Tsubscript ioffset=Mspectrumarray.first_offset();
// pointer to first array element in memory
TAspectrum::Trepresentation::Tpointer ipointer=&irep[ioffset];
const int idist=Cspectrumarray.stride(1);
// casted pointer
fftw_complex* in=aff::SizeCheckedCast<TAspectrum::Tvalue,fftw_complex>::cast(ipointer);
fftw_complex* in=Cspectrumarray.castedpointer<fftw_complex>();
// output array
// ------------
aff::CArray<TAseries::Tvalue> Cseriesarray(Mseriesarray);
// one-dimensional transform: use default
int* onembed=0;
// distance to next sample
const int ostride=Mseries.stride(0);
const int ostride=Cseriesarray.stride(0);
// distance to next signal
const int odist=Mseries.stride(1);
// reference to memory
TAseries::Trepresentation orep=Mseries.representation();
// offset in array representation
aff::Tsubscript ooffset=Mseries.first_offset();
// pointer to first array element in memory
TAseries::Trepresentation::Tpointer opointer=&orep[ooffset];
const int odist=Cseriesarray.stride(1);
// casted pointer
double* out=aff::SizeCheckedCast<TAseries::Tvalue,double>::cast(opointer);
double* out=Cseriesarray.castedpointer<double>();
// create plan
Mplanr2c=fftw_plan_many_dft_c2r(rank, &n, howmany,
......
......@@ -73,7 +73,9 @@ namespace fourier {
* provided through member functions.
*
* The first index to the array is the sample index, the second index is
* the signal index.
* the signal index.
* This is due to the column major arrangement used by aff::Array
* containers by default (this is the common Fortran layout).
*/
class DRFFTWAFFArrayEngine {
public:
......@@ -107,7 +109,8 @@ namespace fourier {
void createplanr2c();
void createplanc2r();
void delete_plans();
static int ncoeff(const int& nsamples) { return(nsamples/2+1); }
static unsigned int ncoeff(const unsigned int& nsamples)
{ return(nsamples/2+1); }
TAseries Mseriesarray;
TAspectrum Mspectrumarray;
fftw_plan Mplanr2c;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment