Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TensorProduct is bottleneck #21

Open
itsubaki opened this issue May 17, 2022 · 1 comment
Open

TensorProduct is bottleneck #21

itsubaki opened this issue May 17, 2022 · 1 comment
Assignees

Comments

@itsubaki
Copy link
Owner

after

@itsubaki itsubaki self-assigned this May 17, 2022
@itsubaki
Copy link
Owner Author

itsubaki commented May 17, 2022

q/pkg/math/matrix/matrix.go

Lines 300 to 319 in 74c1226

func (m Matrix) TensorProduct(n Matrix) Matrix {
p, q := m.Dimension()
a, b := n.Dimension()
out := make(Matrix, 0, p*a)
for i := 0; i < p; i++ {
for k := 0; k < a; k++ {
r := make([]complex128, 0, q*b)
for j := 0; j < q; j++ {
for l := 0; l < b; l++ {
r = append(r, m[i][j]*n[k][l])
}
}
out = append(out, r)
}
}
return out
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant