MCPcopy
hub / github.com/arnauddri/algorithms / substract

Method substract

data-structures/matrix/matrix.go:104–115  ·  view source on GitHub ↗
(B *Matrix)

Source from the content-addressed store, hash-verified

102}
103
104func (A *Matrix) substract(B *Matrix) error {
105 if A.cols != B.cols && A.rows != B.rows {
106 return errors.New("Wrong input sizes")
107 }
108 for i := 0; i < A.rows; i++ {
109 for j := 0; j < A.cols; j++ {
110 A.SetElm(i, j, A.GetElm(i, j)-B.GetElm(i, j))
111 }
112 }
113
114 return nil
115}
116
117func (A *Matrix) scale(a float64) {
118 for i := 0; i < A.rows; i++ {

Callers 1

TestSubstractFunction · 0.80

Calls 2

SetElmMethod · 0.95
GetElmMethod · 0.95

Tested by 1

TestSubstractFunction · 0.64