# HG changeset patch # User flatmax # Date 1361875406 0 # Node ID b1cbc2617c7fc6258dd1fff11c92dea91f78a6af # Parent b4323584c9fa03e18e5aef8cf440fa07dcc32f40 Updated Matrix resizing and Zeroing using rif@google's suggestions. diff -r b4323584c9fa -r b1cbc2617c7f trunk/C++/CAR.C --- a/trunk/C++/CAR.C Wed Feb 20 22:34:13 2013 +0000 +++ b/trunk/C++/CAR.C Tue Feb 26 10:43:26 2013 +0000 @@ -34,11 +34,11 @@ void CAR::designFilters(FP_TYPE fs, int n_ch) { // don't really need these zero arrays, but it's a clue to what fields // and types are need in ohter language implementations: - coeff.r1_coeffs.resize(n_ch, 1); coeff.r1_coeffs-=coeff.r1_coeffs; // resize and zero - coeff.a0_coeffs.resize(n_ch, 1); coeff.a0_coeffs-=coeff.a0_coeffs; - coeff.c0_coeffs.resize(n_ch, 1); coeff.c0_coeffs-=coeff.c0_coeffs; - coeff.h_coeffs.resize(n_ch, 1); coeff.h_coeffs-=coeff.h_coeffs; - coeff.g0_coeffs.resize(n_ch, 1); coeff.g0_coeffs-=coeff.g0_coeffs; + coeff.r1_coeffs=Matrix::Zero(n_ch,1); // resize and zero + coeff.a0_coeffs=Matrix::Zero(n_ch,1); + coeff.c0_coeffs=Matrix::Zero(n_ch,1); + coeff.h_coeffs=Matrix::Zero(n_ch,1); + coeff.g0_coeffs=Matrix::Zero(n_ch,1); // zr_coeffs is not zeroed ... perhaps it should be ? // zero_ratio comes in via h. In book's circuit D, zero_ratio is 1/sqrt(a), @@ -76,12 +76,11 @@ // for unity gain at min damping, radius r; only used in CARFAC_Init: Array relative_undamping(n_ch, 1); - relative_undamping=(relative_undamping-=relative_undamping).cos();// what is an efficient way to set a matrix to 1. ? As this is in a design phase, I will leave it for now + relative_undamping=Array::Zero(n_ch, 1).cos(); // this function needs to take CAR_coeffs even if we haven't finished // constucting it by putting in the g0_coeffs: coeff.g0_coeffs = stageG(relative_undamping); - } Array CAR::stageG(Array &relative_undamping) { diff -r b4323584c9fa -r b1cbc2617c7f trunk/C++/codeblocks/CARFAC.layout --- a/trunk/C++/codeblocks/CARFAC.layout Wed Feb 20 22:34:13 2013 +0000 +++ b/trunk/C++/codeblocks/CARFAC.layout Tue Feb 26 10:43:26 2013 +0000 @@ -25,8 +25,8 @@ - - + + @@ -35,7 +35,7 @@ - + @@ -58,8 +58,8 @@ - - + +