tangled
alpha
login
or
join now
stau.space
/
costas
0
fork
atom
Permutation matrices research.
0
fork
atom
overview
issues
pulls
pipelines
docs: Added time complexity for functions.
Diego A. Estrada Rivera
1 year ago
70940790
d0e74d24
+16
1 changed file
expand all
collapse all
unified
split
src
lib
lib.cpp
+16
src/lib/lib.cpp
···
5
5
#include <iostream>
6
6
#include <unordered_set>
7
7
8
8
+
/*
9
9
+
* Complexity: O(n^2)
10
10
+
*/
8
11
fn is_permutation_matrix(Vec<UInt> a) noexcept -> Bool {
12
12
+
// Complexity: O(n)
9
13
let h = [&](Size stride) {
10
14
// NOTE: std::unordered_set cannot be constexpr, therefore this
11
15
// function is not constexpr.
···
24
28
return true;
25
29
}
26
30
31
31
+
/*
32
32
+
* Complexity: O(n^2)
33
33
+
*/
27
34
fn is_costas(Vec<UInt> const& vec) -> Bool {
28
35
using Set = std::unordered_set<UInt>;
29
36
···
47
54
return flag;
48
55
}
49
56
57
57
+
/*
58
58
+
* Complexity: O((n^2)!)
59
59
+
*/
50
60
fn costas_nxn(Vec<UInt> v) -> Vec<Vec<UInt>> {
51
61
auto out = Vec<Vec<UInt>>();
52
62
ra::sort(v);
···
59
69
return out;
60
70
}
61
71
72
72
+
/*
73
73
+
* Complexity: O(n^3)
74
74
+
*/
62
75
fn build_all_naive(Vec<UInt> const& vec, UInt x) -> Vec<Vec<UInt>> {
63
76
var out = Vec<Vec<UInt>>();
64
77
for (Size i = 0; i < vec.size(); ++i) {
···
70
83
return out;
71
84
}
72
85
86
86
+
/*
87
87
+
* Complexity: O(n)
88
88
+
*/
73
89
void print(Vec<UInt> const& v) {
74
90
for (var x : v)
75
91
std::cout << x << ' ';