% Delivered to the Government in Accordance with Contract FA8650-10-C-7080
% 
%  (c) 2011 United Technologies Corp.
% Developed with the sponsorship of the Defense Advanced Research Projects Agency (DARPA).
%  
% Permission is hereby granted, free of charge, to any person obtaining a copy of this data, including any software or models in source or binary form, as well as any drawings, specifications, and documentation (collectively "the Data"), to deal in the Data without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Data, and to permit persons to whom the Data is furnished to do so, subject to the following conditions:
%  
% The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Data.
%  
% THE DATA IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS, SPONSORS, DEVELOPERS, CONTRIBUTORS, OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE DATA OR THE USE OR OTHER DEALINGS IN THE DATA.
% 

x = linspace(1,100,100);
y = linspace(1,100,100);
k  =0;
for count1= 1:100
    for count2 = 1:100
        k = k+1;
        z(count1,count2) = (x(count1))^2+(y(count2))^2;
        x_t(k) = x(count1);
        y_t(k) = y(count2);
        z_t(k) = z(count1,count2);
    end
end


x_new = linspace(1,100,100);
y_new = linspace(1,100,100);

%
tic;
for count1 = 1:100
    for count2 = 1:100
z_new_n(count1,count2) = interp2(x,y,z,x_new(count1),y_new(count2));
    end
end
Time_n = toc;



c = 0;
for count1 = 1:100
    for count2 = 1:100
    c = c+1;
    x_new_t(c)= x_new(count1);
    y_new_t(c) = y_new(count2);
    end
end

x_t = x_t';
y_t = y_t';
z_t = z_t';


F = TriScatteredInterp(x_t,y_t,z_t);

tic
for count1 = 1:10000
    z_new_t(count1) = F(x_new_t(count1),y_new_t(count1));
end
Time_t = toc;


tic
       e00 =     -0.2422;
       e10 =      -3.346;
       e01 =       9.833;
       e20 =       1.707;
       e11 =       16.84;
       e02 =      -35.44;
       e30 =       1.818;
       e21 =      -11.81;
       e12 =      -25.88;
       e03 =       58.45;
       e40 =     -0.7842;
       e31 =      -1.915;
       e22 =       16.56;
       e13 =       15.53;
       e04 =      -43.53;
       e50 =      0.1999;
       e41 =      0.2284;
       e32 =      0.6619;
       e23 =      -6.843;
       e14 =      -2.925;
       e05 =       11.87;
  
beta = linspace(0,1,100);
speed = linspace(0.8,1.1,100);
       
for count1 = 1:100
    for count2 = 1:100
    Speed = speed(count1);
    Beta = beta(count2);    
    Efficiency_nd(count2) = e00 + e10*Beta + e01*Speed + e20*Beta^2 + e11*Beta*Speed + e02*Speed^2 + e30*Beta^3 + e21*Beta^2*Speed... 
                    + e12*Beta*Speed^2 + e03*Speed^3 + e40*Beta^4 + e31*Beta^3*Speed + e22*Beta^2*Speed^2 ...
                    + e13*Beta*Speed^3 + e04*Speed^4 + e50*Beta^5 + e41*Beta^4*Speed + e32*Beta^3*Speed^2 ...
                    + e23*Beta^2*Speed^3 + e14*Beta*Speed^4 + e05*Speed^5;
    end
end

Time_p = toc;
Ratio_t=  Time_n/Time_t;
Ratio_p = Time_n/Time_p;