From 2ffa91dfb20589c118ca5a067d3d9fffbbd3df23 Mon Sep 17 00:00:00 2001 From: MialLewis <95620982+MialLewis@users.noreply.github.com> Date: Fri, 11 Jul 2025 11:55:33 +0100 Subject: [PATCH 01/12] use Eigen Directly --- Framework/Muon/src/PhaseQuadMuon.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Framework/Muon/src/PhaseQuadMuon.cpp b/Framework/Muon/src/PhaseQuadMuon.cpp index c42af16d0e80..eaab9d53081a 100644 --- a/Framework/Muon/src/PhaseQuadMuon.cpp +++ b/Framework/Muon/src/PhaseQuadMuon.cpp @@ -9,13 +9,14 @@ #include "MantidAPI/Axis.h" #include "MantidAPI/ITableWorkspace.h" #include "MantidAPI/MatrixWorkspaceValidator.h" -#include "MantidCurveFitting/EigenMatrix.h" #include "MantidDataObjects/Workspace2D.h" #include "MantidDataObjects/WorkspaceCreation.h" #include "MantidHistogramData/Histogram.h" #include "MantidKernel/PhysicalConstants.h" #include "MantidKernel/Unit.h" +#include "Eigen/Dense" + using namespace Mantid::DataObjects; using namespace Mantid::HistogramData; @@ -238,7 +239,7 @@ API::MatrixWorkspace_sptr PhaseQuadMuon::squash(const API::MatrixWorkspace_sptr } std::vector emptySpectrum; emptySpectrum.reserve(nspec); - std::vector n0Vectors(nspec); + std::vector n0Vectors(nspec); // Calculate coefficients aj, bj @@ -254,21 +255,20 @@ API::MatrixWorkspace_sptr PhaseQuadMuon::squash(const API::MatrixWorkspace_sptr const double phi = phase->Double(h, phaseIndex); const double X = n0[h] * asym * cos(phi); const double Y = n0[h] * asym * sin(phi); - n0Vectors[h] = CurveFitting::EigenVector({X, Y}); + Eigen::Vector2d n0vec; + n0vec << X, Y; + n0Vectors[h] = n0vec; sxx += X * X; syy += Y * Y; sxy += X * Y; } else { - n0Vectors[h] = CurveFitting::EigenVector({0.0, 0.0}); + n0Vectors[h] = Eigen::Vector2d::Zero(); } } - CurveFitting::EigenMatrix muLamMatrix(2, 2); - muLamMatrix.set(0, 0, sxx); - muLamMatrix.set(0, 1, sxy); - muLamMatrix.set(1, 0, sxy); - muLamMatrix.set(1, 1, syy); - muLamMatrix.invert(); + Eigen::Matrix muLamMatrix; + muLamMatrix << sxx, sxy, sxy, syy; + muLamMatrix = muLamMatrix.inverse().eval(); std::vector aj(nspec), bj(nspec); for (size_t h = 0; h < nspec; h++) { From c1bc14e49c1df2f049a8591ffab6bf4a16dcc652 Mon Sep 17 00:00:00 2001 From: MialLewis <95620982+MialLewis@users.noreply.github.com> Date: Fri, 11 Jul 2025 14:02:11 +0100 Subject: [PATCH 02/12] revert test number changes --- Framework/Muon/test/PhaseQuadMuonTest.h | 36 ++++++++++++------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Framework/Muon/test/PhaseQuadMuonTest.h b/Framework/Muon/test/PhaseQuadMuonTest.h index ecb0c95b4780..ae05e539fe31 100644 --- a/Framework/Muon/test/PhaseQuadMuonTest.h +++ b/Framework/Muon/test/PhaseQuadMuonTest.h @@ -224,19 +224,19 @@ class PhaseQuadMuonTest : public CxxTest::TestSuite { const auto specImY = outputWs->getSpectrum(1).y(); const auto specImE = outputWs->getSpectrum(1).e(); // Check real Y values - TS_ASSERT_DELTA(specReY[0], 2.3212, DELTA); + TS_ASSERT_DELTA(specReY[0], 2.1969, DELTA); TS_ASSERT_DELTA(specReY[20], 0.0510, DELTA); - TS_ASSERT_DELTA(specReY[50], -0.0578, DELTA); + TS_ASSERT_DELTA(specReY[50], -0.0525, DELTA); // Check real E values - TS_ASSERT_DELTA(specReE[0], 0.0027, DELTA); - TS_ASSERT_DELTA(specReE[20], 0.0043, DELTA); - TS_ASSERT_DELTA(specReE[50], 0.0050, DELTA); + TS_ASSERT_DELTA(specReE[0], 0.0024, DELTA); + TS_ASSERT_DELTA(specReE[20], 0.0041, DELTA); + TS_ASSERT_DELTA(specReE[50], 0.0047, DELTA); // Check imaginary Y values - TS_ASSERT_DELTA(specImY[0], 0.0328, DELTA); - TS_ASSERT_DELTA(specImY[20], -0.0003, DELTA); - TS_ASSERT_DELTA(specImY[50], -0.0033, DELTA); + TS_ASSERT_DELTA(specImY[0], -0.1035, DELTA); + TS_ASSERT_DELTA(specImY[20], -0.0006, DELTA); + TS_ASSERT_DELTA(specImY[50], 0.0047, DELTA); // Check imaginary E values - TS_ASSERT_DELTA(specImE[0], 0.0003, DELTA); + TS_ASSERT_DELTA(specImE[0], 0.0002, DELTA); TS_ASSERT_DELTA(specImE[20], 0.0004, DELTA); TS_ASSERT_DELTA(specImE[50], 0.0005, DELTA); } @@ -280,19 +280,19 @@ class PhaseQuadMuonTest : public CxxTest::TestSuite { const auto specImY = outputWs->getSpectrum(1).y(); const auto specImE = outputWs->getSpectrum(1).e(); // Check real Y values - TS_ASSERT_DELTA(specReY[0], 2.3212, DELTA); + TS_ASSERT_DELTA(specReY[0], 2.1969, DELTA); TS_ASSERT_DELTA(specReY[20], 0.0510, DELTA); - TS_ASSERT_DELTA(specReY[50], -0.0578, DELTA); + TS_ASSERT_DELTA(specReY[50], -0.0525, DELTA); // Check real E values - TS_ASSERT_DELTA(specReE[0], 0.0027, DELTA); - TS_ASSERT_DELTA(specReE[20], 0.0043, DELTA); - TS_ASSERT_DELTA(specReE[50], 0.0050, DELTA); + TS_ASSERT_DELTA(specReE[0], 0.0024, DELTA); + TS_ASSERT_DELTA(specReE[20], 0.0041, DELTA); + TS_ASSERT_DELTA(specReE[50], 0.0047, DELTA); // Check imaginary Y values - TS_ASSERT_DELTA(specImY[0], 0.0328, DELTA); - TS_ASSERT_DELTA(specImY[20], -0.0003, DELTA); - TS_ASSERT_DELTA(specImY[50], -0.0033, DELTA); + TS_ASSERT_DELTA(specImY[0], -0.1035, DELTA); + TS_ASSERT_DELTA(specImY[20], -0.0006, DELTA); + TS_ASSERT_DELTA(specImY[50], 0.0047, DELTA); // Check imaginary E values - TS_ASSERT_DELTA(specImE[0], 0.0003, DELTA); + TS_ASSERT_DELTA(specImE[0], 0.0002, DELTA); TS_ASSERT_DELTA(specImE[20], 0.0004, DELTA); TS_ASSERT_DELTA(specImE[50], 0.0005, DELTA); } From 011ac0b73985f1c3cb24b1cdb1cabaeed9cd4ed6 Mon Sep 17 00:00:00 2001 From: MialLewis <95620982+MialLewis@users.noreply.github.com> Date: Fri, 11 Jul 2025 14:03:35 +0100 Subject: [PATCH 03/12] unlink curvefitting lib --- Framework/Muon/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Framework/Muon/CMakeLists.txt b/Framework/Muon/CMakeLists.txt index bcbdf43ad59a..b3b6ed426d32 100644 --- a/Framework/Muon/CMakeLists.txt +++ b/Framework/Muon/CMakeLists.txt @@ -122,7 +122,7 @@ set_property(TARGET Muon PROPERTY FOLDER "MantidFramework") target_link_libraries( Muon - PUBLIC Mantid::API Mantid::Kernel Mantid::Geometry Mantid::CurveFitting + PUBLIC Mantid::API Mantid::Kernel Mantid::Geometry PRIVATE Mantid::DataObjects Mantid::Indexing ) # Add the unit tests directory From 0aa2963a3fd7467cb14ea9c44b60218b3d33cf16 Mon Sep 17 00:00:00 2001 From: MialLewis <95620982+MialLewis@users.noreply.github.com> Date: Mon, 14 Jul 2025 11:35:52 +0100 Subject: [PATCH 04/12] force Eigen to use PartialPivLU decomposition --- Framework/Muon/src/PhaseQuadMuon.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Framework/Muon/src/PhaseQuadMuon.cpp b/Framework/Muon/src/PhaseQuadMuon.cpp index eaab9d53081a..f7c5938a0488 100644 --- a/Framework/Muon/src/PhaseQuadMuon.cpp +++ b/Framework/Muon/src/PhaseQuadMuon.cpp @@ -266,9 +266,9 @@ API::MatrixWorkspace_sptr PhaseQuadMuon::squash(const API::MatrixWorkspace_sptr } } - Eigen::Matrix muLamMatrix; + Eigen::Matrix2d muLamMatrix; muLamMatrix << sxx, sxy, sxy, syy; - muLamMatrix = muLamMatrix.inverse().eval(); + muLamMatrix = Eigen::PartialPivLU(muLamMatrix).inverse(); std::vector aj(nspec), bj(nspec); for (size_t h = 0; h < nspec; h++) { From 8dbf55593174258371f95fecaf07577ca62e4144 Mon Sep 17 00:00:00 2001 From: MialLewis <95620982+MialLewis@users.noreply.github.com> Date: Mon, 14 Jul 2025 11:36:33 +0100 Subject: [PATCH 05/12] Revert "revert test number changes" This reverts commit c1bc14e49c1df2f049a8591ffab6bf4a16dcc652. --- Framework/Muon/test/PhaseQuadMuonTest.h | 36 ++++++++++++------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Framework/Muon/test/PhaseQuadMuonTest.h b/Framework/Muon/test/PhaseQuadMuonTest.h index ae05e539fe31..ecb0c95b4780 100644 --- a/Framework/Muon/test/PhaseQuadMuonTest.h +++ b/Framework/Muon/test/PhaseQuadMuonTest.h @@ -224,19 +224,19 @@ class PhaseQuadMuonTest : public CxxTest::TestSuite { const auto specImY = outputWs->getSpectrum(1).y(); const auto specImE = outputWs->getSpectrum(1).e(); // Check real Y values - TS_ASSERT_DELTA(specReY[0], 2.1969, DELTA); + TS_ASSERT_DELTA(specReY[0], 2.3212, DELTA); TS_ASSERT_DELTA(specReY[20], 0.0510, DELTA); - TS_ASSERT_DELTA(specReY[50], -0.0525, DELTA); + TS_ASSERT_DELTA(specReY[50], -0.0578, DELTA); // Check real E values - TS_ASSERT_DELTA(specReE[0], 0.0024, DELTA); - TS_ASSERT_DELTA(specReE[20], 0.0041, DELTA); - TS_ASSERT_DELTA(specReE[50], 0.0047, DELTA); + TS_ASSERT_DELTA(specReE[0], 0.0027, DELTA); + TS_ASSERT_DELTA(specReE[20], 0.0043, DELTA); + TS_ASSERT_DELTA(specReE[50], 0.0050, DELTA); // Check imaginary Y values - TS_ASSERT_DELTA(specImY[0], -0.1035, DELTA); - TS_ASSERT_DELTA(specImY[20], -0.0006, DELTA); - TS_ASSERT_DELTA(specImY[50], 0.0047, DELTA); + TS_ASSERT_DELTA(specImY[0], 0.0328, DELTA); + TS_ASSERT_DELTA(specImY[20], -0.0003, DELTA); + TS_ASSERT_DELTA(specImY[50], -0.0033, DELTA); // Check imaginary E values - TS_ASSERT_DELTA(specImE[0], 0.0002, DELTA); + TS_ASSERT_DELTA(specImE[0], 0.0003, DELTA); TS_ASSERT_DELTA(specImE[20], 0.0004, DELTA); TS_ASSERT_DELTA(specImE[50], 0.0005, DELTA); } @@ -280,19 +280,19 @@ class PhaseQuadMuonTest : public CxxTest::TestSuite { const auto specImY = outputWs->getSpectrum(1).y(); const auto specImE = outputWs->getSpectrum(1).e(); // Check real Y values - TS_ASSERT_DELTA(specReY[0], 2.1969, DELTA); + TS_ASSERT_DELTA(specReY[0], 2.3212, DELTA); TS_ASSERT_DELTA(specReY[20], 0.0510, DELTA); - TS_ASSERT_DELTA(specReY[50], -0.0525, DELTA); + TS_ASSERT_DELTA(specReY[50], -0.0578, DELTA); // Check real E values - TS_ASSERT_DELTA(specReE[0], 0.0024, DELTA); - TS_ASSERT_DELTA(specReE[20], 0.0041, DELTA); - TS_ASSERT_DELTA(specReE[50], 0.0047, DELTA); + TS_ASSERT_DELTA(specReE[0], 0.0027, DELTA); + TS_ASSERT_DELTA(specReE[20], 0.0043, DELTA); + TS_ASSERT_DELTA(specReE[50], 0.0050, DELTA); // Check imaginary Y values - TS_ASSERT_DELTA(specImY[0], -0.1035, DELTA); - TS_ASSERT_DELTA(specImY[20], -0.0006, DELTA); - TS_ASSERT_DELTA(specImY[50], 0.0047, DELTA); + TS_ASSERT_DELTA(specImY[0], 0.0328, DELTA); + TS_ASSERT_DELTA(specImY[20], -0.0003, DELTA); + TS_ASSERT_DELTA(specImY[50], -0.0033, DELTA); // Check imaginary E values - TS_ASSERT_DELTA(specImE[0], 0.0002, DELTA); + TS_ASSERT_DELTA(specImE[0], 0.0003, DELTA); TS_ASSERT_DELTA(specImE[20], 0.0004, DELTA); TS_ASSERT_DELTA(specImE[50], 0.0005, DELTA); } From 450c669f0b41103e6c20e4d677c2dc5a4e5e8a8c Mon Sep 17 00:00:00 2001 From: MialLewis <95620982+MialLewis@users.noreply.github.com> Date: Mon, 14 Jul 2025 13:56:37 +0100 Subject: [PATCH 06/12] change to dynamic matrix --- Framework/Muon/src/PhaseQuadMuon.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Framework/Muon/src/PhaseQuadMuon.cpp b/Framework/Muon/src/PhaseQuadMuon.cpp index f7c5938a0488..9e8f7414f01c 100644 --- a/Framework/Muon/src/PhaseQuadMuon.cpp +++ b/Framework/Muon/src/PhaseQuadMuon.cpp @@ -266,9 +266,9 @@ API::MatrixWorkspace_sptr PhaseQuadMuon::squash(const API::MatrixWorkspace_sptr } } - Eigen::Matrix2d muLamMatrix; + Eigen::MatrixXd muLamMatrix(2, 2); muLamMatrix << sxx, sxy, sxy, syy; - muLamMatrix = Eigen::PartialPivLU(muLamMatrix).inverse(); + muLamMatrix = muLamMatrix.inverse(); std::vector aj(nspec), bj(nspec); for (size_t h = 0; h < nspec; h++) { From 4fba47cfc153b55a7401b472bb80d58ee7cc876c Mon Sep 17 00:00:00 2001 From: MialLewis <95620982+MialLewis@users.noreply.github.com> Date: Tue, 15 Jul 2025 09:13:15 +0100 Subject: [PATCH 07/12] use map of vector --- Framework/Muon/src/PhaseQuadMuon.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Framework/Muon/src/PhaseQuadMuon.cpp b/Framework/Muon/src/PhaseQuadMuon.cpp index 9e8f7414f01c..54dbc97fb97f 100644 --- a/Framework/Muon/src/PhaseQuadMuon.cpp +++ b/Framework/Muon/src/PhaseQuadMuon.cpp @@ -266,8 +266,8 @@ API::MatrixWorkspace_sptr PhaseQuadMuon::squash(const API::MatrixWorkspace_sptr } } - Eigen::MatrixXd muLamMatrix(2, 2); - muLamMatrix << sxx, sxy, sxy, syy; + std::vector muLamVec{sxx, sxy, sxy, syy}; + Eigen::Map> muLamMatrix(muLamVec.data(), 2, 1); muLamMatrix = muLamMatrix.inverse(); std::vector aj(nspec), bj(nspec); From daa6ad6c328c1ce51838a631306aadc7cb91c5f6 Mon Sep 17 00:00:00 2001 From: MialLewis <95620982+MialLewis@users.noreply.github.com> Date: Tue, 15 Jul 2025 09:25:36 +0100 Subject: [PATCH 08/12] hardcode test --- buildconfig/Jenkins/Conda/run-tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildconfig/Jenkins/Conda/run-tests b/buildconfig/Jenkins/Conda/run-tests index d61ac05fb40b..659ad23f3bb0 100755 --- a/buildconfig/Jenkins/Conda/run-tests +++ b/buildconfig/Jenkins/Conda/run-tests @@ -92,7 +92,7 @@ cd $WORKSPACE/build # mkdir for test logs mkdir -p test_logs if [[ $ENABLE_UNIT_TESTS == true ]]; then - run_with_xvfb ctest -j$UNIT_TEST_THREADS --no-compress-output -T Test -O test_logs/ctest_$OSTYPE.log --schedule-random --output-on-failure --repeat until-pass:3 $WINDOWS_TEST_OPTIONS $WINDOWS_UNITTEST_TIMEOUT_OPTIONS + run_with_xvfb ctest -j$UNIT_TEST_THREADS --no-compress-output -T Test -O test_logs/ctest_$OSTYPE.log -R PhaseQuadMuonTest --schedule-random --output-on-failure --repeat until-pass:3 $WINDOWS_TEST_OPTIONS $WINDOWS_UNITTEST_TIMEOUT_OPTIONS fi if [[ $ENABLE_DOCS == true && $ENABLE_DOC_TESTS == true ]]; then From 80dca9e9bed92eb70db301fbbf4028fc397998fb Mon Sep 17 00:00:00 2001 From: MialLewis <95620982+MialLewis@users.noreply.github.com> Date: Tue, 15 Jul 2025 10:22:00 +0100 Subject: [PATCH 09/12] use eigen map --- Framework/Muon/src/PhaseQuadMuon.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Framework/Muon/src/PhaseQuadMuon.cpp b/Framework/Muon/src/PhaseQuadMuon.cpp index 54dbc97fb97f..eeaf3d8513d9 100644 --- a/Framework/Muon/src/PhaseQuadMuon.cpp +++ b/Framework/Muon/src/PhaseQuadMuon.cpp @@ -266,8 +266,8 @@ API::MatrixWorkspace_sptr PhaseQuadMuon::squash(const API::MatrixWorkspace_sptr } } - std::vector muLamVec{sxx, sxy, sxy, syy}; - Eigen::Map> muLamMatrix(muLamVec.data(), 2, 1); + std::array muLamVec{sxx, sxy, sxy, syy}; + Eigen::Map> muLamMatrix(muLamVec.data(), 2, 2); muLamMatrix = muLamMatrix.inverse(); std::vector aj(nspec), bj(nspec); From 631e1b02704b75f6ab4bf420bf3a170eb93f7e2b Mon Sep 17 00:00:00 2001 From: MialLewis <95620982+MialLewis@users.noreply.github.com> Date: Tue, 15 Jul 2025 18:13:15 +0100 Subject: [PATCH 10/12] use long double --- Framework/Muon/src/PhaseQuadMuon.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Framework/Muon/src/PhaseQuadMuon.cpp b/Framework/Muon/src/PhaseQuadMuon.cpp index eeaf3d8513d9..07c2ce5f41b6 100644 --- a/Framework/Muon/src/PhaseQuadMuon.cpp +++ b/Framework/Muon/src/PhaseQuadMuon.cpp @@ -239,7 +239,7 @@ API::MatrixWorkspace_sptr PhaseQuadMuon::squash(const API::MatrixWorkspace_sptr } std::vector emptySpectrum; emptySpectrum.reserve(nspec); - std::vector n0Vectors(nspec); + std::vector> n0Vectors(nspec); // Calculate coefficients aj, bj @@ -255,22 +255,21 @@ API::MatrixWorkspace_sptr PhaseQuadMuon::squash(const API::MatrixWorkspace_sptr const double phi = phase->Double(h, phaseIndex); const double X = n0[h] * asym * cos(phi); const double Y = n0[h] * asym * sin(phi); - Eigen::Vector2d n0vec; - n0vec << X, Y; - n0Vectors[h] = n0vec; + Eigen::Vector n0vec; + n0Vectors[h] = {X, Y}; sxx += X * X; syy += Y * Y; sxy += X * Y; } else { - n0Vectors[h] = Eigen::Vector2d::Zero(); + n0Vectors[h] = Eigen::Vector::Zero(); } } - std::array muLamVec{sxx, sxy, sxy, syy}; - Eigen::Map> muLamMatrix(muLamVec.data(), 2, 2); - muLamMatrix = muLamMatrix.inverse(); + Eigen::Matrix muLamMatrix; + muLamMatrix << sxx, sxy, sxy, syy; + muLamMatrix = Eigen::PartialPivLU>(muLamMatrix).inverse(); - std::vector aj(nspec), bj(nspec); + std::vector aj(nspec), bj(nspec); for (size_t h = 0; h < nspec; h++) { aj[h] = bj[h] = 0; if (!emptySpectrum[h]) { From 5b968fc15ec52b438ba439024067655378a2186c Mon Sep 17 00:00:00 2001 From: MialLewis <95620982+MialLewis@users.noreply.github.com> Date: Tue, 15 Jul 2025 18:21:45 +0100 Subject: [PATCH 11/12] Revert "hardcode test" This reverts commit daa6ad6c328c1ce51838a631306aadc7cb91c5f6. --- buildconfig/Jenkins/Conda/run-tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildconfig/Jenkins/Conda/run-tests b/buildconfig/Jenkins/Conda/run-tests index 659ad23f3bb0..d61ac05fb40b 100755 --- a/buildconfig/Jenkins/Conda/run-tests +++ b/buildconfig/Jenkins/Conda/run-tests @@ -92,7 +92,7 @@ cd $WORKSPACE/build # mkdir for test logs mkdir -p test_logs if [[ $ENABLE_UNIT_TESTS == true ]]; then - run_with_xvfb ctest -j$UNIT_TEST_THREADS --no-compress-output -T Test -O test_logs/ctest_$OSTYPE.log -R PhaseQuadMuonTest --schedule-random --output-on-failure --repeat until-pass:3 $WINDOWS_TEST_OPTIONS $WINDOWS_UNITTEST_TIMEOUT_OPTIONS + run_with_xvfb ctest -j$UNIT_TEST_THREADS --no-compress-output -T Test -O test_logs/ctest_$OSTYPE.log --schedule-random --output-on-failure --repeat until-pass:3 $WINDOWS_TEST_OPTIONS $WINDOWS_UNITTEST_TIMEOUT_OPTIONS fi if [[ $ENABLE_DOCS == true && $ENABLE_DOC_TESTS == true ]]; then From 65cfeb736f748d7d8e088fc8a45a11a12252e58e Mon Sep 17 00:00:00 2001 From: MialLewis <95620982+MialLewis@users.noreply.github.com> Date: Wed, 16 Jul 2025 15:29:05 +0100 Subject: [PATCH 12/12] use long double only on arm mac --- Framework/Muon/src/PhaseQuadMuon.cpp | 20 ++++++++++++++------ Framework/Muon/test/PhaseQuadMuonTest.h | 6 +++--- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/Framework/Muon/src/PhaseQuadMuon.cpp b/Framework/Muon/src/PhaseQuadMuon.cpp index 07c2ce5f41b6..3ff9525ee598 100644 --- a/Framework/Muon/src/PhaseQuadMuon.cpp +++ b/Framework/Muon/src/PhaseQuadMuon.cpp @@ -17,6 +17,14 @@ #include "Eigen/Dense" +// Use of a `long double` datatype is required on osx-arm64 to bring the precision of eigen vector-matrix multiplication +// inline with the other operating systems. +#if defined(__APPLE__) && defined(__arm64__) +typedef long double eigenDataType; +#else +typedef double eigenDataType; +#endif + using namespace Mantid::DataObjects; using namespace Mantid::HistogramData; @@ -239,7 +247,7 @@ API::MatrixWorkspace_sptr PhaseQuadMuon::squash(const API::MatrixWorkspace_sptr } std::vector emptySpectrum; emptySpectrum.reserve(nspec); - std::vector> n0Vectors(nspec); + std::vector> n0Vectors(nspec); // Calculate coefficients aj, bj @@ -255,21 +263,21 @@ API::MatrixWorkspace_sptr PhaseQuadMuon::squash(const API::MatrixWorkspace_sptr const double phi = phase->Double(h, phaseIndex); const double X = n0[h] * asym * cos(phi); const double Y = n0[h] * asym * sin(phi); - Eigen::Vector n0vec; + Eigen::Vector n0vec; n0Vectors[h] = {X, Y}; sxx += X * X; syy += Y * Y; sxy += X * Y; } else { - n0Vectors[h] = Eigen::Vector::Zero(); + n0Vectors[h] = Eigen::Vector::Zero(); } } - Eigen::Matrix muLamMatrix; + Eigen::Matrix muLamMatrix; muLamMatrix << sxx, sxy, sxy, syy; - muLamMatrix = Eigen::PartialPivLU>(muLamMatrix).inverse(); + muLamMatrix = Eigen::PartialPivLU>(muLamMatrix).inverse(); - std::vector aj(nspec), bj(nspec); + std::vector aj(nspec), bj(nspec); for (size_t h = 0; h < nspec; h++) { aj[h] = bj[h] = 0; if (!emptySpectrum[h]) { diff --git a/Framework/Muon/test/PhaseQuadMuonTest.h b/Framework/Muon/test/PhaseQuadMuonTest.h index ecb0c95b4780..1b91985872f0 100644 --- a/Framework/Muon/test/PhaseQuadMuonTest.h +++ b/Framework/Muon/test/PhaseQuadMuonTest.h @@ -312,14 +312,14 @@ class PhaseQuadMuonTestPerformance : public CxxTest::TestSuite { void setUp() override { m_loadedData = loadMuonDataset(); - phaseQuad = setupAlg(m_loadedData, false); + m_phaseQuad = setupAlg(m_loadedData, false); } void tearDown() override { Mantid::API::AnalysisDataService::Instance().remove("outputWs"); } - void testPerformanceWs() { phaseQuad->execute(); } + void testPerformanceWs() { m_phaseQuad->execute(); } private: MatrixWorkspace_sptr m_loadedData; - IAlgorithm_sptr phaseQuad; + IAlgorithm_sptr m_phaseQuad; };