From 8ec55c474c06a325b82fe96e0f2943c1c78cc830 Mon Sep 17 00:00:00 2001 From: mattsignorelli Date: Fri, 3 May 2024 14:57:03 -0400 Subject: [PATCH] clearord --- docs/src/man/k_methods.md | 2 ++ docs/src/man/o_all.md | 2 +- src/GTPSA.jl | 1 + src/methods.jl | 24 ++++++++++++++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/docs/src/man/k_methods.md b/docs/src/man/k_methods.md index a799cb0c..0979d428 100644 --- a/docs/src/man/k_methods.md +++ b/docs/src/man/k_methods.md @@ -1,5 +1,7 @@ # [TPS Methods](@id tpsmethods) ```@docs +clearord +clearord! clear! complex! compose! diff --git a/docs/src/man/o_all.md b/docs/src/man/o_all.md index b9b619fa..04e64adb 100644 --- a/docs/src/man/o_all.md +++ b/docs/src/man/o_all.md @@ -16,7 +16,7 @@ rand **`LinearAlgebra`**: `norm`, `mul!` **`SpecialFunctions`**: `erf`, `erfc` -`GTPSA.jl` also provides the following functions NOT included in Base or any of the above packages: +`GTPSA.jl` also provides the following functions NOT included in Base or any of the above packages (and not already documented in [TPS Methods](@ref tpsmethods)): ``` add!, sub!, div!, unit, sinhc, asinc, asinhc, polar, rect ``` diff --git a/src/GTPSA.jl b/src/GTPSA.jl index e52eeca5..8b42d024 100644 --- a/src/GTPSA.jl +++ b/src/GTPSA.jl @@ -118,6 +118,7 @@ export deriv, ∂, deriv!, ∂!, getord, getord!, cutord, cutord!, + clearord, clearord!, translate, translate!, par, scalar, diff --git a/src/methods.jl b/src/methods.jl index 19e9aa90..203e7735 100644 --- a/src/methods.jl +++ b/src/methods.jl @@ -315,6 +315,30 @@ function cutord(t1::Union{TPS, ComplexTPS}, order::Integer) return t end +# --- clearord! --- +clrord!(t::Ptr{RTPSA}, ord::Cuchar) = mad_tpsa_clrord!(t, ord) +clrord!(t::Ptr{CTPSA}, ord::Cuchar) = mad_ctpsa_clrord!(t, ord) + +""" + clearord!(t::Union{TPS,ComplexTPS}, order::Integer) + +Clears all monomial coefficients in `t` at order `order`. +""" +clearord!(t::Union{TPS,ComplexTPS}, order::Integer) = clrord!(t.tpsa, convert(Cuchar, order)) + +""" + clearord(t1::Union{TPS,ComplexTPS}, order::Integer) + +Returns a new TPS equal to `t1` but with all monomial coefficients +at the given `order` cleared (set equal to 0). +""" +function clearord(t1::Union{TPS,ComplexTPS}, order::Integer) + t = zero(t1) + copy!(t,t1) + clearord!(t,order) + return t +end + # --- scalar --- """