17
17
18
18
#include " Eigen/Dense"
19
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
+
20
28
using namespace Mantid ::DataObjects;
21
29
using namespace Mantid ::HistogramData;
22
30
@@ -239,7 +247,7 @@ API::MatrixWorkspace_sptr PhaseQuadMuon::squash(const API::MatrixWorkspace_sptr
239
247
}
240
248
std::vector<bool > emptySpectrum;
241
249
emptySpectrum.reserve (nspec);
242
- std::vector<Eigen::Vector<long double , 2 >> n0Vectors (nspec);
250
+ std::vector<Eigen::Vector<eigenDataType , 2 >> n0Vectors (nspec);
243
251
244
252
// Calculate coefficients aj, bj
245
253
@@ -255,21 +263,21 @@ API::MatrixWorkspace_sptr PhaseQuadMuon::squash(const API::MatrixWorkspace_sptr
255
263
const double phi = phase->Double (h, phaseIndex);
256
264
const double X = n0[h] * asym * cos (phi);
257
265
const double Y = n0[h] * asym * sin (phi);
258
- Eigen::Vector<long double , 2 > n0vec;
266
+ Eigen::Vector<eigenDataType , 2 > n0vec;
259
267
n0Vectors[h] = {X, Y};
260
268
sxx += X * X;
261
269
syy += Y * Y;
262
270
sxy += X * Y;
263
271
} else {
264
- n0Vectors[h] = Eigen::Vector<long double , 2 >::Zero ();
272
+ n0Vectors[h] = Eigen::Vector<eigenDataType , 2 >::Zero ();
265
273
}
266
274
}
267
275
268
- Eigen::Matrix<long double , 2 , 2 > muLamMatrix;
276
+ Eigen::Matrix<eigenDataType , 2 , 2 > muLamMatrix;
269
277
muLamMatrix << sxx, sxy, sxy, syy;
270
- muLamMatrix = Eigen::PartialPivLU<Eigen::Matrix<long double , 2 , 2 >>(muLamMatrix).inverse ();
278
+ muLamMatrix = Eigen::PartialPivLU<Eigen::Matrix<eigenDataType , 2 , 2 >>(muLamMatrix).inverse ();
271
279
272
- std::vector<long double > aj (nspec), bj (nspec);
280
+ std::vector<eigenDataType > aj (nspec), bj (nspec);
273
281
for (size_t h = 0 ; h < nspec; h++) {
274
282
aj[h] = bj[h] = 0 ;
275
283
if (!emptySpectrum[h]) {
0 commit comments