Skip to content

Commit bf26364

Browse files
Merge release-next into main
2 parents 1bc22d4 + 0afe4e0 commit bf26364

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

Framework/Muon/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ set_property(TARGET Muon PROPERTY FOLDER "MantidFramework")
122122

123123
target_link_libraries(
124124
Muon
125-
PUBLIC Mantid::API Mantid::Kernel Mantid::Geometry Mantid::CurveFitting
125+
PUBLIC Mantid::API Mantid::Kernel Mantid::Geometry
126126
PRIVATE Mantid::DataObjects Mantid::Indexing
127127
)
128128
# Add the unit tests directory

Framework/Muon/src/PhaseQuadMuon.cpp

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,22 @@
99
#include "MantidAPI/Axis.h"
1010
#include "MantidAPI/ITableWorkspace.h"
1111
#include "MantidAPI/MatrixWorkspaceValidator.h"
12-
#include "MantidCurveFitting/EigenMatrix.h"
1312
#include "MantidDataObjects/Workspace2D.h"
1413
#include "MantidDataObjects/WorkspaceCreation.h"
1514
#include "MantidHistogramData/Histogram.h"
1615
#include "MantidKernel/PhysicalConstants.h"
1716
#include "MantidKernel/Unit.h"
1817

18+
#include "Eigen/Dense"
19+
20+
// Use of a `long double` datatype is required on osx-arm64 to bring the precision of eigen vector-matrix multiplication
21+
// inline with the other operating systems.
22+
#if defined(__APPLE__) && defined(__arm64__)
23+
typedef long double eigenDataType;
24+
#else
25+
typedef double eigenDataType;
26+
#endif
27+
1928
using namespace Mantid::DataObjects;
2029
using namespace Mantid::HistogramData;
2130

@@ -238,7 +247,7 @@ API::MatrixWorkspace_sptr PhaseQuadMuon::squash(const API::MatrixWorkspace_sptr
238247
}
239248
std::vector<bool> emptySpectrum;
240249
emptySpectrum.reserve(nspec);
241-
std::vector<CurveFitting::EigenVector> n0Vectors(nspec);
250+
std::vector<Eigen::Vector<eigenDataType, 2>> n0Vectors(nspec);
242251

243252
// Calculate coefficients aj, bj
244253

@@ -254,23 +263,21 @@ API::MatrixWorkspace_sptr PhaseQuadMuon::squash(const API::MatrixWorkspace_sptr
254263
const double phi = phase->Double(h, phaseIndex);
255264
const double X = n0[h] * asym * cos(phi);
256265
const double Y = n0[h] * asym * sin(phi);
257-
n0Vectors[h] = CurveFitting::EigenVector({X, Y});
266+
Eigen::Vector<eigenDataType, 2> n0vec;
267+
n0Vectors[h] = {X, Y};
258268
sxx += X * X;
259269
syy += Y * Y;
260270
sxy += X * Y;
261271
} else {
262-
n0Vectors[h] = CurveFitting::EigenVector({0.0, 0.0});
272+
n0Vectors[h] = Eigen::Vector<eigenDataType, 2>::Zero();
263273
}
264274
}
265275

266-
CurveFitting::EigenMatrix muLamMatrix(2, 2);
267-
muLamMatrix.set(0, 0, sxx);
268-
muLamMatrix.set(0, 1, sxy);
269-
muLamMatrix.set(1, 0, sxy);
270-
muLamMatrix.set(1, 1, syy);
271-
muLamMatrix.invert();
276+
Eigen::Matrix<eigenDataType, 2, 2> muLamMatrix;
277+
muLamMatrix << sxx, sxy, sxy, syy;
278+
muLamMatrix = Eigen::PartialPivLU<Eigen::Matrix<eigenDataType, 2, 2>>(muLamMatrix).inverse();
272279

273-
std::vector<double> aj(nspec), bj(nspec);
280+
std::vector<eigenDataType> aj(nspec), bj(nspec);
274281
for (size_t h = 0; h < nspec; h++) {
275282
aj[h] = bj[h] = 0;
276283
if (!emptySpectrum[h]) {

Framework/Muon/test/PhaseQuadMuonTest.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,14 +312,14 @@ class PhaseQuadMuonTestPerformance : public CxxTest::TestSuite {
312312

313313
void setUp() override {
314314
m_loadedData = loadMuonDataset();
315-
phaseQuad = setupAlg(m_loadedData, false);
315+
m_phaseQuad = setupAlg(m_loadedData, false);
316316
}
317317

318318
void tearDown() override { Mantid::API::AnalysisDataService::Instance().remove("outputWs"); }
319319

320-
void testPerformanceWs() { phaseQuad->execute(); }
320+
void testPerformanceWs() { m_phaseQuad->execute(); }
321321

322322
private:
323323
MatrixWorkspace_sptr m_loadedData;
324-
IAlgorithm_sptr phaseQuad;
324+
IAlgorithm_sptr m_phaseQuad;
325325
};

0 commit comments

Comments
 (0)