FERS 1.0.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
portable_utils.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-only
2//
3// Copyright (c) 2006-2008 Marc Brooker and Michael Inggs
4// Copyright (c) 2008-present FERS Contributors (see AUTHORS.md).
5//
6// See the GNU GPLv2 LICENSE file in the FERS project root for more information.
7
8/**
9 * @file portable_utils.h
10 * @brief Utility functions for mathematical and system operations.
11 */
12
13#pragma once
14
15#include <cmath>
16#include <thread>
17
18#include "config.h"
19
20namespace core
21{
22 /**
23 * @brief Computes the Bessel function of the first kind (order 1) for a given value.
24 *
25 * @param x The value for which the Bessel function is to be computed.
26 * @return The computed value of the Bessel function of the first kind (order 1).
27 */
28 inline RealType besselJ1(const RealType x) noexcept { return j1(x); }
29
30 /**
31 * @brief Detects the number of CPUs on the machine.
32 *
33 * @return The number of CPUs detected, or 1 if detection fails.
34 */
35 inline unsigned countProcessors() noexcept
36 {
37 if (const unsigned hardware_threads = std::thread::hardware_concurrency(); hardware_threads > 0)
38 {
39 return hardware_threads;
40 }
41 LOG(logging::Level::ERROR, "Unable to get CPU count, assuming 1.");
42 return 1;
43 }
44}
Global configuration file for the project.
double RealType
Type for real numbers.
Definition config.h:27
#define LOG(level,...)
Definition logging.h:19
unsigned countProcessors() noexcept
Detects the number of CPUs on the machine.
RealType besselJ1(const RealType x) noexcept
Computes the Bessel function of the first kind (order 1) for a given value.
@ ERROR
Error level for error events.