Vectors and Matrices: Program 1: Received Unauthorized Assistance On This Academic Work."
Vectors and Matrices: Program 1: Received Unauthorized Assistance On This Academic Work."
PROGRAM 1
By
Kristen Conguista
kc1843
“On my honour as a Mississippi State University student, I have neither given nor
received unauthorized assistance on this academic work.”
CSE 2383
Class Section #02
Rikk Anderson
September 14, 2016
Problem Specification:
Three functions need to be created. The first function should multiply two vectors of
same length together to get the dot product. The second function should multiply a
matrix and a vector together with the matrix’s column length matching the vector length.
The final function should take a matrix and find the transpose of it. This essentially is
reversing the order of the row and column indexes.
The only function that should print anything is the main function. Since the transpose
and MxV functions are of void variable types, they should modify the vectors and
matrices passed into them as parameters. The dot product function should return the
total.
Analysis Questions:
1. The asymptotic complexity of the dot product function is O(i) because the vectors are
both of length i. It takes O(i) to traverse through one vector, so O(i) + O(i) will simplify
to O(i).
Note that matrices and vectors are not given to be squares, but must instead be assumed
to be rectangular. Therefore, the dimensions are assumed to be of different sizes and
cannot be reduced to O(n^3) or O(n^2).
Conclusions:
The objectives of this assignment is to introduce the C++ programming language. This
included using single and multi-dimensional arrays, using functions, and passing arrays
as parameters to functions.
While I personally felt unprepared for the assignment, I was still able to complete the
objectives. The first objective of using arrays was completed by creating the variables in
which to store the arrays. For a single variable array, this means essentially storying
items as a list. Multi-dimensional arrays were a bit more difficult and required the use of
two index values, which could be thought of as row and column values. The next portion
of the objective was to use functions. This was easily completed by writing the function
codes and calling them to be used in the main function, which leads to the last objective
of passing arrays as parameters into functions. In the call, the arrays were simply
identified as their variable names. In the function parameters, they were identified by
their variable type, name, and dimensions. It should be noted that two of the three
functions outside of the main function were of variable type void, meaning that they
returned nothing. This meant that the arrays passed in had to be modified globally rather
than changed locally.
References: