void testCube(Vec<GenDescriptor>& vec, long widthBound) { GeneratorTrees trees; long cost = trees.buildOptimalTrees(vec, widthBound); if (!noPrint) { cout << "@TestCube: trees=" << trees << endl; cout << " cost =" << cost << endl; } Vec<long> dims; trees.getCubeDims(dims); CubeSignature sig(dims); for (long cnt=0; cnt<3; cnt++) { Permut pi; randomPerm(pi, trees.getSize()); PermNetwork net; net.buildNetwork(pi, trees); HyperCube<long> cube1(sig), cube2(sig); for (long i=0; i<cube1.getSize(); i++) cube1[i] = i; HyperCube<long> cube3 = cube1; applyPermToVec(cube2.getData(), cube1.getData(), pi); // direct application net.applyToCube(cube3); // applying permutation netwrok if (cube2==cube3) cout << "GOOD\n"; else { cout << "BAD\n"; if (cube1.getSize()<100 && !noPrint) { cout << "in="<<cube1.getData() << endl; cout << "out1="<<cube2.getData()<<", out2=" << cube3.getData()<<endl<<endl; } } } }
void testCube(Vec<GenDescriptor>& vec, long widthBound) { GeneratorTrees trees; long cost = trees.buildOptimalTrees(vec, widthBound); cout << "@TestCube: trees=" << trees << endl; cout << " cost =" << cost << endl; Vec<long> dims; trees.getCubeDims(dims); CubeSignature sig(dims); for (long cnt=0; cnt<3; cnt++) { Permut pi; randomPerm(pi, trees.getSize()); // if (pi.length()<100) cout << "pi="<<pi<<endl; PermNetwork net; net.buildNetwork(pi, trees); // if (pi.length()<100) { // cout << "permutations network {[gIdx,e,isID,shifts]} = " << endl; // cout << net << endl; // } HyperCube<long> cube1(sig), cube2(sig); for (long i=0; i<cube1.getSize(); i++) cube1[i] = i; HyperCube<long> cube3 = cube1; applyPermToVec(cube2.getData(), cube1.getData(), pi); // direct application net.applyToCube(cube3); // applying permutation netwrok if (cube2==cube3) cout << "yay\n"; else { cout << "blech\n"; if (cube1.getSize()<100) { cout << "in="<<cube1.getData() << endl; cout << "out1="<<cube2.getData()<<", out2=" << cube3.getData()<<endl<<endl; } } } }