BasisMatrices.jl
BasisMatrices.jl copied to clipboard
simple BasisMatrix call doesn't work
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
Ahh that’s no good.
I’ll see if I can fix that up soon
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
Looks like you forgot to specify the type of basis matrix representation. Try BasisMatrix(basis, Direct()) after running the code you provided