% 2d noiselet transform matrix: constructor
%
% A = matNoise2(sz,complex)
%
%  sz  [1,2]: size of the image to transform
%  complex [1,2]: complex number treatment A:IN^n->OUT^m,          default [1,1]
%                 first number specifies output field OUT^m and the second the
%                 input field IN^m of the matrix A
%                 1 -  real(z) + 1i*imag(z)    IC:   native complex numbers
%                 2 - [real(z); imag(z)]       IR^2: stacked real numbers
%                 3    real(z)                 IR:   real part only
%
% (c) by Hannes Nickisch, MPI for Biological Cybernetics, 2010 August 23
%
% MEX-code by: Justin Romberg, Georgia Tech
%              Peter Stobbe, Caltech
%
% The code applies a 1d transform to every column of the input; the input 
% therefore has to have a number of rows that is a power of two.

function A = matNoise2(sz,complex)

  imsz = sz(:)';  A.imsz = imsz;                                    % image size
  if numel(A.imsz)==1, A.imsz = [A.imsz,1]; end
  p = log2(A.imsz(1)); 
  if abs(p-fix(p))>eps, error('no of rows needs to be a power of two'), end
  sz = prod(imsz)*[2,1];                                           % matrix size
  if nargin<2, complex = 1; end
  if numel(complex)==1, complex = complex*[1,1]; end
  A = class(A,mfilename,mat(sz,complex));
