Professional Documents
Culture Documents
REALIZATION OF
ARRAYS AND MATRICES
ARRAY
● collection of items stored at contiguous
memory locations
● Storing multiple items of same type together
Import numpy
A= numpy.array([0,1,2,3,4,5])
print (A)
ONE DIMENSIONAL ARRAY
● array()
● arange () - np.arange(start, stop, interval)
● linspace() - evenly spaced points - specify no. of elements - linear
np.linspace(start, stop, no. of elements -N), default N=50
● logspace() - produces evenly spaced points on a logarithmically spaced scale
Eg. logspace(1, 3, 5) - array starts at 101 and ends at 103 with 5 points
ONE DIMENSIONAL ARRAY
● zeros(num, dtype=float or int or complex )
● ones(num, dtype=float or int or complex)
- Generate a 1D complex array and concatenate it with 4.3-4.5j, add 4.3-4.5j to
it.
Array Visualization
Using matplotlib library and pyplot function
plot(), stem etc..
TWO DIMENSIONAL ARRAYS
● SLICING A MATRIX
import numpy as np
A = np.array([[1, 4, 5, 12],
[-5, 8, 9, 0],
[-6, 7, 11, 19]])
print(A[:2, :3]) # two rows, three columns
● DETERMINANT A MATRIX
np.linalg.det()
MATRIX OPERATIONS
OR
X = np.linalg.solve(A,B)
SOLVING A SYSTEM OF LINEAR EQUATIONS
Solve the following equations
2x+y+2z=0
2x-y+z=10
x+3y-z=5
THE RANK OF A MATRIX