#include <stdlib.h>
#include <iostream>
#include <time.h>
#include <string.h>
#include "tools.h"
#include <unistd.h>
Go to the source code of this file.
◆ EOL1
◆ EOL2
◆ choose()
unsigned long choose |
( |
unsigned |
n, |
|
|
unsigned |
k |
|
) |
| |
Definition at line 38 of file tools.cpp.
40 const unsigned long uupSize = 100;
41 static unsigned long uup[uupSize];
43 static unsigned long Nold = 0;
44 static unsigned long Kold = 0;
48 if ( (
n <
k) || !
n )
return 0;
56 if ( (Nold ==
n) && (k < Kold) )
57 return *(uup + k - 1);
61 printf(
"choose( unsigned, unsigned) : overflow\n");
74 for (j=0; j<
mmin(i,k); j++)
84 return *(uup + k - 1);
ql0001_ & k(htemp+1),(cvec+1),(atemp+1),(bj+1),(bl+1),(bu+1),(x+1),(clamda+1), &iout, infoqp, &zero,(w+1), &lenw,(iw+1), &leniw, &glob_grd.epsmac
◆ deleteFile()
void deleteFile |
( |
const char * |
line | ) |
|
◆ error()
Definition at line 107 of file tools.cpp.
109 printf(
"Error due to %s.", s);
110 getchar(); exit(255);
◆ euclidianNorm()
double euclidianNorm |
( |
int |
i, |
|
|
double * |
xp |
|
) |
| |
Definition at line 113 of file tools.cpp.
122 const double SMALL=5.422e-20, BIG=1.304e19/((double)
i);
123 double s1=0,s2=0,s3=0, x1max=0, x3max=0, xabs;
133 s1=1.0+s1*
sqr(x1max/xabs);
144 s3=1.0+s3*
sqr(x3max/xabs);
148 if (xabs!=0) s3+=
sqr(xabs/x3max);
153 if (s1!=0)
return x1max*
sqrt(s1+(s2/x1max)/x1max);
156 if (s2>=x3max)
return sqrt(s2*(1.0+(x3max/s2)*(x3max*s3)));
157 return sqrt(x3max*((s2/x3max)+(x3max*s3)));
159 return x3max*
sqrt(s3);
void sqrt(Image< double > &op)
◆ getNameTable()
char** getNameTable |
( |
const char * |
line, |
|
|
int * |
ncolumn |
|
) |
| |
Definition at line 204 of file tools.cpp.
208 if (ncolumn) nc=*ncolumn;
213 while ((*n)&&(*n!=
'\t')&&(*n!=
' ')&&(*n!=13)&&(*n!=10)) n++;
215 while ((*n)&&((*n==
'\t')||(*n==
' ')||(*n==13)||(*n==10))) n++;
218 if (ncolumn) *ncolumn=nc;
219 char **names=(
char**)malloc(nc*
sizeof(
char**));
220 n=(
char*)malloc(strlen(line)+1);
223 for (j=0; j<nc-1; j++)
226 while ((*n)&&(*n!=
'\t')&&(*n!=
' ')&&(*n!=13)&&(*n!=10)) n++;
227 if (*n) { *n=0; n++; }
228 while ((*n)&&((*n==
'\t')||(*n==
' ')||(*n==13)||(*n==10))) n++;
◆ GetRidOfTheEOL()
char* GetRidOfTheEOL |
( |
char * |
tline | ) |
|
Definition at line 185 of file tools.cpp.
189 while ((*tline!=
EOL1)&&(*tline!=
EOL2)&&(*tline)) tline++;
◆ initRandom()
◆ isEmpty()
char isEmpty |
( |
const char * |
line | ) |
|
◆ isEmptyline()
char isEmptyline |
( |
const char * |
line | ) |
|
Definition at line 177 of file tools.cpp.
179 if (*line==
';')
return 1;
181 if ((*line==
EOL1)||(*line==
EOL2)||(*line==
'\0'))
return 1;
◆ loadFile()
char* loadFile |
( |
FILE * |
f | ) |
|
Definition at line 265 of file tools.cpp.
271 char *buf=(
char*)malloc(l+1);
272 if (fread(buf,l,1,
f) != l) {
273 std::cerr <<
"error while loading file (no more info available)" << std::endl; exit(255);
◆ rand1()
◆ removeAllEOL()
char* removeAllEOL |
( |
char * |
t | ) |
|
Definition at line 246 of file tools.cpp.
251 if ((*t==
'\r')||(*t==
'\n')) *t=
' ';
◆ removeQuotes()
char* removeQuotes |
( |
char * |
t | ) |
|
Definition at line 194 of file tools.cpp.
196 if ((*t==
'\'')||(*t==
'"'))
◆ skipLine()
const char* skipLine |
( |
const char * |
t | ) |
|
Definition at line 257 of file tools.cpp.
259 while ((*t!=
'\r')&&(*t!=
'\n')&&(*t)) t++;
260 if (*t==
'\n') {
if (*(t+1)==
'\r') t++; }
261 else if (*t==
'\r') {
if (*(t+1)==
'\n') t++; }
◆ skipSpaces()
const char* skipSpaces |
( |
const char * |
t | ) |
|
Definition at line 171 of file tools.cpp.
173 while ((*t==
' ')||(*t==
'\t')) t++;
◆ stringDuplicate()
char* stringDuplicate |
( |
const char * |
line | ) |
|
Definition at line 234 of file tools.cpp.
236 int l=(int)strlen(line);
238 if ((*line==
'\'')||(*line==
'"')) { l-=2; line++; }
239 char *t=(
char*)malloc(l+1);
◆ mysrand