
function V=koornwinder_typeII(deg,pts,a)

%--------------------------------------------------------------------------
% OBJECT.
%----------
%
% KOORNWINDER TYPE II BASIS ON THE UNIT DISK "B([0,0],1)". 
% 
%--------------------------------------------------------------------------
% INPUT.
%----------
%
% deg: VANDERMONDE MATRIX UP TO DEGREE d INCLUDED. 
% pts: SETS OF POINTS OF THE UNIT DISK "B([0,0],1)". 
% a:   KOORNWINDER EXPONENT (DEFAULT "a=-0.5").
%--------------------------------------------------------------------------
% OUTPUT.
%----------
%
% V: VANDERMONDE MATRIX w.r.t. THE KOORNWINDER TYPE II BASIS ON THE SET pts.
% 
%--------------------------------------------------------------------------
% FUNCTIONS USED.
%----------------
%
% 1. r_jacobi
% 2. eval_mod_op
% 3. eval_op
%
%--------------------------------------------------------------------------
%%
%% Copyright (C) 2010. Alvise Sommariva, Marco Vianello.
%%
%% 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 2 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 this program; if not, write to the Free Software
%% Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
%%
%% Author:  Alvise Sommariva <alvise@euler.math.unipd.it>
%%          Marco Vianello   <marcov@euler.math.unipd.it>
%%
%% Date: October 25, 2011
%%
%--------------------------------------------------------------------------

if nargin < 3
    a=-0.5;
end

mod_op_type=3; % ORTHONORMAL JACOBI.
op_type=3; % ORTHONORMAL JACOBI.

x=pts(:,1); y=pts(:,2);

c=sqrt(1-x.^2);
t=y; 

a1=a; b1=a;

ab=r_jacobi(deg,a1,b1);
V1=eval_mod_op(deg,ab,a1,b1,t,c,mod_op_type);

t=x; V=[];

for k=0:deg
    
    a2=a+k+0.5; b2=a+k+0.5;
    
    if deg-k > 0
        ab2=r_jacobi(deg-k,a2,b2);    
    else
        ab2=[];
    end
    
    V2loc=eval_op(deg-k,ab2,t,a2,b2,op_type);
    V1loc=repmat(V1(:,k+1),1,size(V2loc,2));
    
    V=[V V1loc.*V2loc];
    
end 



