Skip to content

Instantly share code, notes, and snippets.

def elim(row, minus_row, scale, n=3):
m = np.eye(n)
m[row, minus_row] = -scale
return m
@binary10
binary10 / xor-tri-matrix.py
Last active May 24, 2016 18:55
Numpy ufunc.at()
"""
Initiating a 9000x9000 triangular matrix and applying XOR across all elements
"""
""" Using ufunc without at() """
%%timeit
a = np.tri(9000,dtype=int)
a = np.bitwise_xor(a,1)
# 1 loops, best of 3: 373 ms per loop
@binary10
binary10 / iron-accord-linq
Last active August 29, 2015 14:21
IronPython, Accord.NET, and LINQ expressions
# Import C# CLR interface and system
import clr, sys
# Add C# Library Paths and add references via CLR module
sys.path.append('C:\\Program Files (x86)\\Accord.NET\\Framework\\Release\\net40')
sys.path.append('C:\\Program Files (x86)\\AForge.NET\\Framework\\Release')
clr.AddReference('System.Core')
clr.AddReference('AForge.Math')
clr.AddReference('Accord.Statistics')
clr.AddReference('System.Linq')