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

Method add

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

Source from the content-addressed store, hash-verified

89}
90
91func (A *Matrix) add(B *Matrix) error {
92 if A.cols != B.cols && A.rows != B.rows {
93 return errors.New("Wrong input sizes")
94 }
95 for i := 0; i < A.rows; i++ {
96 for j := 0; j < A.cols; j++ {
97 A.SetElm(i, j, A.GetElm(i, j)+B.GetElm(i, j))
98 }
99 }
100
101 return nil
102}
103
104func (A *Matrix) substract(B *Matrix) error {
105 if A.cols != B.cols && A.rows != B.rows {

Callers 1

TestAddFunction · 0.80

Calls 2

SetElmMethod · 0.95
GetElmMethod · 0.95

Tested by 1

TestAddFunction · 0.64