Question
Write a python code to perform the following tasks: 1. create a numpy matrix a of dimension 5 x 5 with diagnol entries from 0
Write a python code to perform the following tasks:
1. create a numpy matrix a of dimension 5 x 5 with diagnol entries from 0 to 4 using a single line of python
2. multiply (matrix-vector operation) this matric by a numpy array b with entries b[j] = (2^j)+j, j = 0,....,4, such that c = a * b
3. implement the same multiplication with a for loop and check your previous result
4. multiply elementwise the resulting array c by the numpy array d with components d[j] = j + [j*3.1654], j = 0,...,4. Use typecast to implement the operation [ . ]. This is the floor operation which return the integer part of any floating point number.
5. Sum all the components of the resulting array except the last one, using a single line of python code
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started