
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The process of measuring the time taken for basic arithmetic operations (addition, multiplication, and division) on a computer and implementing the gaussian elimination method with partial pivoting using python. A code snippet for the gaussian elimination method and explains how to calculate the time taken for each operation.
Typology: Assignments
1 / 1
This page cannot be seen from the preview
Don't miss anything!

import numpy as np
def round_s(n, decimals= 0 ): if decimals == 0 : n_5s = n + 5 * pow( 10 , - (decimals+ 1 )) else: n_5s = n + 5 * pow( 10 , - (decimals)) if '.' in str(n_5s) and '-' in str(n_5s): return(float(str(n_5s)[ 0 :decimals+ 2 ])) elif '.' in str(n_5s) or '-' in str(n_5s): return (float(str(n_5s)[ 0 :decimals + 1 ])) else: return (float(str(n_5s)[ 0 :decimals])) def Cal_LU(D,g,ds): A=np.array((D),dtype=float) f=np.array((g),dtype=float) num_add = 0 num_sub = 0 num_div = 0 num_mult = 0 n = f.size for i in range( 0 ,n- 1 ): # Loop through the columns of the matrix for j in range(i+ 1 ,n): # Loop through rows below diagonal for each column