This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn calculate-interest | |
[apy base deposit months] | |
(if (= months 0) | |
( + base (* base apy)) | |
(do (def newBase (+ base deposit)) | |
(if (= (mod months 12) 0) | |
(calculate-interest apy (+ newBase (* newBase apy)) deposit (dec months)) | |
(calculate-interest apy newBase deposit (dec months)))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// CUDA function ptr example | |
// For basic vector operations | |
// Based on Chapter 2 of Programming Massively Parallel Processors 3rd Edition Kirk & Hwu | |
#include <stdio.h> | |
#include <cuda.h> | |
__global__ void addKernel(float * a, float * b, float * c, int n) { | |
int i = blockDim.x * blockIdx.x + threadIdx.x; | |
if(i < n) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <ctime> | |
#include <gmpxx.h> | |
using namespace std; | |
mpz_class fibNorm(int n) { | |
if (n <= 1 ) return n; | |
return fibNorm(n-1) + fibNorm(n-2); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "../common/book.h" | |
#include "../common/cpu_bitmap.h" | |
#define DIM 1000 | |
//From Wikipedia's article on the Mandelbrot Set: | |
__device__ int mandelbrot( int xa, int ya, float s, float xpos, float ypos) { | |
float x0 = s * (float) (DIM/2 -xa)/((float)DIM/2) + xpos; | |
float y0 = s * (float)(DIM/2 -ya )/((float)DIM/2) + ypos; | |
int m = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
#include <cmath> | |
struct vec3 { | |
float x, y, z; | |
void set(float X, float Y, float Z) | |
{ | |
x = X; | |
y = Y; | |
z = Z; |
NewerOlder