77 printf(
"%3.0lf%%\b\b\b\b", ( (
double ) incr / procento ) );
96 timer = * p_time / ( double ) CLOCKS_PER_SEC;
97 if( timer > ( 2/24.) ) printf(
"-\b" ); else ;
98 if( timer > ( 4/24.) ) printf(
"\\\b" ); else ;
99 if( timer > ( 6/24.) ) printf(
"|\b" ); else ;
100 if( timer > ( 8/24.) ){
111 return ( 4. *
PI * a * b * c / 3. );
117 return b/a + (1.0-b/a) / (0.5*
PI) * x;
123 return log(x + sqrt(x + 1.0) * sqrt(x - 1.0));
137 void OpenFile( FILE **file,
char *name,
const char mode[] )
139 if ((*file = fopen(name, mode)) == NULL){
148 void OpenFile( FILE* &file,
char name[],
int mode )
152 file = fopen( name,
"r" );
155 file = fopen( name,
"w" );
158 file = fopen( name,
"a" );
161 _errorr(
"OpenFile: ERROR: no valid opening mode selected\n");
176 if ((fclose(file)) == EOF){
189 while( ( c = getc( fr ) ) !=
'\n' ){
198 fprintf( fw,
"\\documentclass[a4paper,11pt]{article}\n");
199 fprintf( fw,
"\\usepackage[pdftex]{graphicx}\n" );
200 fprintf( fw,
"\\usepackage{fullpage}\n" );
201 fprintf( fw,
"\\usepackage{latexsym}\n" );
202 fprintf( fw,
"\n\n\\begin{document}\n\n" );
203 fprintf( fw,
"\\renewcommand{\\arraystretch}{1.2}\n" );
212 fprintf( fw,
"\n\n\\end{document}\n" );
255 while ((c = getc(fr)) != EOF){
279 while ((fscanf(fr,
"%lf", &value)) == 1){
286 _errorr(
"GetRangeOfFileColumns: no lines in tested file\n");
290 return (
int) (i/rows);
305 char tmp_file[] =
"tmp_fileXXXXXX";
310 while( ( c = getc(fr) ) ==
' ' || c ==
'\t' || c ==
'\n'){
317 while( ( c = getc(fr) ) !=
'\n' ){
326 while ((fscanf(fr,
"%lf", &value)) == 1){
349 prd += v1[n] * v2[n];
358 norm +=
SQR( v1[n] - v2[n] );
367 int i = 0, j = 0, rows = 0, columns= 0;
374 for(i = 0; i < rows; i++){
375 for(j = 0; j < columns; j++){
376 fscanf(fr,
"%lf", &p_array[i][j]);
383 void ReadDataTo3DArray(
double *** p_array,
char * p_file_name,
int no_fields,
int no_rows,
int no_columns )
386 int i = 0, j = 0, k = 0;
390 for(i = 0; i < no_fields; i++){
391 for(j = 0; j < no_rows; j++){
392 for(k = 0; k < no_columns; k++){
393 fscanf(fr,
"%lf", &p_array[i][j][k]);
404 int i = 0, j = 0, rows = 0, columns= 0;
411 for(i = 0; i < rows; i++){
412 for(j = 0; j < columns; j++){
413 fscanf(fr,
"%d", &p_array[i][j]);
429 for(i = 0; i < rows; i++){
430 fscanf(fr,
"%d", &p_array[i]);
441 length =
SQR( point_1[0] - point_2[0] )
442 +
SQR( point_1[1] - point_2[1] )
443 +
SQR( point_1[2] - point_2[2] );
445 return sqrt( length );
453 length =
SQR( rx ) +
SQR( ry ) +
SQR( rz );
455 return sqrt( length );
463 if (vect[range] == number)
544 double **
array =
new double*[d1];
545 while (d1--) array[d1] =
new double[d2];
551 if (array != NULL)
_errorr(
"allocation of non NULL array");
573 void CopyArray2D (
const double*
const* src,
double **dest,
long d1,
long d2)
579 dest[i][j] = src[i][j];
585 void CopyArray3D (
const double ***src,
double ***dest,
long d1,
long d2,
long d3)
592 dest[i][j][k] = src[i][j][k];
599 void AddArray2D (
const double*
const* src,
double** dest,
long d1,
long d2)
605 dest[i][j] += src[i][j];
609 void AddArray3D (
double ***src,
double ***dest,
long d1,
long d2,
long d3)
616 dest[i][j][k] += src[i][j][k];
634 void SubtractTwoArrays2D (
const double*
const* a1,
const double*
const* a2,
double **answer,
long d1,
long d2)
640 answer[i][j] = a1[i][j] - a2[i][j];
647 double det = m[0]*m[3] - m[1]*m[2];
649 answer[0] = m[3] / det;
650 answer[1] = -m[1] / det;
651 answer[2] = -m[2] / det;
652 answer[3] = m[0] / det;
658 double det = m[0]*m[4]*m[8] - m[0]*m[5]*m[7] - m[1]*m[3]*m[8] + m[1]*m[5]*m[6] + m[2]*m[3]*m[7] - m[2]*m[4]*m[6];
660 answer[0] = (m[4]*m[8] - m[5]*m[7]) / det;
661 answer[1] = -(m[1]*m[8] - m[2]*m[7]) / det;
662 answer[2] = (m[1]*m[5] - m[2]*m[4]) / det;
664 answer[3] = -(m[3]*m[8] - m[5]*m[6]) / det;
665 answer[4] = (m[0]*m[8] - m[2]*m[6]) / det;
666 answer[5] = -(m[0]*m[5] - m[2]*m[3]) / det;
668 answer[6] = (m[3]*m[7] - m[4]*m[6]) / det;
669 answer[7] = -(m[0]*m[7] - m[1]*m[6]) / det;
670 answer[8] = (m[0]*m[4] - m[1]*m[3]) / det;
679 answer[4] = 1.0 / m[4];
686 answer[ 9] = 1.0 / m[ 9];
687 answer[10] = 1.0 / m[10];
688 answer[11] = 1.0 / m[11];
695 #define _at( mtrx, i, j, n ) mtrx[i * n + j] //n - number of rows of the matrix @mtrx 710 double *auxResVect = NULL;
713 if (vect == resVect) auxResVect =
new double[n];
715 else auxResVect = resVect;
721 for (i = 0; i < n; i++)
722 for (j = 0; j < n; j++)
723 auxResVect[i] +=
_at( mtrx, i, j, n ) * vect[j];
727 if (vect == resVect) {
729 delete [] auxResVect;
747 if (mtrx1 == mtrx2 || mtrx1 == resMtrx || mtrx2 == resMtrx)
errol;
752 for (i = 0; i < n; i++)
753 for (j = 0; j < n; j++)
754 for (k = 0; k < n; k++)
755 _at( resMtrx, i, j, n ) +=
_at( mtrx1, i, k, n ) *
_at( mtrx2, k, j, n );
769 for(
int i = 0; i < n; i++ ){
770 for(
int j = 0; j < n; j++ ){
771 _at( T_mtrx, i, j, n ) =
_at( mtrx, j, i, n );
785 printf(
"%s", notice );
786 for(
int i = 0; i < n; i++ ){
787 for(
int j = 0; j < n; j++ ){
789 printf(
"%.6e ",
_at( mtrx, j, i, n ) );
792 printf(
"%.6e ", 0. );
810 printf(
"%s", notice );
811 for(
int i = 0; i < n; i++ ){
812 for(
int j = 0; j < n; j++ ){
814 printf(
"%.6e ", mtrx[i][j] );
817 printf(
"%.6e ", 0. );
835 printf(
"%s", notice );
836 for(
int i = 0; i < n; i++ ){
838 printf(
"%.6e\n", vect[i] );
841 printf(
"%.6e\n", 0. );
857 printf(
"%s", notice );
858 for(
int i = 0; i < n; i++ ){
859 printf(
"%d\n", vect[i] );
876 printf(
"%s", notice );
877 for(
int i = 0; i < n; i++ ){
879 printf(
"%.6e, ", vect[i] );
882 printf(
"%.6e, ", 0. );
898 printf(
"%s", notice );
899 for(
int i = 0; i < n; i++ ){
900 printf(
"%d, ", vect[i] );
double give_curvature(double x, double a, double b)
void CopyArray3D(const double ***src, double ***dest, long d1, long d2, long d3)
Function copy two 3D double arrays with dimensions d1xd2xd3 from 'src' to 'dest'. ...
file of various types and symbolic constant definitions
void ReadDataToVector(int *p_array, char *p_file_name)
description: function initializes an 'int' vector by values from a given file
double give_quadNormTwoVectors(const double *v1, const double *v2, int n)
Function returns the quadratic norm of two vectors of length 'n'.
void GoToEndOfLine(FILE *fr)
description: functions moves the cursor the the end of line (EOLN) in a text file last edit: 1...
void CloseFile(FILE *file)
description: function closes a previously opened file and tests the succes of the closing note: funct...
#define array(MAT, ROWS, COLS, ROW, COL)
void giveInverseMatrix2x2(double *answer, const double *m)
Function computes inverse of the row-wise saved 2x2 matrix 'm'.
void CopyVector(const double *src, double *dest, long n)
Function copy given number of components from vector, 'a' to vector 'b'.
void giveInverseMatrix6x6to12(double *answer, const double *m)
Function computes inverse of the eshelby-like 3x3 matrix 'm' saved in reduced 6x6to12 form...
int GetRangeOfFileRows(char *p_name)
Funkce zapise LENGTH bytu z BUFFER do docasneho souboru.
int GetRangeOfFileColumns_ii(char *p_name)
Function gives the number columns of a file structured as a table.
void giveInverseMatrix3x3to5(double *answer, const double *m)
Function computes inverse of the eshelby-like 3x3 matrix 'm' saved in reduced 3x3to5 form...
void CopyArray2D(const double *const *src, double **dest, long d1, long d2)
Function copy two 2D double arrays with dimensions d1xd2 from 'src' to 'dest'.
void giveMatrixVectorProduct(const double *mtrx, const double *vect, double *resVect, long n)
Function gives the product of a regular matrix with a vector.
void printVectorRowForm(double *vect, int n, const char *notice)
Function prints the vector of double values as row.
void AddArray2D(const double *const *src, double **dest, long d1, long d2)
Function add 2D double array with dimensions d1xd2 from 'src' to 'dest'.
The header file of usefull macros.
void printVector(double *vect, int n, const char *notice)
Function prints the vector of double values as column.
Collection of the functions of basic manipulations, some of them can be used instead of their counter...
#define _at(mtrx, i, j, n)
void SubtractTwoArrays2D(const double *const *a1, const double *const *a2, double **answer, long d1, long d2)
Function subtracts two 2D double arrays with dimensions d1xd2. answer = v1 - v2.
double acosh(double x)
Inverse hyperbolic cosine.
void giveMatrixMatrixProduct(const double *mtrx1, const double *mtrx2, double *resMtrx, long n)
Function gives the product of two regular matrices.
#define FileError(fmode, name)
void ReadDataToArray(double **p_array, char *p_file_name)
description: function initializes a 2D 'double' array from a given file
void giveInverseMatrix3x3(double *answer, const double *m)
Function computes inverse of the row-wise saved 3x3 matrix 'm'.
void PrintProgress(double procento, int incr)
Operations with arrays of chars.
void printMatrix(double *mtrx, int n, const char *notice)
Function prints a matrix which are saved in 'row-by-row' C arrangement as 1D arrays.
void ReadDataTo3DArray(double ***p_array, char *p_file_name, int no_fields, int no_rows, int no_columns)
description: function initializes a 3D 'double' array by values from a given file ...
double ** AllocateArray2D(long d1, long d2)
Operations with 2d, 3d, 4d arrays of various sizes.
void AddArray3D(double ***src, double ***dest, long d1, long d2, long d3)
Function add 3D double array with dimensions d1xd2xd3 from 'src' to 'dest'.
double giveVectorLength(const double *point_1, const double *point_2)
void LatexPreambule(FILE *fw)
description: function prints a simple preamble of a LaTEX document last edit: 16.05.2007
void OpenFile(FILE **file, char *name, const char mode[])
Operations with file descriptors.
double give_VectorVectorProduct(const double *v1, const double *v2, long n)
Operations with 1d arrays of various length.
double giveVolumeEllipsoid(double a, double b, double c)
Function gives the volume of an allipsoid defined by its semiaxes a, b, c.
void CleanVector(double *a, long n)
Functin cleans a 'double' vector, initialize each value being 0-zero.
void LatexEnd(FILE *fw)
description: function prints the end (closing part) of LaTEX document last edit: 16.05.2007
bool isNumberPresentInVector(int number, int *vect, int range)
description: function returns TRUE/FALSE if a occurs/doesn't occurs in a , respectively ...
void DivideArray2D(double **a, double val, long d1, long d2)
Function divides 2D double array 'a' with dimensions d1xd2 by value 'val'.
void giveTransposedMatrix(const double *mtrx, double *T_mtrx, int n)
Function gives the trasposition of a matrix saved in row-by-row C arrangement.
int GetRangeOfFileColumns(char *p_name)
Function gives the number columns of the file such as is not necessarilly.