/* -*- mode: C++ -*- */
//////////////////////////////////////////////////////////////////////////////
// FILE   : BaseC2.Concat.tol
// PURPOSE: Defines class @BaseC2.Concat
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////////
Text _.autodoc.member.BaseC2.Concat = 
"Concats a set of linearly independent bases over the same domain "
"vectorial space.";
Class @BaseC2.Concat : @BaseC2
//////////////////////////////////////////////////////////////////////////////
{
  Set _.base;   //Set of @BaseC2

  //Auxiliar member to map concatenated bases
  Set _.map;

  ////////////////////////////////////////////////////////////////////////////
  Static Text _.autodoc.member.New = "Creates an instance of "
  "@BaseC2.Concat on R^n with specified maximum degree.";
  Static @BaseC2.Concat New(Set base)
  ////////////////////////////////////////////////////////////////////////////
  {
    Real n = (base[1])::_.n;
    Set map = BinGroup("<<", For(1,Card(base),Set(Real h)
    {
      If((base[h])::_.n!=n,WriteLn("[@BaseC2.Concat::New] "
      "Cannot concat bases with different domain vectorial space dimension "
      <<n+"!="<<(base[h])::_.n),"E");
      For(1,(base[h])::_.K,Set(Real k)
      {
        [[h,k]]
      })
    }));
    @BaseC2.Concat aux = [[
      Real _.n = base::_.n;
      Real _.K = Card(map);
      Set _.base = base; 
      Set _.map = map
  ]]};

  //For efficience reasonsthe base has specific method for evaluation over 
  //massive data stored in a matrix

  ////////////////////////////////////////////////////////////////////////////
  Static Text _.autodoc.member._build.function.v = 
  "Evaluates the k-th basic function for an "
  "array of points given as the rows of a matrix ";
  VMatrix _build.function.v(Real k, VMatrix X)
  ////////////////////////////////////////////////////////////////////////////
  {
    Set aux = _.map[k];
    (_.base[aux::h])::_.base::function.v(aux::k, X)
  }; 
  ////////////////////////////////////////////////////////////////////////////
  Static Text _.autodoc.member._build.partial.derivative.1.v = 
  "Evaluates the first partial derivative of k-th basic function for an "
  "array of points given as the rows of a matrix";
  VMatrix _build.partial.derivative.1.v(Real k, VMatrix X, Real i)
  ////////////////////////////////////////////////////////////////////////////
  {
    Set aux = _.map[k];
    (_.base[aux::h])::_.base::partial.derivative.1.v(aux::k, X, i)
  };
  ////////////////////////////////////////////////////////////////////////////
  Static Text _.autodoc.member._build.partial.derivative.2.v = 
  "Evaluates the second partial derivative of k-th basic function for an "
  "array of points given as the rows of a matrix";
  VMatrix _build.partial.derivative.2.v(Real k, VMatrix X, Real i, Real j)
  ////////////////////////////////////////////////////////////////////////////
  {
    Set aux = _.map[k];
    (_.base[aux::h])::_.base::partial.derivative.2.v(aux::k, X, i, j)
  }
};
