Skip to content

Define values for ArraySpace - #688

Merged
jishnub merged 1 commit into
masterfrom
jishnub/arrayspace_values
Aug 24, 2026
Merged

Define values for ArraySpace#688
jishnub merged 1 commit into
masterfrom
jishnub/arrayspace_values

Conversation

@jishnub

@jishnub jishnub commented Aug 22, 2026

Copy link
Copy Markdown
Member

Fixes #647.

values(f) errored for an array-valued Fun, so iszero broke for these
after #635 started consulting values:

julia> Af = Fun(t -> [0 1; -10cos(t)-1 -24-19sin(t)], Fourier(0..2pi));

julia> iszero(Af)
ERROR: Override for ApproxFunBase.ArraySpace(...)

There were three separate causes:

  • itransform was only defined for a VectorSpace, so a MatrixSpace fell
    through to the generic Space method and reached checkcanonicalspace,
    which errors because canonicalspace is applied component-wise and an
    ArraySpace of canonical spaces is therefore its own canonical space. The
    method is now defined for an ArraySpace, and reshapes the values to the
    shape of the space.

  • The component coefficients are views if the interlacer is trivial, in which
    case pad! can't resize them. This broke values for a VectorSpace as
    well, e.g. Fun(x->[exp(x),sin(x)], -1..1). pad is used instead.

  • _values asserted a Vector{float(T)} return type for every space over a
    numeric domain. UnivariateSpace only constrains the domain type, so an
    ArraySpace over one matched, and the assertion rejected the array-valued
    result. The assertion is now restricted to spaces with a scalar range type.

Additionally, points(f::Fun{<:ArraySpace}) passed ncoefficients(f), the
total number of interlaced coefficients, where points(::ArraySpace, n)
expects a per-component count. This was silently wrong for Fourier, and an
error for a finite-dimensional component space such as PointSpace. It now
matches the padding used in itransform, so values(f) == f.(points(f)).

Tests cover PointSpace and HeavisideSpace components at vector and matrix
shapes; the latter is over a numeric domain and has a trivial interlacer, so
it exercises the second and third points above.

Downstream ApproxFun tests pass against this branch.

🤖 Generated with Claude Code

`values(f)` errored for an array-valued `Fun`, which broke `iszero`
since it started consulting `values` in #635. Three separate causes:

* `itransform` was only defined for `VectorSpace`, so a `MatrixSpace`
  fell through to the generic `Space` method and hit
  `checkcanonicalspace`, which errors as an `ArraySpace` of canonical
  spaces is its own canonical space. Widen the method to `ArraySpace`
  and reshape the values to the shape of the space.

* The component coefficients may be views, so `pad!` may not resize
  them. Use `pad` instead.

* `_values` asserted a `Vector{float(T)}` return for any space over a
  numeric domain, which includes array-valued ones. Restrict the
  assertion to spaces with a scalar range type.

Also fix `points(f::Fun{<:ArraySpace})`, which passed the total number
of interlaced coefficients where a per-component count is expected, so
that `values(f) == f.(points(f))`.

Fixes #647

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@jishnub
jishnub merged commit 67bed18 into master Aug 24, 2026
20 checks passed
@jishnub
jishnub deleted the jishnub/arrayspace_values branch August 24, 2026 08:25
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 this pull request may close these issues.

Error in iszero in Julia v1.10

1 participant