// ajusta_g.sci

function [c1, c2] = ajusta_g(T)
  [nl, nc] = size(T);
  n = nc;
  
  getf("gausspv.sci");
  
  A = zeros (2, 2);
  b = zeros (2, 1);
  
  // modelo
  deff("y = f1(x)", "y = x^2");
  deff("y = f2(x)", "y = 1");
  
  for i = 1:n do
    A(1,1) = A(1,1) + f1(T(1,i)) * f1(T(1,i));
    A(1,2) = A(1,2) + f1(T(1,i)) * f2(T(1,i));
    A(2,1) = A(2,1) + f2(T(1,i)) * f1(T(1,i));
    A(2,2) = A(2,2) + f2(T(1,i)) * f2(T(1,i));
    
    b(1) = b(1) + f1(T(1,i)) * T(2,i);
    b(2) = b(2) + f2(T(1,i)) * T(2,i);
  end
  
  mprintf ("%.2f\t%.2f\t%.2f\n", A, b);
  mprintf ("\n");
  
  [p, B, c] = gausspv (A, b);
  
  c1 = c(1);
  c2 = c(2);
endfunction

  
