Skip to content

Commit

Permalink
Revert "Update Matrix"
Browse files Browse the repository at this point in the history
This reverts commit 413ba3e.
  • Loading branch information
itsubaki committed Oct 14, 2023
1 parent 413ba3e commit 625470e
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions matrix/matrix.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
type Matrix [][]float64

func New(v ...[]float64) Matrix {
m := make(Matrix, len(v))
copy(m, v)
return m
out := make(Matrix, len(v))
copy(out, v)
return out
}

func Zero(m, n int) Matrix {
Expand Down Expand Up @@ -210,12 +210,14 @@ func BroadcastTo(shape []int, m Matrix) Matrix {
a, b := shape[0], shape[1]

if len(m) == 1 && len(m[0]) == 1 {
v := make([]float64, a*b)
for i := 0; i < a*b; i++ {
v[i] = m[0][0]
out := Zero(a, b)
for i := 0; i < a; i++ {
for j := 0; j < b; j++ {
out[i][j] = m[0][0]
}
}

return Reshape(shape, New(v))
return out
}

if len(m) == 1 {
Expand Down

0 comments on commit 625470e

Please sign in to comment.