File: dense_reduction_methods.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 (39 lines) | stat: -rw-r--r-- 920 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
31
32
33
34
35
36
37
38
39
package tensor

import "github.com/pkg/errors"

func (t *Dense) Sum(along ...int) (retVal *Dense, err error) {
	var e Engine = t.e
	if sumer, ok := e.(Sumer); ok {
		var ret Tensor
		if ret, err = sumer.Sum(t, along...); err != nil {
			return
		}
		return ret.(*Dense), nil
	}
	return nil, errors.Errorf("Engine does not support Sum")
}

func (t *Dense) Max(along ...int) (retVal *Dense, err error) {
	var e Engine = t.e
	if maxer, ok := e.(Maxer); ok {
		var ret Tensor
		if ret, err = maxer.Max(t, along...); err != nil {
			return
		}
		return ret.(*Dense), nil
	}
	return nil, errors.Errorf("Engine does not support Max")
}

func (t *Dense) Min(along ...int) (retVal *Dense, err error) {
	var e Engine = t.e
	if miner, ok := e.(Miner); ok {
		var ret Tensor
		if ret, err = miner.Min(t, along...); err != nil {
			return
		}
		return ret.(*Dense), nil
	}
	return nil, errors.Errorf("Engine does not support Min")
}