Skip to content

Commit 051a8aa

Browse files
committed
Cleaned up debugging and print code
1 parent 622652b commit 051a8aa

3 files changed

Lines changed: 2 additions & 45 deletions

File tree

.vscode/launch.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@
5050
"-a crls",
5151
"-i data/truck-and-construction-noises.wav",
5252
"-t data/pink-noise.wav",
53-
"-m prerecorded",
54-
"-s 50"
53+
"-m prerecorded"
5554
]
5655
},
5756
{

clms.c

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -220,68 +220,33 @@ void rls(float *targetSignalIn, float *inputSignalIn, float muParam, int nParam,
220220

221221
zeroes(y, length);
222222
zeroes(e, length);
223-
zeroes(weights, 2); //TODO might need to change to random instead
223+
zeroes(weights, 2);
224224

225-
//TODO
226-
//1. Implement R
227-
//2. Implement transpose
228-
//3. Implement a divide and subtract
229-
//self.R = 1/self.eps * np.identity(n)
230-
/*y[k] = np.dot(self.w, x[k])
231-
e[k] = d[k] - y[k]
232-
R1 = np.dot(
233-
np.dot(
234-
np.dot(self.R,x[k])
235-
x[k].T)
236-
self.R)
237-
R2 = self.mu + np.dot(np.dot(x[k],self.R),x[k].T)
238-
self.R = 1/self.mu * (self.R - R1/R2)
239-
dw = np.dot(self.R, x[k].T) * e[k]
240-
self.w += dw*/
241225
float * R = malloc (sizeof(float) * 4);
242226
float r_eps = 1 / eps;
243227
R[0] = 1*r_eps;
244228
R[1] = 0;
245229
R[2] = 0;
246230
R[3] = 1*r_eps;
247-
//printf("mu: " ANSI_COLOR_MAGENTA "%f\n" ANSI_COLOR_RESET, mu);
248-
//printf("eps: " ANSI_COLOR_MAGENTA "%f\n" ANSI_COLOR_RESET, eps);
249-
//printf("R: [" ANSI_COLOR_MAGENTA "%f, %f" ANSI_COLOR_RESET "], [" ANSI_COLOR_MAGENTA "%f, %f" ANSI_COLOR_RESET "]\n" , R[0], R[1], R[2], R[3]);
250231
for (int k = 0; k < length; k++) {
251-
//float * blah = sub(inputSignal, k);
252-
//printf("inputSignal[" ANSI_COLOR_BLUE "%d" ANSI_COLOR_RESET "]: [" ANSI_COLOR_MAGENTA "%f, %f" ANSI_COLOR_RESET "]\n", k, blah[0], blah[1]);
253232
y[k] = dot(weights, sub(inputSignal, k));
254-
//printf("y[" ANSI_COLOR_BLUE "%d" ANSI_COLOR_RESET "] = " ANSI_COLOR_MAGENTA "%f\n" ANSI_COLOR_RESET, k, y[k]);
255233
e[k] = subone(targetSignal,k) - y[k];
256-
//printf("e[" ANSI_COLOR_BLUE "%d" ANSI_COLOR_RESET "] = " ANSI_COLOR_MAGENTA "%f\n" ANSI_COLOR_RESET, k, e[k]);
257234

258235
float *inputTranspose = transpose(sub(inputSignal, k), 2);
259-
//printf("inputTranspose: [" ANSI_COLOR_MAGENTA "%f, %f" ANSI_COLOR_RESET "]\n", inputTranspose[0], inputTranspose[1]);
260236
float *dotRInput = dotp(R, sub(inputSignal, k));
261-
//printf("dotRInput: [" ANSI_COLOR_MAGENTA "%f, %f" ANSI_COLOR_RESET "]\n", dotRInput[0], dotRInput[1]);
262237
float dotRInputTranspose = dotfloat(dotRInput, inputTranspose);
263-
//printf("dotRInputTranspose: " ANSI_COLOR_MAGENTA "%f\n" ANSI_COLOR_RESET, dotRInputTranspose);
264238
float *R1 = multifour(dotRInputTranspose, R);
265-
//printf("R1: [" ANSI_COLOR_MAGENTA "%f, %f" ANSI_COLOR_RESET "], [" ANSI_COLOR_MAGENTA "%f, %f" ANSI_COLOR_RESET "]\n" , R1[0], R1[1], R1[2], R1[3]);
266239

267240
float * dotInputR = dotpreverse(sub(inputSignal, k), R);
268-
//printf("dotInputR: [" ANSI_COLOR_MAGENTA "%f, %f" ANSI_COLOR_RESET "]\n", dotInputR[0], dotInputR[1]);
269241
float dotInputRTranspose = dotfloat(dotInputR, inputTranspose);
270-
//printf("dotInputRTranspose: " ANSI_COLOR_MAGENTA "%f\n" ANSI_COLOR_RESET, dotInputRTranspose);
271242
float R2 = mu + dotInputRTranspose;
272-
//printf("R2: " ANSI_COLOR_MAGENTA "%f\n" ANSI_COLOR_RESET, R2);
273243

274244
float * r1DivideR2 = divide(R1, R2);
275-
//printf("R1 Divided by R2: [" ANSI_COLOR_MAGENTA "%f, %f" ANSI_COLOR_RESET "], [" ANSI_COLOR_MAGENTA "%f, %f" ANSI_COLOR_RESET "]\n", r1DivideR2[0], r1DivideR2[1], r1DivideR2[2], r1DivideR2[3]);
276245
float * rMinusR1DivideR2 = subtract(R, r1DivideR2);
277-
//printf("R minus R1/R2: [" ANSI_COLOR_MAGENTA "%f, %f" ANSI_COLOR_RESET "], [" ANSI_COLOR_MAGENTA "%f, %f" ANSI_COLOR_RESET "]\n", rMinusR1DivideR2[0], rMinusR1DivideR2[1], rMinusR1DivideR2[2], rMinusR1DivideR2[3]);
278246
R = multifour((1 / mu), rMinusR1DivideR2);
279-
//printf("R: [" ANSI_COLOR_MAGENTA "%f, %f" ANSI_COLOR_RESET "], [" ANSI_COLOR_MAGENTA "%f, %f" ANSI_COLOR_RESET "]\n" , R[0], R[1], R[2], R[3]);
280247

281248
float * dw = multi(e[k], dotp(R, inputTranspose));
282-
//printf("dw: [" ANSI_COLOR_MAGENTA "%f, %f" ANSI_COLOR_RESET "]\n", dw[0], dw[1]);
283249
add(weights,dw);
284-
//printf("weights: [" ANSI_COLOR_MAGENTA "%f, %f" ANSI_COLOR_RESET "]\n", weights[0], weights[1]);
285250
}
286251

287252
delSignal(targetSignal);

soundwave/algorithms/least_mean_squares.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ def rls(inputSignal, targetSignal, mu, n):
5555
f = pa.filters.FilterRLS(n=n, mu=mu, w="zeros")
5656
y, e, w = f.run(targetSignal, inputSignal)
5757

58-
with open('rls.txt', 'w') as filehandle:
59-
for listitem in y:
60-
filehandle.write('%s\n' % listitem)
61-
6258
return y, e
6359

6460
def crls(inputSignal, targetSignal, mu, n):
@@ -81,7 +77,4 @@ def crls(inputSignal, targetSignal, mu, n):
8177

8278
c_lib.rls(targetSignal_p, inputSignal_p, mu, n, y, e, length)
8379

84-
with open('crls.txt', 'w') as filehandle:
85-
for listitem in y:
86-
filehandle.write('%s\n' % listitem)
8780
return y, e

0 commit comments

Comments
 (0)