378
378
points, values, 1, weightFunction);
380
380
// polynomial order should be 1
381
EXPECT_EQ(pVec->PolynomialOrder(), 1);
381
EXPECT_EQ(pVec->PolynomialOrder(), static_cast<size_t>(1));
383
383
// with polynomial order 1, the number of poly. coeff. is just the number of
384
384
// variables plus one for the constant term
385
EXPECT_EQ(pVec->NumberOfPolynomialCoefficients(), 4);
385
EXPECT_EQ(pVec->NumberOfPolynomialCoefficients(), static_cast<size_t>(4));
387
387
CLHEP::HepMatrix recCoeff
388
388
= MAUS::CLHEP::HepMatrix(pVec->GetCoefficientsAsMatrix());
459
459
points, values, 1, constraintPVec->GetCoefficientsAsVector(), weights);
461
461
// polynomial order should be 1
462
EXPECT_EQ(pVec->PolynomialOrder(), 1);
462
EXPECT_EQ(pVec->PolynomialOrder(), static_cast<size_t>(1));
464
464
// with polynomial order 1, the number of poly. coeff. is just the number of
465
465
// variables plus one for the constant term
466
EXPECT_EQ(pVec->NumberOfPolynomialCoefficients(), 4);
466
EXPECT_EQ(pVec->NumberOfPolynomialCoefficients(), static_cast<size_t>(4));
468
468
recCoeff = MAUS::CLHEP::HepMatrix(pVec->GetCoefficientsAsMatrix());
469
469
Squeak::mout(Squeak::debug) << "Constrained Input\n" << *constraintPVec
610
610
1e-20, delta, 10., 100, deltaMax);
612
612
// polynomial order should be 2
613
EXPECT_EQ(pVec->PolynomialOrder(), 2);
613
EXPECT_EQ(pVec->PolynomialOrder(), static_cast<size_t>(2));
615
615
// with point size 3 and polynomial order 2,
616
616
// the number of poly. coeff. is (3+2)!/(3!2!) = 10
617
EXPECT_EQ(pVec->NumberOfPolynomialCoefficients(), 10);
617
EXPECT_EQ(pVec->NumberOfPolynomialCoefficients(), static_cast<size_t>(10));
619
619
Squeak::mout(Squeak::debug) << "delta variable walls: ";
620
620
for (size_t i = 0; i < delta.size(); i++) {
727
727
coefficient.SpaceTransform(space_in, space_out);
728
728
testpass = false;
729
} catch (Squeal squeal) {}
729
} catch (MAUS::Exception exc) {}
730
ASSERT_TRUE(testpass);
734
TEST_F(PolynomialMapTest, MakePolynomialVector) {
735
const double point_data[2] = {1.0, 2.0};
736
Vector<double> point(point_data, 2);
737
Vector<double> polynomial_vector;
738
test.polynomial_map_->MakePolynomialVector(point, polynomial_vector);
739
for (size_t index = 0; index < 2; ++index) {
740
EXPECT_NEAR(point[index], point_data[index], 1.e-6);
745
TEST_F(PolynomialMapTest, SetCoefficients) {
746
Matrix<double> coefficient_matrix(3, 6, 0.); // initialize all elements to zero
747
PolynomialMap test_map(2, coefficient_matrix);
748
const double coefficients[18] = {
749
1., 2., 3., 4., 5., 6.,
750
0., 1., 4., 9., 16., 25.,
751
-1., -2., -3., -4., -5., -6.,
753
coefficient_matrix = Matrix<double>(3, 6, coefficients);
754
test_map.SetCoefficients(coefficient_matrix);
755
const Matrix<double> test_coefficient_matrix
756
= test_map.GetCoefficientsAsMatrix();
757
const Matrix<double> master_coefficient_matrix
758
= polynomial_map_->GetCoefficientsAsMatrix();
759
for (size_t row = 0; row < 3; ++row) {
760
for (size_t column = 0; column < 6; ++column) {
761
EXPECT_NEAR(test_coefficient_matrix(row+1, column+1),
762
master_coefficient_matrix(row+1, column+1),
768
TEST_F(PolynomialMapTest, UnmakePolynomialVector) {
769
const double point_data[2] = {1.0, 2.0};
770
Vector<double> point(point_data, 2);
771
Vector<double> polynomial_vector;
772
polynomial_map_->MakePolynomialVector(point, polynomial_vector);
773
polynomial_map_->UnmakePolynomialVector(polynomial_vector, point);
774
for (size_t index = 0; index < 2; ++index) {
775
EXPECT_NEAR(point[index], point_data[index], 1.e-6);
778
Vector<double> empty_point;
779
polynomial_map_->UnmakePolynomialVector(polynomial_vector, empty_point);
780
for (size_t index = 0; index < 2; ++index) {
781
EXPECT_NEAR(empty_point[index], point_data[index], 1.e-6);
784
Vector<double> wrong_size_point(4);
785
bool testpass = true;
787
polynomial_map_->UnmakePolynomialVector(polynomial_vector, wrong_size_point);
789
} catch (MAUS::Exception exc) {}
790
ASSERT_TRUE(testpass);
792
double polynomial_vector_data[polynomial_vector.size()];
793
polynomial_map_->MakePolynomialVector(point_data, polynomial_vector_data);
794
double point_test[2];
795
polynomial_map_->UnmakePolynomialVector(polynomial_vector_data, point_test);
796
for (size_t index = 0; index < 2; ++index) {
797
EXPECT_NEAR(point_test[index], point_data[index], 1.e-6);
801
TEST_F(PolynomialMapTest, generate_polynomial_2) {
802
const double y0[3] = {1., 0., -1.};
803
const double y1[3] = {7., 10., -7.};
804
for (size_t value_var_index = 0; value_var_index < 3; ++value_var_index) {
805
Vector<double> polynomial = generate_polynomial_2D(*polynomial_map_,
806
0, // point var index
810
1.); // point var delta
811
const double y[2] = {y0[value_var_index], y1[value_var_index]};
812
for (size_t index = 0; index < 2; ++index) {
813
EXPECT_NEAR(y[index], polynomial[index], 1.e-6);
818
TEST_F(PolynomialMapTest, RecentredNotSupported) {
819
bool testpass = true;
821
double * point = NULL;
822
polynomial_map_->Recentred(point);
824
} catch (MAUS::Exception exc) {}
825
ASSERT_TRUE(testpass);
828
TEST_F(PolynomialMapTest, InverseNotSupported) {
829
bool testpass = true;
831
polynomial_map_->Inverse();
833
} catch (MAUS::Exception exc) {}
730
834
ASSERT_TRUE(testpass);