|
@ -205,8 +205,9 @@ void testMultiPolys() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
template <int N> |
|
|
template <int N> |
|
|
void power2BernsteinTensorProduct(const xarray<real, N>& phiPower, xarray<real, N>& phiBernsetin) |
|
|
void power2BernsteinTensorProduct(const xarray<real, N>& phiPower, xarray<real, N>& phiBernstein) |
|
|
{ |
|
|
{ |
|
|
|
|
|
xarrayInit(phiBernstein); |
|
|
for (auto i = phiPower.loop(); ~i; ++i) { |
|
|
for (auto i = phiPower.loop(); ~i; ++i) { |
|
|
// phi.l(i) = powerFactors.l(i);
|
|
|
// phi.l(i) = powerFactors.l(i);
|
|
|
real factorBase = phiPower.l(i); |
|
|
real factorBase = phiPower.l(i); |
|
@ -228,7 +229,7 @@ void power2BernsteinTensorProduct(const xarray<real, N>& phiPower, xarray<real, |
|
|
for (auto ii = subgrid.loop(); ~ii; ++ii) { |
|
|
for (auto ii = subgrid.loop(); ~ii; ++ii) { |
|
|
real factor = factorBase; |
|
|
real factor = factorBase; |
|
|
for (int dim = 0; dim < N; ++dim) { factor *= decompFactors[dim][ii(dim)]; } |
|
|
for (int dim = 0; dim < N; ++dim) { factor *= decompFactors[dim][ii(dim)]; } |
|
|
phiBernsetin.m(i() + ii()) += factor; |
|
|
phiBernstein.m(i() + ii()) += factor; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -324,7 +325,6 @@ void testSpherePowerDirectly() |
|
|
xarray<real, 3> phiPower(nullptr, ext), phiBernstein(nullptr, ext); |
|
|
xarray<real, 3> phiPower(nullptr, ext), phiBernstein(nullptr, ext); |
|
|
algoim_spark_alloc(real, phiPower, phiBernstein); |
|
|
algoim_spark_alloc(real, phiPower, phiBernstein); |
|
|
xarrayInit(phiPower); |
|
|
xarrayInit(phiPower); |
|
|
xarrayInit(phiBernstein); |
|
|
|
|
|
auto v = xarray2StdVector(phiPower); |
|
|
auto v = xarray2StdVector(phiPower); |
|
|
auto vv = xarray2StdVector(phiBernstein); |
|
|
auto vv = xarray2StdVector(phiBernstein); |
|
|
for (int dim = 0; dim < 3; ++dim) { |
|
|
for (int dim = 0; dim < 3; ++dim) { |
|
@ -336,7 +336,7 @@ void testSpherePowerDirectly() |
|
|
phiPower.m(idx) = a[dim] * k(dim) * k(dim); |
|
|
phiPower.m(idx) = a[dim] * k(dim) * k(dim); |
|
|
} |
|
|
} |
|
|
phiPower.m(0) -= r * r; |
|
|
phiPower.m(0) -= r * r; |
|
|
auto integrand = [](const uvector<real, 3>& x) { return 1.0; }; |
|
|
auto integrand = [](const uvector<real, 3>&) { return 1.0; }; |
|
|
power2BernsteinTensorProduct(phiPower, phiBernstein); |
|
|
power2BernsteinTensorProduct(phiPower, phiBernstein); |
|
|
|
|
|
|
|
|
v = xarray2StdVector(phiPower); |
|
|
v = xarray2StdVector(phiPower); |
|
@ -393,7 +393,6 @@ void testSpherePowerDirectlyByTransformation() |
|
|
xarray<real, 3> phiPower(nullptr, ext), phiBernstein(nullptr, ext); |
|
|
xarray<real, 3> phiPower(nullptr, ext), phiBernstein(nullptr, ext); |
|
|
algoim_spark_alloc(real, phiPower, phiBernstein); |
|
|
algoim_spark_alloc(real, phiPower, phiBernstein); |
|
|
xarrayInit(phiPower); |
|
|
xarrayInit(phiPower); |
|
|
xarrayInit(phiBernstein); |
|
|
|
|
|
auto v = xarray2StdVector(phiPower); |
|
|
auto v = xarray2StdVector(phiPower); |
|
|
auto vv = xarray2StdVector(phiBernstein); |
|
|
auto vv = xarray2StdVector(phiBernstein); |
|
|
for (int dim = 0; dim < 3; ++dim) { |
|
|
for (int dim = 0; dim < 3; ++dim) { |
|
@ -435,7 +434,6 @@ void testCylinderPowerDirectly() |
|
|
xarray<real, 3> phiPower(nullptr, ext), phiBernstein(nullptr, ext); |
|
|
xarray<real, 3> phiPower(nullptr, ext), phiBernstein(nullptr, ext); |
|
|
algoim_spark_alloc(real, phiPower, phiBernstein); |
|
|
algoim_spark_alloc(real, phiPower, phiBernstein); |
|
|
xarrayInit(phiPower); |
|
|
xarrayInit(phiPower); |
|
|
xarrayInit(phiBernstein); |
|
|
|
|
|
auto v = xarray2StdVector(phiPower); |
|
|
auto v = xarray2StdVector(phiPower); |
|
|
auto vv = xarray2StdVector(phiBernstein); |
|
|
auto vv = xarray2StdVector(phiBernstein); |
|
|
real top = c[2] + h * 0.5, bottom = c[2] - h * 0.5; |
|
|
real top = c[2] + h * 0.5, bottom = c[2] - h * 0.5; |
|
@ -869,7 +867,7 @@ void test3PlanesPowerDirectly() |
|
|
-1, |
|
|
-1, |
|
|
1, |
|
|
1, |
|
|
integrand, |
|
|
integrand, |
|
|
30, |
|
|
10, |
|
|
{ |
|
|
{ |
|
|
{1, 1, 0, 0 }, |
|
|
{1, 1, 0, 0 }, |
|
|
{1, -1, 0, 0 }, |
|
|
{1, -1, 0, 0 }, |
|
@ -1011,7 +1009,8 @@ void test4PlanesAlgoim() |
|
|
real x = xx(0); |
|
|
real x = xx(0); |
|
|
real y = xx(1); |
|
|
real y = xx(1); |
|
|
real z = xx(2); |
|
|
real z = xx(2); |
|
|
return x + y - z; |
|
|
// return x + y - z;
|
|
|
|
|
|
return y - 1; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1065,13 +1064,16 @@ void test4PlanesPowerDirectly() |
|
|
compositePower(phiPowers, 0, 0, 1, phiPowerAll); |
|
|
compositePower(phiPowers, 0, 0, 1, phiPowerAll); |
|
|
auto v = xarray2StdVector(phiPowerAll); |
|
|
auto v = xarray2StdVector(phiPowerAll); |
|
|
|
|
|
|
|
|
uvector<real, 3> testX(0., 0.75, 0); |
|
|
uvector<real, 3> testX(0., 0.75, 0.2); |
|
|
|
|
|
|
|
|
real testEval = powerEvaluation(phiPowerAll, testX); |
|
|
real testEval = powerEvaluation(phiPowerAll, testX); |
|
|
std::cout << "eval power before trans:" << testEval << std::endl; |
|
|
std::cout << "eval power before trans:" << testEval << std::endl; |
|
|
|
|
|
|
|
|
powerTransformation(range, xmin, phiPowerAll); |
|
|
powerTransformation(range, xmin, phiPowerAll); |
|
|
|
|
|
|
|
|
|
|
|
real testEvalAfterTrans = powerEvaluation(phiPowerAll, testX); |
|
|
|
|
|
std::cout << "eval power after trans:" << testEvalAfterTrans << std::endl; |
|
|
|
|
|
|
|
|
auto vAfterTrans = xarray2StdVector(phiPowerAll); |
|
|
auto vAfterTrans = xarray2StdVector(phiPowerAll); |
|
|
auto integrand = [](const uvector<real, 3>& x) { return 1.0; }; |
|
|
auto integrand = [](const uvector<real, 3>& x) { return 1.0; }; |
|
|
power2BernsteinTensorProduct(phiPowerAll, phiBernstein); |
|
|
power2BernsteinTensorProduct(phiPowerAll, phiBernstein); |
|
@ -1086,6 +1088,7 @@ void test4PlanesPowerDirectly() |
|
|
real testEval2 = powerEvaluation(phiPowers[2], testX); |
|
|
real testEval2 = powerEvaluation(phiPowers[2], testX); |
|
|
std::cout << "eval power2:" << testEval2 << std::endl; |
|
|
std::cout << "eval power2:" << testEval2 << std::endl; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
real testEvalBernstein = bernstein::evalBernsteinPoly(phiBernstein, testX); |
|
|
real testEvalBernstein = bernstein::evalBernsteinPoly(phiBernstein, testX); |
|
|
auto vec = xarray2StdVector(phiBernstein); |
|
|
auto vec = xarray2StdVector(phiBernstein); |
|
|
std::cout << "eval bernstein:" << testEvalBernstein << std::endl; |
|
|
std::cout << "eval bernstein:" << testEvalBernstein << std::endl; |
|
@ -1094,7 +1097,7 @@ void test4PlanesPowerDirectly() |
|
|
-1, |
|
|
-1, |
|
|
1, |
|
|
1, |
|
|
integrand, |
|
|
integrand, |
|
|
20, |
|
|
10, |
|
|
{ |
|
|
{ |
|
|
{1, 1, 0, 0 }, |
|
|
{1, 1, 0, 0 }, |
|
|
{1, -1, 0, 0 }, |
|
|
{1, -1, 0, 0 }, |
|
@ -1149,6 +1152,24 @@ void testBooluarray() |
|
|
std::cout << tmp.bits << std::endl; |
|
|
std::cout << tmp.bits << std::endl; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void testPower2Bernstein() |
|
|
|
|
|
{ |
|
|
|
|
|
uvector<real, 3> ext(3, 3, 3); |
|
|
|
|
|
xarray<real, 3> power(nullptr, ext), bernstein(nullptr, ext); |
|
|
|
|
|
algoim_spark_alloc(real, power, bernstein); |
|
|
|
|
|
xarrayInit(power); |
|
|
|
|
|
power.m(uvector<int, 3>(1, 2, 0)) = 3; |
|
|
|
|
|
power.m(uvector<int, 3>(0, 1, 2)) = 4; |
|
|
|
|
|
power.m(uvector<int, 3>(1, 2, 2)) = 5; |
|
|
|
|
|
power.m(uvector<int, 3>(0, 0, 0)) = 3; |
|
|
|
|
|
uvector3 X(0.8, 0.7, 0.6); |
|
|
|
|
|
auto evalPower = powerEvaluation(power, X); |
|
|
|
|
|
power2BernsteinTensorProduct(power, bernstein); |
|
|
|
|
|
auto evalBernstein = bernstein::evalBernsteinPoly(bernstein, X); |
|
|
|
|
|
std::cout << "eval power: " << evalPower << std::endl; |
|
|
|
|
|
std::cout << "eval bernstein: " << evalBernstein << std::endl; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void testMain() |
|
|
void testMain() |
|
|
{ |
|
|
{ |
|
|
// testBooluarray();
|
|
|
// testBooluarray();
|
|
@ -1162,11 +1183,11 @@ void testMain() |
|
|
// test8PlanesAlgoim();
|
|
|
// test8PlanesAlgoim();
|
|
|
// test8PlanesPowerDirectly();
|
|
|
// test8PlanesPowerDirectly();
|
|
|
|
|
|
|
|
|
// test3PlanesAlgoim();
|
|
|
|
|
|
// test3PlanesPowerDirectly();
|
|
|
|
|
|
|
|
|
|
|
|
test4PlanesPowerDirectly(); |
|
|
// test4PlanesPowerDirectly();
|
|
|
// test4PlanesAlgoim();
|
|
|
// test4PlanesAlgoim();
|
|
|
|
|
|
|
|
|
// testQuarterSphere();
|
|
|
// testQuarterSphere();
|
|
|
|
|
|
|
|
|
|
|
|
// testPower2Bernstein();
|
|
|
} |
|
|
} |
|
|