## Copyright (C) 2015 Loriane Weber
## 
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 3 of the License, or
## (at your option) any later version.
## 
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
## 
## You should have received a copy of the GNU General Public License
## along with Octave; see the file COPYING.  If not, see
## <http://www.gnu.org/licenses/>.

## csquare1

## Author: Loriane Weber <lweber@rnice7-0103>
## Created: 2015-06-04

function csq=csquare1(betah,f,varargin)

f_isall = 0;
switch nargin
case 3
    f_isall = varargin{1};
end 

csq=cos((pi*betah)*f.^2);

if (f_isall~=1)
    [n m]=size(f);
    n=n-1;
    m=m-1;
    csq=cat(2,cat(1,csq,flipdim(csq(2:n,:,:),1)),cat(1,flipdim(csq(:,2:m,:),2),flipdim(flipdim(csq(2:n,2:m,:),1),2)));
end


end
