Construct an Interpoland from a function.

The function must have the signature f(::AbstractMatrix)::AbstractArray where each column of the input matrix is a vector of values along a single dimension


Finds all of the unidimensional disjoint sets of Chebychev extrema that are used to construct the grid. It improves on past algorithms by noting that $A_{n} = S_{n}$ [evens] except for $A_1= \{0\}$ and $A_2 = \{-1, 1\}$. Additionally, $A_{n} = A_{n+1}$ [odds] This prevents the calculation of these nodes repeatedly. Thus we only need to calculate biggest of the Sn's to build the sequence of ``An`` 's

See section 3.2 of the paper...

basis_eltype(p::Union{BasisParams,Type{<:BasisParams}, x)

Return the eltype of the Basis matrix that would be obtained by calling evalbase(p, x)


Compute the matrix B(pts) from equation 22 in JMMV 2013. This is the basis matrix


Use disjoint Smolyak sets to construct Smolyak grid of degree d and density parameter mu


Computes first n Chebychev polynomials of the kind kind evaluated at each point in x and places them in out. The trailing dimension of out indexes the chebyshev polynomials. All inner dimensions correspond to points in x.


Do common transformations to all constructor of BasisMatrix


  • N::Int: The number of dimensions in the corresponding Basis
  • x::AbstractArray: The points for which the BasisMatrix should be


  • order::Array{Int}: The order of evaluation for each dimension of the basis


  • m::Int: the total number of derivative order basis functions to compute.

This will be the number of rows in the matrix form of order

  • order::Matrix{Int}: A m × N matrix that, for each of the m desired

specifications, gives the derivative order along all N dimensions

  • minorder::Matrix{Int}: A 1 × N matrix specifying the minimum desired

derivative order along each dimension

  • numbases::Matrix{Int}: A 1 × N matrix specifying the total number of

distinct derivative orders along each dimension

  • x::AbstractArray: The properly transformed points at which to evaluate

the basis


Construct basis matrix for complete polynomial of degree d, given input data z. z is assumed to be the degree 1 realization of each variable. For example, if variables are q, r, and s, then z should be z = [q r s]

Output is a basis matrix. In our example, with d set to 2 we would have

out = [ones(size(z,1)) q q.^2 q.*r q.*s r r.^2 r.*s s s.^2]

TODO: Currently a bit more code repetition than is desireable. It would be nice to cut down on the repetition between the complete_polynomial functions TODO: Current algorithm for computing derivatives is kind of slow – Is there any obvious ways to improve this?


Evaluate spline basis matrices for a certain order derivative at x


  • p::SplineParams: A SplineParams summarizing spline properties
  • x(nodes(p)) : the nodes at which to evaluate the basis matrices
  • order(0) : The order(s) of derivative for which to evaluate the basis

matrices. order=0 corresponds to the function itself, negative numbers correspond to integrals.


  • B::SparseMatrixCSC : Matrix containing the evaluation of basis functions

at each point in x. Each column represents a basis function.

  • x: Points at which the functions were evaluated
lookup(table::AbstractVector, x, p::Int=0)

For a sorted vector table, return the index of the last point smaller than x. p specifies endpoint adjustments and takes one of 4 values:

  1. p=0: no adjustment made
  2. p=1: if x < minimum(table), then return sum(table .== table[1])
  3. p=2: if x > maximum(table), then return length(table)-sum(table .== table[end])
  4. p=3: do both adjustments 1 and 2

If p > 3, the p=3 case is applied

When x is a vector, a vector of integers is returned


Construct interpolation nodes, given SplineParams

Note that p.k - 1 additional nodes will be inserted


  • p::SplineParams: SplineParams instance


  • x::Vector: The Vector of 1d interpolation nodes.

For each number in 1 to n, compute the Smolyak indices for the corresponding basis functions. This is the $n$ in $\phi_n$. The output is A dictionary whose keys are the Smolyak index n and values are ranges containing all basis polynomial subscripts for that Smolyak index


Build indices specifying all the Cartesian products of Chebychev polynomials needed to build Smolyak polynomial


Finds the set S_n , which is the nth Smolyak set of Chebychev extrema

smol_inds(d::Int, mu::AbstractVector{Int})

Finds all of the indices that satisfy the requirement that $d \leq \sum_{i=1}^d \leq d + \mu_i$.

This is the anisotropic version of the method that allows mu to vary for each dimension

smol_inds(d::Int, mu::Int)

Finds all of the indices that satisfy the requirement that $d \leq \sum_{i=1}^d \leq d + \mu$.