feat: initial release
Assisted-by: GLM 5.3 Flash
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
// Copyright (c) 2026 Petr Balvín <opensource@petrbalvin.org> (https://petrbalvin.org)
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
package linalg
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"sourcedock.dev/petrbalvin/tensor/internal/core"
|
||||
)
|
||||
|
||||
// mustFloats builds a float array, failing the test on a bad shape.
|
||||
// Without an explicit shape it defaults to a vector of len(vals).
|
||||
func mustFloats(t *testing.T, vals []float64, shape ...int) *core.Array {
|
||||
t.Helper()
|
||||
if len(shape) == 0 {
|
||||
shape = []int{len(vals)}
|
||||
}
|
||||
a, err := core.FromFloats(vals, shape...)
|
||||
if err != nil {
|
||||
t.Fatalf("FromFloats(%v, %v): %v", vals, shape, err)
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
// mustFromFloats builds a float array, failing the test on a bad shape.
|
||||
func mustFromFloats(t *testing.T, vals []float64, shape ...int) *core.Array {
|
||||
t.Helper()
|
||||
a, err := core.FromFloats(vals, shape...)
|
||||
if err != nil {
|
||||
t.Fatalf("FromFloats(%v, %v): %v", vals, shape, err)
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
// mustFromFloat32s builds a float32 array, failing the test on a bad shape.
|
||||
func mustFromFloat32s(t *testing.T, vals []float32, shape ...int) *core.Array {
|
||||
t.Helper()
|
||||
a, err := core.FromFloat32s(vals, shape...)
|
||||
if err != nil {
|
||||
t.Fatalf("FromFloat32s(%v, %v): %v", vals, shape, err)
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
// mustFromInts builds an int array, failing the test on a bad shape.
|
||||
func mustFromInts(t *testing.T, vals []int64, shape ...int) *core.Array {
|
||||
t.Helper()
|
||||
a, err := core.FromInts(vals, shape...)
|
||||
if err != nil {
|
||||
t.Fatalf("FromInts(%v, %v): %v", vals, shape, err)
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
// mustFromComplexes builds a complex array, failing the test on a bad shape.
|
||||
func mustFromComplexes(t *testing.T, vals []complex128, shape ...int) *core.Array {
|
||||
t.Helper()
|
||||
a, err := core.FromComplexes(vals, shape...)
|
||||
if err != nil {
|
||||
t.Fatalf("FromComplexes(%v, %v): %v", vals, shape, err)
|
||||
}
|
||||
return a
|
||||
}
|
||||
Reference in New Issue
Block a user