20 #include <gsl/gsl_linalg.h> 27 #if !defined(__WIN32__) && !defined(__WIN64__) 28 #include <sys/types.h> 35 static char *oldLocaleStatic;
36 static int localeStaticType;
41 unsigned int bufSize=strlen(s)+1;
42 const unsigned int BUF_MAX=10000;
47 char *buf =(
char *)malloc(bufSize);
48 strncpy(buf,s,bufSize);
53 #if defined(__CYGWIN__) || defined(__MINGW__) 56 return c < 128 && c > 0;
67 ASSERT(type == LC_NUMERIC || type == LC_MONETARY || type == LC_CTYPE
68 || type == LC_COLLATE || type == LC_ALL || type == LC_TIME);
71 oldLocaleStatic=setlocale(type,NULL);
76 oldLocaleStatic=
myStrDup(oldLocaleStatic);
83 if(strcmp(oldLocaleStatic,newLocale))
85 setlocale(type,newLocale);
86 localeStaticType=type;
98 if(localeStaticType != -1)
99 setlocale(localeStaticType,oldLocaleStatic);
103 free(oldLocaleStatic);
109 std::ifstream f(fname,std::ios::binary);
114 f.seekg(0,std::ios::end);
124 for (
size_t i = 0; i < m->size1; i++)
126 for (
size_t j = 0; j < m->size2; j++)
127 printf(
"%g ", gsl_matrix_get(m, i, j));
136 for (
size_t i = 0; i < v->size; i++)
138 printf(
"%g ", gsl_vector_get(v, i));
146 ASSERT(m->size1==m->size2);
149 gsl_permutation * p = gsl_permutation_alloc (m->size1);
150 gsl_matrix *tmpM=gsl_matrix_alloc(m->size1,m->size2);
153 gsl_matrix_memcpy(tmpM,m);
157 gsl_linalg_LU_decomp (tmpM, p, &sign);
159 float d=gsl_linalg_LU_det(tmpM,sign);
162 gsl_matrix_free(tmpM);
163 gsl_permutation_free(p);
168 #if !defined(__WIN32__) && !defined(__WIN64) 174 if(stat(filename,&statbuf) == -1)
177 return (statbuf.st_mode !=S_IFDIR);
float gsl_determinant(const gsl_matrix *m)
void gsl_print_matrix(const gsl_matrix *m)
bool isNotDirectory(const char *filename)
void pushLocale(const char *newLocale, int type)
char * myStrDup(const char *s)
bool getFilesize(const char *fname, size_t &size)
void gsl_print_vector(const gsl_vector *v)