TP Intégration Numérique
 All Files Functions
utils.h File Reference

Useful tools to illustrate the course of C Language : header file. More...

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include "textcolors.h"

Go to the source code of this file.

Macros

#define PRINT_DEBUG(C, A)
 
#define PRINT_VERBOSE(C)
 
#define MAX(a, b)   ((a>b)?(a):(b))
 
#define MIN(a, b)   ((a>b)?(b):(a))
 

Typedefs

typedef unsigned long MEMORY_TYPE
 

Enumerations

enum  Bool { false =0, true =1 }
 

Functions

void * Calloc (size_t nmemb, size_t size)
 Interface to usual calloc function with same parameters.
 
void * Malloc (size_t size)
 Interface to usual malloc function with same parameters.
 
void Free (void *ptr)
 Interface to usual free function with same parameters.
 
void FREE (void **ptr)
 Modified version of the usual free function.
 
void printDoubleDynArray (double *X, int N, char *Name, char *format, int perline)
 Matlab like printing array.
 
void saveDoubleDynArray (double *X, int N, char *FileName, char *format)
 save X array in file
 
void saveTwoDoubleDynArray (double *X, double *Y, int N, char *FileName, char *format)
 save X and Y arrays in file
 

Detailed Description

Useful tools to illustrate the course of C Language : header file.

Author
F. Cuvelier
Version
0.1
Date
18th November 2013

For printing memory information compile with -DDEBUG option and for more information compile with -DVERBOSE option.
gcc sample command:

 gcc -DDEBUG -DVERBOSE -c utils.c

or more generaly

 make DEBUG=1 VERBOSE=1

Definition in file utils.h.

Function Documentation

void FREE ( void **  ptr)

Modified version of the usual free function.

Parameters
[in]*ptrpointer to free.
[out]*ptrpointer set to NULL pointer after memory freeing .

Definition at line 43 of file utils.c.

void printDoubleDynArray ( double *  X,
int  N,
char *  Name,
char *  format,
int  perline 
)

Matlab like printing array.

Parameters
[in]Xpointer to dynamic array of doubles,
[in]Nnumber of doubles in X,
[in]Namedisplaying name,
[in]formatformat specification for displaying double values, "%.16lf" for example,
[in]perlinenumber of double values per line.

Definition at line 51 of file utils.c.

void saveDoubleDynArray ( double *  X,
int  N,
char *  FileName,
char *  format 
)

save X array in file

Parameters
[in]Xpointer to dynamic array of doubles,
[in]Nnumber of doubles in X,
[in]FileNamename of the file,
[in]formatformat specification for writing double values, "%.16lf" for example,

One double value by line!

Definition at line 68 of file utils.c.

void saveTwoDoubleDynArray ( double *  X,
double *  Y,
int  N,
char *  FileName,
char *  format 
)

save X and Y arrays in file

Parameters
[in]Xpointer to dynamic array of doubles,
[in]Ypointer to dynamic array of doubles,
[in]Nnumber of doubles in X and in Y,
[in]FileNamename of the file,
[in]formatformat specification for writing double values, "%.16lf %.16lf" for example,

Two double values by line!

Definition at line 82 of file utils.c.