@@ -454,6 +454,50 @@ function test_svd_algs_batched_oversized(
454454 end
455455end
456456
457+ # Whether the driver for `alg` reports support for ragged batches of each SVD function,
458+ # and if so, that ragged batches of all distinct sizes are decomposed correctly.
459+ function test_svd_algs_batched_ragged_support (
460+ T:: Type , algs, batch_size:: Int ;
461+ supported:: Bool = true ,
462+ atol:: Real = 0 , rtol:: Real = precision (eltype (T)),
463+ kwargs...
464+ )
465+ summary_str = testargs_summary (T)
466+ return @testset " batched svd ragged support, algorithm $alg $summary_str " for alg in algs
467+ driver = MatrixAlgebraKit. default_driver (alg, T)
468+ for f! in (svd_compact!, svd_full!, svd_vals!)
469+ @test MatrixAlgebraKit. supports_ragged_batch (f!, alg, driver, T) == supported
470+ @test MatrixAlgebraKit. supports_ragged_batch (f!, alg, MatrixAlgebraKit. DefaultDriver (), T) == supported
471+ end
472+ # only the SVD functions have ragged batched implementations
473+ @test ! MatrixAlgebraKit. supports_ragged_batch (qr_full!, alg, driver, T)
474+
475+ if supported
476+ Ar = [instantiate_matrix (T, (2 + i, 1 + (i * 7 ) % (batch_size + 3 ))) for i in 1 : batch_size]
477+ @test allunique (size .(Ar))
478+
479+ U, S, Vᴴ = @testinferred batched_svd_compact (Ar; alg)
480+ for (a, u, s, vᴴ) in zip (Ar, U, S, Vᴴ)
481+ @test u * s * vᴴ ≈ a
482+ @test isisometric (u)
483+ @test isisometric (vᴴ; side = :right )
484+ end
485+
486+ Uf, Sf, Vfᴴ = @testinferred batched_svd_full (Ar; alg)
487+ for (a, u, s, vᴴ) in zip (Ar, Uf, Sf, Vfᴴ)
488+ @test u * s * vᴴ ≈ a
489+ @test isunitary (u)
490+ @test isunitary (vᴴ)
491+ end
492+
493+ Sv = @testinferred batched_svd_vals (Ar; alg)
494+ for (s, sv) in zip (S, Sv)
495+ @test collect (diagview (s)) ≈ collect (sv)
496+ end
497+ end
498+ end
499+ end
500+
457501function test_svd_trunc (
458502 T:: Type , sz;
459503 atol:: Real = 0 , rtol:: Real = precision (eltype (T)),
0 commit comments