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

Add string macro to define KnotVector{Int} #315

Closed
hyrodium opened this issue Jun 9, 2023 · 1 comment · Fixed by #316
Closed

Add string macro to define KnotVector{Int} #315

hyrodium opened this issue Jun 9, 2023 · 1 comment · Fixed by #316

Comments

@hyrodium
Copy link
Owner

hyrodium commented Jun 9, 2023

The following macro is not useful for most people but is useful for debugging and writing tests.

julia> using BasicBSpline

julia> macro knotvector_str(s)
           return sum(KnotVector(findall(==('0'+i), s))*i for i in 1:9)
       end
@knotvector_str (macro with 1 method)

julia> knotvector"1111"
KnotVector([1, 2, 3, 4])

julia> k1 = knotvector" 1 2  4 5"
KnotVector([2, 4, 4, 7, 7, 7, 7, 9, 9, 9, 9, 9])

julia> k2 = knotvector" 1 21 5 5"
KnotVector([2, 4, 4, 5, 7, 7, 7, 7, 7, 9, 9, 9, 9, 9])

julia> k3 = knotvector" 1 21 5 3"
KnotVector([2, 4, 4, 5, 7, 7, 7, 7, 7, 9, 9, 9])

julia> k1  k2
true

julia> k1  k3
false
@hyrodium
Copy link
Owner Author

hyrodium commented Jun 9, 2023

I'm not sure we really need this macro in src, but I'm planning to add it just for fun.

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

Successfully merging a pull request may close this issue.

1 participant