본문 바로가기

미연시리뷰

(30)
고소실 깃허브 https://github.com/jwgdmkj/advancedSoftware
horner계산을 이용한 테일러급수 계산 및 loop unrolling void Eval_Poly_Naive(double y[], double x[], int n_x, double a[], int deg) { //p = c[0] + c[1] * x + c[2] * pow(x, 2.0) + c[3] * //pow(x, 3.0) + c[4] * pow(x, 4.0); for (int j = 0; j < deg; j++) { y[j] = a[0]; for (int i = 1; i < deg; i++) { y[j] += a[i] * pow(x[j], i); } printf("naive ret %lf\n", y[j]); } } void Eval_Poly_Horner(double y[], double x[], int n_x, double a[], int deg) { for (int j..
머신러닝 cll - forward backwrad /* *Multi-Layer Perceptron example */ #include "mlp.h" #include int num_of_epoch = 2; int main() { int num_of_train, num_of_valid; MNIST* valid = ReadMNIST("./mnist/t10k-images.idx3-ubyte", "./mnist/t10k-labels.idx1-ubyte", &num_of_valid, 0); // validation data MNIST* train = ReadMNIST("./mnist/train-images.idx3-ubyte", "./mnist/train-labels.idx1-ubyte", &num_of_train, 0); // training data //입력층..
오일러 path/cycle #define _CRT_SECURE_NO_WARNINGS using namespace std; #include #include #include "DBL.h" //#define NO_PATH_OUT // comment out this line for path output void Error_Exit(const char *s); typedef struct _Vertex { dblStack S;// adj list contains edge index int degree; } Vertex; typedef struct _Edge { int v1, v2; } Edge; void graphGeneration(Vertex **V, Edge **E, int *VN, int *EN); void adjListGenerate..
최근접 점의 쌍 찾기 #include #include # define SWAP(x, y, temp) ( (temp)=(x), (x)=(y), (y)=(temp) ) void merging(double* X, unsigned* Xid, unsigned* TMP, unsigned left, unsigned mid, unsigned right) { int i, j, k, l; i = left; j = mid + 1; k = left; /* 분할 정렬된 list의 합병 */ while (i
(알고리즘 설계와 분석)리스트에 기반한 그래프의 bfs #include #include #include #include #define NONE -1 void errorExit(const char *s); typedef struct _SLL { int i; struct _SLL *p; } SLL; class SLList2 { private: SLL *SLL_pool; public: SLList2(void) { SLL_pool = NULL; } ~SLList2(void) { } unsigned long SLL_cnt; unsigned long UsedMemoryForSLLs; SLL *allocSLL(void); void freeSLL(SLL *p); void freeSLL_pool(void); }; //class sllStack :public SLList { ..
(알고리즘 설계와 분석)배열에 기반한 그래프의 dfs #include #include #include #define NONE -1 typedef struct _edge { int name; int vf, vr; // e = (vf, vr) where vf, vr are vertex array indices int cost; // edge cost bool flag; // true if in an SP, false otherwise int fp, rp; // adj list ptr of forward and reverse (-1 if none) } edge; typedef struct _vertex { int name; bool flag; int f_hd, r_hd; // adj list header(-1 if none) } vertex; #include "..
os 0-2 1번 임시 swap #include #include #include struct node { int card; struct node* next; struct node* prev; }; void swap(struct node* a, struct node* b) { struct node* t; t = (struct node*)malloc(sizeof(struct node)); *t = *a; *a = *b; *b = *t; b->next = a->next; a->next = t->next; b->prev = a->prev; a->prev = t->prev; printf("first's next %d prev %d\n", a->next->card, a->prev->card); printf("next's next %d prev %..