Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

sub matrix python

'''
A matrix is a list containing lists, to form a 2 dimensonal data table.
A submatrix is a matrix made of selected values of a larger matrix.

To extract a submatrix, we'll use the following example
'''
Y = np.arange(16).reshape(4,4)
'''
Y is
[[ 0  1  2  3]
 [ 4  5  6  7]
 [ 8  9 10 11]
 [12 13 14 15]]
 
 We want to extract columns/rows 0 and 3, resulting in
 [[0 3]
 [12 15]]
 '''
 Y[np.ix_([0,3],[0,3])]
 
 '''
 this outputs 
 array([[ 0,  3],
       [12, 15]])
 
 According to the numpy database, "Using ix_ one can quickly construct index arrays
 that will index the cross product. a[np.ix_([1,3],[2,5])] returns the array
 [[a[1,2] a[1,5]], [a[3,2] a[3,5]]]."
 
 '''
Comment

PREVIOUS NEXT
Code Example
Python :: split pdf python 
Python :: extract bigrams python 
Python :: layer enable time arcpy 
Python :: regex_2/_regex.c:50:10: fatal error: Python.h: No such file or directory 
Python :: what is tensor in deep learning 
Python :: how to change todays date formate in python 
Python :: np reshape 
Python :: pandas read_excel 
Python :: python swarm plot seaborn 
Python :: check if string equals string in list python 
Python :: torch.load 
Python :: pyaduio 
Python :: python how to get last element in a list 
Python :: how to search for a data in excel pandas 
Python :: map python 3 
Python :: (models.W042) Auto-created primary key 
Python :: python lists 
Python :: test with python 
Python :: why to use self in python 
Python :: input two numbers in python in a single line 
Python :: how to add array in python 
Python :: len python 
Python :: code for merge sort 
Python :: python sum 
Python :: url_for 
Python :: what is django 
Python :: python tkinter ttk 
Python :: python scipy moving average 
Python :: create virtual env pyhton3 
Python :: rotate 2d array 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =