testChebTensorProduct.cpp 16.6 KB
Newer Older
1
// ===================================================================================
2 3 4 5
// Copyright ScalFmm 2016 INRIA, Olivier Coulaud, Bérenger Bramas,
// Matthias Messner olivier.coulaud@inria.fr, berenger.bramas@inria.fr
// This software is a computer program whose purpose is to compute the
// FMM.
6
//
7
// This software is governed by the CeCILL-C and LGPL licenses and
8
// abiding by the rules of distribution of free software.
9 10 11
// An extension to the license is given to allow static linking of scalfmm
// inside a proprietary application (no matter its license).
// See the main license file for more details.
12 13 14 15
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 17 18
// GNU General Public and CeCILL-C Licenses for more details.
// "http://www.cecill.info".
// "http://www.gnu.org/licenses".
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
// ===================================================================================

// ==== CMAKE =====
// @FUSE_BLAS
// ================

#include <iostream>

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#include "../../Src/Utils/FTic.hpp"
#include "../../Src/Utils/FMath.hpp"
#include "../../Src/Utils/FBlas.hpp"
#include "../../Src/Utils/FParameters.hpp"

#include "../../Src/Containers/FVector.hpp"

38
#include "../../Src/Utils/FAssert.hpp"
39 40 41 42 43
#include "../../Src/Utils/FPoint.hpp"

#include "../../Src/Kernels/Chebyshev/FChebTensor.hpp"
#include "../../Src/Kernels/Chebyshev/FChebInterpolator.hpp"

44 45
#include "../../Src/Utils/FParameterNames.hpp"

46
template <class FReal>
47 48 49
void applyM2M(FReal *const S,	FReal *const w, const unsigned int n,	FReal *const W, const unsigned int N)
{ FBlas::gemtva(n, N, FReal(1.), S,	w, W); }

50
template <class FReal>
51 52 53
void applym2m(FReal *const S,	FReal *const w, const unsigned int n,	FReal *const W, const unsigned int N)
{ FBlas::gemtm(n, n, n*n, FReal(1.), S, n, w, n, W, n); }

54
template <class FReal>
55
void applyL2L(FReal *const S,	FReal *const F, const unsigned int n,	FReal *const f, const unsigned int N)
56
{ FBlas::gemva(N, n, FReal(1.), S, F, f);	}
57

58
template <class FReal>
59 60 61 62 63
void applyl2l(FReal *const S,	FReal *const F, const unsigned int n,	FReal *const f, const unsigned int N)
{ FBlas::gemm(n, n, n*n, FReal(1.), S, n, F, n, f, n); }


/**
64 65
 * In this file we show how to use octree
 */
66 67 68

int main(int argc, char* argv[])
{
69 70
    FHelpDescribeAndExit(argc, argv, "Test Chebyshev tensor product.");

71
    typedef double FReal;
72
	const unsigned int ORDER = 10;
73
	const unsigned int nnodes = TensorTraits<ORDER>::nnodes;
74 75
    FPoint<FReal> X[nnodes];
	FChebInterpolator<FReal,ORDER> Interpolator;
76 77

	{
78 79
        FChebTensor<FReal,ORDER>::setRoots(FPoint<FReal>(0.,0.,0.), FReal(2.), X);
        FPoint<FReal> x[nnodes];
80
	
81 82 83 84 85 86 87 88
        //	const FPoint<FReal> cx(-.5, -.5, -.5);
        //	const FPoint<FReal> cx(-.5, -.5,  .5);
        //	const FPoint<FReal> cx(-.5,  .5, -.5);
        //	const FPoint<FReal> cx(-.5,  .5,  .5);
        //	const FPoint<FReal> cx( .5, -.5, -.5);
        //	const FPoint<FReal> cx( .5, -.5,  .5);
        //	const FPoint<FReal> cx( .5,  .5, -.5);
        const FPoint<FReal> cx( .5,  .5,  .5);
89
		const FReal  wx(1.);
90
		FChebTensor<FReal,ORDER>::setRoots(cx, wx, x);
91 92 93 94 95 96
	
		FReal w[nnodes], f[nnodes];
		for (unsigned int n=0; n<nnodes; ++n) {
			w[n] = f[n] = FReal(n);
			//		std::cout << w[n] << "\t" << X[n] << "\t" << x[n] << std::endl;
		}
97 98 99



100
		FReal coords[3][ORDER];
101
		FChebTensor<FReal,ORDER>::setPolynomialsRoots(cx, wx, coords);
102
	
103 104 105 106 107
		//	for (unsigned int n=0; n<ORDER; ++n) {
		//		std::cout << coords[0][n] << "\t"
		//							<< coords[1][n] << "\t"
		//							<< coords[2][n] << std::endl;
		//	}
108

109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
		FReal S[3][ORDER*ORDER];
		Interpolator.assembleInterpolator(ORDER, coords[0], S[0]);
		Interpolator.assembleInterpolator(ORDER, coords[1], S[1]);
		Interpolator.assembleInterpolator(ORDER, coords[2], S[2]);

		FReal Skron[nnodes * nnodes];
		Interpolator.assembleInterpolator(nnodes, x, Skron);



		FReal W0[nnodes];
		for (unsigned int i=0; i<nnodes; ++i) W0[i] = FReal(0.);
		applyM2M(Skron, w, nnodes, W0, nnodes);


		FReal F0[nnodes];
		for (unsigned int i=0; i<nnodes; ++i) F0[i] = FReal(0.);
		applyL2L(Skron, f, nnodes, F0, nnodes);




		unsigned int perm[3][nnodes];
		for (unsigned int i=0; i<ORDER; ++i) {
			for (unsigned int j=0; j<ORDER; ++j) {
				for (unsigned int k=0; k<ORDER; ++k) {
					const unsigned int index = k*ORDER*ORDER + j*ORDER + i;
					perm[0][index] = k*ORDER*ORDER + j*ORDER + i;
					perm[1][index] = i*ORDER*ORDER + k*ORDER + j;
					perm[2][index] = j*ORDER*ORDER + i*ORDER + k;
				}
140 141 142
			}
		}

143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
		//	for (unsigned int n=0; n<nnodes; ++n)
		//		std::cout << perm[0][n] << "\t" << perm[1][n] << "\t" << perm[2][n] << std::endl;


		FReal W[nnodes];
		for (unsigned int i=0; i<nnodes; ++i) W[i] = FReal(0.);
		applym2m(S[0], w, ORDER, W, ORDER);
		for (unsigned int n=0; n<nnodes; ++n)	w[n] = W[perm[1][n]];
		applym2m(S[2], w, ORDER, W, ORDER);
		for (unsigned int n=0; n<nnodes; ++n)	w[perm[1][n]] = W[perm[2][n]];
		applym2m(S[1], w, ORDER, W, ORDER);
		for (unsigned int n=0; n<nnodes; ++n)	w[perm[2][n]] = W[n];
		FReal m2m_error(0.);
		for (unsigned int n=0; n<nnodes; ++n) {
			//std::cout << n << "\t" << w[n] << " - " << W0[n] << " = " << w[n]-W0[n] << std::endl;
			m2m_error += w[n] - W0[n];
		}
160

161 162
		std::cout << "------------------------------------------"
							<< "\n - M2M: ERROR = " << m2m_error << std::endl;
163 164 165



166 167 168 169 170 171 172 173
		FReal F[nnodes];
		for (unsigned int i=0; i<nnodes; ++i) F[i] = FReal(0.);
		applyl2l(S[0], f, ORDER, F, ORDER);
		for (unsigned int n=0; n<nnodes; ++n)	f[n] = F[perm[1][n]];
		applyl2l(S[2], f, ORDER, F, ORDER);
		for (unsigned int n=0; n<nnodes; ++n)	f[perm[1][n]] = F[perm[2][n]];
		applyl2l(S[1], f, ORDER, F, ORDER);
		for (unsigned int n=0; n<nnodes; ++n)	f[perm[2][n]] = F[n];
174

175 176 177 178 179
		FReal l2l_error(0.);
		for (unsigned int n=0; n<nnodes; ++n) {
			//std::cout << n << "\t" << f[n] << " - " << F0[n] << " = " << f[n]-F0[n] << std::endl;
			l2l_error += f[n] - F0[n];
		}
180 181 182
		
		std::cout << "------------------------------------------"
							<< "\n - L2L: ERROR = " << l2l_error << std::endl;
183 184 185 186 187 188 189 190 191 192 193 194 195
		
	}

	////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////
	// P2M /////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////
		

	const unsigned int M = 10;
	FReal points[3][M];
	FReal weights[M];
196
    FPoint<FReal> lp[M];
197 198
	FReal equivW[nnodes];

BRAMAS Berenger's avatar
BRAMAS Berenger committed
199
    { ////////////////////////////////////////////////////////
200
		for(unsigned int p=0; p<M; ++p){
BRAMAS Berenger's avatar
BRAMAS Berenger committed
201 202 203 204
            points[0][p] = (FReal(drand48()) - FReal(.5)) * FReal(2.);
            points[1][p] = (FReal(drand48()) - FReal(.5)) * FReal(2.);
            points[2][p] = (FReal(drand48()) - FReal(.5)) * FReal(2.);
            weights[p] = FReal(drand48());
205 206 207 208 209
			lp[p].setX(points[0][p]);
			lp[p].setY(points[1][p]);
			lp[p].setZ(points[2][p]);
		}
	} ////////////////////////////////////////////////////////
210

211
	
212
	{ // compute exact equivalent source values
213 214 215 216 217
		for(unsigned int i=0; i<nnodes; ++i) equivW[i] = FReal(0.);
		FReal Snorm[M * nnodes];
		Interpolator.assembleInterpolator(M, lp, Snorm);
		applyM2M(Snorm, weights, M, equivW, nnodes);
	}
218

219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279
	FReal W1;
	FReal W2[3][ ORDER-1];
	FReal W4[3][(ORDER-1)*(ORDER-1)];
	FReal W8[   (ORDER-1)*(ORDER-1)*(ORDER-1)];
	
	{ ////////////////////////////////////////////////////////
		W1 = FReal(0.);
		for(unsigned int i=0; i<ORDER-1; ++i)
			W2[0][i] = W2[1][i] = W2[2][i] = FReal(0.);
		for(unsigned int i=0; i<(ORDER-1)*(ORDER-1); ++i)
			W4[0][i] = W4[1][i] = W4[2][i] = FReal(0.);
		for(unsigned int i=0; i<(ORDER-1)*(ORDER-1)*(ORDER-1); ++i)
			W8[i] = FReal(0.);
		
		// loop over source particles
		for (unsigned int p=0; p<M; ++p) {
			FReal T_of_x[3][ORDER];
			T_of_x[0][0] = FReal(1.); T_of_x[0][1] = points[0][p];
			T_of_x[1][0] = FReal(1.); T_of_x[1][1] = points[1][p];
			T_of_x[2][0] = FReal(1.); T_of_x[2][1] = points[2][p];
			const FReal x2 = FReal(2.) * T_of_x[0][1]; // 1 flop
			const FReal y2 = FReal(2.) * T_of_x[1][1]; // 1 flop
			const FReal z2 = FReal(2.) * T_of_x[2][1]; // 1 flop
			for (unsigned int j=2; j<ORDER; ++j) {
				T_of_x[0][j] = x2 * T_of_x[0][j-1] - T_of_x[0][j-2]; // 2 flops
				T_of_x[1][j] = y2 * T_of_x[1][j-1] - T_of_x[1][j-2]; // 2 flops
				T_of_x[2][j] = z2 * T_of_x[2][j-1] - T_of_x[2][j-2]; // 2 flops
			}
			
			W1 += weights[p]; // 1 flop
			for (unsigned int i=1; i<ORDER; ++i) {
				const FReal wx = weights[p] * T_of_x[0][i]; // 1 flop
				const FReal wy = weights[p] * T_of_x[1][i]; // 1 flop
				const FReal wz = weights[p] * T_of_x[2][i]; // 1 flop
				W2[0][i-1] += wx; // 1 flop
				W2[1][i-1] += wy; // 1 flop
				W2[2][i-1] += wz; // 1 flop
				for (unsigned int j=1; j<ORDER; ++j) {
					const FReal wxy = wx * T_of_x[1][j]; // 1 flop
					const FReal wxz = wx * T_of_x[2][j]; // 1 flop
					const FReal wyz = wy * T_of_x[2][j]; // 1 flop
					W4[0][(j-1)*(ORDER-1) + (i-1)] += wxy; // 1 flop
					W4[1][(j-1)*(ORDER-1) + (i-1)] += wxz; // 1 flop
					W4[2][(j-1)*(ORDER-1) + (i-1)] += wyz; // 1 flop
					for (unsigned int k=1; k<ORDER; ++k) {
						const FReal wxyz = wxy * T_of_x[2][k]; // 1 flop
						W8[(k-1)*(ORDER-1)*(ORDER-1) + (j-1)*(ORDER-1) + (i-1)] += wxyz; // 1 flop
					} // flops: (ORDER-1) * 2
				} // flops: (ORDER-1) * (6 + (ORDER-1) * 2) 
			} // flops: (ORDER-1) * (6 + (ORDER-1) * (6 + (ORDER-1) * 2))
			
		} // flops: M * (3 + (ORDER-2) * 6 + (ORDER-1) * (6 + (ORDER-1) * (6 + (ORDER-1) * 2)))

	} ////////////////////////////////////////////////////////


	FReal F2[3][ORDER];
	FReal F4[3][ORDER*ORDER];
	FReal F8[   ORDER*ORDER*ORDER];

	{ ////////////////////////////////////////////////////////
280 281
		for(unsigned int i=0; i<ORDER; ++i)
			F2[0][i] = F2[1][i] = F2[2][i] = FReal(0.);
282 283 284 285 286 287 288 289
		for(unsigned int i=0; i<ORDER*ORDER; ++i)
			F4[0][i] = F4[1][i] = F4[2][i] = FReal(0.);
		for(unsigned int i=0; i<ORDER*ORDER*ORDER; ++i)
			F8[i] = FReal(0.);

		FReal T_of_y[ORDER * (ORDER-1)];
    for (unsigned int o=1; o<ORDER; ++o)
      for (unsigned int j=0; j<ORDER; ++j)
290
        T_of_y[(o-1)*ORDER + j] = FReal(FChebRoots<FReal,ORDER>::T(o, FReal(FChebRoots<FReal,ORDER>::roots[j])));
291

292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309
		for (unsigned int l=0; l<ORDER-1; ++l)
			for (unsigned int i=0; i<ORDER; ++i) {
				F2[0][i] += T_of_y[l*ORDER + i] * W2[0][l];
				F2[1][i] += T_of_y[l*ORDER + i] * W2[1][l];
				F2[2][i] += T_of_y[l*ORDER + i] * W2[2][l];
				
				for (unsigned int m=0; m<ORDER-1; ++m)
					for (unsigned int j=0; j<ORDER; ++j) {
						F4[0][j*ORDER + i] += T_of_y[l*ORDER + i] * T_of_y[m*ORDER + j] * W4[0][m*(ORDER-1) + l];
						F4[1][j*ORDER + i] += T_of_y[l*ORDER + i] * T_of_y[m*ORDER + j] * W4[1][m*(ORDER-1) + l];
						F4[2][j*ORDER + i] += T_of_y[l*ORDER + i] * T_of_y[m*ORDER + j] * W4[2][m*(ORDER-1) + l];
							
						for (unsigned int n=0; n<ORDER-1; ++n)
							for (unsigned int k=0; k<ORDER; ++k)
								F8[k*ORDER*ORDER + j*ORDER + i] +=
									T_of_y[l*ORDER + i] * T_of_y[m*ORDER + j] * T_of_y[n*ORDER + k]	*
									W8[n*(ORDER-1)*(ORDER-1) + m*(ORDER-1) + l];
								}
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329
			}

	} ////////////////////////////////////////////////////////


	FReal W[nnodes];
	{
		//for (unsigned int i=0; i<nnodes; ++i) W[i] = FReal(0.);
		for (unsigned int i=0; i<ORDER; ++i) {
			for (unsigned int j=0; j<ORDER; ++j) {
				for (unsigned int k=0; k<ORDER; ++k) {
					const unsigned int idx = k*ORDER*ORDER + j*ORDER + i;
					W[idx] = (W1 +
										FReal(2.) * (F2[0][i] + F2[1][j] + F2[2][k]) +
										FReal(4.) * (F4[0][j*ORDER+i] + F4[1][k*ORDER+i] + F4[2][k*ORDER+j]) +
										FReal(8.) *  F8[idx]) / (ORDER*ORDER*ORDER);
				}
			}
		}
	}
330

331 332 333 334
	FReal p2m_error(0.);
	for (unsigned int i=0; i<nnodes; ++i) {
		p2m_error += W[i] - equivW[i];
		//std::cout << W[i] - equivW[i] << std::endl;
335
	}
336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366

	std::cout << "------------------------------------------"
						<< "\n - P2M: ERROR = " << p2m_error << std::endl;



	////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////
	// L2P /////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////
	////////////////////////////////////////////////////////////////////


	FReal exactf[M];
	FReal f[M];
	for(unsigned int i=0; i<M; ++i) exactf[i] = f[i] = FReal(0.);


	{ // compute exact target values
		FReal Snorm[M * nnodes];
		Interpolator.assembleInterpolator(M, lp, Snorm);
		applyL2L(Snorm, W, nnodes, exactf, M);
		//for (unsigned int i=0; i<M; ++i)
		//	std::cout << exactf[i] << std::endl;
	}

	FReal f1;
	{ // sum over interpolation points
		FReal T_of_y[ORDER * (ORDER-1)];
    for (unsigned int o=1; o<ORDER; ++o)
      for (unsigned int j=0; j<ORDER; ++j)
367
        T_of_y[(o-1)*ORDER + j] = FReal(FChebRoots<FReal,ORDER>::T(o, FReal(FChebRoots<FReal,ORDER>::roots[j])));
368 369 370 371 372 373 374 375 376 377 378 379
		
		// set everything to zero
		f1 = FReal(0.);
		for(unsigned int i=0; i<ORDER-1; ++i)
			W2[0][i] = W2[1][i] = W2[2][i] = FReal(0.);
		for(unsigned int i=0; i<(ORDER-1)*(ORDER-1); ++i)
			W4[0][i] = W4[1][i] = W4[2][i] = FReal(0.);
		for(unsigned int i=0; i<(ORDER-1)*(ORDER-1)*(ORDER-1); ++i)
			W8[i] = FReal(0.);

		{
			unsigned int nids[nnodes][3];
380
			FChebTensor<FReal,ORDER>::setNodeIds(nids);
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462

			for (unsigned int idx=0; idx<nnodes; ++idx) {
				f1 += W[idx];
				const unsigned int i = nids[idx][0];
				const unsigned int j = nids[idx][1];
				const unsigned int k = nids[idx][2];
				
				//std::cout << i << "\t" << j << "\t" << k << std::endl;

				for (unsigned int l=0; l<ORDER-1; ++l) {
					W2[0][l] += T_of_y[l*ORDER+i] * W[idx];
					W2[1][l] += T_of_y[l*ORDER+j] * W[idx];
					W2[2][l] += T_of_y[l*ORDER+k] * W[idx];
					for (unsigned int m=0; m<ORDER-1; ++m) {
						W4[0][m*(ORDER-1)+l] += T_of_y[l*ORDER+i] * T_of_y[m*ORDER+j] * W[idx];
						W4[1][m*(ORDER-1)+l] += T_of_y[l*ORDER+i] * T_of_y[m*ORDER+k] * W[idx];
						W4[2][m*(ORDER-1)+l] += T_of_y[l*ORDER+j] * T_of_y[m*ORDER+k] * W[idx];
						for (unsigned int n=0; n<ORDER-1; ++n)
							W8[n*(ORDER-1)*(ORDER-1) + m*(ORDER-1) + l]
								+= T_of_y[l*ORDER+i]*T_of_y[m*ORDER+j]*T_of_y[n*ORDER+k] * W[idx];
					}
				}
			}

		}

	}

	{ // sum over targets
		for (unsigned int p=0; p<M; ++p) {

			FReal T_of_x[3][ORDER];
			{
				T_of_x[0][0] = FReal(1.); T_of_x[0][1] = points[0][p];
				T_of_x[1][0] = FReal(1.); T_of_x[1][1] = points[1][p];
				T_of_x[2][0] = FReal(1.); T_of_x[2][1] = points[2][p];
				const FReal x2 = FReal(2.) * T_of_x[0][1]; // 1 flop
				const FReal y2 = FReal(2.) * T_of_x[1][1]; // 1 flop
				const FReal z2 = FReal(2.) * T_of_x[2][1]; // 1 flop
				for (unsigned int j=2; j<ORDER; ++j) {
					T_of_x[0][j] = x2 * T_of_x[0][j-1] - T_of_x[0][j-2]; // 2 flops
					T_of_x[1][j] = y2 * T_of_x[1][j-1] - T_of_x[1][j-2]; // 2 flops
					T_of_x[2][j] = z2 * T_of_x[2][j-1] - T_of_x[2][j-2]; // 2 flops
				}
			}
			
			FReal f2, f4, f8;
			{
				f2 = f4 = f8 = FReal(0.);
				for (unsigned int l=1; l<ORDER; ++l) {
					f2 +=
						T_of_x[0][l] * W2[0][l-1] +
						T_of_x[1][l] * W2[1][l-1] +
						T_of_x[2][l] * W2[2][l-1];
					for (unsigned int m=1; m<ORDER; ++m) {
						f4 +=
							T_of_x[0][l] * T_of_x[1][m] * W4[0][(m-1)*(ORDER-1)+(l-1)] +
							T_of_x[0][l] * T_of_x[2][m] * W4[1][(m-1)*(ORDER-1)+(l-1)] +
							T_of_x[1][l] * T_of_x[2][m] * W4[2][(m-1)*(ORDER-1)+(l-1)];
						for (unsigned int n=1; n<ORDER; ++n)
							f8 +=
								T_of_x[0][l]*T_of_x[1][m]*T_of_x[2][n] *
								W8[(n-1)*(ORDER-1)*(ORDER-1) + (m-1)*(ORDER-1) + (l-1)];
					}
				}
			}
			f[p] = (f1 + FReal(2.)*f2 + FReal(4.)*f4 + FReal(8.)*f8) / (ORDER*ORDER*ORDER);
			
		}
	}


	FReal l2p_error(0.);
	for (unsigned int i=0; i<M; ++i) {
		l2p_error += f[i] - exactf[i];
		//std::cout << exactf[i] << "\t" << f[i] << std::endl;
	}

	std::cout << "------------------------------------------"
						<< "\n - L2P: ERROR = " << l2p_error << std::endl;


463 464 465 466 467 468 469


	return 0;
}


// [--END--]
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491

		//for (unsigned int l=0; l<ORDER-1; ++l)
		//	for (unsigned int m=0; m<ORDER-1; ++m)
		//		for (unsigned int n=0; n<ORDER-1; ++n)
		//			
		//			for (unsigned int i=0; i<ORDER; ++i)
		//				for (unsigned int j=0; j<ORDER; ++j)
		//					for (unsigned int k=0; k<ORDER; ++k) {
		//
		//						const unsigned int idx = k*ORDER*ORDER + j*ORDER + i;
		//
		//						W2[0][l] += T_of_y[l*ORDER+i] * W[idx];
		//						W2[1][m] += T_of_y[m*ORDER+j] * W[idx];
		//						W2[2][n] += T_of_y[n*ORDER+k] * W[idx];
		//
		//						W4[0][m*(ORDER-1) + l] += T_of_y[l*ORDER+i] * T_of_y[m*ORDER+j] * W[idx];
		//						W4[1][n*(ORDER-1) + l] += T_of_y[l*ORDER+i] * T_of_y[n*ORDER+k] * W[idx];
		//						W4[2][n*(ORDER-1) + m] += T_of_y[m*ORDER+j] * T_of_y[n*ORDER+k] * W[idx];
		//
		//						W8[n*(ORDER-1)*(ORDER-1) + m*(ORDER-1) + l]
		//							+= T_of_y[l*ORDER+i]*T_of_y[m*ORDER+j]*T_of_y[n*ORDER+k] * W[idx];
		//					}