Skip to content

Instantly share code, notes, and snippets.

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

Paul Ledbetter plediii

👨‍🚀
computing
View GitHub Profile
const webpack = require('webpack');
const nodeExternals = require('webpack-node-externals');
module.exports = {
entry: './sum.test.js',
output: {
filename: 'bundle.test.js'
},
optimization: {
minimize: false,
},
### 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:
@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
@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);
});
@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 / global.el
Created December 10, 2008 00:22 — forked from wfarr/global.el
(defun prepend-to-path (&rest paths)
(map 'nil (lambda (path)
(let ((old-paths (getenv "PATH")))
(if (and old-paths (not (equal old-paths "")))
(if (not (member path (split-string old-paths ":")))
(setenv "PATH" (concat path ":" old-paths)))
(setenv "PATH" path)))
(if (not (member path exec-path))
(setq exec-path (cons path exec-path))))
(reverse (prune-directory-list paths)))