python
slove matrix inner product without numpy
A: 5x5 matrix, B: 5x5 matrix
(make array and use loop ?)
Python Code:
Output:
Above code:
# Program to get inner product of two 5 x 5 matrix A and B using loops
# A matrix of the size 5x5
A = [[1,7,3,5,6],
[1,2,4,5,6],
[6,3,7,8,9],
[2,8,6,4,3],
[1,3,8,6,4]]
# B matrix of the size 5x5
B = [[4,8,1,2,7],
[6,7,3,2,2],
[4,1,2,1,8],
[1,2,4,4,8],
[4,6,8,6,8]]
# Ineer product result is matrix of the size 5x5
InnerProduct = [[0,0,0,0,0],
[0,0,0,0,0],
[0,0,0,0,0],
[0,0,0,0,0],
[0,0,0,0,0]]
# iteration through A's rows
for i in range(len(A)):
# iteration through B's columns
for j in range(len(B[0])):
# iteration through B's rows
for k in range(len(B)):
InnerProduct[i][j] += A[i][k] * B[k][j]
print("Inner Product Result is:")
for result in InnerProduct:
print(result)
python slove matrix inner product without numpy A: 5x5 matrix, B: 5x5 matrix (make array and...
Select the description(s) that result in a ragged 2-D (matrix) array instantiation. (This means that directly after the described instantiation, the matrix will be a ragged array with some row lengths being different from other row lengths in the matrix, not a matrix in which all the row lengths in are the same.) A. A NumPy 2-D array whose shape is described by a tuple, like (4, 8) or (3, 4), passed to the constructor. B. A Python list-of-lists in...
For python: Use np.random.rand(5,5) to create a random 5x5 array. Use boolean indexing to set the nine entries in a 3x3 block in the bottom right corner to 0. Print the result. (Hint: Use np.ones() or np.zeros() with the dtype argument to get a 5x5 array full of True's or False's. Use this array to build a boolean filter, in order to set only the entries you want equal to 0.)
IN PYTHON: Write a function that computes the outer product of two vectors WITHOUT using numpy / inbuilt functions. For example, the outer product of [1,2,3] x [1,2] is outer product 2 1 2 3 2 4 6 2 outer product 2 1 2 3 2 4 6 2
D Question 12 1.5 pts Check the true statements about NumPy arrays: O A single instantiated NumPy array can store multiple types (e.g., ints and strings) in its individual element positions. A NumPy array object can be instantiated using multiple types (e.g., ints and strings) in the list passed to its constructor O Memory freeing will require a double-nested loop. The number of bits used to store a particular NumPy array object is fixed. O The numpy.append(my.array, new_list) operation mutates...
PLEASE USE PYTHON*** 11.2 Create a numpy array with values 10, 11, ..., 49 and give it to a variable named var. Then print out var
Hi - For Python, I am trying to find the first maximum value in an array. I currently have written numpy code: first_max_index = int(np.where(biofuel_int_array == max_biofuel_int)[0][0]) Is there another way to identify the first maximum index in the array, without using a loop?
Please write this in python codes(please use actual python file to write this and make a screenshot about the code without write them in txt file,thank you) Exercise 1 Consider the orthogonal transformation matnx S and vectors à and b 0.80 0.60 0.00 0.64 s-1-0.48 0.60 a=101 b= 0.360.48 0.80 a Construct the matrx S as a numpy array and caiculate its determinant. In [ ]: b. Verify that a b is invariant under the transformation S In : C....
need help with this python progam using numpy Create a 4x4 two dimensional array with numbers from 1 thru 16. show this then: Change the last element by dividing it in half. Show that the original array has changed. show this then: Set all values in row 2 to zero. Show the original array contains this change show this then: Set all values in column 1 to one. Shoe the original array contains this change. show this then: Display the...
code that I started: # THIS IS NEEDED TO USE ARRAYS IN PYTHON: from array import * # THIS IS NEEDED TO MAKE PLOTS IN PYTHON: import matplotlib.pyplot as plt # IMPORT A ROUTINE FROM NUMPY USEFUL FOR CREATING AN # ARRAY FILLED WITH ZEROS from numpy import zeros # THIS COMMAND CREATES AN ARRAY OF ZEROS WITH DESIRED SHAPE: V=zeros([31,21]) newV=zeros([31,21]) # SET UP THE BOUNDARY VALUES: V=8 ON TOP OF BOX iy=20 for ix in range(0,31): V[ix,iy]=8.0 #...
write in python The main goal of this file will be to produce a 2D numpy array that could serve as a visual look-up table for the following length units: kilometers, miles, and nautical miles. The variable name for this array should be ltable (standing for length table). The look-up values will be dictated by values for kilometers that should go from 0 to 30 in half-kilometer increments (0, 0.5, 1, 1.5, ..., 28.5, 29, 29.5, 30). The kilometer (km)...