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: 10 Weeks Ago, 5 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 25 Apr 2017 My Price 9.00

Introduction to ProgrammingMatrix Multiplication

The computer language must be done in python, the problem is at the bottom of the page. The algorithms given need on the assignment need to be manipulated to work for dot multiplication of a matrix.

 

Introduction to ProgrammingMatrix MultiplicationThe following program willaddtwo “square arrays.” Note the change from the code we workedon in class.# add 2 square matricesdef add(a,b):lena=len(a)x=[lena*[0] for i in range(lena)]for i in range(lena):for j in range(lena):x[i][j]=a[i][j]+b[i][j]return xx=[[1,1],[1,1]]y=[[1,1],[3,4]]c=add(x,y)print(c)Write a function mult(a,b)thatwill “multiply” the two square matrices a and b as we discussedin class.If we write c=mult(a,b) then c[i][j] will be the dot product of rowiof matrix a with columnjofmatrix b.Recall that if we have 2 lists a and b of the same size, then we can define dot as follows:z=[1,2,3]v=[4,5,6]def dot(a,b):lena=len(a)g=0for i in range(lena):g=g+a[i]*b[i]return gprint(dot(z,v))Problem1. Ask your user for an integer n.2. Create two nXn matrices (two dimensional lists) filled with random integers. Call one A andthe other B.3. Print A and B.4. Multiply (by using the matrix multiplication algorithm) A and B to get matrix C.5. Print matrix C.6. Go back to step 1 and repeat until the user enters “done”.Test out your function on matrices of various sizes. The values in the matrices should begenerated by using randint(). I would suggest using small random numbers so that it will beeasier for you to check.

Attachments:

Answers

(11)
Status NEW Posted 25 Apr 2017 06:04 AM My Price 9.00

-----------

Attachments

file 1493100598-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)