1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
allsm [11]
2 years ago
5

Write a naive implementation (i.e. non-vectorized) of matrix multiplication, and then write an efficient implementation that uti

lizes Numpy's vectorization. When writing the function ensure that the matrix dimensions are correct (print the message Wrong dimensions! otherwise).

Engineering
1 answer:
erik [133]2 years ago
7 0

Answer:

import numpy as np  

import time  

def matrixMul(m1,m2):      

   if m1.shape[1] == m2.shape[0]:  

       

       t1 = time.time()

       r1 = np.zeros((m1.shape[0],m2.shape[1]))

       for i in range(m1.shape[0]):

           for j in range(m2.shape[1]):

               r1[i,j] = (m1[i]*m2.transpose()[j]).sum()

       t2 = time.time()

       print("Native implementation: ",r1)

       print("Time: ",t2-t1)

       

       t1 = time.time()

       r2 = m1.dot(m2)

       t2 = time.time()

       print("\nEfficient implementation: ",r2)

       print("Time: ",t2-t1)

       

   else:

       print("Wrong dimensions!")

Explanation:

We define a function (matrixMul) that receive two arrays representing the two matrices to be multiplied, then we verify is the dimensions are appropriated for matrix multiplication if so we proceed with the native implementation consisting of two for-loops and prints the result of the operation and the execution time, then we proceed with the efficient implementation using .dot method then we return the result with the operation time. As you can see from the image the execution time is appreciable just for large matrices, in such a case the execution time of the efficient implementation can be 1000 times faster than the native implementation.

You might be interested in
A skull and crossbones pictogram indicates this kind of information about a chemical.
Oliga [24]

Answer:

This pictogram indicates that the chemical is toxic and dangerous.

Explanation:

3 0
2 years ago
Dalton needs to prepare a close-out report for his project. Which part of the close-out report would describe
lys-0071 [83]

Answer:

Dalton

The part of the close-out report that would describe how he would plan and manage projects in the future is:

summary of project management effectiveness

Explanation:

The Project Close-out Report is a project management document, which identifies the variances from the baseline plans.  These variances are specified in terms of project performance, project cost, and schedule.  The project close-out report records the completion of the project and the subsequent handover of project deliverables to others.  The project management effectiveness summary details the project's objectives and the achievements recorded, including the lessons learned.

4 0
2 years ago
Which of the following is a possible unit of ultimate tensile strength?
levacccp [35]

Answer:

Newton per square meter (N/m2)

Explanation:

Required

Unit of ultimate tensile strength

Ultimate tensile strength (U) is calculated using:

U = \frac{Ultimate\ Force}{Area}

The units of force is N (Newton) and the unit of Area is m^2

So, we have:

U = \frac{N}{m^2}

or

U = N/m^2

<em>Hence: (c) is correct</em>

4 0
2 years ago
If a vacuum gau ge reads 9.62 psi, it means that: a. the very highest column of mercury it could support would be 19.58 inches.
scZoUnD [109]

Answer:All of the above

Explanation:

9.62 psi means 497.49 mm of Hg pressure

for (a)19.58 inches is equals to 497.49 mm of Hg

(b)atmospheric pressure is 14.69 psi

vaccum gauge is 9.62psi

absolute pressure is=14.69-9.62=5.07

(c)vaccum means air is sucked and there is negative pressure so it tells about below atmospheric pressure.

thus all are correct

8 0
3 years ago
A reciprocating compressor takes a compresses it to 5 bar. Assuming that the compression is reversible and has an index, k, of 1
Gelneren [198K]

Answer:

final temperature is 424.8 K

so correct option is e 424.8 K

Explanation:

given data

pressure p1 = 1 bar

pressure p2 = 5 bar

index k = 1.3

temperature t1 = 20°C = 293 k

to find out

final temperature  t2

solution

we have given compression is reversible and has an index k

so we can say temperature is

\frac{t2}{t1}= [\frac{p2}{p1}]^{\frac{k-1}{k} }  ...........1

put here all these value and we get t2

\frac{t2}{293}= [\frac{5}{1}]^{\frac{1.3-1}{1.3} }

t2 = 424.8

final temperature is 424.8 K

so correct option is e

5 0
3 years ago
Other questions:
  • : The interior wall of a furnace is maintained at a temperature of 900 0C. The wall is 60 cm thick, 1 m wide, 1.5 m broad of mat
    12·1 answer
  • There is a proposal in Brooklyn to construct a new mid-rise apartment building on a vacant lot at the intersection of Avenue A a
    8·1 answer
  • A vehicle experiences hard shifting. Technician A says that the bell housing may be misaligned. Technician B says that incorrect
    5·1 answer
  • an adiabatic compressor receives 1.5 meter cube per second of air at 30 degrees celsius and 101 kpa. The discharge pressure is 5
    11·1 answer
  • A heat pump and a refrigerator are operating between the same two thermal reservoirs. Which one has a higher COP?
    10·1 answer
  • Water of dynamic viscosity 1.12E-3 N*s/m2 flows in a pipe of 30 mm diameter. Calculate the largest flowrate for which laminar fl
    13·1 answer
  • When a user process is interrupted or causes a processor exception, the x86 hardware switches the stack pointer to a kernel stac
    13·1 answer
  • Benzene gas (C6H6) at 25° C and 1 atm, enters a combustion chamber operating at steady state and burns with 95% theoretical air
    6·2 answers
  • Refrigerant-134a enters an adiabatic compressor at -30oC as a saturated vapor at a rate of 0.45 m3 /min and leaves at 900 kPa an
    13·1 answer
  • Who does each person work for? Monica works for a power company, Travis works for a utilities company, and Maggie is self-employ
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!