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

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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