C++Guns – RoboBlog

26.02.2015

rosettacode - Simple moving variance

Filed under: Allgemein — Tags: , — Thomas @ 11:02

As mentioned in my earlier post original C++ rosettacode sucks. Here is my example for a simple moving variance and standard deviation. One has to add only a few lines of code: in add() ... sum2 = sum2 - oldValue*oldValue + value*value; ... double var() const { return sum2/size - avg()*avg(); } double std() const […]

23.02.2015

c++ CYK implementation

Filed under: Allgemein — Tags: — Thomas @ 14:02

Die Wikipedia Artikel zum Cocke-Younger-Kasami-Algorithmu kann man vergessen. Man kapiert nichts. Hab auf youtube ein 15min Video [1] von Benny Neugebauer dazu gefunden. Wunderbar, alles gleich verstanden :) Hab ihn mal schnell in C++ implementiert. Hier die Hauptschleife: /* Für j = 2 ... n Für i = 1 ... n - j + 1 […]

18.02.2015

rosettacode - Simple moving average

Filed under: Allgemein — Tags: , , — Thomas @ 12:02

http://rosettacode.org/wiki/Averages/Simple_moving_average#C.2B.2B The original rosetta C example shows the usage of variable function arguments. The C++ example shows how to implement a circular buffer. They are confusing and inefficient. My Version shows how to implement a simple moving average using modern c++ techniques. #include < iostream > #include < vector > class SMA { public: SMA(int […]

Flussschlauch

Filed under: Allgemein — Thomas @ 10:02

11.02.2015

replace templates with c++14 auto

Filed under: Allgemein — Tags: — Thomas @ 21:02

#include < iostream > template< class T > T func1(T t) { return t; } auto func2(auto t) { return t; } int main() { std::cout

09.02.2015

gfortran bug

Filed under: Allgemein — Tags: — Thomas @ 18:02

Jo en Bug. So assigment subroutine und gfort 4.8 4.9. Vllt geht es in 5.0 ja wieder. gfortramnbug.F90

02.02.2015

normalized-rgb

Filed under: Allgemein — Tags: , — Thomas @ 11:02

Als ich gestern etwas mit OpenCV gearbeitet habe, bin ich auf eine interesannte Seite gestossen [1] . Es wird dort von normailsierten RGB geredet. Dabei wird getrennt für jeden Kanal, der Pixelwert durch die Summe des Pixels über alle 3 Kanäle geteilt. R’ = R/(R+G+B) G’ = G/(R+G+B) B’ = B/(R+G+B) Dabei geht die Lichtinformation […]

more crazy C

Filed under: Allgemein — Tags: — Thomas @ 09:02

#include #define CACHE 256 enum { h_unknown = 0, h_yes, h_no }; unsigned char buf[CACHE] = {0, h_yes, 0}; int happy(int n) { int sum = 0, x, nn; if (n < CACHE) { if (buf[n]) return 2 - buf[n]; buf[n] = h_no; } for (nn = n; nn; nn /= 10) x = nn […]

stuff

Filed under: Allgemein — Tags: — Thomas @ 09:02

traceroute -m 100 216.81.59.173

Powered by WordPress