ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 4 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 05 May 2017 My Price 9.00

Given an RA ×CA matrix A and an RB ×CB matrix B

Given an RA ×CA matrix A and an RB ×CB matrix B, with 1 ≤ RA, RB ,CA,CB ≤ 300, write a programthat computes the matrix product C = AB. All entries in matrices A and B are integers with absolutevalue less than 1000, so you don’t need to worry about overflow. If matrices A and B do not have theright dimensions to be multiplied, the product matrix C should have its number of rows and columnsboth set to zero.Use the code at provided in the file matrix.data.zip as a basis for your program–the input/outputneeded is already written for you. Matrices will be stored as a structure which we’ll typedefas Matrix. This structure will contain the size of our matrix along with a statically-sizedtwo-dimensional array to store the entries.#define MAXN 300typedef struct Matrix s {size t R, C;int index[MAXN][MAXN];} Matrix;Of course, this is rather inefficient if we need to create a lot of matrices, since every single matrix structholds MAXN*MAXN ints! For this problem, we only use three matrices, so it’s fine for this use, but we’llsee how to dynamically allocate a matrix in problem matrix2.Input FormatLine 1: Two space-separated integers, RA and CA.Lines 2 . . . RA + 1: Line i + 1 contains CA space-separated integers: row i of matrix A.Line RA + 2: Two space-separated integers, RB and CB .Lines RA + 3 . . . RA + RB + 4: Line i + RA + 3 contains CB space-separated integers: row i of matrix A.Sample Input (file matrix.in)3 21 11 2-4 02 31 2 13 2 1Output FormatLine 1: Two space-separated integers RC and CC , the dimensions of the product matrix C .Lines 2 . . . RC + 1: Line i + 1 contains CC space-separated integers: row i of matrix C .1 MIT 6.S096 Assignment 1, Problem 2If A and B do not have the right dimensions to be multiplied, your output should just be one linecontaining 0 0.Sample Output (file matrix.out)3 34 4 27 6 3-4 -8 -4Output ExplanationWe are given⎛ ⎞ 1 1 1 2 1 A = ⎝ 1 2⎠ and B = 3 2 1 −4 0so the product is the 3 × 3 matrix⎛ ⎞ ⎛ ⎞ 1 1 4 4 2 1 2 1 AB = ⎝ 1 2⎠ = ⎝ 7 6 3 ⎠. 3 2 1 −4 0 −4 −8 −4

 

-MIT 6.S096Assignment 1, Problem 2Problem 2: Matrix Multiplication (matrix)Given anRA×CAmatrixAand anRB×CBmatrixB, with 1≤RA,RB,CA,CB≤300, write a programthat computes the matrix productC=AB. All entries in matricesAandBare integers with absolutevalue less than 1000, so you don’t need to worry about overflow. If matricesAandBdo not have theright dimensions to be multiplied, the product matrixCshould have its number of rows and columnsboth set to zero.Use the code atprovided in the file matrix.data.zip as a basis for your program–the input/outputneeded is already written for you. Matrices will be stored as a structure which we’lltypedefasMatrix. This structure will contain the size of our matrix along with a statically-sizedtwo-dimensional array to store the entries.#defineMAXN300typedefstructMatrix s{size tR,C;intindex[MAXN][MAXN];}Matrix;Of course, this is rather ineFcient if we need to create a lot of matrices, since every single matrix structholdsMAXN*MAXNints! ±or this problem, we only use three matrices, so it’s fine for this use, but we’llsee how to dynamically allocate a matrix in problemmatrix2.Input FormatLine 1: Two space-separated integers,RAandCA.²Lines 2.. .RA+1: Linei+1containsCAspace-separated integers: rowiof matrixA.²LineRA+2: Two space-separated integers,RBandCB.²LinesRA+3...RA+RB+4: Linei+RA+3containsCBspace-separated integers: rowiof matrixA.²Sample Input (file matrix.in)3 21 11 2-402 31 2 13 21Output FormatLine 1: Two space-separated integersRCandCC, the dimensions of the product matrixC.Lines 2.. .RC+1: Linei+1containsCCspace-separated integers: rowiof matrixC.1²

Attachments:

Answers

(11)
Status NEW Posted 05 May 2017 08:05 AM My Price 9.00

-----------

Attachments

file 1493972747-Solutions file 2.docx preview (51 words )
H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly -----------onl-----------ine----------- an-----------d g-----------ive----------- yo-----------u e-----------xac-----------t f-----------ile----------- an-----------d t-----------he -----------sam-----------e f-----------ile----------- is----------- al-----------so -----------sen-----------t t-----------o y-----------our----------- em-----------ail----------- th-----------at -----------is -----------reg-----------ist-----------ere-----------d o-----------n -----------THI-----------S W-----------EBS-----------ITE-----------. ----------- Th-----------ank----------- yo-----------u -----------
Not Rated(0)