PYTHON
Import the green channel of the following image URL (make sure your code works for this URL):
https://raw.githubusercontent.com/dpploy/chen-3170/master/notebooks/images/nerve-cells.jpg
as a matrix A intended for linear algebra operations and show the matrix as an image as below (make sure the data is normalized). Show the complete data type specification of the matrix including maximum, minimum, average, and standard deviation values.
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 1 images
Compute the LU factorization of the symmetric part of A(100*100)and verify that your factorization is correct; explain. The symmetric part of a matrix sym(A) is defined as
sym(A) =( A+ A^T)/2
Make your best visual demonstration (art contest) that it (the sym(A)
matrix) is indeed symmetric.
The LU factorization program code is :
def lu_factorization(A):
2 """
3 Performs LU factorization of a matrix A without pivoting.
4
5 Args:
6 A: A square matrix.
7
8 Returns:
9 A tuple (L, U) where L is the lower triangular matrix and U is the upper triangular matrix.
10 """
11 n = len(A)
12 L = [[0.0] * n for _ in range(n)]
13 U = [[0.0] * n for _ in range(n)]
14
15 for k in range(n - 1):
16 for i in range(k + 1, n):
17
18 mik = A[i][k] / A[k][k]
19 L[i][k] = mik
20
21 for j in range(k + 1, n):
22 A[i][j] = A[i][j] - mik * A[k][j]
23
24 U[k][i] = mik
25
26 for i in range(n):
27 L[i][i] = 1.0
28
29 return L, U
30
31A = [[1.0, 2.0, 3.0],
32 [4.0, 5.0, 6.0],
33 [7.0, 8.0, 9.0]]
34
35L, U = lu_factorization(A)
36
37print("L:")
38for row in L:
39 print(row)
40
41print("U:")
42for row in U:
43 print(row)
Compute the LU factorization of the symmetric part of A(100*100)and verify that your factorization is correct; explain. The symmetric part of a matrix sym(A) is defined as
sym(A) =( A+ A^T)/2
Make your best visual demonstration (art contest) that it (the sym(A)
matrix) is indeed symmetric.
The LU factorization program code is :
def lu_factorization(A):
2 """
3 Performs LU factorization of a matrix A without pivoting.
4
5 Args:
6 A: A square matrix.
7
8 Returns:
9 A tuple (L, U) where L is the lower triangular matrix and U is the upper triangular matrix.
10 """
11 n = len(A)
12 L = [[0.0] * n for _ in range(n)]
13 U = [[0.0] * n for _ in range(n)]
14
15 for k in range(n - 1):
16 for i in range(k + 1, n):
17
18 mik = A[i][k] / A[k][k]
19 L[i][k] = mik
20
21 for j in range(k + 1, n):
22 A[i][j] = A[i][j] - mik * A[k][j]
23
24 U[k][i] = mik
25
26 for i in range(n):
27 L[i][i] = 1.0
28
29 return L, U
30
31A = [[1.0, 2.0, 3.0],
32 [4.0, 5.0, 6.0],
33 [7.0, 8.0, 9.0]]
34
35L, U = lu_factorization(A)
36
37print("L:")
38for row in L:
39 print(row)
40
41print("U:")
42for row in U:
43 print(row)
- Create a copy of S, say P. Subtract -5 from all the middle column elements of P. Insert a new row of all ones in the middle P, such that the new dimensions of P become 11 * 7 . Print both S and P.arrow_forwardWrite one or two lines of Matlab code that sums up all the values in the square-shaped submatrix consisting of rows 3 through 5 and columns 8 through 10 of the matrix A where A = peaks(10). The command window should display 3.7474 when you run it.arrow_forwardProgramming Language :- Carrow_forward
- Consider the graph below Can you determine whether this graph is bidirectional or not? Write a program that will store this graph as a matrix ( a 2D array) You don’t have to print out the elements Write a program that will store this graph as a 1D array of vectors and print the elements Extra credit: The subroutine included in the reference below (void printGraph) for the array of vectors ( question c) is not ideal. Consider modifying it to reference each node(vertex) by the size of the vector for each array element. So it would be ideal to replace for( auto x : adj[v]) with something like for (int j = 0; j < adj[v].size(); j++) cout << adj[v][j] << " "; Regardless, add a function to the program that will map the label to the nodes to the following characters: [ 0 → ‘cat’, 1→ ‘dog’, 2 → ‘car’, 3 → ‘dub’, 4 → ‘boo’, 5 → ‘foo’, 6 → ‘doo’ ]. Which means that when you call function, myfunc(4) it should return ‘boo’. And then adding a secondary…arrow_forwardJAVA. PLEASE ADD COMMENTS TO CODE ALSO INCLUDE TEST CASES IN THE FORM OF CODE AND NOT PROSE Below is how the filenames are represented ARRAY[] = [50, 11, 33, 21, 40, 50, 40, 40, 21] Below is the expected output after de-duplication ARRAY[] = [11, 21, 33, 40, 50] Notice the reduced size of the output array. Also, take a look again at the input array and be reminded that the input array is not sorted ! Further, please DO NOT use library functions to either sort and or perform the de-duplication operation. (1) Implement your solution in such a way that your solution uses Bubble Sort as a sorting routine which brings the sorting time complexity to O(nˆ2). After sorting, solve the de-duplication problem. De-duplication part of the solution in itself must adhere to O(n) time and O(1) space bounds. Example of cases to be tested for are like : What if the array input which is expected does not exist - that is , input is a null. How should your code handle such a situation ? Maybe…arrow_forwardCreate a Java array FirstArray, type int, length 10. Initialize it with the multiple of 2. Print the array using comma separators. (Hint: Use Arrays.toSring method. You need to import java.util.Arrays package) Print the array with vertical line (|) separator. DO NOT put the vertical line after last element.arrow_forward
- procedure generate( G : group; P : property; s : 1..k+l; i : 1..k+1;[)'1, T2 ..... )'i-1] : initial segment of base image;var K : group );(* Generate the elements of G (s) whose base image startwith 1(1, T2 ..... 1I/-1 and that may have property P.If one is found then extend K, the subgroup of G (s) of elementswith property P that have already been found, and return to search. *) Algorithm to Backtrack Search Restricting Choice of Base Imagesarrow_forwardWrite a program that randomly fills in 0s and 1s into a 4-by-4 matrix, prints the matrix, and finds the first row and column with the most 1s. Here is a sample run of the program: 0011 0011 1101 1011 The largest row index: 2 The largest column index: 3arrow_forwardA 2-dimensional 3x3 array of ints, has been created and assigned to tictactoe. Write an expression whose value is true if the elements of the diagonal that does NOT include the first element of the first row are all equal.arrow_forward
- I would like to represent the "residuals" part of the code (see below) as a surface (meshplot), in essence a 3D plot of 2D data # Import librariesimport matplotlib.pyplot as pltimport globfrom astropy.io import fitsfrom astropy.wcs import WCSimport numpy as npimport seaborn as sns # Initial plotfig, ax = plt.subplots(figsize=(7, 7)) # Data from the FITSdata_dir = glob.glob('/Users/petrderuyter/Desktop/harpn_sun_release_package_ccf_2018/2018-04-02/*.fits') #'/Users/xxxxxxxxxxxx/Desktop/harpn_sun_release_package_ccf_2018/2018-01-18/*.fits' # Empty lists for storagelams = []fluxs = [] # Read the FITS files and extract datafor file_path in data_dir: hdul = fits.open(file_path) data = hdul[1].data h1 = hdul[1].header flux = data[1] w = WCS(h1, naxis=1, relax=False, fix=False) lam = w.wcs_pix2world(np.arange(len(flux)), 0)[0] lams.append(lam) fluxs.append(flux) ax.plot(lam, flux) # Calculate mean fluxmean_ccf = np.mean(fluxs, axis=0) # New figure for the mean…arrow_forwardPython Create a 2-D array as shown in exampleArray. Then, delete the second column from the given array and insert the newColumn given below in its placearrow_forwardCreate a square matrix that has ones in the first row and first column, and whose remaining elements are the sum of two elements: the element above and the element to the left. Your program should be able to make a matrix of any size. Do this exercise using a loop (for or while) with break/continue statements as necessary.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education