//#####################################################################
// Copyright 2021, Craig Schroeder.
// This file is part of PhysBAM whose distribution is governed by the license contained in the accompanying file PHYSBAM_COPYRIGHT.txt.
//#####################################################################
#include <Core/Interpolation/CUBIC_SPLINE_INTERPOLATION.h>
#include <Core/Interpolation/GENERAL_INTERPOLATION_CELL_DEFINITION.h>
#include <Core/Interpolation/GENERAL_INTERPOLATION_FACE_DEFINITION.h>
#include <Core/Interpolation/GENERAL_INTERPOLATION_NODE_DEFINITION.h>
#include <Core/Interpolation/INTERPOLATION_UNIFORM_FORWARD.h>
namespace PhysBAM{

template<int a,int d,class T>
VECTOR<VECTOR<T,4>,1> CUBIC_SPLINE_INTERPOLATION_STENCIL::
Value(T t)
{
    T s=1-t,u=s*t;
    VECTOR<T,4> r={u*s,-2*s+u*(3*t-2),-2*t+u*(1-3*t),u*t};
    return {-(T).5*r};
}
template<int a,int d,class T>
VECTOR<VECTOR<T,4>,1>
CUBIC_SPLINE_INTERPOLATION_STENCIL::Diff(T t)
{
    T s=1-t,u=3*s*t;
    VECTOR<T,4> r={u-s,-3*u-t,3*u+s,-u+t};
    return {(T).5*r};
}
template<int a,int d,class T>
VECTOR<VECTOR<T,4>,1>
CUBIC_SPLINE_INTERPOLATION_STENCIL::Hess(T t)
{
    return {{2-3*t,9*t-5,4-9*t,3*t-1}};
}
template class GENERAL_INTERPOLATION_CELL<VECTOR<double,2>,double,CUBIC_SPLINE_INTERPOLATION_STENCIL,false>;
template class GENERAL_INTERPOLATION_CELL<VECTOR<double,3>,double,CUBIC_SPLINE_INTERPOLATION_STENCIL,false>;
template class GENERAL_INTERPOLATION_FACE<VECTOR<double,2>,double,CUBIC_SPLINE_INTERPOLATION_STENCIL,false,ARRAY<double,FACE_INDEX<2> > >;
template class GENERAL_INTERPOLATION_FACE<VECTOR<double,3>,double,CUBIC_SPLINE_INTERPOLATION_STENCIL,false,ARRAY<double,FACE_INDEX<3> > >;
template class GENERAL_INTERPOLATION_FACE<VECTOR<float,2>,float,CUBIC_SPLINE_INTERPOLATION_STENCIL,false,ARRAY<float,FACE_INDEX<2> > >;
template class GENERAL_INTERPOLATION_FACE<VECTOR<float,3>,float,CUBIC_SPLINE_INTERPOLATION_STENCIL,false,ARRAY<float,FACE_INDEX<3> > >;
template class GENERAL_INTERPOLATION_NODE<VECTOR<double,2>,double,CUBIC_SPLINE_INTERPOLATION_STENCIL,false>;
template class GENERAL_INTERPOLATION_NODE<VECTOR<double,3>,double,CUBIC_SPLINE_INTERPOLATION_STENCIL,false>;
template class GENERAL_INTERPOLATION_NODE<VECTOR<float,2>,float,CUBIC_SPLINE_INTERPOLATION_STENCIL,false>;
template class GENERAL_INTERPOLATION_NODE<VECTOR<float,3>,float,CUBIC_SPLINE_INTERPOLATION_STENCIL,false>;
}
