Changes

Jump to navigation Jump to search

Numpy linalg

1,023 bytes added, 20:15, 20 June 2014
a3_e = np.einsum(a3, [Ellipsis, 0, 1], a3, [Ellipsis, 1, 2])
print a3_e
 
</source>
 
 
== Stride tricks ==
http://chintaksheth.wordpress.com/2013/07/31/numpy-the-tricks-of-the-trade-part-ii/
 
http://stackoverflow.com/questions/8070349/using-numpy-stride-tricks-to-get-non-overlapping-array-blocks
 
http://stackoverflow.com/questions/4936620/using-strides-for-an-efficient-moving-average-filter
 
http://www.rigtorp.se/2011/01/01/rolling-statistics-numpy.html
 
http://stackoverflow.com/questions/8070349/using-numpy-stride-tricks-to-get-non-overlapping-array-blocks
 
http://wiki.scipy.org/Cookbook/GameOfLifeStrides
 
http://wiki.scipy.org/Cookbook/SegmentAxis
 
 
<source lang="python">
from numpy.lib.stride_tricks import as_strided
import numpy as np
 
NE, NS, NM, NO, ND, Row, Col = 1, 2, 2, 1, 2, 2, 2
 
mat = np.arange(1,NE*NS*NM*NO*ND*Row*Col+1).reshape(NE, NS, NM, NO, ND, Row, Col)
print "mat is:"
print mat
 
sz = mat.itemsize
print "itemsize is:"
print sz
 
print "strides is"
print mat.strides
 
print "height and width are"
print h, w
 
bh,bw = Row,Col
 
shape = (h/bh, w/bw, bh, bw)
print shape
</source>

Navigation menu