Files
tensor/linalg/det_factor_dispatch_test.go
T
petrbalvin af4ee19703
Release / gates (push) Successful in 4m38s
Test / test (push) Successful in 5m16s
Release / release (push) Successful in 35s
feat: initial release
Assisted-by: GLM 5.3 Flash
2026-09-03 10:00:00 +02:00

35 lines
1.0 KiB
Go

// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
// SPDX-License-Identifier: MIT
package linalg
import (
"math"
"testing"
)
// TestDetFactorsThroughParallelDispatch drives base.Factor's rank-1
// update dispatch through the public Det entry: a 200 by 200 upper
// triangular matrix keeps every pivot on the diagonal, and the first
// pivot's update spans 199 rows times 200 columns, past the dispatch
// quantum, so the crewed path runs rather than the inline one. No row
// changes under the elimination, since the multiplier of every row is
// zero, so the determinant is exactly 2 to the 200th, which float64
// holds as an exact power of two.
func TestDetFactorsThroughParallelDispatch(t *testing.T) {
const n = 200
vals := make([]float64, n*n)
for i := range n {
for j := i; j < n; j++ {
vals[i*n+j] = 2
}
}
d, err := Det(mustFloats(t, vals, n, n))
if err != nil {
t.Fatalf("Det: %v", err)
}
if want := math.Ldexp(1, 200); d != want {
t.Fatalf("Det = %v, want exactly %v", d, want)
}
}