--- /dev/null
+function b = open_quant_slope(b)
+ b(2) = quantise([-1 -0.5 0.5 1], b(2));
+ b(1) = quantise([0.5 1.0], b(1));
+end
for i=1:nVec
c = [sum(target) target*(1:nCols)' target*vq(i,:)' ]';
b = inv(A(:,:,i))*c;
- if nargin == 3;
+ if nargin >= 3;
b = feval(closed_quant_fn,b);
- end;
+ end
b_log(i,:) = b;
diff(i,:) = target - (b(1)*vq(i,:) + b(2)*(1:nCols) + b(3));
errors(f) = mn;
idx(f) = min_ind(1);
b = b_log(min_ind,:);
- b_log2(f,:) = b;
+
+ % optional quantisation performed after error min loop
+ % - note we recalc gain to match energy after quantisation
- %printf("f: %d i: %d mg: %f sl: %f g: %f\n", f, idx(f), b(1), b(2), b(3));
+ if nargin == 4
+ b = feval(open_quant_fn, b);
+ b(3) = (sum(target) - sum(b(1)*vq(min_ind,:) + b(2)*(1:nCols)))/nCols;
+ end
+
+ printf("f: %d i: %d mg: %f sl: %f g: %f\n", f, idx(f), b(1), b(2), b(3));
+ b_log2(f,:) = b;
contrib(f,:) = b(1)*vq(min_ind,:) + b(2)*(1:nCols) + b(3);
end