Skip to content

Instantly share code, notes, and snippets.

View bradleybauer's full-sized avatar

Bradley Bauer bradleybauer

View GitHub Profile
@bradleybauer
bradleybauer / backpropagationExample.cpp
Last active December 23, 2016 18:44
A small example of computing the gradient of a function by backpropagation.
#include <iostream>
#include <cmath>
using std::cout;
using std::endl;
struct vec2
{
double x;
double y;
@bradleybauer
bradleybauer / main.cpp
Last active March 18, 2018 03:34
Transposed Convolution in Eigen
#include <iostream>
using std::cout; using std::endl;
#include <Eigen>
using namespace Eigen;
double f(const Matrix3d &a, Matrix3d &y) {
return 1/2. * (a-y).squaredNorm();
}
Matrix3d conv(Matrix4d &x, Matrix2d &w) {
#include "stdafx.h"
#include <iostream>
using std::cout; using std::endl;
#include <functional>
using std::function;
#include <string>
using std::string;
#include <vector>
using std::vector;
string SVM::MSVMAdapter::Generate3dShader() {
string ret = string(R"(
const int MaxNumClasses = )") + to_string(SVM::MaxNumClasses) + string(R"( ;
const int MaxNumExamples = )") + to_string(SVM::MaxNumExamples) + string(R"( ;
uniform vec4 Examples[ MaxNumExamples ];
uniform int Labels[ MaxNumExamples ];
uniform vec4 Weights[ MaxNumClasses ];
uniform vec3 Colors[ MaxNumClasses ];
uniform float weightToClassMap[ MaxNumClasses ];
@bradleybauer
bradleybauer / change_color_code.xsh
Last active August 24, 2018 17:20
A xonsh script to change the colors of my desktop
# the following code is in my ~/.xonshrc
# mkdir ~/.config/themes; cd ~/.config/themes
# git clone https://github.com/aaron-williamson/base16-alacritty
# git clone https://github.com/khamer/base16-i3
# git clone https://github.com/0xdec/base16-rofi
# git clone https://github.com/nicodebo/base16-zathura
# set to the correct directories
conf_dir = '/home/xdaimon/.config'
@bradleybauer
bradleybauer / float_adder.c
Created October 20, 2018 22:00
software float addition
// This is my solution for a project in cse 320 at msu
// Turn off assert
#define NDEBUG
#include <stdint.h> // uint64_t
#include <stdbool.h>
#include <assert.h>
#include "/user/cse320/Projects/project06.support.h"
@bradleybauer
bradleybauer / fft_mult.cpp
Created March 27, 2019 22:22
multiply two big numbers with the FFT
#include <iostream>
using std::cout;
using std::endl;
#include <complex>
using std::complex;
#include <string>
using std::string;
#include <fstream>
using std::ofstream;
#include "fftw3.h"
#include <bits/stdc++.h>
using namespace std;
#include <range/v3/all.hpp>
namespace views = ranges::views;
mt19937 generator(1252414);
struct Agent {
int id{};
int score{};
int main() {
Config* config = new Config;
Programs* programs = new Programs;
Renderer* renderer = new Renderer;
Window* window = new Window;
while (true) {
if (user_config_changed()) {
logger.log("Updating state.");
int main() {
Config* config = new Config;
Programs* programs = new Programs;
Renderer* renderer = new Renderer;
Window* window = new Window;
while (true) {
if (user_config_changed()) {
logger.log("Updating state.");