Commit 65c91783 authored by perdacherMartin's avatar perdacherMartin

changed filename error

parent 26b28674
......@@ -14,10 +14,10 @@ int main(int argc, char** argv) {
double *dmatrix = NULL;
CUtilTimer timer;
bool isBinary = false;
char filename[] = "";
char filename[MAX_LINE_LENGTH] = "";
int threads = 0;
int N=64, K=40, D=20;
size_t N=64, K=40, D=20;
#ifndef __AVX__
fprintf (stderr, "Unfortunately your CPU does not support AVX intrinsics. \nExit.\n");
......@@ -31,6 +31,7 @@ int main(int argc, char** argv) {
}
const int n = 1024 * 1024 * N ;
// const int n = 10000 ;
const int d = D ;
const int k = K ;
......@@ -42,6 +43,7 @@ int main(int argc, char** argv) {
}else{
read_file(dmatrix, n, d, filename, isBinary);
}
// use first k points for means
memcpy(means, dmatrix, k * d * sizeof (double));
......
......@@ -3,7 +3,7 @@
#include "arguments.h"
void parsing_args(int argc, char* argv[], int *n, int *k, int *d, int *threads, char *filename, bool isBinary){
void parsing_args(int argc, char* argv[], size_t *n, size_t *k, size_t *d, int *threads, char *filename, bool isBinary){
char c;
FILE *file;
......@@ -24,7 +24,7 @@ void parsing_args(int argc, char* argv[], int *n, int *k, int *d, int *threads,
if ( optarg ){
switch(c){
case 'n':
*n = atol(optarg);
*n = atol(optarg);
break;
case 't':
*threads = atoi(optarg);
......@@ -55,6 +55,8 @@ void parsing_args(int argc, char* argv[], int *n, int *k, int *d, int *threads,
break;
}
}
}
}
......@@ -8,6 +8,6 @@
#include <string.h>
#include <ctype.h>
void parsing_args(int argc, char* argv[], int *n, int *k, int *d, int *threads, char *filename, bool isBinary);
void parsing_args(int argc, char* argv[], size_t *n, size_t *k, size_t *d, int *threads, char *filename, bool isBinary);
#endif //KMEANS_ARGS_H
#include "dataIo.h"
void random_init(double *array, const int N, const int D){
void random_init(double *array, const size_t N, const size_t D){
short unsigned seed[3];
int i;
......@@ -13,13 +13,13 @@ void random_init(double *array, const int N, const int D){
}
}
void read_file(double *array, const int N, const int D, char filename[], bool isBinary){
void read_file(double *array, const size_t N, const size_t D, char filename[], bool isBinary){
FILE *fp;
size_t counts = 0;
size_t i=0,j=0;
char line[MAX_LINE_LENGTH];
char *token=NULL;
const char space[2] = " ";
const char space[2] = ",";
fp = fopen(filename,"r");
......@@ -43,12 +43,16 @@ void read_file(double *array, const int N, const int D, char filename[], bool is
i = 0;
while ( fgets ( line, MAX_LINE_LENGTH, fp ) != NULL &&
i < N ) {
if ( line[0] != '%'){ // ignore '%' comment char
token = strtok(line, space);
j=0;
while ( token != NULL &&
j < D ){
array[i*D + j] = atof(token); // 0.0 if no valid conversion
token = strtok(NULL, space);
j++;
......@@ -61,7 +65,7 @@ void read_file(double *array, const int N, const int D, char filename[], bool is
fclose(fp);
}
void save_binary_file(double *array, const int N, const int D, char filename[]){
void save_binary_file(double *array, const size_t N, const size_t D, char filename[]){
FILE *fp=NULL;
size_t counts = 0;
......@@ -82,7 +86,7 @@ void save_binary_file(double *array, const int N, const int D, char filename[]){
fclose(fp);
}
void save_text_file(double *array, const int N, const int D, char filename[]){
void save_text_file(double *array, const size_t N, const size_t D, char filename[]){
FILE *fp=NULL;
size_t counts = 0;
size_t i=0, j=0;
......
......@@ -8,9 +8,9 @@
#define MAX_LINE_LENGTH 2049
void random_init(double *array, const int N, const int D);
void read_file(double *array, const int N, const int D, char filename[], bool isBinary);
void save_binary_file(double *array, const int N, const int D, char filename[]);
void save_text_file(double *array, const int N, const int D, char filename[]);
void random_init(double *array, const size_t N, const size_t D);
void read_file(double *array, const size_t N, const size_t D, char filename[], bool isBinary);
void save_binary_file(double *array, const size_t N, const int D, char filename[]);
void save_text_file(double *array, const size_t N, const int D, char filename[]);
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment