File: tensor_test.go

package info (click to toggle)
golang-github-yourbasic-graph 1.0.5-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 400 kB
  • sloc: makefile: 2
file content (41 lines) | stat: -rw-r--r-- 974 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package build

import "testing"

func TestTensor(t *testing.T) {
	res := Empty(4).Tensor(Grid(1, 2))
	exp := "8 []"
	if mess, diff := diff(res.String(), exp); diff {
		t.Errorf("Tensor %s", mess)
	}
	Consistent("Tensor", t, res)

	res = Kn(1).Tensor(Grid(1, 2))
	exp = "2 []"
	if mess, diff := diff(res.String(), exp); diff {
		t.Errorf("Tensor %s", mess)
	}
	Consistent("Tensor", t, res)

	exp = "4 [{0 3} {1 2}]"
	res = Grid(1, 2).Tensor(Grid(1, 2))
	if mess, diff := diff(res.String(), exp); diff {
		t.Errorf("Tensor %s", mess)
	}
	Consistent("Tensor", t, res)

	exp = "6 [{0 3} {1 2} {2 5} {3 4}]"
	res = Grid(1, 3).Tensor(Grid(1, 2))
	if mess, diff := diff(res.String(), exp); diff {
		t.Errorf("Tensor %s", mess)
	}
	Consistent("Tensor", t, res)

	for m := 0; m < 4; m++ {
		for n := 0; n < 4; n++ {
			Consistent("Tensor", t, Kn(m).Tensor(Kn(n)))
			Consistent("Tensor", t, Kn(m).Tensor(Grid(m, m+n)))
			Consistent("Tensor", t, Grid(m, m+n).Tensor(Kn(m)))
		}
	}
}