0% found this document useful (0 votes)
65 views3 pages

Vectors and Matrices: Program 1: Received Unauthorized Assistance On This Academic Work."

The document describes a programming assignment to create three functions - one to calculate the dot product of two vectors, another to multiply a matrix and vector, and a third to find the transpose of a matrix. It analyzes the asymptotic complexity of each function and discusses completing the objectives of using arrays, functions, and passing arrays as parameters in C++.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views3 pages

Vectors and Matrices: Program 1: Received Unauthorized Assistance On This Academic Work."

The document describes a programming assignment to create three functions - one to calculate the dot product of two vectors, another to multiply a matrix and vector, and a third to find the transpose of a matrix. It analyzes the asymptotic complexity of each function and discusses completing the objectives of using arrays, functions, and passing arrays as parameters in C++.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

VECTORS AND MATRICES:

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).

2. The asymptotic complexity of the MxV function is O(ij^2) because it requires


traversing through a matrix of dimensions i x j and a vector of dimensions 1 x j. O(ij) *
O(j) results in O(ij^2).

3. The asymptotic complexity of the transpose function is O(ij) because it requires


traversal through every element of a matrix of dimensions i x j.

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:

“C++ Multi-dimensional Arrays,” Tutorials Point,


http://www.tutorialspoint.com/cplusplus/cpp_multi_dimensional_arrays.htm (accessed
Sept 13, 2016)

All other resources:


* in class notes

You might also like