Skip to content

SampledIntegralProblem matrix integration over non-float axis fails in v5 fast path #341

Description

@cmichelenstrofer

Describe the bug 🐞

Starting with version 5, Integrating matrices along an axis does not work for Unitful types. This worked with version 4.7 and earlier. Seems to be a problem with the initialization of the accumulator.

Expected behavior

A clear and concise description of what you expected to happen.

Minimal Reproducible Example 👇

using Integrals, Unitful

data = ones(2, 3)
axis = [0.0, 1.0, 2.0]u"m"

prob = SampledIntegralProblem(data, axis; dim=2)
solve(prob, TrapezoidalRule())

Error & Stacktrace ⚠️

DimensionError: 0.0 and 0.5 m are not dimensionally compatible

Environment (please complete the following information):

  • Output of using Pkg; Pkg.status()
Integrals v5.4.2
Unitful v1.28.0
  • Output of using Pkg; Pkg.status(; mode = PKGMODE_MANIFEST)
  • Output of versioninfo()
Julia Version 1.12.6
Commit 15346901f00 (2026-04-09 19:20 UTC)
Build Info:
  Official https://julialang.org release
Platform Info:
  OS: macOS (arm64-apple-darwin24.0.0)
  CPU: 8 × Apple M3
  WORD_SIZE: 64
  LLVM: libLLVM-18.1.7 (ORCJIT, apple-m3)
  GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 4 virtual cores)
Environment:
  JULIA_NO_VERIFY_HOSTS = pkg.julialang.org,github.com
  JULIA_SSL_CA_ROOTS_PATH = 
  JULIA_EDITOR = vim

Additional context

The problem seems to be the initialization of out as float.

out = zeros(T, m)
...
out[j] += w * data[j, i]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions