QuantEcon / QuantEcon/BasisMatrices.jl

funeval error with Smolyak basis

Open
#45 0 comments 0 reactions 1 assignee View on GitHub

@sglyon is already working on this.

Since Dec 6, 2017.

bug
Dominant language
Julia
Stars
33
Forks
20
PR merge metrics
No merged PRs in 30d

Description

I've noticed that the package has code for Smolyak interpolation, although I'm not sure if it's finished and supposed to be used. Anyway, it doesn't seem to work with funeval:

using BasisMatrices
parms = SmolyakParams(2,3,zeros(2),ones(2))
fspace = Basis(parms)
b = zeros(length(fspace))
x = [0.5, 0.5]
funeval(b, fspace, x)

yields an error:

ERROR: MethodError: Cannot `convert` an object of type Array{Float64,2} to an object of type BasisMatrices.SplineSparse{Float64,Int64,n_chunks,chunk_len} where chunk_len where n_chunks
This may have arisen from a call to the constructor BasisMatrices.SplineSparse{Float64,Int64,n_chunks,chunk_len} where chunk_len where n_chunks(...),
since type constructors fall back to convert methods.
Stacktrace:
 [1] BasisMatrices.BasisMatrix(::Type{BasisMatrices.SplineSparse}, ::BasisMatrices.Basis{1,Tuple{BasisMatrices.SmolyakParams{Float64,Int64}}}, ::BasisMatrices.Direct, ::Array{Float64,2}, ::Array{Int64,2}) at /home/ivansml/.julia/v0.6/BasisMatrices/src/basis_structure.jl:231
 [2] funeval(::Array{Float64,1}, ::BasisMatrices.Basis{1,Tuple{BasisMatrices.SmolyakParams{Float64,Int64}}}, ::Array{Float64,2}, ::Int64) at /home/ivansml/.julia/v0.6/BasisMatrices/src/interp.jl:197
 [3] funeval(::Array{Float64,1}, ::BasisMatrices.Basis{1,Tuple{BasisMatrices.SmolyakParams{Float64,Int64}}}, ::Array{Float64,1}, ::Int64) at /home/ivansml/.julia/v0.6/BasisMatrices/src/interp.jl:148 (repeats 2 times)

and funeval(b, fspace, x') (i.e. when x is 1 by 2 matrix) results in

ERROR: x must have d=1 columns
Stacktrace:
 [1] funeval(::Array{Float64,1}, ::BasisMatrices.Basis{1,Tuple{BasisMatrices.SmolyakParams{Float64,Int64}}}, ::Array{Float64,2}, ::Int64) at /home/ivansml/.julia/v0.6/BasisMatrices/src/interp.jl:188 (repeats 2 times)

The immediate cause seems to be that fspace here is of type Basis{1,...} (since it contains only one set of parameters) and thus the call is dispatched to methods intended for 1D basis structures.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.