function codes = omp_coding(patch_feats, dict, G, layer_params)
% compute sparse codes by batch orthogonal matching pursuit in the first layer

switch layer_params.coding

    case 'omp'
        % overcomplete basis vectors        
        DxX = dict'*patch_feats;
        codes = abs(omp(DxX, G, layer_params.sparsity));
 
    case 'omp_sign'        
        DxX = dict'*patch_feats;
        sign_codes = omp(DxX, G, layer_params.sparsity);
        codes_pos = double(sign_codes > 0);
        codes_neg = double(sign_codes < 0);
        codes = [sign_codes.*codes_pos; -sign_codes.*codes_neg];
                
    otherwise
        disp('Unknown coding type');
end