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

Function Add

data-structures/matrix/matrix.go:125–135  ·  view source on GitHub ↗
(A *Matrix, B *Matrix)

Source from the content-addressed store, hash-verified

123}
124
125func Add(A *Matrix, B *Matrix) *Matrix {
126 result := MakeMatrix(make([]float64, A.cols*A.rows), A.cols, A.rows)
127
128 for i := 0; i < A.rows; i++ {
129 for j := 0; j < A.cols; j++ {
130 result.SetElm(i, j, A.GetElm(i, j)+B.GetElm(i, j))
131 }
132 }
133
134 return result
135}
136
137func Substract(A *Matrix, B *Matrix) *Matrix {
138 result := MakeMatrix(make([]float64, A.cols*A.rows), A.cols, A.rows)

Callers

nothing calls this directly

Calls 3

MakeMatrixFunction · 0.85
SetElmMethod · 0.80
GetElmMethod · 0.80

Tested by

no test coverage detected