Skip to content

Commit

Permalink
Merge pull request #37 from jyrkialakuijala/main
Browse files Browse the repository at this point in the history
occasionally renormalize unitary rotators to 1.0
  • Loading branch information
jyrkialakuijala authored Mar 7, 2024
2 parents b03bcba + 3a55b63 commit 730ed7c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions speaker_experiments/identity_sliding_fft.cc
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,13 @@ struct Rotators {
rot[4][i] += rot[2][i] * audio;
rot[5][i] += rot[3][i] * audio;
}
void OccasionallyRenormalize() {
for (int i = 0; i < kNumRotators; ++i) {
float norm = 1.0 / sqrt(rot[2][i] * rot[2][i] + rot[3][i] * rot[3][i]);
rot[2][i] *= norm;
rot[3][i] *= norm;
}
}
void IncrementAll() {
for (int i = 0; i < kNumRotators; ++i) {
float tr = rot[0][i] * rot[2][i] - rot[1][i] * rot[3][i];
Expand Down Expand Up @@ -341,6 +348,9 @@ struct RotatorFilterBank {
int64_t FilterAllSingleThreaded(const double* history, int64_t total_in, int64_t len,
FilterMode mode, double* output, size_t output_size) {
size_t out_ix = 0;
for (size_t c = 0; c < num_channels_; ++c) {
rotators_[c].OccasionallyRenormalize();
}
for (int64_t i = 0; i < len; ++i) {
for (size_t c = 0; c < num_channels_; ++c) {
for (int k = 0; k < kNumRotators; ++k) {
Expand Down

0 comments on commit 730ed7c

Please sign in to comment.