Create class to representing and manipulating sparse matrice

Assignment Help Computer Engineering
Reference no: EM13332239

Motivation

A sparse matrix is defined as a matrix in which a significant number of the elements are set to some base value, 0 for most applications. This provides an excellent opportunity for memory savings as we do not always need to represent every element in the matrix. For example, consider the following matrix:

0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 1

At first glance, one might attempt to allocate a 2 dimmensional array of size 4x4 to represent the matrix. While this would provide an adequate solution for a matrix of this small size, imagine a case where a 100000x100000 matrix was filled with only one non-zero value. Obviously, there is room for some simplification here. This is where you come in.

General Description

Your job in this assignment is to create a class for representing and manipulating sparse matrices. Your class should represent the matrix in a manner such as the one described below. This method provides a reasonable savings in memory and, if properly coded, can avoid incurring too much of a speed penalty.

Sparse Array Example

The method to be used in this assignment uses a row simplification in order to reduce the matrix. By eliminating all zeros not contained between non-zero fields, the COLUMNS can be represented by much smaller data sets. This concept is best illustrated by an example.

The following sparse array:

1 0 0 0 1
0 1 1 0 0
0 0 1 0 0
0 1 0 1 1
0 0 0 0 0

Can be represented as follows:

COLUMN Data Offset Size
0 [1] 0 1
1 [1 0 1] 1 3
2 [1 1] 1 2
3 [1] 3 1
4 [1 0 0 1] 0 4

The memory used by this sparce array = 148 bytes

Where Offset, an integer array, represents the number of zeros before the first non-zero element of each COLUMN. Size, an integer array, represents the number of elements in the data set.As you can see, there is no data lost in this simpler representation and some memory savings can already be realized.

Specific Program Requirements

o Your program MUST use COLUMNS of Data to represent the matrix.
o For this program you will have to have a 'set' and 'get' member functions (see 'sarray.h' below) these SHOULD NOT BE called by any of the operator member functions.
o In the 'get' and 'set' member functions 'i' is ROW number and 'j' is the COLUMN number of the element.

example:
0 0 0 0 0
0 0 0 1 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
the only '1' value in this matrix is located at
i=1
j=3

o Your class should implement the member functions defined in sarray.h. DO NOT change the names of these functions.
o Values within the matrix should be stored as double.
o Matrix arithmetic should be performed using operator overloading.
o All operations must be done within the class. ie: no functions to do math outside class.
o You must use new/delete for memory allocation instead of malloc/free or static allocation.

Reference no: EM13332239

Questions Cloud

The absolute uncertainty written in the form : The absolute uncertainty written in the form
How much net work does the engine do in a cycle : An engine with reservoir temperatures of 387 K and 725 K operates at half the efficiency of a Carnot engine. If the hot reservoir supplies the engine 4670 J of heat energy during each cycle, how much net work does the engine do in a cycle?
How fast must he go in order to catch the ball : During a game of football, the ball is kicked by the punter with a speed of 20m/s at an angle of 40 degrees above the horizontal. A player on the other team, standing 50m away, starts running to catch the ball immediately after it is kicked. ASsu..
What was the avg force of vertical ground reaction force : After crossing the finish line, the marathon runner stops, and then performs a celebratory vertical jump. what was the avg. force of the vertical ground reaction force
Create class to representing and manipulating sparse matrice : For this program you will have to have a 'set' and 'get' member functions (see 'sarray.h' below) these SHOULD NOT BE called by any of the operator member functions.
What will the velocity of the referee be after the collision : A 140 kg hockey player skating at -12 m/s runs into the back of a referee that weighs 70 kg and is traveling in the same direction but at only -6 m/s. what will the velocity of the referee be after the collision
A capillary tube with a closed end is place into water : A capillary tube with a closed end is place into water.
Calculate the bulk modulus of the liquid : In a liquid with a density of 1450kg/m3 , longitudinal waves with a frequency of 390Hz are found to have a wavelength of 7.50m
What was the angular acceleration of the tires : The tires of a car make 62 revolutions as the car reduces its speed uniformly from 90km/h to 40km/h . The tires have a diameter of 0.86m. What was the angular acceleration of the tires

Reviews

Write a Review

Computer Engineering Questions & Answers

  Risk linked with using public infrastructure like internet

Describe in detail some probable difficulties and risk associated with utilizing a public infrastructure like the Internet, as part of the private business solution.

  Educating about computer viruses and malware

The University of Calgary provides a senior-level computer science course known as, “Computer Viruses and Malware.” The course taught the students how to write the viruses, worms, and Trojan Horses. It also describes the history of the computer vi..

  A new column would be added to the table

A table was created, Whse.IStock. This table contains a column, SKU that holds stock numbers. The SKU column was created as a data type char(20) and right-justified the stock numbers with leading blanks.

  Discuss their main applicability as well as their advantages

Autonomous (intelligent) software agents are used in Artificial Intelligence to solve an increasing number of complex problems.

  Give sign that could be mounted outside the store

give sign that could be mounted outside the store

  Attributes and specifications of software package

Build a weighted ranking in accordance to your own evaluation of attributes and specifications of each software package.

  Consider architecture a that has the addressing

Consider architecture A that has the addressing modes below for the ADD instruction. Based on the ADD instruction, is this architecture better be encoded as a fixed-length instruction or a variablelength

  Describe uses for each of intellectual property protection

Give two examples of how a social pressure or need led to the development of a new information technology. Give two examples of how the adoption of a new information technology changed society.

  Define the way in which a person writes or sends e-mails

explain a scenario in which someone displayed bad netiquette. How did someone react to receiving the email? what could the sender have done differently to display good netiquette.

  Find an isomorphic between the boolean algebra

Find an isomorphic between the boolean algebra with set b ={ 0,1,p,p' } in formal logic and the boolean algebra wih set p({a,b}).

  Program to implement the calculations

Write down a program which has a function named presentValue which carry out this calculation. The function must accept future value, annual interest rate, and number of the years as arguments.

  What are the implications for management

Reduction in cost of hardware with time.What are the implications for management of each of the trends.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd