20#define ROOT_MATH_ARCH MathSYCL
48#include <sycl/sycl.hpp>
68int compare(
double v1,
double v2,
double scale = 1.0)
73 double eps = scale * std::numeric_limits<double>::epsilon();
75 double delta =
v2 -
v1;
79 if (
v1 == 0 ||
v2 == 0) {
91 if (delta /
d > eps && delta > eps)
98template <
class Transform>
99bool IsEqual(
const Transform &
t1,
const Transform &t2,
unsigned int size)
102 std::vector<double> x1(
size);
103 std::vector<double> x2(
size);
104 t1.GetComponents(x1.begin(), x1.end());
105 t2.GetComponents(x2.begin(), x2.end());
111 std::abs(x1[i] - x2[i]) < std::numeric_limits<double>::epsilon() * (std::abs(x1[i]) + std::abs(x2[i]));
120 std::cout <<
"\n************************************************************************\n " <<
" Vector 3D Test"
121 <<
"\n************************************************************************\n";
123 sycl::buffer<int, 1> ok_buf(&ok, sycl::range<1>(1));
124 sycl::default_selector device_selector;
125 sycl::queue queue(device_selector);
128 queue.submit([&](sycl::handler &cgh) {
129 auto ok_device = ok_buf.get_access<sycl::access::mode::read_write>(cgh);
130 cgh.single_task<
class testVector3D>([=]() {
133 GlobalXYZVector vg(1., 2., 3.);
134 GlobalXYZVector vg2(vg);
135 GlobalPolar3DVector vpg(vg);
137 ok_device[0] += compare(vpg.R(), vg2.R());
141 double r = vg.Dot(vpg);
142 ok_device[0] += compare(
r, vg.Mag2());
144 GlobalXYZVector vcross = vg.Cross(vpg);
145 ok_device[0] += compare(vcross.R(), 0.0, 10);
150 GlobalXYZVector vg3 = vg + vpg;
151 ok_device[0] += compare(vg3.R(), 2 * vg.R());
153 GlobalXYZVector vg4 = vg - vpg;
154 ok_device[0] += compare(vg4.R(), 0.0, 10);
160 std::cout <<
"\t\t OK " << std::endl;
167 std::cout <<
"\n************************************************************************\n " <<
" Point 3D Tests"
168 <<
"\n************************************************************************\n";
170 sycl::buffer<int, 1> ok_buf(&ok, sycl::range<1>(1));
171 sycl::default_selector device_selector;
172 sycl::queue queue(device_selector);
175 queue.submit([&](sycl::handler &cgh) {
176 auto ok_device = ok_buf.get_access<sycl::access::mode::read_write>(cgh);
177 cgh.single_task<
class testPoint3D>([=]() {
180 GlobalXYZPoint pg(1., 2., 3.);
181 GlobalXYZPoint pg2(pg);
183 GlobalPolar3DPoint ppg(pg);
185 ok_device[0] += compare(ppg.R(), pg2.R());
188 GlobalXYZVector vg(pg);
190 double r = pg.Dot(vg);
191 ok_device[0] += compare(
r, pg.Mag2());
193 GlobalPolar3DVector vpg(pg);
194 GlobalXYZPoint pcross = pg.Cross(vpg);
195 ok_device[0] += compare(pcross.R(), 0.0, 10);
197 GlobalPolar3DPoint pg3 = ppg + vg;
198 ok_device[0] += compare(pg3.R(), 2 * pg.R());
200 GlobalXYZVector vg4 = pg - ppg;
201 ok_device[0] += compare(vg4.R(), 0.0, 10);
207 ok_device[0] += compare(
XYZVector(q2) ==
v2,
true);
213 std::cout <<
"\t OK " << std::endl;
218int testLorentzVector()
220 std::cout <<
"\n************************************************************************\n "
221 <<
" Lorentz Vector Tests"
222 <<
"\n************************************************************************\n";
224 sycl::buffer<int, 1> ok_buf(&ok, sycl::range<1>(1));
225 sycl::default_selector device_selector;
226 sycl::queue queue(device_selector);
228 std::cout <<
"sycl::queue check - selected device:\n"
229 << queue.get_device().get_info<sycl::info::device::name>() << std::endl;
232 queue.submit([&](sycl::handler &cgh) {
233 auto ok_device = ok_buf.get_access<sycl::access::mode::read_write>(cgh);
234 cgh.single_task<
class testRotations3D>([=]() {
237 ok_device[0] += compare(
v1.DeltaR(
v2), 4.60575f);
240 ok_device[0] += compare(
v.M(), 62.03058f);
246 std::cout <<
"\tOK\n";
248 std::cout <<
"\t FAILED\n";
253void mathcoreGenVectorSYCL()
260 std::cout <<
"\n\nNumber of tests " << ntest <<
" failed = " << nfail << std::endl;
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
Class describing a generic displacement vector in 3 dimensions.
Tag for identifying vectors based on a global coordinate system.
Tag for identifying vectors based on a local coordinate system.
Class describing a generic LorentzVector in the 4D space-time, using the specified coordinate system ...
Class describing a generic position vector (point) in 3 dimensions.
Global Helper functions for generic Vector classes.
PositionVector3D< Cartesian3D< double >, DefaultCoordinateSystemTag > XYZPoint
3D Point based on the cartesian coordinates x,y,z in double precision
DisplacementVector3D< Cartesian3D< double >, DefaultCoordinateSystemTag > XYZVector
3D Vector based on the cartesian coordinates x,y,z in double precision
bool areEqual(const RULE *r1, const RULE *r2, bool moduloNameOrPattern=false)