Skip to content

Instantly share code, notes, and snippets.

View plediii's full-sized avatar
👨‍🚀
computing

Paul Ledbetter plediii

👨‍🚀
computing
View GitHub Profile
### Keybase proof
I hereby claim:
* I am plediii on github.
* I am plediii (https://keybase.io/plediii) on keybase.
* I have a public key ASCxRulhHMZYVwHNIehhN98w4jk4Vk5l-JVpp3QE0QhooAo
To claim this, I am signing this object:
const webpack = require('webpack');
const nodeExternals = require('webpack-node-externals');
module.exports = {
entry: './sum.test.js',
output: {
filename: 'bundle.test.js'
},
optimization: {
minimize: false,
},
@plediii
plediii / test.sum.js
Last active April 21, 2020 02:47
A simple test
/* A Simple test */
import sum from './sum'
test('adds 1 + 2 to equal 3', () => {
expect(sum(1, 2)).toBe(3);
});
@plediii
plediii / sum.js
Last active April 21, 2020 02:48
A simple function to test
/* A simple function to test */
function sum(a, b) {
return a + b;
}
export default sum
@tf.function
def unitary_from_real(m):
"""Create a unitary matrix with dimensions equal to real matrix `m`"""
return tf.linalg.expm(tf.complex(tf.transpose(m) - m, tf.transpose(m) + m))
@plediii
plediii / unitary_from_real.py
Created December 2, 2019 03:11
Unitary matrix from real variable
@tf.function
def unitary_from_real(m):
def ihermitian_element(m, idx, jdx):
if idx == jdx:
return tf.complex(0., m[idx][jdx])
elif idx < jdx:
return tf.complex(-m[jdx][idx], m[idx][jdx])
else:
return tf.complex(m[idx][jdx], m[jdx][idx])
N = m.shape[0]
@tf.function
def unitary_from_real(m):
def ihermitian_element(m, idx, jdx):
if idx == jdx:
return tf.complex(0., m[idx][jdx])
elif idx < jdx:
return tf.complex(-m[jdx][idx], m[idx][jdx])
else:
return tf.complex(m[idx][jdx], m[jdx][idx])
N = m.shape[0]
@plediii
plediii / quantum_bit_tensorflow.py
Created November 26, 2019 22:55
A quick random quantum bit in tensorflow
# First we create a random complex vector
x = tf.complex(tf.random.normal((2, 1)), tf.random.normal((2, 1)))
# Then we normalize it
quantum_bit = x / tf.sqrt(tf.reduce_sum(tf.math.conj(x) * x))
@plediii
plediii / quantum_bit_tensorflow.py
Created November 26, 2019 22:52
Quick construction of a quantum bit state vector in tensorflow
x = tf.complex(tf.random.normal((2, 1)), tf.random.normal((2, 1)))
quantum_bit = x / tf.sqrt(tf.reduce_sum(tf.math.conj(x) * x))
@plediii
plediii / gist:4b6b20007c48600ba65e
Created September 5, 2014 15:03
emacs xml stuff
(require 'my-xml)
(add-hook 'js-mode-hook 'configure-tabs)
(add-hook 'nxml-mode-hook 'configure-tabs)
(defun configure-tabs ()
(setq indent-tabs-mode nil))
(setq indent-tabs-mode nil)