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

Add support for asterisk overloads #24

Open
taless474 opened this issue May 2, 2019 · 0 comments
Open

Add support for asterisk overloads #24

taless474 opened this issue May 2, 2019 · 0 comments
Labels
enhancement New feature or request

Comments

@taless474
Copy link
Contributor

taless474 commented May 2, 2019

Using Blaze, the result of a matrix * vector is the same as their dot product:

blaze::DynamicVector<int> a{1, 1, 0};
blaze::DynamicMatrix<int> b{{1, 2, 3}, {-1, -2, -3}};
auto ans = b * a;

would results in

(           3 )
(          -3 )

Having a matrix * matrix is also results in their dot product:

blaze::DynamicMatrix<int> a{{1, 0}, {1, -1}, {2, -2}};
blaze::DynamicMatrix<int> b{{1, 2, 3}, {-1, -2, -3}};
auto ans = b * a;
(            9           -8 )
(           -9            8 )

That would be really useful to have the same overloads for a tensor. I think we need to add the equivalents of dot3d1d, dot3d2d and dot2d3d.

For example, for calculating tensor * vector (like in dot3d1d), the for loop in the following:

blaze::DynamicVector<int> a{1, 1, 0};
blaze::DynamicTensor<int> b{{{1, 2, 3}, {-1, -2, -3}},
                                              {{4, 5, 6}, {-4, -5, -6}}};
blaze::DynamicMatrix<int> ans(b.pages(), b.rows());

for (std::size_t i = 0; i != b.pages(); ++i)
     blaze::row(blaze::submatrix(ans, i, 0, 1, b.rows()), 0) =
         blaze::trans(blaze::pageslice(b, i) * a);

would results in the desired ans = b*a.

@hkaiser hkaiser added the enhancement New feature or request label May 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants