Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simple BasisMatrix call doesn't work #49

Open
floswald opened this issue Mar 8, 2018 · 3 comments
Open

simple BasisMatrix call doesn't work #49

floswald opened this issue Mar 8, 2018 · 3 comments

Comments

@floswald
Copy link

floswald commented Mar 8, 2018

hi,

i was trying to replicate the example on the readme:

grid1 = linspace(1,3,10)
sp = SplineParams(collect(grid1),0,3)  # nodes, whether only 2 nodes, degree of spline
sb = Basis(sp)
s,n = nodes(sb)
B  = BasisMatrix(sb)
ERROR: MethodError: Cannot `convert` an object of type BasisMatrices.Basis{1,Tuple{BasisMatrices.SplineParams{Array{Float64,1}}}} to an object of type BasisMatrices.BasisMatrix
This may have arisen from a call to the constructor BasisMatrices.BasisMatrix(...),
since type constructors fall back to convert methods.
Stacktrace:
 [1] BasisMatrices.BasisMatrix(::BasisMatrices.Basis{1,Tuple{BasisMatrices.SplineParams{Array{Float64,1}}}}) at ./sysimg.jl:24
@sglyon
Copy link
Member

sglyon commented Mar 8, 2018

Ahh that’s no good.

I’ll see if I can fix that up soon

@HariharanJayashankar
Copy link

Hello,

I have a similar issue with the direct BasisMatrix call.

linspace(a,b,n) = range(a; stop=b, length=n)
ygrid0 = linspace(-4, 4, 10)
agrid0 = linspace(0.0.^0.4, 100.0.^0.4, 25).^(1/0.4)

# method one, using the Basis constructor multiple times
basis = Basis(SplineParams(agrid0, 0, 3),  # cubic spline
              SplineParams(ygrid0, 0, 1))  # linear
Φ = BasisMatrix(basis)

I get a method error

 MethodError: no method matching BasisMatrix(::Basis{2, Tuple{SplineParams{Vector{…}}, SplineParams{StepRangeLen{…}}}})

Closest candidates are:
  BasisMatrix(::Basis, ::TBM, ::Union{Tuple{Vararg{AbstractVector}}, AbstractArray}) where TBM<:AbstractBasisMatrixRep
   @ BasisMatrices C:\Users\harih\.julia\packages\BasisMatrices\qnJMD\src\basis_structure.jl:302
  BasisMatrix(::Basis, ::TBM, ::Union{Tuple{Vararg{AbstractVector}}, AbstractArray}, ::Any) where TBM<:AbstractBasisMatrixRep
   @ BasisMatrices C:\Users\harih\.julia\packages\BasisMatrices\qnJMD\src\basis_structure.jl:302
  BasisMatrix(::Basis, ::Union{Tuple{Vararg{AbstractVector}}, AbstractArray})
   @ BasisMatrices C:\Users\harih\.julia\packages\BasisMatrices\qnJMD\src\basis_structure.jl:307
  ...

Stacktrace:
 [1] top-level scope
   @ REPL[10]:1
Some type information was truncated. Use `show(err)` to see complete types.

This is on windows 11, Julia version 1.10.0

@sglyon
Copy link
Member

sglyon commented Mar 13, 2024

Looks like you forgot to specify the type of basis matrix representation. Try BasisMatrix(basis, Direct()) after running the code you provided

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants