How to print out the matrices

Assignment Help Computer Engineering
Reference no: EM1330379

My assignment is to test which algorithm is more efficient in transposing a matrix: a Naive or Fast Sparse algorithm. I need to construct functions for reach algorithm that call from an input file, which is a sparse Matrix.

A text file called M5x5.mat looks like this.

5 5 11
0 3 297
1 0 230
1 4 291
2 0 390
2 2 250
2 3 286
2 4 330
3 2 333
3 4 464
4 0 184
4 3 347

5 and 5 represent the 5x5 matrix and 11 the number of elements. M10x10 has 50 elements and so on. The matrice is set up <row, col, value>, with the first column being 'row', second column being 'col' and the third column being 'value'.

My main problem is that I don't know how to convert a text file like this into a matrice that I can use. I wasn't taught how to in my previous classes and I think my professor assumes that we know how.

I need to know how to print out the matrice as it appears on the text and a new transposed Matrice.

My primary assignment was to measure each algorithm in efficiency. I do this by adding units every time the for loop executes.

This is the Fast Transpose algorithm in pseudocode, using the units counter as mentioned:

start of algorithm/

for (i=0; i < M[0].row; i++)
rowterms[i]=0;
units++;

for (i=1; i<=M[0].value; i++)
rowterms[M[i].col]++;
units++;

startingposition[0]=1
for (i=1; i< M[0].row; i++)
startingposition[i] = startingposition[i-1] + rowterms[i-1]
units++;

/*primary transpose alg*/
for (i=1; i<= M[0].value; i++)
{

j=startingposition[M[i].col]++

/*Mt is the transposed matrice*/
Mt[j].row = M[i].col
Mt[j].col = M[i].row
Mt[j].value = M[i].value
units++;

/end of algorithm

That's just one of the algorithms.

Summing up what I need:

1. How to call the input matrice files and implement them in the functions. Or to convert the txt file into a matrice?

2. How to print out the matrices.

3. I would like to have the pseudocode above converted into a java function complemented with the calling of the Matrice file, but if that's too much, I understand.

Any help at all would be appreciated.

Reference no: EM1330379

Questions Cloud

Illustrate what are the benefits and drawbacks : Illustrate what are the benefits and drawbacks of dynamic pricing for that particular company.
Hersey and blanchard-s situational theory leadership : How does Hersey and Blanchard's Situational Theory leadership apply to your organization?
Modifying the roles of human resource : Use at least five references from the reading assignment, Internet articles, Electronic Reserve Readings (ERR) articles, and/or HR journal articles to support your paper.
Renewable energy producers : To meet the objective of increasing fuel options for automobiles in order to reduce demand for and prices of petroleum, suppose  there is a commitment to make available plug in hybrid vehicles that will be accepted by customers as soon as possible.
How to print out the matrices : My main problem is that I don't know how to convert a text file like this into the matrice that I can use. I wasn't taught how to in my previous classes and I think my professor imagine that we know how.
Explain brick and mortar : Explain Brick and Mortar and explain how the supply chain would be modified from brick and mortar of such a company as Budweiser
Evaluating either it should build the company the firm : Later on evaluating either it should build the company the firm decides that it should:
Details regarding annuity : Sam deposited $1,000 dollars today in a fixed-rate, tax-deferred annuity, which guarantees an 8% return with quarterly compounding. Find out the value of the annuity at maturity?
Challenges in public sector human resource management : Search a recent article on the Internet which discusses the challenges for HRM related issues in the public sector. Discuss the issues and potential impacts if not resolved.

Reviews

Write a Review

Computer Engineering Questions & Answers

  How many register windows must be saved to memory

How many register windows must be saved to memory.

  Test a program that generates 1000 random numbers

write and test a program that generates 1000 random numbers between 1 and 6 and stores them in a data file.Write down a second program the takes the data produced by the first program and analyses it to produce a table showing the number of times ..

  Issues or problems related to database architecture

In a Microsoft Word document, write an 800- to 1,000-word research paper. Your research paper should contain the following sections.

  Describe different structures and areas within brain

make sure to discuss the location in the brain, their functions, disorders/pathology related to damage to these structures, and other important information in regards to these structures.

  Make a public static method named comparescores

Write down a public static method named compareScores that takes two doubles as its arguments and returns the integer value of -1 if the first argument is less than the second, 0 if the first argument is the same as the second, and +1 if the first..

  Modify the pseudocode and optimize

offer valid reasons why the pseudocode is now more efficient.

  Program that has a function named presentvalue

Program that has a function named presentValue

  Explain networking of cis 505

Explain networking of CIS 505? 1. Network Neutrality 2. Web2.0

  Computer forensics investigation

As a new computer forensics investigator and as a matter of the forensics policy and procedure, you will require to understand the procedures for processing incident scene for the digital and the logical evidence.

  How to create the clients by service rep report

How to create the clients by service rep report create mailing label for client table

  Explaining the role of cio

Assess the role of CIO within any health care organization and explain the key characteristics a CIO would require to possess to be effective in that position.

  Make an idef1x e-r diagram

The scenario is that the Public Affairs Office at Highline University receives requests for speakers on particular topics. To be capable to respond to such request, that office wants to build a database.

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