namespace gismo {

/** 
  \defgroup Nurbs Nurbs module
\ingroup Modules

This module contains the B-spline and NURBS basis functions.

\gismo is very powerful in dealing with tensor-product B-splines:

\image html tb1.png "A tensor B-spline basis."

\section BSeval Evaluation of B-splines

There are several functions with similar names. The following table
should help you in find the proper one for you. 

Name of procedure        | Which basis function | Evaluate what
-------------------------|----------------------|-------------------------------
\c eval(u)                 | all active at u        | value
\c evalSingle(i, u)	       | basis function i	    | value
\c deriv(u)		           | all active at u	    | first derivative(s)
\c derivSingle(i, u)       | basis function i	    | first derivative(s)
\c deriv2(u)		       | all active at u	    | second derivative(s)
\c deriv2Single(i, u)	   | basis function i	    | second derivative(s)
\c evalAllDers(u, k)       | all active at u        | value and all derivatives up to order k
\c evalAllDersSingle(i,u,k)| basis function i       | value and all derivatives up to order k
\c evalDerSingle(i, u, k)  | basis function i 	    | k-th derivative (k=0, ... , p-1)

<!--\c evalDer(i,u, k)         | all active at u 	    | k-th derivative (k=0, ... , p-1)-->

All above functions return by a unique pointer. Also, for all
functions there is version suffixed with \c _into, for example \c eval_into,
\c deriv2Single_into, and so on, which return \c void, take an additional
matrix \c result as argument and write the result in that matrix.

Here \c u is a matrix of values, and every column corresponds to one
evaluation point.

One of the lovely things about G+Smo is that it in works nicely in arbitrary dimension and the functions look virtually the same.
So if you work with a tensor-product basis, your matrix \c u has to have exactly as many rows as the number of variables and then
it is used the same way as in univariate case.

The price you pay for arbitrary dimension is that the results are returned in a somehow magical manner.
That is, every column of \c result then contains values of **active functions** in ascending order. Thus it is usually used together
with \c active_into. See the following example.

\subsection EvExample Example of evaluation

We create a bivariate quadratic tensor-product basis and evaluate the basis functions in several points. First, we need knot vectors:
\verbatim
gsKnotVector<> kv0(0,1,1,3); //start,end,interior knots, start/end multiplicites of knots
gsKnotVector<> kv1(0,1,1,3);
\endverbatim
Then we create the basis by
\verbatim
gsTensorBSplineBasis<2,double> tbas (new gsBSplineBasis< double >(kv0), new gsBSplineBasis< double >(kv1));
\endverbatim
Now we have 16 basis functions, the following figure shows them together with the points where we are going to evaluate them.

\image html evaluation.png "Mesh, numbers correspond to Greville abscissae of the basis functions, red dots to evaluation points."

We prepare six evaluation points (0,0), (0.1,0), (1,0), (0.5,0.5), (0.6,0.6), (1,1) by
\verbatim
gsMatrix< double > uVals(2,6);
uVals << 0,0.1,1,0.5,0.6,1, 0,0,0,0.5,0.6,1;
\endverbatim
and the matrices for results by
\verbatim
gsMatrix< unsigned > actRes;
gsMatrix< double > valRes;
\endverbatim
\b Tipp: Note that \c actRes requires a matrix of \c unsigned, otherwise you obtain a hardly comprehensible error.
This situation is good to remember in similar cases.

Now we ask for the evaluation and printing of the results
\verbatim
tbas.active_into(uVals,actRes);
tbas.eval_into(uVals,valRes);
std::cout << "Active functions:\n" << actRes << "\n\nResults of evaluation:\n" << valRes << "\n";
\endverbatim
You should obtain something like
\verbatim
Active functions:
 0  0  1  5  5  5
 1  1  2  6  6  6
 2  2  3  7  7  7
 4  4  5  9  9  9
 5  5  6 10 10 10
 6  6  7 11 11 11
 8  8  9 13 13 13
 9  9 10 14 14 14
10 10 11 15 15 15

Results of evaluation:
     1   0.64      0   0.25 0.1024      0
     0   0.34      0   0.25 0.2048      0
     0   0.02      1      0 0.0128      0
     0      0      0   0.25 0.2048      0
     0      0      0   0.25 0.4096      0
     0      0      0      0 0.0256      0
     0      0      0      0 0.0128      0
     0      0      0      0 0.0256      0
     0      0      0      0 0.0016      1
\endverbatim
From the first matrix we may read that the active functions in (0,0) are functions number 0, 1, 2, 4, 5, 6, 8, 9, 10 (check with the figure).
Similarly, the second column shows us the basis functions active in (0.1, 0) etc.

In the second matrix we see the actual values. The first column tells us that there is just one active function in (0,0) and is equal to 1 there.
In (0.1, 0) we have more active functions; value of the 0th is equal to 0.64, 1th to 0.34, 2nd to 0.02 and the others are equal to zero (don't
worry about that, the evaluation point is at the border of their supports). Interesting is the fourth column: we may see that in the middle of
the domain there are four nonzero functions, their indices are 5, 6, 9 and 10 and all the values are equal to 0.25.

\b Tipp: You may observe the partition of unity. Sum of all the entries in each column should be equal to one.

Evaluation of derivatives goes along similar lines and we invite you to play around with them
in your test file.


*/

}
