Exemplo n.º 1
0
SparseMatrix BSplineBasis::insertKnots(double tau, unsigned int dim, unsigned int multiplicity)
{
    SparseMatrix A(1,1);
//    A.resize(1,1);
    A.insert(0,0) = 1;

    // Calculate multivariate knot insertion matrix
    for (unsigned int i = 0; i < numVariables; i++)
    {
        SparseMatrix temp = A;
        SparseMatrix Ai;

        if (i == dim)
        {
            // Build knot insertion matrix
            Ai = bases.at(i).insertKnots(tau, multiplicity);
        }
        else
        {
            // No insertion - identity matrix
            int m = bases.at(i).getNumBasisFunctions();
            Ai.resize(m,m);
            Ai.setIdentity();
        }

        //A = kroneckerProduct(temp, Ai);
        A = myKroneckerProduct(temp, Ai);
    }

    A.makeCompressed();

    return A;
}
Exemplo n.º 2
0
SparseMatrix BSplineBasis::decomposeToBezierForm()
{
    SparseMatrix A(1,1);
    A.insert(0,0) = 1;

    for (unsigned int i = 0; i < numVariables; i++)
    {
        SparseMatrix temp = A;
        SparseMatrix Ai = bases.at(i).decomposeToBezierForm();

        //A = kroneckerProduct(temp, Ai);
        A = myKroneckerProduct(temp, Ai);
    }

    A.makeCompressed();

    return A;
}
Exemplo n.º 3
0
SparseMatrix BSplineBasis::refineKnotsLocally(DenseVector x)
{
    SparseMatrix A(1,1);
    A.insert(0,0) = 1;

    for (unsigned int i = 0; i < numVariables; i++)
    {
        SparseMatrix temp = A;
        SparseMatrix Ai = bases.at(i).refineKnotsLocally(x(i));

        //A = kroneckerProduct(temp, Ai);
        A = myKroneckerProduct(temp, Ai);
    }

    A.makeCompressed();

    return A;
}
bool Basis::refineKnots(SparseMatrix &A)
{
    A.resize(1,1);
    A.insert(0,0) = 1;

    for (unsigned int i = 0; i < numVariables; i++)
    {
        SparseMatrix temp = A;
        SparseMatrix Ai;

        if (!bases.at(i).refineKnots(Ai))
            return false;

        //A = kroneckerProduct(temp, Ai);
        myKroneckerProduct(temp,Ai,A);
    }

    A.makeCompressed();

    return true;
}
Exemplo n.º 5
0
SparseMatrix BSplineBasis::reduceSupport(std::vector<double>& lb, std::vector<double>& ub)
{
    assert(lb.size() == ub.size());
    assert(lb.size() == numVariables);

    SparseMatrix A(1,1);
    A.insert(0,0) = 1;

    for (unsigned int i = 0; i < numVariables; i++)
    {
        SparseMatrix temp = A;
        SparseMatrix Ai;

        Ai = bases.at(i).reduceSupport(lb.at(i), ub.at(i));

        //A = kroneckerProduct(temp, Ai);
        A = myKroneckerProduct(temp, Ai);
    }

    A.makeCompressed();

    return A;
}
Exemplo n.º 6
0
SparseMatrix BSplineBasis::reduceSupport(std::vector<double>& lb, std::vector<double>& ub)
{
    if (lb.size() != ub.size() || lb.size() != numVariables)
        throw Exception("BSplineBasis::reduceSupport: Incompatible dimension of domain bounds.");

    SparseMatrix A(1,1);
    A.insert(0,0) = 1;

    for (unsigned int i = 0; i < numVariables; i++)
    {
        SparseMatrix temp = A;
        SparseMatrix Ai;

        Ai = bases.at(i).reduceSupport(lb.at(i), ub.at(i));

        //A = kroneckerProduct(temp, Ai);
        A = myKroneckerProduct(temp, Ai);
    }

    A.makeCompressed();

    return A;
}
bool Basis::reduceSupport(std::vector<double>& lb, std::vector<double>& ub, SparseMatrix &A)
{
    assert(lb.size() == ub.size());
    assert(lb.size() == numVariables);

    A.resize(1,1);
    A.insert(0,0) = 1;

    for (unsigned int i = 0; i < numVariables; i++)
    {
        SparseMatrix temp = A;
        SparseMatrix Ai;

        if (!bases.at(i).reduceSupport(lb.at(i), ub.at(i), Ai))
            return false;

        //A = kroneckerProduct(temp, Ai);
        myKroneckerProduct(temp, Ai, A);
    }

    A.makeCompressed();

    return true;
}