File: example_dense_reduction_test.go

package info (click to toggle)
golang-github-gorgonia-tensor 0.9.24-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,696 kB
  • sloc: sh: 18; asm: 18; makefile: 8
file content (30 lines) | stat: -rw-r--r-- 443 bytes parent folder | download
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
package tensor

import "fmt"

func Example_sum_Sliced() {
	T := New(WithShape(4, 4), WithBacking([]int{
		1, 2, 3, 4,
		5, 6, 7, 8,
		1, 2, 3, 4,
		5, 6, 7, 8,
	}))
	s, _ := T.Slice(S(1, 3), S(1, 3))
	sum, _ := Sum(s)

	fmt.Printf("T:\n%v\nsliced:\n%v\nSum: %v", T, s, sum)

	// Output:
	// T:
	// ⎡1  2  3  4⎤
	// ⎢5  6  7  8⎥
	// ⎢1  2  3  4⎥
	// ⎣5  6  7  8⎦
	//
	// sliced:
	// ⎡6  7⎤
	// ⎣2  3⎦
	//
	// Sum: 18

}