Skip to content

Instantly share code, notes, and snippets.

@volkansalma
volkansalma / gist:627767
Created October 15, 2010 07:20
Naive Bayes Sınıflandırıcı. http://volkansalma.blogspot.com
#include <iostream>
#include <vector>
#include <fstream>
#include <cmath>
using namespace std;
struct FeatureVector
{
@volkansalma
volkansalma / tavlamaOutput
Created March 27, 2011 08:15
tavlama benzetimi sonucu
0 My Solution: SGGYVNFHLND@HEL@RFOYMGEO (143) Temp:99.6667
1 My Solution: SGGYHNFHLND@HEL@RFOYMGEO (129) Temp:99.3333
2 My Solution: SGGYHNFHLND@HEL@RFOYAGEO (117) Temp:99
3 My Solution: SGGYHNRHLND@HEL@RFOYAGEO (105) Temp:98.6667
4 My Solution: SGGLHNRHLND@HEL@RFOYAGEO (92) Temp:98.3333
5 My Solution: SGGLHNRHLND@HEL@RFOYAGRO (85) Temp:98
6 My Solution: SGGLHNRHLND@HEL@RMOYAGRO (78) Temp:97.6667
7 My Solution: SGGLHNRHLND@HML@RMOYAGRO (72) Temp:97.3333
8 My Solution: SNGLHNRHLND@HML@RMOYAGRO (65) Temp:97
9 My Solution: SNGLBNRHLND@HML@RMOYAGRO (59) Temp:96.6667
@volkansalma
volkansalma / hill.cpp
Created March 27, 2011 09:00
hill climbing algoritması
//f(bd) = |20 * bir_sayisi(bd) - 100| fonksiyonunu max yapan
// 30 karakterlik binary dizisinin(bd) hill climbing algoritmasi ile
//bulunmasi.
//Volkan SALMA. http://volkansalma.blogspot.com
#include <iostream>
#include <vector>
#include <stdlib.h> //for rand funct.
#include <time.h> //time for rand function seed.
#include <math.h> // for abs function
@volkansalma
volkansalma / optHints
Created March 27, 2011 09:48
optimizasyon ipuçları
1- 32-bit data tiplerini kullanın. (Neden çünkü mimari bunun üzerine.
Bütün aritmatik işlem birimleri 32 bit için design edilmiş. Daha büyük veri tipleri bölünüp yapılır.
Küçük olanlarda 32 bitlik registerlara taşınır işaretli ise işaret genişletilir ekstra işlemler...)
2- Integer işlemlerinin işaretine önceden karar verin. Bölüm ve kalan hesaplarken, döngü sayaçları,
array indexleri için unsigned tipler, Integer-to-float dönüşümleri için signed tipler kullanın.
Kötü örnek:
double x; // MOV [tmep+4],0
unsigned int i; // MOV EAX, i
@volkansalma
volkansalma / genetikAlgoritma.cpp
Created March 27, 2011 08:08
genetik algoritma örnek kod
#pragma warning(disable:4786) // disable debug warning
#include <iostream> // for cout etc.
#include <vector> // for vector class
#include <string> // for string class
#include <algorithm> // for sort algorithm
#include <time.h> // for random seed
#include <math.h> // for abs()
#define GA_POPSIZE 2048 // ga population size
@volkansalma
volkansalma / opencvcpp
Created March 27, 2011 08:00
OpenCV C++
#ifdef _DEBUG
#pragma comment(lib,"opencv_core220d")
#pragma comment(lib,"opencv_highgui220d")
#pragma comment(lib,"opencv_imgproc220d")
#else
#pragma comment(lib,"opencv_core220")
#pragma comment(lib,"opencv_highgui220")
#pragma comment(lib,"opencv_imgproc220")
#endif
@volkansalma
volkansalma / coloredConsole.cpp
Created June 28, 2012 06:31
Colored console (windows)
#include <iostream>
#include <windows.h> // WinApi header
using namespace std; // std::cout, std::cin
int main()
{
HANDLE hConsole;
int k;
@volkansalma
volkansalma / anaglyph3d.c
Created June 30, 2012 07:04
Return an anaglyph image of a right and left channel
// Return an anaglyph image of a right and left channel
// Author : Nicolas Bourré 20100927
IplImage * toAnaglyph(IplImage * imgLeft, IplImage *imgRight)
{
IplImage *iplReturn;
IplImage *l_R, * l_G, *l_B;
IplImage *r_R, * r_G, *r_B;
iplReturn = cvCreateImage( cvGetSize (imgLeft), 8, 3);
@volkansalma
volkansalma / gist:1170793
Created August 25, 2011 14:29
OpenCV 2.3 ile Optical Flow C++
#include <opencv2/opencv.hpp>
#include <iostream>
#include <vector>
#include <cmath>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
@volkansalma
volkansalma / opencvSVM.cpp
Created March 27, 2011 09:04
opencv svm sample
#include<iostream>
#include <cv.h>
#include <cxcore.h>
#include <ml.h>
using namespace std;
int main()
{
CvSVM SVM;