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

cannot multiply matrix by vector #6

Open
sneakyimp opened this issue Dec 29, 2022 · 0 comments
Open

cannot multiply matrix by vector #6

sneakyimp opened this issue Dec 29, 2022 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@sneakyimp
Copy link

In matlab/octave, I can define a m x n matrix (3 x 5 in this case) and multiply it by a n x 1 column vector (5 x 1 in this case). It yields a 3x1 column vector:

X = [1 1 1 1 1; 2 2 2 2 2; 3 3 3 3 3]
    X =

       1   1   1   1   1
       2   2   2   2   2
       3   3   3   3   3

octave:427> w = [1;2;3;4;5]
    w =

       1
       2
       3
       4
       5

octave:428> X * w
    ans =

       15
       30
       45

However, ghostjat cannot multiply a 3 x 5 matrix times a vector with size=5:

require __DIR__ . '/np/vendor/autoload.php';
use Np\matrix;
use Np\vector;

$x = Np\matrix::ar([
        [1,1,1,1,1],
        [2,2,2,2,2],
        [3,3,3,3,3]
]);

$w = Np\vector::ar([1, 2, 3, 4, 5]);

$p = $x->dot($w); // throws exception Mismatch Dimensions of given Objects! Obj-A col & Obj-B row amount need to be the same!
$p = $x->multiply($w); // throws exception Mismatch Dimensions of given Objects! Obj-A col & Obj-B row amount need to be the same!
@ghostjat ghostjat pinned this issue Dec 29, 2022
@ghostjat ghostjat added the bug Something isn't working label Jan 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants