source: framspy/evolalg/base/remove_diagonal.py

Last change on this file was 1190, checked in by Maciej Komosinski, 2 years ago

Added the "evolalg" module for evolutionary optimization

File size: 401 bytes
Line 
1import numpy as np
2
3
4def remove_diagonal(arrays):
5    numpy_arrays = np.array(arrays)
6    n_of_arrays = numpy_arrays.shape[0]
7    strided = np.lib.stride_tricks.as_strided
8    stride_0, stride_1 = numpy_arrays.strides
9    return strided(numpy_arrays.ravel()[1:],
10                   shape=(n_of_arrays-1, n_of_arrays),
11                   strides=(stride_0+stride_1, stride_1)).reshape(n_of_arrays, -1)
Note: See TracBrowser for help on using the repository browser.