Beispiel #1
0
WGSLIB_DECL bool fft_crossvarmap_3d_declus(
	VarOut& Yout,

	const std::vector<double>& weigth1,
	const std::vector<double>& data1,
	const std::vector<int>& has_point1,

	const std::vector<double>& data2,
	const std::vector<int>& has_point2,
	int N, int M, int K)
{
	omp_set_num_threads(fft_get_num_threads());
	fftw_plan_with_nthreads(fft_get_num_threads());

	fftw_complex *i1i2,  *I1I2;
	fftw_complex *z1i2,  *Z1I2;
	fftw_complex *i1z2,  *I1Z2;
	fftw_complex *z1z2,  *Z1Z2;
	fftw_complex *w,     *W;
	fftw_complex *wz1,   *WZ1;
	fftw_complex *wz2,   *WZ2;
	fftw_complex *wz1z2, *WZ1Z2;
	
	fftw_plan p;

	int ZS = (2 * N + 1) * (2 * M + 1) * (2 * K + 1);

	fft_lock();
	i1i2 = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);  
	I1I2 = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	
	z1i2 = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS); 
	Z1I2 = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	
	i1z2 = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS); 
	I1Z2 = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);

	z1z2 = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS); 
	Z1Z2 = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);

	w = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS); 
	W = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);

	wz1 = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	WZ1 = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);

	wz2 = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	WZ2 = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	wz1z2 = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS); 
	WZ1Z2 = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	fft_unlock();

	#pragma omp parallel for
	for (int i = 0; i < ZS; ++i) {
		i1i2[i][REAL] = i1i2[i][IMAG] = 0;
		I1I2[i][REAL] = I1I2[i][IMAG] = 0;

		z1i2[i][REAL] = z1i2[i][IMAG] = 0;
		Z1I2[i][REAL] = Z1I2[i][IMAG] = 0;

		i1z2[i][REAL] = i1z2[i][IMAG] = 0;
		I1Z2[i][REAL] = I1Z2[i][IMAG] = 0;

		z1z2[i][REAL] = z1z2[i][IMAG] = 0;
		Z1Z2[i][REAL] = Z1Z2[i][IMAG] = 0;

		w[i][REAL] = w[i][IMAG] = 0;
		W[i][REAL] = W[i][IMAG] = 0;

		wz1[i][REAL] = wz1[i][IMAG] = 0;
		WZ1[i][REAL] = WZ1[i][IMAG] = 0;

		wz2[i][REAL] = wz2[i][IMAG] = 0;
		WZ2[i][REAL] = WZ2[i][IMAG] = 0;

		wz1z2[i][REAL] = wz1z2[i][IMAG] = 0;
		WZ1Z2[i][REAL] = WZ1Z2[i][IMAG] = 0;
	}

	#pragma omp parallel for
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < M; ++j) {
			for (int k = 0; k < K; ++k) {
				double v1 = data1 _p(i, j, k);
				double w1_ = weigth1 _p(i, j, k);
				int    i1 = has_point1 _p(i, j, k);
				
				double v2 = data2 _p(i, j, k);
				int    i2 = has_point2 _p(i, j, k);

				i1i2  _p3(i, j, k)[REAL] = i1 * i2;
				z1i2  _p3(i, j, k)[REAL] = v1 * i2;
				i1z2  _p3(i, j, k)[REAL] = i1 * v2;
				z1z2  _p3(i, j, k)[REAL] = v1 * v2;

				w     _p3(i, j, k)[REAL] = w1_;
				wz1   _p3(i, j, k)[REAL] = w1_ * v1;
				wz2   _p3(i, j, k)[REAL] = w1_ * v2;
				wz1z2 _p3(i, j, k)[REAL] = w1_ * v1 * v2;
			}
		}
	}

	///////////////////////////////////////////////////////////////////

	fft_lock();
	p = fftw_plan_dft_3d(2 * N + 1, 2 * M + 1, 2 * K + 1, i1i2, I1I2, FFTW_FORWARD, FFTW_ESTIMATE);
	fft_unlock();
	fftw_execute(p);

	fft_lock();
	p = fftw_plan_dft_3d(2 * N + 1, 2 * M + 1, 2 * K + 1, z1i2, Z1I2, FFTW_FORWARD, FFTW_ESTIMATE);
	fft_unlock();
	fftw_execute(p);

	fft_lock();
	p = fftw_plan_dft_3d(2 * N + 1, 2 * M + 1, 2 * K + 1, i1z2, I1Z2, FFTW_FORWARD, FFTW_ESTIMATE);
	fft_unlock();
	fftw_execute(p);

	fft_lock();
	p = fftw_plan_dft_3d(2 * N + 1, 2 * M + 1, 2 * K + 1, z1z2, Z1Z2, FFTW_FORWARD, FFTW_ESTIMATE);
	fft_unlock();
	fftw_execute(p);
	
	////////////////////////////////////////////////////////////////////////////////////

	fft_lock();
	p = fftw_plan_dft_3d(2 * N + 1, 2 * M + 1, 2 * K + 1, w, W, FFTW_FORWARD, FFTW_ESTIMATE);
	fft_unlock();
	fftw_execute(p);

	fft_lock();
	p = fftw_plan_dft_3d(2 * N + 1, 2 * M + 1, 2 * K + 1, wz1, WZ1, FFTW_FORWARD, FFTW_ESTIMATE);
	fft_unlock();
	fftw_execute(p);

	fft_lock();
	p = fftw_plan_dft_3d(2 * N + 1, 2 * M + 1, 2 * K + 1, wz2, WZ2, FFTW_FORWARD, FFTW_ESTIMATE);
	fft_unlock();
	fftw_execute(p);

	fft_lock();
	p = fftw_plan_dft_3d(2 * N + 1, 2 * M + 1, 2 * K + 1, wz1z2, WZ1Z2, FFTW_FORWARD, FFTW_ESTIMATE);
	fft_unlock();
	fftw_execute(p);

	#pragma omp parallel for
	for (int h = 0; h < ZS; ++h) {
		fftw_complex W_I1I2;
		fftw_complex I1I2_W;

		fftw_complex WZ1Z2_I1I2;
		fftw_complex I1I2_WZ1Z2;

		fftw_complex WZ2_Z1I2;
		fftw_complex Z1I2_WZ2;


		fftw_complex WZ1_I1Z2;
		fftw_complex I1Z2_WZ1;

		fftw_complex W_Z1Z2;
		fftw_complex Z1Z2_W;


		mul_conj(W_I1I2, W[h], I1I2[h]);
		mul_conj(I1I2_W, I1I2[h], W[h]);


		mul_conj(WZ1Z2_I1I2, WZ1Z2[h], I1I2[h]);
		mul_conj(I1I2_WZ1Z2, I1I2[h], WZ1Z2[h]);

		mul_conj(WZ2_Z1I2, WZ2[h], Z1I2[h]);
		mul_conj(Z1I2_WZ2, Z1I2[h], WZ2[h]);


		mul_conj(WZ1_I1Z2, WZ1[h], I1Z2[h]);
		mul_conj(I1Z2_WZ1, I1Z2[h], WZ1[h]);

		mul_conj(W_Z1Z2, W[h], Z1Z2[h]);
		mul_conj(Z1Z2_W, Z1Z2[h], W[h]);

		Z1Z2[h][REAL] =
			WZ1Z2_I1I2[REAL] -
			WZ2_Z1I2[REAL] -
			WZ1_I1Z2[REAL] +
			W_Z1Z2[REAL] +

			Z1Z2_W[REAL] -
			I1Z2_WZ1[REAL] -
			Z1I2_WZ2[REAL] +
			I1I2_WZ1Z2[REAL];

		Z1Z2[h][IMAG] =
			WZ1Z2_I1I2[IMAG] -
			WZ2_Z1I2[IMAG] -
			WZ1_I1Z2[IMAG] +
			W_Z1Z2[IMAG] +

			Z1Z2_W[IMAG] -
			I1Z2_WZ1[IMAG] -
			Z1I2_WZ2[IMAG] +
			I1I2_WZ1Z2[IMAG];

		W[h][REAL] = 2 * (W_I1I2[REAL] + I1I2_W[REAL]);
		W[h][IMAG] = 2 * (W_I1I2[IMAG] + I1I2_W[IMAG]);
	}

	fft_lock();
	p = fftw_plan_dft_3d(2 * N + 1, 2 * M + 1, 2 * K + 1, Z1Z2, z1z2, FFTW_BACKWARD, FFTW_ESTIMATE); 
	fft_unlock();

	fftw_execute(p);
	
	fft_lock();
	p = fftw_plan_dft_3d(2 * N + 1, 2 * M + 1, 2 * K + 1, W, w, FFTW_BACKWARD, FFTW_ESTIMATE);
	fft_unlock();

	fftw_execute(p);

	#pragma omp parallel for
	for (int hx = 0; hx < N; ++hx) {
		for (int hy = 0; hy < M; ++hy) {
			for (int hz = 0; hz < K; ++hz) {
				double Y = z1z2 _p3(hx, hy, hz)[REAL] / ZS;
				double N = w _p3(hx, hy, hz)[REAL] / ZS;

				if (N > 0.01) {
					Yout.varmap _p(hx, hy, hz) = Y / (N);
				}
				else {
					Yout.varmap _p(hx, hy, hz) = 0;
				}

				Yout.ni _p(hx, hy, hz) = N;
			}
		}
	}

	fft_lock();
	fftw_destroy_plan(p);

	fftw_free(i1i2);
	fftw_free(I1I2);

	fftw_free(z1i2);
	fftw_free(Z1I2);

	fftw_free(i1z2);
	fftw_free(I1Z2);

	fftw_free(z1z2);
	fftw_free(Z1Z2);

	fftw_free(w);
	fftw_free(W);

	fftw_free(wz1);
	fftw_free(WZ1);

	fftw_free(wz2);
	fftw_free(WZ2);
	
	fftw_free(wz1z2);
	fftw_free(WZ1Z2);
	fft_unlock();

	return true;
}
Beispiel #2
0
WGSLIB_DECL bool fft_varmap_3d(
	VarOut& Yout, 
	const std::vector<double>& data, 
	const std::vector<int>& has_point, 
	int N, int M, int K)
{

	omp_set_num_threads(fft_get_num_threads());
	fftw_plan_with_nthreads(fft_get_num_threads());

	fftw_complex *z,  *Z, *ZI;
	fftw_complex *z2, *Z2;
	fftw_complex *ni, *NI, *INI;

	fftw_plan p;

	int ZS = (2 * N + 1) * (2 * M + 1) * (2 * K + 1);

	fft_lock();
	z = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	Z = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	ZI = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);

	z2 = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	Z2 = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	
	ni = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	NI = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	INI = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	fft_unlock();

	#pragma omp parallel for
	for (int i = 0; i < ZS; ++i) {
		z[i][REAL] = z[i][IMAG] = 0;
		z2[i][REAL] = z2[i][IMAG] = 0;
		ni[i][REAL] = ni[i][IMAG] = 0;
	}

	#pragma omp parallel for
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < M; ++j) {
			for (int k = 0; k < K; ++k) {
				double v = data _p(i, j, k);
				int hp = has_point _p(i, j, k);

				ni _p3(i, j, k)[REAL] = hp;
				
				if (hp) {
					z _p3(i, j, k)[REAL] = v;
				
					z2 _p3(i, j, k)[REAL] = v * v;
				}
			}
		}
	}

	fft_lock();
	p = fftw_plan_dft_3d(2 * N + 1, 2 * M + 1, 2 * K + 1, z, Z, FFTW_FORWARD, FFTW_ESTIMATE);
	fft_unlock();

	fftw_execute(p);

	fft_lock();
	p = fftw_plan_dft_3d(2 * N + 1, 2 * M + 1, 2 * K + 1, z2, Z2, FFTW_FORWARD, FFTW_ESTIMATE);
	fft_unlock();

	fftw_execute(p);

	fft_lock();
	p = fftw_plan_dft_3d(2 * N + 1, 2 * M + 1, 2 * K + 1, ni, NI, FFTW_FORWARD, FFTW_ESTIMATE);
	fft_unlock();

	fftw_execute(p);

	#pragma omp parallel for
	for (int h = 0; h < ZS; ++h) {
		fftw_complex Z2_I;
		fftw_complex Z_Z;
		fftw_complex I_Z2;
		fftw_complex I_I;

		mul_conj(Z2_I, Z2[h], NI[h]);
		mul_conj(Z_Z, Z[h], Z[h]);
		mul_conj(I_Z2, NI[h], Z2[h]);
		mul_conj(I_I, NI[h], NI[h]);

		Z[h][REAL] = Z2_I[REAL] - 2 * Z_Z[REAL] + I_Z2[REAL];
		Z[h][IMAG] = Z2_I[IMAG] - 2 * Z_Z[IMAG] + I_Z2[IMAG];

		NI[h][REAL] = I_I[REAL];
		NI[h][IMAG] = I_I[IMAG];
	}

	fft_lock();
	p = fftw_plan_dft_3d(2 * N + 1, 2 * M + 1, 2 * K + 1, Z, ZI, FFTW_BACKWARD, FFTW_ESTIMATE);
	fft_unlock();

	fftw_execute(p);

	fft_lock();
	p = fftw_plan_dft_3d(2 * N + 1, 2 * M + 1, 2 * K + 1, NI, INI, FFTW_BACKWARD, FFTW_ESTIMATE);
	fft_unlock();

	fftw_execute(p);

	#pragma omp parallel for
	for (int hx = 0; hx < N; ++hx) {
		for (int hy = 0; hy < M; ++hy) {
			for (int hz = 0; hz < K; ++hz) {
				double Y = ZI _p3(hx, hy, hz)[REAL]  / ZS;
				double N = INI _p3(hx, hy, hz)[REAL] / ZS;

				if (N > 0.01) {
					Yout.varmap _p(hx, hy, hz) = Y / (2 * N);
				} else {
					Yout.varmap _p(hx, hy, hz) = 0;
				}

				Yout.ni _p(hx, hy, hz) = N;
			}
		}
	}

	fft_lock();
	fftw_destroy_plan(p);
	fftw_free(z);
	fftw_free(Z);
	fftw_free(ZI);

	fftw_free(z2);
	fftw_free(Z2);

	fftw_free(ni);
	fftw_free(NI);
	fftw_free(INI);
	fft_unlock();

	return true;
}
Beispiel #3
0
WGSLIB_DECL bool fft_crossvarmap_3d(
	VarOut& Yout,
	const std::vector<double>& data1,
	const std::vector<int>& has_point1,
	const std::vector<double>& data2,
	const std::vector<int>& has_point2,
	int N, int M, int K)
{
	omp_set_num_threads(fft_get_num_threads());
	fftw_plan_with_nthreads(fft_get_num_threads());

	fftw_complex *Z1I;
	fftw_complex *I1I;

	fftw_complex *z1z2, *Z1Z2;

	fftw_complex *i2z1, *I2Z1;
	fftw_complex *i1z2, *I1Z2;

	fftw_complex *i1i2, *I1I2;
	
	fftw_plan p;


	int ZS = (2 * N + 1) * (2 * M + 1) * (2 * K + 1);

	fft_lock();
	Z1I = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	I1I = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);

	z1z2 = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	Z1Z2 = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	
	i2z1 = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	I2Z1 = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	
	i1z2 = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	I1Z2 = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	
	i1i2 = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	I1I2 = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	fft_unlock();

	#pragma omp parallel for
	for (int i = 0; i < ZS; ++i) {
		z1z2[i][REAL] = z1z2[i][IMAG] = 0;
		i1z2[i][REAL] = i1z2[i][IMAG] = 0;
		i2z1[i][REAL] = i2z1[i][IMAG] = 0;
		i1i2[i][REAL] = i1i2[i][IMAG] = 0;
	}

	#pragma omp parallel for
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < M; ++j) {
			for (int k = 0; k < K; ++k) {
				double v1 = data1 _p(i, j, k);
				double v2 = data2 _p(i, j, k);
				int hp1 = has_point1 _p(i, j, k);
				int hp2 = has_point2 _p(i, j, k);	
		
				z1z2 _p3(i, j, k)[REAL] =  v1 * v2;
				i1z2 _p3(i, j, k)[REAL] = hp1 * v2;
				i2z1 _p3(i, j, k)[REAL] = hp2 * v1;
				i1i2 _p3(i, j, k)[REAL] = hp1 * hp2;
			}
		}
	}

	fft_lock();
	p = fftw_plan_dft_3d(2 * N + 1, 2 * M + 1, 2 * K + 1, z1z2, Z1Z2, FFTW_FORWARD, FFTW_ESTIMATE);
	fft_unlock();

	fftw_execute(p);

	fft_lock();
	p = fftw_plan_dft_3d(2 * N + 1, 2 * M + 1, 2 * K + 1, i1z2, I1Z2, FFTW_FORWARD, FFTW_ESTIMATE);
	fft_unlock();

	fftw_execute(p);

	fft_lock();
	p = fftw_plan_dft_3d(2 * N + 1, 2 * M + 1, 2 * K + 1, i2z1, I2Z1, FFTW_FORWARD, FFTW_ESTIMATE);
	fft_unlock();

	fftw_execute(p);

	fft_lock();
	p = fftw_plan_dft_3d(2 * N + 1, 2 * M + 1, 2 * K + 1, i1i2, I1I2, FFTW_FORWARD, FFTW_ESTIMATE);
	fft_unlock();

	fftw_execute(p);

	#pragma omp parallel for
	for (int h = 0; h < ZS; ++h) {
		fftw_complex A;   
		fftw_complex B;  

		fftw_complex C;  
		fftw_complex D;  
		fftw_complex I1_I2;  
		
		mul_conj(A, Z1Z2[h],  I1I2[h]);
		mul_conj(D, I1I2[h],  Z1Z2[h]);

		mul_conj(B, I2Z1[h], I1Z2[h]);
		mul_conj(C, I1Z2[h], I2Z1[h]);

		mul_conj(I1_I2, I1I2[h], I1I2[h]);

		Z1Z2[h][REAL] = A[REAL] - B[REAL] - C[REAL] + D[REAL];
		Z1Z2[h][IMAG] = A[IMAG] - B[IMAG] - C[IMAG] + D[IMAG];

		I1I2[h][REAL] = I1_I2[REAL];
		I1I2[h][IMAG] = I1_I2[IMAG];
	}

	fft_lock();
	p = fftw_plan_dft_3d(2 * N + 1, 2 * M + 1, 2 * K + 1, Z1Z2, Z1I, FFTW_BACKWARD, FFTW_ESTIMATE);
	fft_unlock();

	fftw_execute(p);

	fft_lock();
	p = fftw_plan_dft_3d(2 * N + 1, 2 * M + 1, 2 * K + 1, I1I2, I1I, FFTW_BACKWARD, FFTW_ESTIMATE);
	fft_unlock();

	fftw_execute(p);

	#pragma omp parallel for
	for (int hx = 0; hx < N; ++hx) {
		for (int hy = 0; hy < M; ++hy) {
			for (int hz = 0; hz < K; ++hz) {
				double Y = Z1I _p3(hx, hy, hz)[REAL] / ZS;
				double N = I1I _p3(hx, hy, hz)[REAL] / ZS;

				if (N > 0.01) {
					Yout.varmap _p(hx, hy, hz) =  Y / (2 * N);
				} else {
					Yout.varmap _p(hx, hy, hz) = 0;
				}

				Yout.ni _p(hx, hy, hz) = N;

			}
		}
	}

	fft_lock();
	fftw_destroy_plan(p);

	fftw_free(Z1I);
	fftw_free(I1I);
	
	fftw_free(z1z2); 
	fftw_free(Z1Z2);
	
	fftw_free(i2z1); 
	fftw_free(I2Z1); 
	
	fftw_free(i1z2);
	fftw_free(I1Z2);
	
	fftw_free(i1i2); 
	fftw_free(I1I2);
	fft_unlock();

	return true;
}
Beispiel #4
0
WGSLIB_DECL bool fft_varmap_3d_declus(
	VarOut& Yout,
	const std::vector<double>& data,
	const std::vector<double>& weigth,
	const std::vector<int>& has_point,
	int N, int M, int K)
{
	omp_set_num_threads(fft_get_num_threads());
	fftw_plan_with_nthreads(fft_get_num_threads());

	fftw_complex *z, *Z, *ZI;
	fftw_complex *z2, *Z2;
	fftw_complex *ni, *NI, *INI;

	fftw_complex *w, *W;

	fftw_complex *z2w, *Z2W;
	fftw_complex *zw, *ZW;
	
	fftw_plan p;


	int ZS = (2 * N + 1) * (2 * M + 1) * (2 * K + 1);

	fft_lock();
	z = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	Z = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	ZI = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);

	z2 = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	Z2 = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	
	ni = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	NI = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	INI = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	
	w = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	W = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	
	z2w = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	Z2W = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	
	zw = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	ZW = (fftw_complex*)fftw_malloc(sizeof(fftw_complex)* ZS);
	fft_unlock();


	#pragma omp parallel for
	for (int i = 0; i < ZS; ++i) {
		z[i][REAL] = z[i][IMAG] = 0;
		z2[i][REAL] = z2[i][IMAG] = 0;
		ni[i][REAL] = ni[i][IMAG] = 0;
		w[i][REAL] = w[i][IMAG] = 0;
		z2w[i][REAL] = z2w[i][IMAG] = 0;
		zw[i][REAL] = zw[i][IMAG] = 0;
	}

	#pragma omp parallel for
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < M; ++j) {
			for (int k = 0; k < K; ++k) {
				double v = data _p(i, j, k);
				double w_ = weigth _p(i, j, k);
				int hp = has_point _p(i, j, k);

				ni _p3(i, j, k)[REAL] = hp;
				
				if (hp) {
					z _p3(i, j, k)[REAL] = v;
					
					z2 _p3(i, j, k)[REAL] = v * v;
					
					zw _p3(i, j, k)[REAL] = v * w_;

					z2w _p3(i, j, k)[REAL] = v * v * w_;

					w _p3(i, j, k)[REAL] = w_;

				}
			}
		}
	}


	//LEVA z para o dominio da frequencia
	fft_lock();
	p = fftw_plan_dft_3d(2 * N + 1, 2 * M + 1, 2 * K + 1, z, Z, FFTW_FORWARD, FFTW_ESTIMATE);
	fft_unlock();

	fftw_execute(p);

	fft_lock();
	p = fftw_plan_dft_3d(2 * N + 1, 2 * M + 1, 2 * K + 1, w, W, FFTW_FORWARD, FFTW_ESTIMATE);
	fft_unlock();

	fftw_execute(p);

	fft_lock();
	p = fftw_plan_dft_3d(2 * N + 1, 2 * M + 1, 2 * K + 1, zw, ZW, FFTW_FORWARD, FFTW_ESTIMATE);
	fft_unlock();

	fftw_execute(p);

	fft_lock();
	p = fftw_plan_dft_3d(2 * N + 1, 2 * M + 1, 2 * K + 1, z2w, Z2W, FFTW_FORWARD, FFTW_ESTIMATE);
	fft_unlock();

	fftw_execute(p);

	fft_lock();
	p = fftw_plan_dft_3d(2 * N + 1, 2 * M + 1, 2 * K + 1, z2, Z2, FFTW_FORWARD, FFTW_ESTIMATE);
	fft_unlock();

	fftw_execute(p);

	fft_lock();
	p = fftw_plan_dft_3d(2 * N + 1, 2 * M + 1, 2 * K + 1, ni, NI, FFTW_FORWARD, FFTW_ESTIMATE);
	fft_unlock();

	fftw_execute(p);

	//Realiza convolução
	#pragma omp parallel for
	for (int h = 0; h < ZS; ++h) {
		fftw_complex Z2W_I;
		fftw_complex ZW_Z;
		fftw_complex W_Z2;
		fftw_complex Z2_W;
		fftw_complex Z_ZW;
		fftw_complex I_Z2W;
		fftw_complex W_I;
		fftw_complex I_W;

		mul_conj(Z2W_I, Z2W[h], NI[h]);
		mul_conj(ZW_Z, ZW[h], Z[h]);
		mul_conj(W_Z2, W[h], Z2[h]);
		mul_conj(Z2_W, Z2[h], W[h]);
		mul_conj(Z_ZW, Z[h], ZW[h]);
		mul_conj(I_Z2W, NI[h], Z2W[h]);

		mul_conj(I_W, NI[h], W[h]);
		mul_conj(W_I, W[h], NI[h]);

		Z[h][REAL] = Z2W_I[REAL] - 2 * ZW_Z[REAL] + W_Z2[REAL] + 
					 Z2_W[REAL] - 2 * Z_ZW[REAL] + I_Z2W[REAL];

		Z[h][IMAG] = Z2W_I[IMAG] - 2 * ZW_Z[IMAG] + W_Z2[IMAG] +
					 Z2_W[IMAG] - 2 * Z_ZW[IMAG] + I_Z2W[IMAG];

		NI[h][REAL] = 2 * (W_I[REAL] + I_W[REAL]);
		NI[h][IMAG] = 2 * (W_I[IMAG] + I_W[IMAG]);
	}

	fft_lock();
	p = fftw_plan_dft_3d(2 * N + 1, 2 * M + 1, 2 * K + 1, Z, ZI, FFTW_BACKWARD, FFTW_ESTIMATE);
	fft_unlock();

	fftw_execute(p);

	fft_lock();
	p = fftw_plan_dft_3d(2 * N + 1, 2 * M + 1, 2 * K + 1, NI, INI, FFTW_BACKWARD, FFTW_ESTIMATE);
	fft_unlock();

	fftw_execute(p);
	
	#pragma omp parallel for
	for (int hx = 0; hx < N; ++hx) {
		for (int hy = 0; hy < M; ++hy) {
			for (int hz = 0; hz < K; ++hz) {
				double Y = ZI _p3(hx, hy, hz)[REAL] / ZS;
				double N = INI _p3(hx, hy, hz)[REAL] / ZS;

				if (N > 0.01) {
					Yout.varmap _p(hx, hy, hz) = Y / N;
				}
				else {
					Yout.varmap _p(hx, hy, hz) = 0;
				}

				Yout.ni _p(hx, hy, hz) = N;
			}
		}
	}

	fft_lock();
	fftw_destroy_plan(p);
	fftw_free(z);
	fftw_free(Z);
	fftw_free(ZI);

	fftw_free(z2);
	fftw_free(Z2);

	fftw_free(zw);
	fftw_free(ZW);

	fftw_free(z2w);
	fftw_free(Z2W);

	fftw_free(w);
	fftw_free(W);

	fftw_free(ni);
	fftw_free(NI);
	fftw_free(INI);
	fft_unlock();

	return true;
}
Beispiel #5
0
void drive_operation()
{

    // Uint64 tests

    CQLValue a1(Uint64(10));
    CQLValue a2(Uint64(15));
    CQLValue a3(Uint64(25));
    CQLValue a4(Uint64(30));
    CQLValue a5(Uint64(150));

    PEGASUS_TEST_ASSERT(a1 != a2);
    PEGASUS_TEST_ASSERT(a5 == a5);
    PEGASUS_TEST_ASSERT(a1 < a2);
    PEGASUS_TEST_ASSERT(a2 >= a1);
    PEGASUS_TEST_ASSERT(a1 <= a2);
    PEGASUS_TEST_ASSERT(a2 > a1);

    // Sint64 tests

    CQLValue b1(Sint64(10));
    CQLValue b2(Sint64(15));
    CQLValue b3(Sint64(25));
    CQLValue b4(Sint64(30));
    CQLValue b5(Sint64(150));

    PEGASUS_TEST_ASSERT(b1 != b2);
    PEGASUS_TEST_ASSERT(b5 == b5);
    PEGASUS_TEST_ASSERT(b1 < b2);
    PEGASUS_TEST_ASSERT(b2 >= b1);
    PEGASUS_TEST_ASSERT(b1 <= b2);
    PEGASUS_TEST_ASSERT(b2 > b1);

    // Real64 tests

    CQLValue c1(Real64(10.00));
    CQLValue c2(Real64(15.00));
    CQLValue c3(Real64(25.00));
    CQLValue c4(Real64(30.00));
    CQLValue c5(Real64(150.00));

    PEGASUS_TEST_ASSERT(c1 != c2);
    PEGASUS_TEST_ASSERT(c5 == c5);
    PEGASUS_TEST_ASSERT(c1 < c2);
    PEGASUS_TEST_ASSERT(c2 >= c1);
    PEGASUS_TEST_ASSERT(c1 <= c2);
    PEGASUS_TEST_ASSERT(c2 > c1);

    // Misc
    PEGASUS_TEST_ASSERT(a1 == b1);
    PEGASUS_TEST_ASSERT(a1 == c1);
    PEGASUS_TEST_ASSERT(b1 == a1);
    PEGASUS_TEST_ASSERT(b1 == c1);
    PEGASUS_TEST_ASSERT(c1 == a1);
    PEGASUS_TEST_ASSERT(c1 == b1);

    PEGASUS_TEST_ASSERT(a2 != b1);
    PEGASUS_TEST_ASSERT(a2 != c1);
    PEGASUS_TEST_ASSERT(b2 != a1);
    PEGASUS_TEST_ASSERT(b2 != c1);
    PEGASUS_TEST_ASSERT(c2 != a1);
    PEGASUS_TEST_ASSERT(c2 != b1);

    PEGASUS_TEST_ASSERT(a2 >= b1);
    PEGASUS_TEST_ASSERT(a2 >= c1);
    PEGASUS_TEST_ASSERT(b2 >= a1);
    PEGASUS_TEST_ASSERT(b2 >= c1);
    PEGASUS_TEST_ASSERT(c2 >= a1);
    PEGASUS_TEST_ASSERT(c2 >= b1);

    PEGASUS_TEST_ASSERT(a2 <= b3);
    PEGASUS_TEST_ASSERT(a2 <= c3);
    PEGASUS_TEST_ASSERT(b2 <= a3);
    PEGASUS_TEST_ASSERT(b2 <= c3);
    PEGASUS_TEST_ASSERT(c2 <= a3);
    PEGASUS_TEST_ASSERT(c2 <= b3);

    PEGASUS_TEST_ASSERT(a2 > b1);
    PEGASUS_TEST_ASSERT(a2 > c1);
    PEGASUS_TEST_ASSERT(b2 > a1);
    PEGASUS_TEST_ASSERT(b2 > c1);
    PEGASUS_TEST_ASSERT(c2 > a1);
    PEGASUS_TEST_ASSERT(c2 > b1);

    PEGASUS_TEST_ASSERT(a2 < b3);
    PEGASUS_TEST_ASSERT(a2 < c3);
    PEGASUS_TEST_ASSERT(b2 < a3);
    PEGASUS_TEST_ASSERT(b2 < c3);
    PEGASUS_TEST_ASSERT(c2 < a3);
    PEGASUS_TEST_ASSERT(c2 < b3);

    //Overflow testing
    CQLValue real1(Real64(0.00000001));
    CQLValue sint1(Sint64(-1));
    CQLValue uint1(Sint64(1));
    CQLValue uint2(Uint64(0));

    PEGASUS_TEST_ASSERT(uint1 > sint1);
    PEGASUS_TEST_ASSERT(real1 > sint1);
    PEGASUS_TEST_ASSERT(uint2 > sint1);
    PEGASUS_TEST_ASSERT(real1 > uint2);

    CQLValue real2(Real64(25.00000000000001));
    CQLValue real3(Real64(24.99999999999999));
    CQLValue sint2(Sint64(25));
    CQLValue uint3(Uint64(25));

    PEGASUS_TEST_ASSERT(real2 > real3);
    PEGASUS_TEST_ASSERT(real2 > sint2);
    PEGASUS_TEST_ASSERT(real2 > uint3);
    PEGASUS_TEST_ASSERT(real3 < sint2);
    PEGASUS_TEST_ASSERT(real3 < uint3);

    // String tests

    CQLValue d1(String("HELLO"));
    CQLValue d2(String("HEL"));
    CQLValue d3(String("LO"));
    CQLValue d4(String("AHELLO"));
    CQLValue d5(String("ZHELLO"));

    PEGASUS_TEST_ASSERT(d1 == d2 + d3);
    PEGASUS_TEST_ASSERT(d1 != d2 + d4);

    PEGASUS_TEST_ASSERT(d1 <= d5);
    PEGASUS_TEST_ASSERT(d1 <  d5);

    PEGASUS_TEST_ASSERT(d1 >= d4);
    PEGASUS_TEST_ASSERT(d1 >  d4);

    String str1("0x10");
    String str2("10");
    String str3("10B");
    String str4("10.10");


    CQLValue e1( str1, CQLValue::Hex);
    CQLValue e2( str2, CQLValue::Decimal);
    CQLValue e3( str3, CQLValue::Binary);
    CQLValue e4( str4, CQLValue::Real);

    CQLValue e5(Uint64(16));
    CQLValue e6(Uint64(10));
    CQLValue e7(Uint64(2));
    CQLValue e8(Real64(10.10));

    PEGASUS_TEST_ASSERT(e1 == e5);
    PEGASUS_TEST_ASSERT(e2 == e6);
    PEGASUS_TEST_ASSERT(e3 == e7);
    PEGASUS_TEST_ASSERT(e4 == e8);

    Array<Uint64> array1;

    array1.append(1);
    array1.append(2);
    array1.append(3);
    array1.append(4);
    array1.append(5);
    array1.append(6);
    array1.append(7);
    array1.append(8);
    array1.append(9);
    array1.append(10);

    Array<Sint64> array2;

    array2.append(1);
    array2.append(2);
    array2.append(3);
    array2.append(4);
    array2.append(5);
    array2.append(6);
    array2.append(7);
    array2.append(8);
    array2.append(9);
    array2.append(10);
    array2.append(3);

    Array<Real64> array3;

    array3.append(1.00);
    array3.append(2.00);
    array3.append(3.00);
    array3.append(9.00);
    array3.append(10.00);
    array3.append(3.00);
    array3.append(4.00);
    array3.append(5.00);
    array3.append(6.00);
    array3.append(7.00);
    array3.append(8.00);

    Array<Uint64> array4;

    array4.append(1);
    array4.append(23);
    array4.append(3);
    array4.append(4);
    array4.append(5);
    array4.append(6);
    array4.append(7);
    array4.append(88);
    array4.append(9);
    array4.append(10);

    Array<Sint64> array5;

    array5.append(-1);
    array5.append(2);
    array5.append(3);
    array5.append(4);
    array5.append(5);
    array5.append(-6);
    array5.append(7);
    array5.append(8);
    array5.append(9);
    array5.append(10);
    array5.append(-3);

    Array<Real64> array6;

    array6.append(1.23);
    array6.append(2.00);
    array6.append(3.00);
    array6.append(9.00);
    array6.append(10.00);
    array6.append(3.00);
    array6.append(4.14);
    array6.append(5.00);
    array6.append(6.00);
    array6.append(7.00);
    array6.append(8.00);

    CIMValue cv1(array1);
    CIMValue cv2(array2);
    CIMValue cv3(array3);
    CIMValue cv4(array4);
    CIMValue cv5(array5);
    CIMValue cv6(array6);

    CQLValue vr1(cv1);
    CQLValue vr2(cv1);
    CQLValue vr3(cv2);
    CQLValue vr4(cv3);
    CQLValue vr5(cv4);
    CQLValue vr6(cv5);
    CQLValue vr7(cv6);

    PEGASUS_TEST_ASSERT(vr1 == vr2);
    PEGASUS_TEST_ASSERT(vr1 == vr3);
    PEGASUS_TEST_ASSERT(vr1 == vr4);
    PEGASUS_TEST_ASSERT(vr4 == vr3);

    PEGASUS_TEST_ASSERT(vr1 != vr5);
    PEGASUS_TEST_ASSERT(vr3 != vr6);
    PEGASUS_TEST_ASSERT(vr4 != vr7);

    const CIMName _cimName(String("CIM_OperatingSystem"));

    CIMInstance _i1(_cimName);
    CIMProperty _p1(CIMName("Description"),CIMValue(String("Dave Rules")));
    CIMProperty _p2(CIMName("EnabledState"),CIMValue(Uint16(2)));
    CIMProperty _p3(CIMName("CurrentTimeZone"),CIMValue(Sint16(-600)));
    CIMProperty _p4(CIMName("TimeOfLastStateChange"),
                    CIMValue(CIMDateTime(String("20040811105625.000000-360"))));

    _i1.addProperty(_p1);
    _i1.addProperty(_p2);
    _i1.addProperty(_p3);
    _i1.addProperty(_p4);

    CIMInstance _i2(_cimName);
    CIMProperty _p5(CIMName("Description"),
                    CIMValue(String("Dave Rules Everything")));
    CIMProperty _p6(CIMName("EnabledState"),CIMValue(Uint16(2)));
    CIMProperty _p7(CIMName("CurrentTimeZone"),CIMValue(Sint16(-600)));
    CIMProperty _p8(CIMName("TimeOfLastStateChange"),
                    CIMValue(CIMDateTime(String("20040811105625.000000-360"))));

    _i2.addProperty(_p5);
    _i2.addProperty(_p6);
    _i2.addProperty(_p7);
    _i2.addProperty(_p8);

    CQLValue cql1(_i1);
    CQLValue cql2(_i1);
    CQLValue cql3(_i2);
    CQLValue cql4(_i2);

    //PEGASUS_TEST_ASSERT(cql1 == cql1);

    return;
}
Beispiel #6
0
void drive_resolve_specialChars()
{


    const char* env = getenv("PEGASUS_HOME");
    String repositoryDir(env);
    repositoryDir.append("/repository");
    //String repositoryDir("c:/pegasus-cvs/pegasus/repository");
    CIMNamespaceName _ns("root/cimv2");
    CIMRepository *_rep = new CIMRepository(repositoryDir);
    RepositoryQueryContext _query(_ns, _rep);
    RepositoryQueryContext _query1(_ns, _rep);
    try {
        const CQLIdentifier _Id1(String("CIM_OperatingSystem"));

        _query.insertClassPath(_Id1);

        const CIMName _cimName(String("CIM_OperatingSystem"));

        CIMInstance _i1(_cimName);
        CIMProperty _p1(CIMName("OSType"),CIMValue(Uint16(11)));
        CIMProperty _p2(CIMName("Status"),CIMValue(String("Degraded")));
        Array<Uint16> array16;
        array16.append(Uint16(0));
        array16.append(Uint16(1));
        array16.append(Uint16(2));
        array16.append(Uint16(3));
        CIMProperty _p3(CIMName("OperationalStatus"),CIMValue(array16));

        _i1.addProperty(_p1);
        _i1.addProperty(_p2);
        _i1.addProperty(_p3);

        CQLChainedIdentifier ci1(String("CIM_OperatingSystem.OSType#OS400"));
        CQLChainedIdentifier ci2(String("CIM_OperatingSystem.OSType#LINUX"));
        CQLChainedIdentifier ci3(String("CIM_OperatingSystem.Status#Degraded"));

        CQLChainedIdentifier ci5(String("CIM_OperatingSystem.Status#BOGUS"));

        CQLChainedIdentifier ci6(
            String("CIM_OperatingSystem.CIM_OperatingSystem::"
                   "OperationalStatus[2]"));
        CQLValue a1(ci1);
        CQLValue a2(ci2);
        CQLValue a3(ci3);

        CQLValue a5(ci5);
        CQLValue a6(ci6);


        a1.resolve(_i1, _query);
        a2.resolve(_i1, _query);

        a6.resolve(_i1, _query);

        try
        {
            a3.resolve(_i1, _query);
            PEGASUS_TEST_ASSERT(0);
        }
        catch(...)
        {
            PEGASUS_TEST_ASSERT(1);
        }

        try
        {
            a5.resolve(_i1, _query);
            PEGASUS_TEST_ASSERT(0);
        }
        catch(...)
        {
            PEGASUS_TEST_ASSERT(1);
        }

        PEGASUS_TEST_ASSERT(a1 == CQLValue(Uint64(11)));
        PEGASUS_TEST_ASSERT(a2 == CQLValue(Uint64(36)));


        PEGASUS_TEST_ASSERT(a6 == CQLValue(Uint64(2)));


    }
    catch(Exception & e)
    {
        cout << e.getMessage() << endl;
        PEGASUS_TEST_ASSERT(0);
    }
    delete _rep;
    return;
}
Beispiel #7
0
void drive_resolve_primitive()
{


    const char* env = getenv("PEGASUS_HOME");
    String repositoryDir(env);
    repositoryDir.append("/repository");
    //String repositoryDir("c:/pegasus-cvs/pegasus/repository");
    CIMNamespaceName _ns("root/cimv2");
    CIMRepository *_rep = new CIMRepository(repositoryDir);
    RepositoryQueryContext _query(_ns, _rep);
    RepositoryQueryContext _query1(_ns, _rep);
    try {
        const CQLIdentifier _Id1(String("CIM_OperatingSystem"));

        _query.insertClassPath(_Id1);

        const CIMName _cimName(String("CIM_OperatingSystem"));

        CIMInstance _i1(_cimName);
        CIMProperty _p1(CIMName("Description"),CIMValue(String("Dave Rules")));
        CIMProperty _p2(CIMName("EnabledState"),CIMValue(Uint16(2)));
        CIMProperty _p3(CIMName("CurrentTimeZone"),CIMValue(Sint16(-600)));
        CIMProperty _p4(CIMName("TimeOfLastStateChange"),
                        CIMValue(CIMDateTime(String("20040811105625.000000-360"))));

        _i1.addProperty(_p1);
        _i1.addProperty(_p2);
        _i1.addProperty(_p3);
        _i1.addProperty(_p4);

        CQLChainedIdentifier ci1(
            String("CIM_OperatingSystem.CIM_OperatingSystem::Description"));
        CQLChainedIdentifier
        ci2(String("CIM_OperatingSystem.CIM_OperatingSystem::EnabledState"));
        CQLChainedIdentifier ci3(
            String("CIM_OperatingSystem.CIM_OperatingSystem::CurrentTimeZone"));
        CQLChainedIdentifier ci4(
            String("CIM_OperatingSystem.CIM_OperatingSystem::TimeOfLastStateChange"));

        CQLChainedIdentifier
        ci5(String(
                "CIM_OperatingSystem.CIM_EnabledLogicalElement::TimeOfLastStateChange"));

        CQLChainedIdentifier
        ci7(String("CIM_OperatingSystem"));

        CQLChainedIdentifier
        ci9(String(
                "CIM_EnabledLogicalElement.CIM_OperatingSystem::CSCreationClassName"));

        CQLChainedIdentifier
        ci10(String("CIM_OperatingSystem.CIM_OperatingSystem::Bubba"));

        CQLValue a1(ci1);
        CQLValue a2(ci2);
        CQLValue a3(ci3);
        CQLValue a4(ci4);
        CQLValue a5(ci5);

        CQLValue a7(ci7);

        CQLValue a9(ci9);
        CQLValue a10(ci10);

        CQLValue a11(_query.getClass(CIMName("CIM_OperatingSystem")));

        a1.resolve(_i1, _query);
        a2.resolve(_i1, _query);
        a3.resolve(_i1, _query);
        a4.resolve(_i1, _query);
        a5.resolve(_i1, _query);
        a7.resolve(_i1, _query);
        a10.resolve(_i1, _query1);

        a9.resolve(_i1, _query);

        PEGASUS_TEST_ASSERT(a1 == CQLValue(String("Dave Rules")));
        PEGASUS_TEST_ASSERT(a2 == CQLValue(Uint64(2)));
        PEGASUS_TEST_ASSERT(a3 == CQLValue(Sint64(-600)));
        PEGASUS_TEST_ASSERT(a4 == CQLValue(
                                CIMDateTime(String("20040811105625.000000-360"))));
        PEGASUS_TEST_ASSERT(a5 == CQLValue(
                                CIMDateTime(String("20040811105625.000000-360"))));
        //PEGASUS_TEST_ASSERT(a7 == CQLValue(_i1));
        PEGASUS_TEST_ASSERT(a9.isNull());
        PEGASUS_TEST_ASSERT(a10.isNull());

    }
    catch(Exception & e)
    {
        cout << e.getMessage() << endl;
        PEGASUS_TEST_ASSERT(0);
    }
    delete _rep;
    return;
}