BasisMatrices.jl icon indicating copy to clipboard operation
BasisMatrices.jl copied to clipboard

simple BasisMatrix call doesn't work

Open floswald opened this issue 7 years ago • 3 comments

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

floswald avatar Mar 08 '18 09:03 floswald

Ahh that’s no good.

I’ll see if I can fix that up soon

sglyon avatar Mar 08 '18 13:03 sglyon

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

HariharanJayashankar avatar Mar 13 '24 18:03 HariharanJayashankar

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

sglyon avatar Mar 13 '24 19:03 sglyon