Skip to content

Instantly share code, notes, and snippets.

View wiai's full-sized avatar

Aimo Winkelmann wiai

View GitHub Profile
@telegraphic
telegraphic / dp4a_cross_correlator.py
Last active November 10, 2021 20:31
Use of CUDA DP4A instruction using PyCUDA
import pycuda.driver as cuda
import pycuda.autoinit
from pycuda.compiler import SourceModule
import numpy as np
def compute_xcorr_cpu(d):
dc = d.astype('float32').view('complex64')
dc = dc.transpose((0,2,3,1)).copy()
xcorr_cpu = np.einsum('...i,...j', dc, np.conj(dc)).view('float32').astype('int32').sum(axis=-4)
return xcorr_cpu
@sklam
sklam / glinterop.py
Created August 16, 2016 18:03
Numba, PyCUDA, OpenGL interop. Adapted from https://wiki.tiker.net/PyCuda/Examples/GlInterop
# GL interoperability example, by Peter Berrington.
# Draws a rotating teapot, using cuda to invert the RGB value
# each frame
from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.GLU import *
from OpenGL.GL.ARB.vertex_buffer_object import *
from OpenGL.GL.ARB.pixel_buffer_object import *
@LeeKamentsky
LeeKamentsky / AQLM_2016.ipynb
Last active November 28, 2016 15:57
AQLM 2016 presentation on image analysis
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pwuertz
pwuertz / PyQt5_OpenGl_TextureFromNumpy.py
Created October 27, 2014 09:44
PyQt5 Example: Create OpenGL texture from numpy array via mapped pixel buffer
from OpenGL import GL
from PyQt5 import QtWidgets, QtCore, QtGui, QtOpenGL
from OpenGL.GL.ARB.texture_rg import GL_R32F
import numpy as np
import ctypes
import time
w, h = 400, 400
class TestWidget(QtOpenGL.QGLWidget):
# This file is part of VISVIS. This file may be distributed
# seperately, but under the same license as VISVIS (LGPL).
#
# images2gif is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# images2gif is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
@cryos
cryos / avogadrostandalone.py
Created July 28, 2012 17:50
Using Avogadro from Python
# Developed by Tim Vandermeersch, with a blog post at
# http://timvdm.blogspot.com/2009/05/using-avogadro-library-from-python.html
#
#import openbabel
# needed for OB formats on linux (can be omitted by importing openbabel first)
import sys
if sys.platform.find('linux') != -1:
try:
import dl
except ImportError:
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@webwurst
webwurst / pyside_webkit_javascript.py
Created March 26, 2012 08:01
PySide/WebKit/Javascript
import sys
from PySide.QtCore import QObject, Slot
from PySide.QtGui import QApplication
from PySide.QtWebKit import QWebView
html = """
<html>
<body>
<h1>Hello!</h1><br>
@ssorgatem
ssorgatem / integration.py
Created March 22, 2012 12:00
An example of integrating the Jmol viewer into a jython application, with optional console.
#-*- coding:utf-8 -*-
#
# Copyright 2012 Adrià Cereto Massagué <adrian.cereto@urv.cat>
# This is the jython version of Jmol's Integration.java.
# It is under public domain
"""
An example of integrating the Jmol viewer into a jython application, with optional console.
"""
from java.lang.System import exit