Daniel B. answered 09/07/22
PhD in Computer Science with 42 years in Computer Research
I think there is a terminology problem.
A VECTOR is a 1-dimensional arrangement of numbers, while
a MATRIX is a 2-dimensional arrangement of numbers.
The author of the problem statement keeps using the term "vector"
possibly because you are supposed to input a 2×4 matrix represented
as a 1×8 vector, and only then interpret it as a 2×4 matrix.
Especially confusing is the term "dot product of two vectors",
which he equates to "matrix multiplication".
Let me try to clarify the two terms.
A DOT PRODUCT of two vectors {ai} and {bi} of the same length k is defined as
{a1, a2, ..., ak} . {b1, b2, ..., bk} = a1b1 + a2b2 + ... + akbk
A MATRIX PRODUCT of a n×k matrix A and a k×m matrix B is an n×m matrix C,
where the i,j-entry of C is the dot product of the i-th row of A and the j-th column of B.
Note that matrix product is defined for a pair of matrices only if the rows of the first matrix
have the same length k as the columns of the second matrix.
Hopefully that answers your question about what a dot product looks like.
If not, please let me know.
Let me rephase the original assignment, where I capitalize all the changes.
-------------------
- We need to create a java program with the name “TheDotProduct2D.java”. This program will transpose a two-dimensional MATRIX (array) using nested loops. Once transpose has occurred, the original and resulting transposed MATRIX will be passed to a new method.
- Then create the “DotProd2D()” method that will take the original MATRIX and the newly transposed MATRIX as the two parameters. In this new method, we must use several nested loops to compute the MATRIX product of the two MATRICES. Then before exiting the “DotProd2D()” method, call the “PrintVect2D()” to print the new MATRIX product.
- Change the “my2D_wide” variable to be a 3x3 MATRIX and run the program again, for example: int[][] my2D_wide={{1,3},{4,6},{15,16}}; // THIS EXAMPLE IS 3x2, NOT 3x3
Target Output1:
Original Vector REPRESENTAION OF A 2x4 MATRIX:
{ 21,32,23,34
13,14,15,16 }
Transposed Vector REPRESENTATION OF A 4x2 MATRIX:
{ 21,13
32,14
23,15
34,16 }
MATRIX Product of THE two MATRICES:
{ 3150,1610
1610,846 }
Target Output2:
Original Vector REPRESENTATION OF A 3x2 MATRIX:
{ 1,3
4,6
15,16 }
Transposed 2x3 MATRIX:
{ 1,4,15
3,6,16 }
---------------------------------