You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: minL2Potts.m
    path of file: ./repos/Pottslab/Potts
    
    the code of the file until where you have to start completion: function u = minL2Potts(f, gamma, weights)
%MINL2POTTS Minimizes the classical L^2-Potts problem
%
%Description

    
function u = minL2Potts(f, gamma, weights)
%MINL2POTTS Minimizes the classical L^2-Potts problem
%
%Description
% Computes an exact minimizer of the L^2-Potts functional
%
%  \gamma \| D u \|_0 + \| u - f \|_2^2
%
% in O(n^2) time.
%
%Reference:
% F. Friedrich, A. Kempe, V. Liebscher, G. Winkler,
% Complexity penalized M-estimation: Fast computation
% Journal of Computational and Graphical Statistics, 2008
%
% See also: minL2iPotts, minL1Potts, minL1iPotts

% written by M. Storath
% $Date: 2013-10-04 13:43:18 +0200 (Fr, 04 Okt 2013) $	$Revision: 80 $

% weighted and vector valued version exists only in Java
if ~exist('weights', 'var')
    weights = ones(size(f));
end