From e605773a4fa192b02fa36298025c63b4cbea6dc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Wed, 10 Jul 2024 14:23:49 +0200 Subject: [PATCH] Fix format --- src/lagrange.jl | 36 +++++++++++++++++++++++++++++------- src/orthogonal.jl | 17 +++++++++-------- 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/src/lagrange.jl b/src/lagrange.jl index d60b150..8afb2a5 100644 --- a/src/lagrange.jl +++ b/src/lagrange.jl @@ -38,7 +38,10 @@ struct ImplicitLagrangeBasis{T,P,N<:AbstractNodes{T,P},V} <: SA.ImplicitBasis{LagrangePolynomial{T,P,V},Pair{V,P}} variables::V nodes::AbstractNodes{T,P} - function ImplicitLagrangeBasis(variables, nodes::AbstractNodes{T,P}) where {T,P} + function ImplicitLagrangeBasis( + variables, + nodes::AbstractNodes{T,P}, + ) where {T,P} return new{T,P,typeof(nodes),typeof(variables)}(variables, nodes) end end @@ -48,7 +51,10 @@ struct LagrangeBasis{T,P,U<:AbstractVector{P},V} <: points::U function LagrangeBasis(variables, points::AbstractVector) P = eltype(points) - return new{eltype(P),P,typeof(points),typeof(variables)}(variables, points) + return new{eltype(P),P,typeof(points),typeof(variables)}( + variables, + points, + ) end end @@ -59,16 +65,26 @@ function Base.getindex(basis::LagrangeBasis, I::AbstractVector{<:Integer}) return LagrangeBasis(basis.variables, basis.points[I]) end -function explicit_basis_type(::Type{<:ImplicitLagrangeBasis{T,_P,N,V}}) where {T,_P,N,V} +function explicit_basis_type( + ::Type{<:ImplicitLagrangeBasis{T,_P,N,V}}, +) where {T,_P,N,V} points = eachcol(ones(T, 1, 1)) P = eltype(points) return LagrangeBasis{eltype(P),P,typeof(points),V} end -function eval_basis!(univariate_buffer, result, basis::SubBasis{B}, variables, values) where {B} +function eval_basis!( + univariate_buffer, + result, + basis::SubBasis{B}, + variables, + values, +) where {B} for v in MP.variables(basis) if !(v in variables) - error("Cannot evaluate `$basis` as its variable `$v` is not part of the variables `$variables` of the `LagrangeBasis`") + error( + "Cannot evaluate `$basis` as its variable `$v` is not part of the variables `$variables` of the `LagrangeBasis`", + ) end end for i in eachindex(values) @@ -79,7 +95,7 @@ function eval_basis!(univariate_buffer, result, basis::SubBasis{B}, variables, v result[i] = one(eltype(result)) for j in eachindex(values) d = MP.degree(basis.monomials[i], variables[j]) - result[i] = MA.operate!!(*, result[i], univariate_buffer[d + 1, j]) + result[i] = MA.operate!!(*, result[i], univariate_buffer[d+1, j]) end end return result @@ -91,7 +107,13 @@ function transformation_to(basis::SubBasis, lag::LagrangeBasis{T}) where {T} univariate_buffer = Matrix{T}(undef, length(basis), MP.nvariables(lag)) V = Matrix{T}(undef, length(lag), length(basis)) for i in eachindex(lag) - eval_basis!(univariate_buffer, view(V, i, :), basis, MP.variables(lag), lag.points[i]) + eval_basis!( + univariate_buffer, + view(V, i, :), + basis, + MP.variables(lag), + lag.points[i], + ) end return V end diff --git a/src/orthogonal.jl b/src/orthogonal.jl index cba17c4..c9c88ef 100644 --- a/src/orthogonal.jl +++ b/src/orthogonal.jl @@ -77,19 +77,15 @@ function recurrence_eval( ) / d end -function univariate_eval!( - ::Type{B}, - values::AbstractVector, - value, -) where {B} +function univariate_eval!(::Type{B}, values::AbstractVector, value) where {B} if 1 in eachindex(values) values[1] = one(value) end if 2 in eachindex(values) values[2] = degree_one_univariate_polynomial(B, value) end - for d in 2:(length(values) - 1) - values[d + 1] = recurrence_eval(B, view(values, 1:d), value, d) + for d in 2:(length(values)-1) + values[d+1] = recurrence_eval(B, view(values, 1:d), value, d) end return values end @@ -111,7 +107,12 @@ function univariate_orthogonal_basis( ) return univariate_eval!( B, - Vector{MP.polynomial_type(Polynomial{B,MP.monomial_type(variable)}, Int)}(undef, degree + 1), + Vector{ + MP.polynomial_type(Polynomial{B,MP.monomial_type(variable)}, Int), + }( + undef, + degree + 1, + ), variable, ) end