Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This program will add two sparse matrices in an efficient manner. Sparse matrices have many zero entries, but such entries are omitted in the input

This program will add two sparse matrices in an efficient manner. Sparse matrices have many zero entries, but such entries are omitted in the input file and corresponding data structures to save memory and reduce processing time. You will read in 2 files and output 1 file; you must ask the user for the names of the files in the console. Please read the images below for full instructions.

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

COSC 1430 HW3: Sparse Matrix Addition 1 - Objective This homework assignment will give you a better understanding of how to parse an input file and use structs to combine several variables in one object 2 - Problem For this assignment, you will create a C++ program, named sparseAdd.cpp and you must submit in your home folder on the server. This program will add two sparse matrices in an efficient manner. Sparse matrices have many zero entries, but such entries are omitted in the input file and corresponding data structures to save memory and reduce processing time. You will read in 2 files and output 1 file; you must ask the user for the names of the files in the console. Note: Functions are a good way to increase the modularity of your code. 2.1 Matrices and Matrix Addition Subscripts in input and output files are matrices that are based on a standard mathematical definition, indexed from 1, Matrices of size m n start on 1,1 and go up to m,n. Therefore, the input/output matrices should always have subscripts starting at 1,1. 2.2 Matrix Addition The addition of 2 matrices is done by adding each element of the matrices that are the same size. Assuming a matrix M1 and M2 are of size m x n, the sum would be M3 = M1 rc + M2,c r,c where 1 r m, 1 c n. Mrc represents the value of the matrix at row r and column c, and M1 and M2 are the input matrices. 2.2 Storage You must store each input matrix as a single 1-dimensional dynamic array of structs struct element int r; int c, double value, element* ml-new element[sizel]; //you must determine the size dynamically element* m2-new element/size2]; //you must determine the size dynamically

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Larry Ellison Database Genius Of Oracle

Authors: Craig Peters

1st Edition

0766019748, 978-0766019744

More Books

Students also viewed these Databases questions