gstlearn  1.0.0
CCC
AStringable.cpp File Reference
#include "geoslib_old_f.h"
#include "Matrix/LinkMatrixSparse.hpp"
#include "Enum/EJustify.hpp"
#include "Basic/AStringable.hpp"
#include "Basic/VectorNumT.hpp"
#include "Basic/String.hpp"
#include "Basic/Utilities.hpp"
#include "Basic/File.hpp"
#include "Basic/OptCst.hpp"
#include <string>
#include <iostream>
#include <sstream>
#include <typeinfo>
#include <iomanip>
#include <stdio.h>
#include <stdarg.h>
#include <math.h>
#include <string.h>
#include "csparse_d.h"
#include "csparse_f.h"

Macros

#define CASE_DOUBLE   0
 
#define CASE_REAL   1
 
#define CASE_INT   2
 
#define CASE_COL   3
 
#define CASE_ROW   4
 
#define TRI(i)   (((i) * ((i) + 1)) / 2)
 
#define TL1(i, j)   (tl[(j)*neq+(i)-TRI(j)]) /* only for i >= j */
 
#define TL2(i, j)   (tl[TRI(i)+(j)]) /* only for i >= j */
 

Functions

std::stringstream _formatColumn (const EJustify &justify, int localSize=0)
 
String _tabPrintString (const String &string, const EJustify &justify, int localSize=0)
 
String _tabPrintDouble (double value, const EJustify &justify, int localSize=0)
 
String _tabPrintInt (int value, const EJustify &justify, int localSize=0)
 
String _tabPrintRowColumn (int icase, int value, int flagAdd)
 
String _printColumnHeader (const VectorString &colnames, int colfrom, int colto, int colSize=_getColumnSize())
 
String _printRowHeader (const VectorString &rownames, int iy, int rowSize=_getColumnSize())
 
String _printTrailer (int ncols, int nrows, int ncols_util, int nrows_util)
 
void message (const char *format,...)
 
void messageNoDiff (const char *format,...)
 
void messageFlush (const String &string)
 
void messerrFlush (const String &string)
 
void messerr (const char *format,...)
 
void mesArg (const char *title, int current, int nmax, bool flagStartOne)
 
void mestitle (int level, const char *format,...)
 
void mes_process (const char *string, int ntot, int iech)
 
String toTitle (int level, const char *format,...)
 
void messageAbort (const char *format,...)
 
String toMatrix (const String &title, const VectorString &colnames, const VectorString &rownames, bool bycol, int ncols, int nrows, const VectorDouble &tab, bool flagOverride)
 
String toMatrixSymmetric (const String &title, const VectorString &colnames, const VectorString &rownames, bool bycol, int ncols, const VectorDouble &tab, bool flagOverride)
 
String toMatrixDiagonal (const String &title, const VectorString &colnames, const VectorString &rownames, int ncols, const VectorDouble &tab, bool flagOverride)
 
String toMatrixDiagCst (const String &title, const VectorString &colnames, const VectorString &rownames, int ncols, const VectorDouble &tab, bool flagOverride)
 
String toMatrix (const String &title, const VectorString &colnames, const VectorString &rownames, bool bycol, int ncols, int nrows, const VectorInt &tab, bool flagOverride)
 
String toMatrix (const String &title, const cs *A, bool flagOverride)
 
String toVector (const String &title, const VectorDouble &tab, bool flagOverride)
 
String toVector (const String &title, const VectorVectorDouble &tab, bool flagOverride)
 
String toVector (const String &title, const VectorString &tab, bool flagOverride)
 
String toVector (const String &title, const VectorInt &tab, bool flagOverride)
 
String toStr (const String &string, const EJustify &justify, int localSize)
 
String toDouble (double value, const EJustify &justify)
 
VectorString toVectorDouble (const VectorDouble &values, const EJustify &justify)
 
String toInt (int value, const EJustify &justify)
 
String toInterval (double zmin, double zmax)
 
void tab_prints (const char *title, const char *string, int ncol, const EJustify &justify)
 
void tab_printg (const char *title, double value, int ncol, const EJustify &justify)
 
void tab_printd (const char *title, double value, int ncol, const EJustify &justify)
 
void tab_printi (const char *title, int value, int ncol, const EJustify &justify)
 
void tab_print_rc (const char *title, int mode, int value, int ncol, const EJustify &justify)
 
void tab_print_rowname (const char *string, int taille)
 
void print_matrix (const char *title, int flag_limit, int bycol, int nx, int ny, const double *sel, const double *tab)
 
void print_trimat (const char *title, int mode, int neq, const double *tl)
 
void print_imatrix (const char *title, int flag_limit, int bycol, int nx, int ny, const double *sel, const int *tab)
 
void print_vector (const char *title, int flag_limit, int ntab, const double *tab)
 
void print_vector (const char *title, int flag_limit, int ntab, const VectorDouble &tab)
 
void print_ivector (const char *title, int flag_limit, int ntab, const int *itab)
 
void print_ivector (const char *title, int flag_limit, int ntab, const VectorInt &itab)
 

Macro Definition Documentation

◆ CASE_COL

#define CASE_COL   3

◆ CASE_DOUBLE

#define CASE_DOUBLE   0

◆ CASE_INT

#define CASE_INT   2

◆ CASE_REAL

#define CASE_REAL   1

◆ CASE_ROW

#define CASE_ROW   4

◆ TL1

#define TL1 (   i,
 
)    (tl[(j)*neq+(i)-TRI(j)]) /* only for i >= j */

◆ TL2

#define TL2 (   i,
 
)    (tl[TRI(i)+(j)]) /* only for i >= j */

◆ TRI

#define TRI (   i)    (((i) * ((i) + 1)) / 2)

Function Documentation

◆ _formatColumn()

std::stringstream _formatColumn ( const EJustify &  justify,
int  localSize = 0 
)

◆ _printColumnHeader()

String _printColumnHeader ( const VectorString colnames,
int  colfrom,
int  colto,
int  colSize = _getColumnSize() 
)

◆ _printRowHeader()

String _printRowHeader ( const VectorString rownames,
int  iy,
int  rowSize = _getColumnSize() 
)

◆ _printTrailer()

String _printTrailer ( int  ncols,
int  nrows,
int  ncols_util,
int  nrows_util 
)

◆ _tabPrintDouble()

String _tabPrintDouble ( double  value,
const EJustify &  justify,
int  localSize = 0 
)

◆ _tabPrintInt()

String _tabPrintInt ( int  value,
const EJustify &  justify,
int  localSize = 0 
)

◆ _tabPrintRowColumn()

String _tabPrintRowColumn ( int  icase,
int  value,
int  flagAdd 
)

◆ _tabPrintString()

String _tabPrintString ( const String string,
const EJustify &  justify,
int  localSize = 0 
)

◆ mes_process()

void mes_process ( const char *  string,
int  ntot,
int  iech 
)

Conditionally print the progress of a procedure

Parameters
stringString to be printed
ntotTotal number of samples
iechRank of the current sample
Remarks
The value 'nproc' designates the quantile such that,
when changed, the printout is provoked.

◆ mesArg()

void mesArg ( const char *  title,
int  current,
int  nmax,
bool  flagStartOne 
)

Print a standard Error Message if an argument does not lie in Interval

Parameters
titleTitle to be printed
currentCurrent value of the argument
nmaxMaximum (inclusive) possible value
flagStartOneTrue if the count starts at 1 (instead of 0)

◆ message()

void message ( const char *  format,
  ... 
)

Print a formatted message

Parameters
formatOutput format
...Additional arguments

◆ messageAbort()

void messageAbort ( const char *  format,
  ... 
)

Function for aborting the API

Parameters
formatFatal error format
...Additional arguments

◆ messageFlush()

void messageFlush ( const String string)

When message has been collected as a String, this function produces it out without passing through useless internal buffering

Parameters
stringString to be printed out

◆ messageNoDiff()

void messageNoDiff ( const char *  format,
  ... 
)

Print a formatted message (with "#NO_DIFF#" prefix)

Parameters
formatOutput format
...Additional arguments

◆ messerr()

void messerr ( const char *  format,
  ... 
)

Print Error message

Parameters
formatOutput format
...Additional arguments

◆ messerrFlush()

void messerrFlush ( const String string)

When the error message has been collected as a String, this function produces it out without passing through useless internal buffering

Parameters
stringString to be produced
Remarks
This function is similar to messageFlush but dedicated to Errors

◆ mestitle()

void mestitle ( int  level,
const char *  format,
  ... 
)

Print a message and underlines it with various formats

Parameters
levelLevel of the title
formatOutput format
...Additional arguments

◆ print_imatrix()

void print_imatrix ( const char *  title,
int  flag_limit,
int  bycol,
int  nx,
int  ny,
const double *  sel,
const int *  tab 
)

Tabulated printout of a matrix (integer version)

Parameters
[in]titleTitle (Optional)
[in]flag_limitoption for the limits
  • 1 if limits must be applied
  • 0 if the whole matrix is printed
[in]bycol1 if values in 'tab' are sorted by column, 0 otherwise
[in]nxnumber of columns in the matrix
[in]nynumber of rows in the matrix
[in]selarray of selection or NULL
[in]tabarray containing the matrix

◆ print_ivector() [1/2]

void print_ivector ( const char *  title,
int  flag_limit,
int  ntab,
const int *  itab 
)

Print a vector of integer values in a matrix form

Parameters
[in]titleTitle (Optional)
[in]flag_limit1 if NTCOL is used; 0 otherwise
[in]ntabNumber of elements in the array
[in]itabArray to be printed

◆ print_ivector() [2/2]

void print_ivector ( const char *  title,
int  flag_limit,
int  ntab,
const VectorInt itab 
)

◆ print_matrix()

void print_matrix ( const char *  title,
int  flag_limit,
int  bycol,
int  nx,
int  ny,
const double *  sel,
const double *  tab 
)

Tabulated printout of a matrix

Parameters
[in]titleTitle (Optional)
[in]flag_limitoption for the limits
  • 1 if limits must be applied
  • 0 if the whole matrix is printed
[in]bycol1 if values in 'tab' are sorted by column, 0 otherwise
[in]nxnumber of columns in the matrix
[in]nynumber of rows in the matrix
[in]selarray of selection or NULL
[in]tabarray containing the matrix
Remarks
The order of the dimension (nx,ny) is opposite
of the one used in R-packages where dim[1]=nrow and dim[2]=ncol

◆ print_trimat()

void print_trimat ( const char *  title,
int  mode,
int  neq,
const double *  tl 
)

Tabulated printout of a upper triangular matrix

Parameters
[in]titleTitle (Optional)
[in]mode1 if the matrix is stored linewise 2 if the matrix is stored columnwise
[in]neqsize of the matrix
[in]tlarray containing the upper triangular matrix
Remarks
The ordering (compatible with matrix_solve is mode==2)

◆ print_vector() [1/2]

void print_vector ( const char *  title,
int  flag_limit,
int  ntab,
const double *  tab 
)

Print a vector of real values in a matrix form

Parameters
[in]titleTitle (Optional)
[in]flag_limit1 if NTCOL is used; 0 otherwise
[in]ntabNumber of elements in the array
[in]tabArray to be printed

◆ print_vector() [2/2]

void print_vector ( const char *  title,
int  flag_limit,
int  ntab,
const VectorDouble tab 
)

◆ tab_print_rc()

void tab_print_rc ( const char *  title,
int  mode,
int  value,
int  ncol,
const EJustify &  justify 
)

Tabulated printout of a row or column value

Parameters
[in]titleoptional title (NULL if not defined)
[in]modeCASE_ROW or CASE_COL
[in]valueValue to be written
[in]ncolnumber of columns for the printout
[in]justifyjustification flag (EJustify::LEFT, EJustify::CENTER or EJustify::RIGHT)

◆ tab_print_rowname()

void tab_print_rowname ( const char *  string,
int  taille 
)

Tabulated printout of a string (character size provided)

Parameters
[in]stringString to be written
[in]tailleNumber of characters
Remarks
The string is printed (left-adjusted) on 'taille' characters

◆ tab_printd()

void tab_printd ( const char *  title,
double  value,
int  ncol,
const EJustify &  justify 
)

Tabulated printout of a double value

Parameters
[in]titleoptional title (NULL if not defined)
[in]valueValue to be written
[in]ncolnumber of columns for the printout
[in]justifyjustification flag (EJustify::LEFT, EJustify::CENTER or EJustify::RIGHT)

◆ tab_printg()

void tab_printg ( const char *  title,
double  value,
int  ncol,
const EJustify &  justify 
)

Tabulated printout of a real value

Parameters
[in]titleoptional title (NULL if not defined)
[in]valueValue to be written
[in]ncolnumber of columns for the printout
[in]justifyjustification flag (EJustify::LEFT, EJustify::CENTER or EJustify::RIGHT)

◆ tab_printi()

void tab_printi ( const char *  title,
int  value,
int  ncol,
const EJustify &  justify 
)

Tabulated printout of an integer value

Parameters
[in]titleoptional title (NULL if not defined)
[in]valueValue to be written
[in]ncolnumber of columns for the printout
[in]justifyjustification flag (EJustify::LEFT, EJustify::CENTER or EJustify::RIGHT)

◆ tab_prints()

void tab_prints ( const char *  title,
const char *  string,
int  ncol,
const EJustify &  justify 
)

Tabulated printout of a string

Parameters
[in]titleoptional title (NULL if not defined)
[in]stringString to be written
[in]ncolnumber of columns for the printout
[in]justifyjustification flag (EJustify::LEFT, EJustify::CENTER or EJustify::RIGHT)

◆ toDouble()

String toDouble ( double  value,
const EJustify &  justify 
)

◆ toInt()

String toInt ( int  value,
const EJustify &  justify 
)

◆ toInterval()

String toInterval ( double  zmin,
double  zmax 
)

◆ toMatrix() [1/3]

String toMatrix ( const String title,
const cs *  A,
bool  flagOverride 
)

◆ toMatrix() [2/3]

String toMatrix ( const String title,
const VectorString colnames,
const VectorString rownames,
bool  bycol,
int  ncols,
int  nrows,
const VectorDouble tab,
bool  flagOverride 
)

Print the contents of a VectorDouble in a Matrix Form

Parameters
titleTitle of the printout
colnamesNames of the columns (optional)
rownamesNames of the rows (optional)
bycoltrue if values as sorted by column; false otherwise
ncolsNumber of columns
nrowsNumber of rows
tabVectorDouble containing the values
flagOverridetrue to override printout limitations

◆ toMatrix() [3/3]

String toMatrix ( const String title,
const VectorString colnames,
const VectorString rownames,
bool  bycol,
int  ncols,
int  nrows,
const VectorInt tab,
bool  flagOverride 
)

Print the contents of a VectorDouble in a Matrix Form

Parameters
titleTitle of the printout
colnamesNames of the columns (optional)
rownamesNames of the rows (optional)
bycoltrue if values as sorted by column; false otherwise
ncolsNumber of columns
nrowsNumber of rows
tabVectorInt containing the values
flagOverridetrue to override printout limitations

◆ toMatrixDiagCst()

String toMatrixDiagCst ( const String title,
const VectorString colnames,
const VectorString rownames,
int  ncols,
const VectorDouble tab,
bool  flagOverride 
)

Specific printout dedicated to square diagonal matrices

Parameters
titleTitle of the printout
colnamesNames of the columns (optional)
rownamesNames of the rows (optional)
ncolsNumber of columns = Number of rows
tabVectorDouble containing the values (Dimension: 1)
flagOverrideOverride the printout limitations
Returns

◆ toMatrixDiagonal()

String toMatrixDiagonal ( const String title,
const VectorString colnames,
const VectorString rownames,
int  ncols,
const VectorDouble tab,
bool  flagOverride 
)

Specific printout dedicated to square diagonal matrices

Parameters
titleTitle of the printout
colnamesNames of the columns (optional)
rownamesNames of the rows (optional)
ncolsNumber of columns = Number of rows
tabVectorDouble containing the values (Dimension: ncols)
flagOverrideOverride the printout limitations
Returns

◆ toMatrixSymmetric()

String toMatrixSymmetric ( const String title,
const VectorString colnames,
const VectorString rownames,
bool  bycol,
int  ncols,
const VectorDouble tab,
bool  flagOverride 
)

Specific printout dedicated to square symmetrical matrices Only the Upper left side is printed

Parameters
titleTitle of the printout
colnamesNames of the columns (optional)
rownamesNames of the rows (optional)
bycoltrue if values as sorted by column; false otherwise
ncolsNumber of columns = Number of rows
tabVectorDouble containing the values (Dimension: n * (n+1) /2)
flagOverrideOverride the printout limitations
Returns

◆ toStr()

String toStr ( const String string,
const EJustify &  justify,
int  localSize 
)

◆ toTitle()

String toTitle ( int  level,
const char *  format,
  ... 
)

Print a message and underlines it with various formats

Parameters
levelLevel of the title
formatOutput format
...Additional arguments

◆ toVector() [1/4]

String toVector ( const String title,
const VectorDouble tab,
bool  flagOverride 
)

Printout a vector in a formatted manner

Parameters
titleTitle of the printout (or empty string)
tabVector (real values) to be printed
flagOverridetrue to override printout limitations
Returns
The string (terminated with a newline)

◆ toVector() [2/4]

String toVector ( const String title,
const VectorInt tab,
bool  flagOverride 
)

Printout a vector in a formatted manner

Parameters
titleTitle of the printout (or empty string)
tabVector (integer values) to be printed
flagOverridetrue to override printout limitations
Returns
The string (terminated with a newline)

◆ toVector() [3/4]

String toVector ( const String title,
const VectorString tab,
bool  flagOverride 
)

◆ toVector() [4/4]

String toVector ( const String title,
const VectorVectorDouble tab,
bool  flagOverride 
)

Printout a list of vectors in a formatted manner

Parameters
titleTitle of the printout (or empty string)
tabVector of vectors (real values) to be printed
flagOverridetrue to override printout limitations
Returns
The string (terminated with a newline)

◆ toVectorDouble()

VectorString toVectorDouble ( const VectorDouble values,
const EJustify &  justify 
)