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
// Model matrix : an identity matrix (model will be at the origin) | |
glm::mat4 Model = glm::mat4(1.0f); | |
// Our ModelViewProjection : multiplication of our 3 matrices | |
glm::mat4 MVP = Projection * View * Model; // Remember, matrix multiplication is the other way around |
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
class RotationalMechanics | |
{ | |
mat4 orientation; | |
mat4 tensorOfInertia; | |
mat4 iTensorOfInertia; | |
vec3 angularMomentum; | |
double width, height, depth; | |
public: | |
void update(float dt); | |
const mat4& getOrientation() const { return orientation; } |
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
void Default_Handler(void); | |
void init(); | |
const void * Vectors[] __attribute__((section(".vectors"))) ={ | |
(void *)0x10002000, /* Top of stack */ | |
init, /* Reset Handler */ | |
Default_Handler, /* NMI */ | |
Default_Handler, /* Hard Fault */ | |
0, /* Reserved */ | |
0, /* Reserved */ |
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
.syntax unified | |
/*Инструктируем транслятор генерировать 16-битные инструкции Thumb*/ | |
.thumb | |
/*То же самое что ключ командной строки -mcpu=cortex-m0 . | |
Говорим транслятору, что хотим код под архитектуру Cortex-M0*/ | |
.cpu cortex-m0 | |
/* Опрделяем секцию .vectors, в которой описываем таблицу прерываний */ |
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
#define REGISTER_32(ADDRESS) (*((volatile unsigned int *)(ADDRESS))) | |
#define SYSAHBCLKCTRL REGISTER_32(0x40048080) | |
#define GPIO0DATA REGISTER_32(0x50003ffc) | |
#define GPIO0DIR REGISTER_32(0x50008000) | |
int main() | |
{ | |
// Turn on clock for GPIO and IOCON | |
SYSAHBCLKCTRL |= (1 << 6) + (1 << 16); | |
GPIO0DIR = (1 << 7); // Make PIO0_7 an output |
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
## Tested on 14.04 and 14.10. Runs as root because why not | |
## Installs: | |
# - Ubuntu developer tools | |
# - Python (using system 2.7.6 / 2.7.8) | |
# - scipy libs | |
# - scikit-learn | |
# - nltk | |
# - Ruby 2.1.5 | |
# - rbenv | |
# - nokogiri |
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
/* useful reference: www.linuxselfhelp.com/gnu/ld/html_chapter/ld_toc.html */ | |
MEMORY | |
{ | |
flash : org = 0x00000000, len = 32k | |
} | |
SECTIONS | |
{ | |
. = ORIGIN(flash); |
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
.syntax unified | |
/*Инструктируем транслятор генерировать 16-битные инструкции Thumb*/ | |
.thumb | |
/*То же самое что ключ командной строки -mcpu=cortex-m0 . | |
Говорим транслятору, что хотим код под архитектуру Cortex-M0*/ | |
.cpu cortex-m0 | |
/* Опрделяем секцию .vectors, в которой описываем таблицу прерываний */ |
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
void MultinomialLogRelModel::featurize(const valarray<double>& sample_features, int label, valarray<double>& modelFeatures) const | |
{ | |
for (int k = 0; k < num_classes; ++k) //Loop through classes | |
{ | |
for (int i = 0; i < num_sample_features; ++i ) //loop through features | |
{ | |
modelFeatures[k * (num_sample_features + 1) + i] = (k == label ? sample_features[i] : 0.0); | |
} | |
modelFeatures[(k + 1) * (num_sample_features + 1) - 1] = (k == label ? 1.0 : 0.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
//Logistic regression example from Saprk documentation | |
val points = spark.textFile(...).map(parsePoint).cache() | |
var w = Vector.random(D) // current separating plane | |
for (i <- 1 to ITERATIONS) { | |
val gradient = points.map(p => | |
(1 / (1 + exp(-p.y*(w dot p.x))) - 1) * p.y * p.x | |
).reduce(_ + _) | |
w -= gradient | |
} | |
println("Final separating plane: " + w) |