This file is indexed.

/usr/include/lorene/C++/Include/utilitaires.h is in liblorene-dev 0.0.0~cvs20161116+dfsg-1ubuntu4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
/*
 *  Prototypes of various utilities for Lorene
 *
 */

/*
 *   Copyright (c) 1999-2001 Eric Gourgoulhon
 *
 *   This file is part of LORENE.
 *
 *   LORENE is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 *   LORENE is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with LORENE; if not, write to the Free Software
 *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */


#ifndef	__UTILITAIRES_H_
#define	__UTILITAIRES_H_


/*
 * $Id: utilitaires.h,v 1.16 2015/01/09 15:28:52 j_novak Exp $
 * $Log: utilitaires.h,v $
 * Revision 1.16  2015/01/09 15:28:52  j_novak
 * New integration function for general non-equally-spaced grids.
 *
 * Revision 1.15  2014/10/13 08:52:37  j_novak
 * Lorene classes and functions now belong to the namespace Lorene.
 *
 * Revision 1.14  2014/10/06 15:09:40  j_novak
 * Modified #include directives to use c++ syntax.
 *
 * Revision 1.13  2014/07/04 12:09:06  j_novak
 * New argument in zerosec(): a boolean (false by default) for aborting if the number of iteration is greater than the max.
 *
 * Revision 1.12  2014/04/25 10:43:50  j_novak
 * The member 'name' is of type string now. Correction of a few const-related issues.
 *
 * Revision 1.11  2008/08/19 06:41:59  j_novak
 * Minor modifications to avoid warnings with gcc 4.3. Most of them concern
 * cast-type operations, and constant strings that must be defined as const char*
 *
 * Revision 1.10  2004/09/01 09:47:55  r_prix
 * fixed/improved string-reading with read_variable(): allocates returned string
 *
 * Revision 1.9  2004/03/22 13:12:44  j_novak
 * Modification of comments to use doxygen instead of doc++
 *
 * Revision 1.8  2003/12/17 23:12:30  r_prix
 * replaced use of C++ <string> by standard ANSI char* to be backwards compatible
 * with broken compilers like MIPSpro Compiler 7.2 on SGI Origin200. ;-)
 *
 * Revision 1.7  2003/12/05 15:05:53  r_prix
 * added read_variable() for (C++-type) strings.
 *
 * Revision 1.6  2003/12/04 12:33:21  r_prix
 * added prototypes and documentation for variable-reading functions
 * (read_variable, load_file, load_file_buffered)
 *
 * Revision 1.5  2002/05/02 15:16:22  j_novak
 * Added functions for more general bi-fluid EOS
 *
 * Revision 1.4  2002/04/16 08:06:44  j_novak
 * Addition of zerosec_borne
 *
 * Revision 1.3  2002/04/11 09:19:46  j_novak
 * Back to old version of zerosec
 *
 * Revision 1.2  2001/12/04 21:24:33  e_gourgoulhon
 *
 * New functions fwrite_be and fread_be for writing/reading in a
 * binary file according to the big endian convention.
 *
 * Revision 1.1.1.1  2001/11/20 15:19:27  e_gourgoulhon
 * LORENE
 *
 * Revision 1.6  2001/09/14  14:23:53  eric
 * Ajout de la fonction zero_list.
 *
 * Revision 1.5  2001/05/29  16:11:21  eric
 * Modif commentaires (mise en conformite Doc++ 3.4.7).
 *
 * Revision 1.4  1999/12/24  12:59:54  eric
 * Ajout de la routine zero_premier.
 *
 * Revision 1.3  1999/12/15  15:39:42  eric
 * *** empty log message ***
 *
 * Revision 1.2  1999/12/15  15:17:03  eric
 * *** empty log message ***
 *
 * Revision 1.1  1999/12/15  09:41:47  eric
 * Initial revision
 *
 *
 * $Header: /cvsroot/Lorene/C++/Include/utilitaires.h,v 1.16 2015/01/09 15:28:52 j_novak Exp $
 *
 */
 
#include "stdio.h"
#include <cstring>

namespace Lorene {
class Param ;
class Tbl ;

/**
 * \defgroup misc Miscellaneous
 * \ingroup (util)
 * @{
 */


/** Setting a stop point in a code.
 * 
 *  Stops the execution of a code, until the 'Enter' case is hit.
 *  @param   a	[input] stops the run if, and only if, a=0.
 *			Default value : 0.
 * 
 * 
 */
void arrete(int a = 0) ;

/** Locates the sub-interval containing the first zero of a function in 
 *  a given interval.
 * 
 *  @param (*f)(double, const Param\&) [input] Function the zero of which is 
 *		    to be searched: 
 *			f(x0, par) = 0 , where par are the parameters of the
 *		    function f, stored in an object of the Lorene class 
 *		    \c Param . 
 *  @param a [input] Lower bound of the search interval [a, b]
 *  @param b [input] Higher bound of the search interval [a, b]
 *  @param n [input] Number of subdivisions of the interval [a, b]
 *  @param a0 [output] Lower bound of the first (i.e. closest to a) interval 
 *		      [a0, b0] which contains a zero of f 
 *  @param b0 [output] Higher bound of the first (i.e. closest to a) interval 
 *		      [a0, b0] which contains a zero of f 
 *  @return  true if the interval [a0, b0] containing a zero of f has been
 *	    found, false otherwise
 */
bool zero_premier(double (*f)(double, const Param&), const Param& par,
		  double a, double b, int n, double& a0, double& b0) ;



/** Finding the zero a function.
 * 
 *  This routine locates a zero by means of the secant method. 
 * 
 *  @param (*f)(double, const Param\&) [input] Function the zero of which is 
 *		    to be searched: the routine computes x0 in a given
 *		    interval [a, b] such that 
 *			f(x0, par) = 0 , where par are the parameters of the
 *		    function f, stored in an object of the Lorene class 
 *		    \c Param . 
 *  @param par [input] Parameters of the function f.
 *  @param a [input] Lower bound of the search interval [a, b]
 *  @param b [input] Higher bound of the search interval [a, b]
 *  @param precis [input] Required precision in the determination of x0 : 
 *			the returned solution will be x0 +/- precis
 *  @param nitermax [input] Maximum number of iterations in the secant 
 *			    method to compute x0.
 *  @param niter [output] Number of iterations effectively used in computing x0
 *  @param abort [input] Should the function abort if the maximal number of
 *                       iterations has been reached?
 *  @return x0 (zero of function f)
 *
 */
double zerosec( double (*f)(double, const Param&), const Param& par, 
		double a, double b, double precis, int nitermax, 
		int& niter, bool abort=true) ;

/** Finding the zero a function on a bounded domain.
 * 
 *  Same as \c zerosec  but insures that all calls to the function f
 *  are within [x1,x2]. Namely, it requires that f(x1)*f(x2)<0. 
 * 
 *  @param (*f)(double, const Param\&) [input] Function the zero of which is 
 *		    to be searched: the routine computes x0 in a given
 *		    interval [a, b] such that 
 *			f(x0, par) = 0 , where par are the parameters of the
 *		    function f, stored in an object of the Lorene class 
 *		    \c Param . 
 *  @param par [input] Parameters of the function f.
 *  @param a [input] Lower bound of the search interval [a, b]
 *  @param b [input] Higher bound of the search interval [a, b]
 *  @param precis [input] Required precision in the determination of x0 : 
 *			the returned solution will be x0 +/- precis
 *  @param nitermax [input] Maximum number of iterations in the secant 
 *			    method to compute x0.
 *  @param niter [output] Number of iterations effectively used in computing x0				
 *  @return x0 (zero of function f)
 *
 */
double zerosec_b( double (*f)(double, const Param&),const Param& par, 
		  double a, double b, double precis, int nitermax, 
		  int& niter) ;

/** Locates approximatively all the zeros of a function in a given interval.
 *  The N zeros are located in N intervals [az(i), bz(i)] with
 *   \f$0\leq i \leq N-1\f$.  
 * 
 *  @param (*f)(double, const Param\&) [input] Function the zeros of which are 
 *		    to be located: a zero x0 is defined by 
 *			f(x0, par) = 0 , where par are the parameters of the
 *		    function f, stored in an object of the Lorene class 
 *		    \c Param . 
 *  @param par [input] Parameters of the function f.
 *  @param xmin [input] Lower bound of the search interval 
 *  @param xmax [input] Higher bound of the search interval 
 *  @param nsub [input] Number of subdivision of the interval [xmin, xmax]
 *		        to locate the zeros
 *  @param az [output] 1-D array (Lorene \c Tbl ) contain the lower bounds
 *			of the intervals containing a zero. This \c Tbl \ 
 *			is allocated by the routine via a \c new Tbl \ 
 *			command (hence the pointer type). 
 *  @param bz [output] 1-D array (Lorene \c Tbl ) contain the higher bounds
 *			of the intervals containing a zero. This \c Tbl \ 
 *			is allocated by the routine via a \c new Tbl \ 
 *			command (hence the pointer type). 
 *  
 */
void zero_list( double (*f)(double, const Param&), const Param& par,
		double xmin, double xmax, int nsub, 
		Tbl*& az, Tbl*& bz ) ;  
		
/** Integrates a function defined on an unequally-spaced grid, approximating
 * it by piece parabolae.
 *
 * This function performs the numerical integration of a function given by its
 * values on a unequally-spaced grid, by means of local parabolic approximation.
 * The resulting primitive is set to 0 on the lower end of the integration
 * interval.
 *      @param xx [input] \c Tbl containing the grid abscissas
 *      @param ff [input] \c Tbl containing the values of the function to be 
 *                integrated, on the grid points
 *      @return a \c Tbl with the values of the primitive of \c ff at the grid
 *                points, such that it is zero at the first grid point.
 */
 Tbl integ1D(const Tbl& xx, const Tbl& ff) ;

/** Writes integer(s) into a binary file according to the
 *  big endian convention.
 *
 *  This function has the same prototype and return value than
 *  the \c fwrite  function of the \c stdio  C library.
 *  The difference is that it ensures that the binary file is
 *  written in the big endian format, whatever the system is
 *  using little endian or big endian.
 *	@param aa [input] integer array to be written (in case of one
 *		element, address of this integer)
 *	@param size [input] number of bytes of one \c int  (must
 *		be 4)
 *	@param nb [input] number of elements in the array \c aa 
 *	@param fich [input] binary file (must have been
 *		open by \c fopen )
 *	@return number of integers effectively written in the file
 */		
int fwrite_be(const int* aa, int size, int nb, FILE* fich) ;

/** Writes double precision number(s) into a binary file according to the
 *  big endian convention.
 *
 *  This function has the same prototype and return value than
 *  the \c fwrite  function of the \c stdio  C library.
 *  The difference is that it ensures that the binary file is
 *  written in the big endian format, whatever the system is
 *  using little endian or big endian.
 *	@param aa [input] array of \c double  to be written (in case of one
 *		element, address of this \c double )
 *	@param size [input] number of bytes of one \c double  (must
 *		be 8)
 *	@param nb [input] number of elements in the array \c aa 
 *	@param fich [input] binary file (must have been
 *		open by \c fopen )
 *	@return number of \c double  effectively written in the file
 */		
int fwrite_be(const double* aa, int size, int nb, FILE* fich) ;

/** Reads integer(s) from a binary file according to the
 *  big endian convention.
 *
 *  This function has the same prototype and return value than
 *  the \c fread  function of the \c stdio  C library.
 *  The difference is that it assumes that the binary file is
 *  written in the big endian format, whatever the system is
 *  using little endian or big endian.
 *	@param aa [output] integer array to be read (in case of one
 *		element, address of this integer)
 *	@param size [input] number of bytes of one \c int  (must
 *		be 4)
 *	@param nb [input] number of elements in the array \c aa 
 *	@param fich [input] binary file (must have been
 *		open by \c fopen )
 *	@return number of integers effectively read in the file
 */		
int fread_be(int* aa, int size, int nb, FILE* fich) ;

/** Reads double precision number(s) from a binary file according to the
 *  big endian convention.
 *
 *  This function has the same prototype and return value than
 *  the \c fread  function of the \c stdio  C library.
 *  The difference is that it assumes that the binary file is
 *  written in the big endian format, whatever the system is
 *  using little endian or big endian.
 *	@param aa [output] array of \c double  to be read (in case of one
 *		element, address of this \c double )
 *	@param size [input] number of bytes of one \c double  (must
 *		be 8)
 *	@param nb [input] number of elements in the array \c aa 
 *	@param fich [input] binary file (must have been
 *		open by \c fopen )
 *	@return number of \c double  effectively read in the file
 */		
int fread_be(double* aa, int size, int nb, FILE* fich) ;


/** Read file into memory and returns pointer to data.
 * 	@return: pointer to allocated memory or NULL on error.\\
 * 
 *  NOTE: don't forget to free the memory after use !
 *
 */
char *load_file(char *fname);

/** Returns pointer to data from a file using a buffer.
 *  This function only reads from disk if the file has not been buffered yet.
 *  If a new file is read, the buffer is free'ed and the new data allocated.
 *	@param fname [input] name of file to read in. You can use NULL for previous file.
 *  	@return : pointer to buffered data or NULL on error.\\
 *
 *   NOTE: do _NEVER_ free the (buffer-)data pointer, or the next call will crash!!
 */
char *load_file_buffered(char *fname);

/** Reads a variable from file. 
 * Variable definitions can be of the type 
 * "variable = value", all other lines are ignored as comments.
 * (alternatively, you can use ":" or whitespace instead of "=")
 * 
 * NOTE: the variable-definition has to be at the beginning of a 
 * line (modulo whitespace), or it will be considered a comment!
 *
 *	@param fname [input] Name of config-file to read from. Use NULL to use buffered file.
 *	@param var_name [input] Variable-name to read from config-file
 *	@param fmt [input]  C-style format string for reading (see \c sscanf ).
 *	@param varp [output] Pointer to C-variable to read value into (has to be big enough!!)
 *
 *	@return 0 on success, -1 on error. \\
 *
 *   NOTE: rather use one of the type-specific overloaded functions below whenever possible
 *   (safer due to type-checking)
 */
int read_variable(const char *fname, const char *var_name, char *fmt, void *varp);

/// Read an integer-variable from file (cf \c read_variable(char *, char *, char *, void *) ).
int read_variable(const char *fname, const char *var_name, int &var);
/// Read a bool variable from file (cf \c read_variable(char *, char *, char *, void *) ).
int read_variable(const char *fname, const char *var_name, bool &var);
/// Read a double variable from file (cf \c read_variable(char *, char *, char *, void *) ).
int read_variable(const char *fname, const char *var_name, double &var);
/// Read a (ANSI C) string variable from file.
int read_variable (const char *fname, const char *var_name, char **str);

/// 'Improved' malloc that sets memory to 0 and also auto-terminates on error.
void *MyMalloc (long bytes);

/// A portable routine to determine the length of a file
int FS_filelength (FILE *f);

/// Helpful function to say something is not implemented yet 
void c_est_pas_fait(const char * ) ;
    
/** @} */
    
}
#endif