Skip to content

Commit 0c752f3

Browse files
committed
math: replace lcm fnc with std one
Signed-off-by: Carlo Galiotto <[email protected]>
1 parent a012666 commit 0c752f3

File tree

4 files changed

+5
-30
lines changed

4 files changed

+5
-30
lines changed

include/srsran/support/math/gcd.h renamed to include/srsran/support/math/lcm.h

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,37 +15,12 @@
1515

1616
namespace srsran {
1717

18-
/// Calculates the greatest common divisor (GCD) of two integers.
19-
template <typename Integer>
20-
Integer gcd(Integer a, Integer b)
21-
{
22-
while (true) {
23-
if (a == 0) {
24-
return b;
25-
}
26-
b %= a;
27-
if (b == 0) {
28-
return a;
29-
}
30-
a %= b;
31-
}
32-
}
33-
34-
/// Calculates the least common multiplier (LCM) of two integers.
35-
template <typename Integer>
36-
Integer lcm(Integer a, Integer b)
37-
{
38-
Integer temp = gcd(a, b);
39-
40-
return temp != 0 ? (a / temp * b) : 0;
41-
}
42-
4318
/// Calculates the least common multiplier (LCM) for a range of integers.
4419
template <typename Integer>
4520
Integer lcm(span<const Integer> values)
4621
{
4722
return std::accumulate(
48-
values.begin(), values.end(), Integer(1), [](Integer a, Integer b) { return lcm<Integer>(a, b); });
23+
values.begin(), values.end(), Integer(1), [](Integer a, Integer b) { return std::lcm<Integer>(a, b); });
4924
}
5025

5126
} // namespace srsran

lib/scheduler/config/ue_configuration.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "../support/pdsch/pdsch_resource_allocation.h"
1616
#include "../support/pusch/pusch_default_time_allocation.h"
1717
#include "../support/pusch/pusch_resource_allocation.h"
18-
#include "srsran/support/math/gcd.h"
18+
#include "srsran/support/math/lcm.h"
1919
#include <algorithm>
2020

2121
using namespace srsran;
@@ -514,7 +514,7 @@ static void generate_crnti_monitored_pdcch_candidates(bwp_info& bwp_cfg, rnti_t
514514
ss_periods.push_back(ss->cfg->get_monitoring_slot_periodicity());
515515
}
516516
max_slot_periodicity = lcm<unsigned>(ss_periods);
517-
max_slot_periodicity = lcm(max_slot_periodicity, slots_per_frame);
517+
max_slot_periodicity = std::lcm(max_slot_periodicity, slots_per_frame);
518518
}
519519

520520
frame_pdcch_candidate_list candidates;

tests/benchmarks/scheduler/scheduler_multi_ue_benchmark.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "srsran/adt/circular_array.h"
1515
#include "srsran/scheduler/scheduler_factory.h"
1616
#include "srsran/support/benchmark_utils.h"
17-
#include "srsran/support/math/gcd.h"
17+
#include "srsran/support/math/lcm.h"
1818
#include <getopt.h>
1919

2020
using namespace srsran;

tests/unittests/du_manager/du_ran_resource_manager_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#include "lib/du_manager/ran_resource_management/du_ran_resource_manager_impl.h"
1212
#include "srsran/du/du_cell_config_helpers.h"
13-
#include "srsran/support/math/gcd.h"
13+
#include "srsran/support/math/lcm.h"
1414
#include "srsran/support/test_utils.h"
1515
#include <gtest/gtest.h>
1616

0 commit comments

Comments
 (0)