31
Dec

2013

2013

I’ve actually found it oddly challenging to find resources on the Internet that talk specifically about how to write assembly code on the Raspberry PI (or any other ARM device) using GCC and C/C++. I specifically wanted to avoid inline assembly as I wish to work with assembly on its own without cluttering up my […]

16
Aug

2013

2013

Tutorials: Light an LED Blinky Fade RGB – Common Cathode RGB – Common Anode 1. Light an LED Description In this tutorial you will set up and turn on a single LED. Note that this code can actually be executed with just the Arduino and no other components as in Figure 5. If you notice, […]

12
Mar

2011

2011

I am creating my own programming language. I have defined my syntax to use python style indentions and no statement terminating character (\n indicates the end of a statement). Most modern languages, such as C/Java use { and } to denote the start and end of a statement block and a ; to denote the […]

05
Mar

2011

2011

The sample covariance matrix describes how the elements of the matrix relate to eachother. It is used, as you might have guessed, in computer vision as well as machine learning. http://en.wikipedia.org/wiki/Covariance_matrix

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
MATRIX* cov(MATRIX* matrix) { MATRIX* c = (MATRIX*)calloc(1, sizeof(MATRIX)); mInit(c, matrix->cols, matrix->cols, 0.0); MATRIX* m; m = mMatSubMean(matrix); MATRIX* row; int r; for (r = 0; r < m->rows; r++) { row = mGetRow(m, r, r + 1); c = add(c, dot(transpose(row), row)); } mMatScalarMul(c, 1.0 / (m->rows - 1)); free(m); return c; } |

The algorithm for determining the covariance of a matrix is relatively simple. Step 1: Get the mean of the matrix and subtract it […]

03
Mar

2011

2011

Row Reduced Echelon Form Without actually turning this into a linear algebra lesson, this method is used to solve a linear system of equations such as: 2x + 3y – 2z = 1 5x – 5y + 9z = 7 4x + 4y – 3z = 9 As you remember from algebra class, you can […]

03
Mar

2011

2011

Presented here is a robust (though naive) 2D matrix library written in C. Commercial applications of course would be better served with libraries such as OpenCV or a version of LAPACK/BLAS. Below I will describe some of its more interesting features. The matrix struct

1 2 3 4 5 6 7 |
typedef struct matrix_t { double** data; unsigned long rows; unsigned long cols; unsigned long size; } MATRIX; |

As you can see, the matrix itself is implemented as […]

27
Jan

2011

2011

Euclid’s Algorithm:

1 2 3 4 5 6 7 8 9 10 |
public long euclid_gcd(long m, long n) { while (n != 0) { long rem = m % n; m = n; n = rem; } return m; } |

27
Jan

2011

2011

1 Comments

The Machine Epsilon (ε) is the smallest value that a computer can add to 1. It does however change depending on the CPU and operating system due to various forms of rounding implemented. In most traditional computers, the epsilon for a double (52 bits of precision for the IEEE standard of floating point representation) would […]

Copyright Ben Barbour - Theme By SiteOrigin