1.4.1
CCC
 
util.cpp File Reference
#include "geoslib_old_f.h"
#include "Basic/Utilities.hpp"
#include "Basic/String.hpp"
#include "Space/ASpaceObject.hpp"
#include "Space/ASpace.hpp"
#include "Space/SpaceSN.hpp"
#include "Geometry/GeometryHelper.hpp"
#include "Basic/Memory.hpp"
#include <string.h>
#include <cmath>

Classes

struct  Keypair
 
struct  Projec_Environ
 
struct  Dim_Loop
 

Functions

void projec_toggle (int mode)
 
void projec_query (int *actif)
 
void projec_print (void)
 
static int st_match_keypair (const char *keyword, int flag_exact)
 
static Keypairst_get_keypair_address (const char *keyword)
 
static void st_keypair_attributes (Keypair *keypair, int mode, int origin, int, int ncol)
 
static void st_keypair_allocate (Keypair *keypair, int nrow, int ncol)
 
static void st_keypair_copy (Keypair *keypair, int type, int start, void *values)
 
void set_keypair (const char *keyword, int origin, int nrow, int ncol, const double *values)
 
void app_keypair (const char *keyword, int origin, int nrow, int ncol, double *values)
 
void set_keypair_int (const char *keyword, int origin, int nrow, int ncol, int *values)
 
void app_keypair_int (const char *keyword, int origin, int nrow, int ncol, int *values)
 
static void del_keypone (int indice)
 
void del_keypair (const char *keyword, int flag_exact)
 
double get_keypone (const char *keyword, double valdef)
 
int get_keypair (const char *keyword, int *nrow, int *ncol, double **values)
 
int get_keypair_int (const char *keyword, int *nrow, int *ncol, int **values)
 
void print_keypair (int flag_short)
 
double ut_distance (int ndim, const double *tab1, const double *tab2)
 
void ut_distance_allocated (int ndim, double **tab1, double **tab2)
 
void set_last_message (int mode, const char *string)
 
void print_last_message (void)
 
int * ut_split_into_two (int ncolor, int flag_half, int verbose, int *nposs)
 
char * convert (const std::string &s)
 

Variables

static Projec_Environ PROJEC = { 0 }
 
static int KEYPAIR_NTAB = 0
 
static KeypairKEYPAIR_TABS = NULL
 
static int DISTANCE_NDIM = 0
 
static double * DISTANCE_TAB1 = NULL
 
static double * DISTANCE_TAB2 = NULL
 
static char ** LAST_MESSAGE = NULL
 
static int NB_LAST_MESSAGE = 0
 

Function Documentation

◆ app_keypair()

void app_keypair ( const char *  keyword,
int  origin,
int  nrow,
int  ncol,
double *  values 
)

Deposit a keypair (double values) - Append to existing array

Parameters
[in]keywordKeyword
[in]origin1 from C; 2 from R
[in]nrowNumber of rows
[in]ncolNumber of columns
[in]valuesArray of values (Dimension: nrow * ncol)
Remarks
Appending extends the number of rows but keeps the number of
columns and the origin unchanged... otherwise fatal error is issued
All keypair related function use realloc (rather than mem_realloc)
not to show up in the memory leak calculations

◆ app_keypair_int()

void app_keypair_int ( const char *  keyword,
int  origin,
int  nrow,
int  ncol,
int *  values 
)

Deposit a keypair (doubleinteger values) - Append to existing array

Parameters
[in]keywordKeyword
[in]origin1 from C; 2 from R
[in]nrowNumber of rows
[in]ncolNumber of columns
[in]valuesArray of values (Dimension: nrow * ncol)
Remarks
Appending extends the number of rows but keeps the number of
columns and the origin unchanged ... otherwise fatal error is issued
All keypair related function use realloc (rather than mem_realloc)
not to show up in the memory leak calculations

◆ convert()

char* convert ( const std::string s)

Convert std::string into a char *

Returns
Pointer to the returned array of characters
Parameters
[in]sInput VectorString

◆ del_keypair()

void del_keypair ( const char *  keyword,
int  flag_exact 
)

Delete a keypair

Parameters
[in]keywordKeyword to be deleted
[in]flag_exact1 if Exact keyword matching is required
Remarks
All keypair related function use malloc (rather than mem_alloc)
not to show up in the memory leak calculations

◆ del_keypone()

static void del_keypone ( int  indice)
static

Delete a keypair

Parameters
[in]indiceIndex of the Keyword to be deleted
Remarks
All keypair related function use malloc (rather than mem_alloc)
not to show up in the memory leak calculations

◆ get_keypair()

int get_keypair ( const char *  keyword,
int *  nrow,
int *  ncol,
double **  values 
)

Inquiry the keypair

Returns
Error returned code
Parameters
[in]keywordKeyword
[out]nrowNumber of rows
[out]ncolNumber of columns
[out]valuesArray of values attached to the keyword
Remarks
The returned array must be freed by the calling function
All keypair related function use malloc (rather than mem_alloc)
not to show up in the memory leak calculations

◆ get_keypair_int()

int get_keypair_int ( const char *  keyword,
int *  nrow,
int *  ncol,
int **  values 
)

Inquiry the keypair (integer values)

Returns
Error returned code
Parameters
[in]keywordKeyword
[out]nrowNumber of rows
[out]ncolNumber of columns
[out]valuesArray of values attached to the keyword
Remarks
The returned array must be freed by the calling function
All keypair related function use malloc (rather than mem_alloc)
not to show up in the memory leak calculations

◆ get_keypone()

double get_keypone ( const char *  keyword,
double  valdef 
)

Inquiry the keypair (for a single value)

Returns
Returned value
Parameters
[in]keywordKeyword
[in]valdefFactory setting value
Remarks
This function will returns systematically the default value
if the targeted keypair contains more than a single value

◆ print_keypair()

void print_keypair ( int  flag_short)

Print the list of keypairs

Parameters
[in]flag_short1 for a short output

◆ print_last_message()

void print_last_message ( void  )

Print the array of last messages

◆ projec_print()

void projec_print ( void  )

Print the characteristics of the projection

◆ projec_query()

void projec_query ( int *  actif)

Returns the projection characteristics

Parameters
[out]actifactivity flag

◆ projec_toggle()

void projec_toggle ( int  mode)

Toggle the status of the Projection flag

Parameters
[in]modeToggle of the projection flag
  • 0 : Switch the flag OFF
  • 1 : Switch the flag ON
  • -1 : Toggle the flag
  • else : Do not modify the flag

◆ set_keypair()

void set_keypair ( const char *  keyword,
int  origin,
int  nrow,
int  ncol,
const double *  values 
)

Deposit a keypair (double values)

Parameters
[in]keywordKeyword
[in]origin1 from C; 2 from R
[in]nrowNumber of rows
[in]ncolNumber of columns
[in]valuesArray of values (Dimension: nrow * ncol)
Remarks
All keypair related function use malloc (rather than mem_alloc)
not to show up in the memory leak calculations

◆ set_keypair_int()

void set_keypair_int ( const char *  keyword,
int  origin,
int  nrow,
int  ncol,
int *  values 
)

Deposit a keypair (integer values)

Parameters
[in]keywordKeyword
[in]origin1 from C; 2 from R
[in]nrowNumber of rows
[in]ncolNumber of columns
[in]valuesArray of values (Dimension: nrow * ncol)
Remarks
All keypair related function use malloc (rather than mem_alloc)
not to show up in the memory leak calculations

◆ set_last_message()

void set_last_message ( int  mode,
const char *  string 
)

Deposit a last message

Parameters
[in]modeType of operation 0 to empty the array of messages 1 to add the string to the array of messages -1 to concatenate the string to the last message
[in]stringCurrent string
Remarks
All keypair related function use malloc (rather than mem_alloc)
not to show up in the memory leak calculations

◆ st_get_keypair_address()

static Keypair* st_get_keypair_address ( const char *  keyword)
static

Internal function to find the keypair stack address or to create a new one if not already existing

Returns
The address in the stack
Parameters
[in]keywordKeyword
Remarks
If the keypair is new, the arguments 'nrow', 'ncol' and 'origin'
are set to zero
Otherwise they are not updated

◆ st_keypair_allocate()

static void st_keypair_allocate ( Keypair keypair,
int  nrow,
int  ncol 
)
static

Internal function to allocate the storage of a keypair

Parameters
[in]keypairKeypair structure
[in]nrowNumber of rows
[in]ncolNumber of columns

◆ st_keypair_attributes()

static void st_keypair_attributes ( Keypair keypair,
int  mode,
int  origin,
int  ,
int  ncol 
)
static

Internal function to copy or check the attributes (append)

Parameters
[in]keypairKeypair structure
[in]mode0 for creation and 1 for appending
[in]origin1 from C; 2 from R
[in]ncolNumber of columns
Remarks
The arguments 'ncol' and 'origin' are updated.
Conversely, the argument 'nrow' is not updated here

◆ st_keypair_copy()

static void st_keypair_copy ( Keypair keypair,
int  type,
int  start,
void *  values 
)
static

Internal function to copy the contents of values into he keypair

Parameters
[in]keypairKeypair structure
[in]type1 for integer, 2 for double
[in]startStaring address within 'values' in keypair
[in]valuesArray to be copied

◆ st_match_keypair()

static int st_match_keypair ( const char *  keyword,
int  flag_exact 
)
static

Look for an already registered keypair

Returns
Rank of the matching item (or -1)
Parameters
[in]keywordKeyword
[in]flag_exact1 if Exact keyword matching is required

◆ ut_distance()

double ut_distance ( int  ndim,
const double *  tab1,
const double *  tab2 
)

Calculate the distance between two endpoints

Returns
Distance value (or TEST if a coordinate is not defined)
Parameters
[in]ndimSpace dimension
[in]tab1Array corresponding to the first endpoint
[in]tab2Array corresponding to the second endpoint

◆ ut_distance_allocated()

void ut_distance_allocated ( int  ndim,
double **  tab1,
double **  tab2 
)

Allocate the necessary arrays for calculating distances using already allocated arrays

Parameters
[in]ndimSpace dimension
[out]tab1Array for coordinates of first sample
[out]tab2Array for coordinates of second sample
Remarks
This function uses realloc (rather than mem_realloc)
not to show up in the memory leak calculations

◆ ut_split_into_two()

int* ut_split_into_two ( int  ncolor,
int  flag_half,
int  verbose,
int *  nposs 
)

Return all the ways to split ncolor into two non-empty subsets

Returns
Return an array of possibilities
Parameters
[in]ncolorNumber of colors
[in]flag_half1 if only half of possibilities must be envisaged
[in]verbose1 for a verbose option
[out]npossNumber of possibilities
Remarks
The calling function must free the returned array.
The array has 'ncolor' columns and 'ncomb' subsets
The elements of each row are set to 0 or 1 (subset rank)

Variable Documentation

◆ DISTANCE_NDIM

int DISTANCE_NDIM = 0
static

◆ DISTANCE_TAB1

double* DISTANCE_TAB1 = NULL
static

◆ DISTANCE_TAB2

double* DISTANCE_TAB2 = NULL
static

◆ KEYPAIR_NTAB

int KEYPAIR_NTAB = 0
static

◆ KEYPAIR_TABS

Keypair* KEYPAIR_TABS = NULL
static

◆ LAST_MESSAGE

char** LAST_MESSAGE = NULL
static

◆ NB_LAST_MESSAGE

int NB_LAST_MESSAGE = 0
static

◆ PROJEC

Projec_Environ PROJEC = { 0 }
static