Functions

NonArchimedeanMachineLearning.AbsolutePolynomialSumType
AbsolutePolynomialSum{S}

A structure representing absolute polynomial sums.

Represents a function as a sum of multivariate polynomials, where absolute values are taken to define the evaluation at arbitrary polydiscs.

Fields

  • polys::Vector{AbstractAlgebra.Generic.MPoly{S}}: Vector of multivariate polynomials

Type Parameters

  • S: The coefficient type (typically p-adic numbers)

Note

We may later want to generalise to allow polydiscs as coefficients.

source
NonArchimedeanMachineLearning.LinearAbsolutePolynomialSumType
LinearAbsolutePolynomialSum{S}

A structure representing a sum of linear polynomials.

Composed of multiple linear polynomials, allowing for efficient evaluation and gradient computation over polydisc spaces.

Fields

  • polys::Vector{LinearPolynomial{S}}: Vector of linear polynomials

Type Parameters

  • S: The coefficient type (typically p-adic numbers)
source
NonArchimedeanMachineLearning.LinearPolynomialType
LinearPolynomial{S}

A structure representing a linear polynomial.

Encodes a polynomial of the form $a_1 T_1 + \cdots + a_n T_n + b$ where $a_i$ are coefficients and $b$ is a constant term.

Fields

  • coefficients::Vector{S}: Array of coefficients for each variable
  • constant::S: The constant term

Type Parameters

  • S: The coefficient type (typically p-adic numbers)
source
NonArchimedeanMachineLearning.PolydiscFunctionType
PolydiscFunction{S}

Abstract base type for functions on polydisc spaces.

Represents any function that can be evaluated on polydisc points and whose directional derivatives can be computed.

Type Parameters

  • S: The coefficient type (typically p-adic numbers)
source
NonArchimedeanMachineLearning.PolydiscFunctionEvaluatorType
PolydiscFunctionEvaluator{S,T,N}

Abstract base type for typed function evaluators.

Separates the mathematical function definition (PolydiscFunction) from the callable evaluator. The evaluator type records S, T, and N.

Type Parameters

  • S: Coefficient type (e.g., ValuedFieldPoint{P,Prec,PadicFieldElem})
  • T: Radius type (typically Int)
  • N: Dimension of polydisc space

Example

f = LinearPolynomial([K(1), K(2)], K(0))
eval = batch_evaluate_init(f, ValuationPolydisc{S,T,N})
result = eval(polydisc)
source
NonArchimedeanMachineLearning.batch_evaluate_initMethod
batch_evaluate_init(f::PolydiscFunction{S}, ::Type{ValuationPolydisc{S,T,N}}) where {S,T,N}

Create a typed evaluator for efficient batch evaluation.

The polydisc type supplies S, T, and N, so the returned callable carries the concrete evaluator type instead of closing over an untyped function.

Arguments

  • f::PolydiscFunction{S}: The function to evaluate
  • ::Type{ValuationPolydisc{S,T,N}}: The polydisc type (determines T and N at compile time)

Returns

PolydiscFunctionEvaluator{S,T,N}: A typed, callable evaluator struct

Example

f = LinearPolynomial([K(1), K(2)], K(0))
eval = batch_evaluate_init(f, ValuationPolydisc{ValuedFieldPoint{2,20,PadicFieldElem},Int,2})
result = eval(some_polydisc)
source
NonArchimedeanMachineLearning.directional_derivativeMethod
directional_derivative(fun::AbsolutePolynomialSum{S}, v::ValuationTangent{S,T,N}) where {S, T, N}

Compute the directional derivative of a polynomial sum along a tangent direction.

Arguments

  • fun::AbsolutePolynomialSum{S}: The polynomial sum
  • v::ValuationTangent{S,T,N}: The tangent direction

Returns

Float64: The directional derivative in direction v

source
NonArchimedeanMachineLearning.directional_derivativeMethod
directional_derivative(f::AbstractAlgebra.Generic.MPoly{S}, v::ValuationTangent{S,T,N}) where {S, T, N}

Compute the directional derivative of a multivariate polynomial along a tangent direction.

Uses the formula: if locally $|f| = a_n r^n$ for exponent $n$, then $d_v |f| = -|n| |a_n| r^n$ where $r$ is the radius of the basepoint.

Arguments

  • f::AbstractAlgebra.Generic.MPoly{S}: The polynomial
  • v::ValuationTangent{S,T,N}: The tangent direction

Returns

Float64: The directional derivative

source
NonArchimedeanMachineLearning.directional_derivativeMethod
directional_derivative(poly::LinearPolynomial{S}, v::ValuationTangent{S,T,N}) where {S, T, N}

Compute the directional derivative of a linear polynomial along a tangent direction.

For poly = Σᵢ aᵢTᵢ + b, expanding around v.direction gives a constant term c₀ = b + Σᵢ aᵢdᵢ and linear terms with coefficients aᵢ. The winning term is found by minimizing the valuation weight v(aₙ) + ⟨r, n⟩, breaking ties via dot(n, v.magnitude). Since all non-constant terms have degree 1, the derivative is:

  • 0 if the constant term wins (degree 0)
  • -p^{-best_val} if a linear term wins

Arguments

  • poly::LinearPolynomial{S}: The linear polynomial
  • v::ValuationTangent{S,T,N}: The tangent direction

Returns

Float64: The directional derivative

source
NonArchimedeanMachineLearning.directional_exponentMethod
directional_exponent(f::AbstractAlgebra.Generic.MPoly{S}, v::ValuationTangent{S,T,N}) where {S, T, N}

Find the exponent vector(s) along which a polynomial achieves its maximum absolute value.

For a polynomial $f$ and tangent vector $v$, finds all exponent vectors $n$ such that locally in the direction of $v$, $|f| = a_n r^n$ for some coefficient $a_n$.

The maximum of $|a_n| \cdot p^{-\langle r, n \rangle}$ is equivalent to minimizing the integer quantity $v(a_n) + \langle r, n \rangle$ over non-zero terms.

Arguments

  • f::AbstractAlgebra.Generic.MPoly{S}: A multivariate polynomial
  • v::ValuationTangent{S,T,N}: The tangent vector defining the direction

Returns

Vector: The exponent vector with minimum valuation weight, breaking ties by minimizing dot(n, v.magnitude)

source
NonArchimedeanMachineLearning.evaluateMethod
evaluate(fun::PolydiscFunction{S}, var::ValuationPolydisc{ValuedFieldPoint{P,Prec,S},T,N}) where {S,P,Prec,T,N}

Lifting adapter: evaluate a function with coefficients of type S on a polydisc with ValuedFieldPoint{P,Prec,S} coordinates. Unwraps the polydisc and delegates to the standard evaluate method.

source
NonArchimedeanMachineLearning.evaluateMethod
evaluate(fun::AbsolutePolynomialSum{S}, var::ValuationPolydisc{S,T,N}) where {S, T, N}

Evaluate an absolute polynomial sum at a polydisc.

Computes the sum of absolute values of each polynomial in the sum evaluated at the point.

Arguments

  • fun::AbsolutePolynomialSum{S}: The polynomial sum
  • var::ValuationPolydisc{S,T,N}: The evaluation point

Returns

Float64: The sum of polynomial evaluations

source
NonArchimedeanMachineLearning.evaluateMethod
evaluate(f::AbstractAlgebra.Generic.MPoly{S}, p::ValuationPolydisc{S,T,N}) where {S, T, N}

Evaluate the absolute value of a multivariate polynomial at a polydisc.

Computes the p-adic absolute value by expanding the polynomial around the center and finding the maximum absolute value term weighted by the radius.

Arguments

  • f::AbstractAlgebra.Generic.MPoly{S}: A multivariate polynomial
  • p::ValuationPolydisc{S,T,N}: The evaluation point (polydisc)

Returns

Float64: The absolute value of the polynomial at the polydisc

source
NonArchimedeanMachineLearning.evaluateMethod
evaluate(f::LinearAbsolutePolynomialSum{S}, p::ValuationPolydisc{S,T,N}) where {S, T, N}

Evaluate a sum of linear polynomials at a polydisc.

For each linear polynomial $a_1 T_1 + \cdots + a_n T_n + b$, computes $\max(|a_1| r_1, \ldots, |a_n| r_n, |b + a_1 c_1 + \cdots + a_n c_n|)$ where $r$ is the radius and $c$ the center of the polydisc.

Arguments

  • f::LinearAbsolutePolynomialSum{S}: The sum of linear polynomials
  • p::ValuationPolydisc{S,T,N}: The evaluation point

Returns

Float64: The sum of evaluations across all linear polynomials

source
NonArchimedeanMachineLearning.evaluateMethod
evaluate(poly::LinearPolynomial{S}, p::ValuationPolydisc{S,T,N}) where {S, T, N}

Evaluate a single linear polynomial at a polydisc.

For a linear polynomial $a_1 T_1 + \cdots + a_n T_n + b$, computes $\max(|a_1| r_1, \ldots, |a_n| r_n, |b + a_1 c_1 + \cdots + a_n c_n|)$

Arguments

  • poly::LinearPolynomial{S}: The linear polynomial
  • p::ValuationPolydisc{S,T,N}: The evaluation point

Returns

Float64: The maximum absolute value term

source
NonArchimedeanMachineLearning.gradMethod
grad(f, v::ValuationTangent{S,T,N}) where {S, T, N}

Compute the gradient of a polynomial by evaluating directional derivatives along all coordinates.

Arguments

  • f: The polynomial or function
  • v::ValuationTangent{S,T,N}: A reference tangent vector defining the space

Returns

Vector: Gradient components, one for each coordinate direction

source
NonArchimedeanMachineLearning.parentMethod
parent(F::AbsolutePolynomialSum{S}) where S

Get the polynomial ring of an absolute polynomial sum.

Arguments

  • F::AbsolutePolynomialSum{S}: The absolute polynomial sum

Returns

Ring: The parent ring of the first polynomial

source
NonArchimedeanMachineLearning.partial_gradientMethod
partial_gradient(f, v::ValuationTangent{S,T,N}, gradient_indices) where {S, T, N}

Compute partial derivatives along specified coordinate directions.

Arguments

  • f: The polynomial or function
  • v::ValuationTangent{S,T,N}: A reference tangent vector
  • gradient_indices: Indices of coordinates for which to compute derivatives

Returns

Vector: Directional derivatives for the specified coordinates

source