Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nulling-python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
smadani2
nulling-python
Commits
253a1e73
Commit
253a1e73
authored
4 years ago
by
Sepehr Madani
Browse files
Options
Downloads
Patches
Plain Diff
Adds limitation on angle changes for vectors
parent
673d0f01
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
algorithms/butterfly_algorithm.py
+19
-4
19 additions, 4 deletions
algorithms/butterfly_algorithm.py
with
19 additions
and
4 deletions
algorithms/butterfly_algorithm.py
+
19
−
4
View file @
253a1e73
...
...
@@ -40,15 +40,18 @@ class ButterflyAlgorithm(BaseAlgorithm):
self
.
null_deg
=
self
.
null_degrees
[
0
]
self
.
theta
=
pi
*
cos
(
radians
(
self
.
null_deg
))
self
.
vector_dirs
=
[
wrapToPi
(
k
*
self
.
theta
)
for
k
in
range
(
self
.
N
)]
self
.
sum_dir
=
wrapToPi
(
phase
(
sum
([
exp
(
1j
*
x
)
for
x
in
self
.
vector_dirs
])))
self
.
vector_changes
=
[
0.0
for
_
in
range
(
self
.
N
)]
self
.
vector_changes
=
[
0.0
]
*
self
.
N
self
.
vector_change_limit
=
(
pi
*
(
2
**
self
.
bit_count
-
1
)
/
2
**
self
.
bit_resolution
)
self
.
update_pattern
()
before_loop
_pattern
=
nan
while
before_loop
_pattern
!=
self
.
pattern
:
before_loop
_pattern
=
self
.
pattern
pattern_
before_loop
=
nan
while
pattern_
before_loop
!=
self
.
pattern
:
pattern_
before_loop
=
self
.
pattern
for
idx
in
range
(
self
.
N
//
2
):
# index for half the vectors
original_vector_changes
=
self
.
vector_changes
[:]
original_pattern
=
self
.
pattern
...
...
@@ -62,6 +65,9 @@ class ButterflyAlgorithm(BaseAlgorithm):
self
.
vector_changes
[
idx
]
-=
alpha
self
.
vector_changes
[
other
]
+=
alpha
self
.
normalize_change_vector
(
idx
)
self
.
normalize_change_vector
(
other
)
self
.
vector_changes
=
vectorWrapToPi
(
self
.
vector_changes
)
self
.
update_pattern
()
...
...
@@ -75,3 +81,12 @@ class ButterflyAlgorithm(BaseAlgorithm):
# print(f'\nFinal pattern value: {abs(self.pattern) = }'
# f'\nFinal score: {-20 * log10(abs(self.pattern))}')
return
-
20
*
log10
(
abs
(
self
.
pattern
))
def
normalize_change_vector
(
self
,
idx
):
limit
=
self
.
vector_change_limit
if
self
.
vector_changes
[
idx
]
>
0
:
self
.
vector_changes
[
idx
]
=
min
(
limit
,
self
.
vector_changes
[
idx
])
if
self
.
vector_changes
[
idx
]
<
0
:
self
.
vector_changes
[
idx
]
=
max
(
-
limit
,
self
.
vector_changes
[
idx
])
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment