|
STK++ 1.0
|
In the Base subproject, we define. More...
|
Classes | |
| struct | STK::IProxy |
| The IProxy classes is an interface class for wrapping the fundamental types. More... | |
| class | STK::ConstProxy< TYPE > |
The ConstProxy class allow to surdefine operators and methods for every kind of constant class and type without using dynamic_cast. More... | |
| class | STK::Proxy< TYPE > |
| The Proxy classe allow to surdefine operators and methods for every kind of class without using dynamic_cast. More... | |
Namespaces | |
| namespace | STK::Chrono |
The namespace Chrono is an utility namespace for computing elapsed time during the execution of a program. | |
Modules | |
| Arithmetic properties. | |
These classes extend the | |
| Runtime Type Identification. | |
These classes allow to handle the Runtime type identification (RTTI) problem and are useful when working with heterogeneous data. | |
| STKernel::Base I/O stream declarations | |
Nearly all of the I/O classes are parameterized on the type of characters they read and write (The major exception is ios_base at the top of the hierarchy). | |
Typedefs | |
| typedef char | STK::Char |
| STK fundamental type of a Char. | |
| typedef long | STK::Integer |
| STK fundamental type of discrete values. | |
| typedef double | STK::Real |
| STK fundamental type of Real values. | |
| typedef std::basic_string< Char > | STK::String |
| STK fundamental type of a String. | |
Enumerations | |
| enum | STK::Binary { STK::zero = 0, STK::one = 1, STK::binaryNA } |
STK fundamental type of a binary. More... | |
| enum | STK::NotAvailable { STK::missing } |
STK fundamental type of a NA value. More... | |
| enum | STK::Sign { STK::negative = -1, STK::positive = 1, STK::SignNA } |
STK fundamental type of a sign. More... | |
Functions | |
| void | STK::Chrono::start () |
| Start the Chrono. | |
| Real | STK::Chrono::elapsed () |
Compute the elapsed time (in second) since last start() call. | |
| template<class TYPE > | |
| TYPE | STK::sign (TYPE const &x, TYPE const &y=1) |
| templated sign value sign(x) * y: TYPE should be Integer , long, float or Real | |
| template<class TYPE > | |
| void | STK::swap (TYPE &x, TYPE &y) |
| templated swap method. | |
| template<class TYPE > | |
| TYPE const & | STK::min (TYPE const &x, TYPE const &y) |
| templated minimum for class having defined <. | |
| template<class TYPE > | |
| TYPE const & | STK::max (TYPE const &x, TYPE const &y) |
| templated maximum for class having defined <. | |
| template<class TYPE > | |
| TYPE | STK::abs (TYPE const &x) |
| templated absolute value: TYPE should be Integer , long, float or Real. | |
| Real | STK::frand () |
| frand() generate a Real uniform number. | |
| bool | STK::isOdd (Integer const &x) |
| is x a odd number ? | |
| bool | STK::isEven (Integer const &x) |
| is x an even number ? | |
| Integer | STK::round (Real const &x) |
| Computation of round off : return an Integer value. | |
| Real | STK::norm (Real const &x, Real const &y) |
| Computation of sqrt(x^2 + y^2) without underflow or overflow. | |
| template<class TYPE > | |
| bool | STK::stringToType (TYPE &t, String const &s, std::ios_base &(*f)(std::ios_base &)=std::dec) |
| convert a String to TYPE | |
| template<class TYPE > | |
| String | STK::typeToString (TYPE const &t, std::ios_base &(*f)(std::ios_base &)=std::dec) |
| convert a TYPE to String | |
| template<class TYPE > | |
| ostream & | STK::operator<< (ostream &os, const ConstProxy< TYPE > &output) |
| Overloading of the operator << for the type TYPE using a constant Proxy. | |
| template<class TYPE > | |
| istream & | STK::operator>> (istream &is, Proxy< TYPE > &input) |
| Overloading of the operator >> for the type TYPE using a Proxy. | |
| istream & | STK::operator>> (istream &is, Proxy< String > &input) |
| Overloading of the istream >> for the type String. | |
| String & | STK::toUpperString (String &s) |
| convert the characters of the String to upper case | |
| String | STK::toUpperString (String const &s) |
| convert the characters of the String to upper case | |
Variables | |
| static const String | STK::STRING_NA = String(_T(".")) |
| Representation of a Not Available value. | |
| static const int | STK::STRING_NA_SIZE = 1 |
| Size (in number of Char) of a Not Available value. | |
In the Base subproject, we define.
| typedef char STK::Char |
STK fundamental type of a Char.
The type Char is defined for the internal representation of the characters. Note that if you change the representation, you don't have to modify the stream classes defined in the file STK_StreamBase.h, but you have to modify the global stream objects std::cout, std::cin, std::cerr, std::clog in order to access to the standard I/O channels.
Definition at line 81 of file STK_Char.h.
| typedef long STK::Integer |
STK fundamental type of discrete values.
The type Integer is defined for the numerical computation and the internal representation of the discrete variables.
Definition at line 50 of file STK_Integer.h.
| typedef double STK::Real |
STK fundamental type of Real values.
The type Real is defined for the numerical computation and the internal representation of the continuous variables.
Definition at line 51 of file STK_Real.h.
| typedef std::basic_string<Char> STK::String |
STK fundamental type of a String.
The type String is defined for the internal representation of the string variables (strings).
Definition at line 54 of file STK_String.h.
| enum STK::Binary |
| enum STK::NotAvailable |
STK fundamental type of a NA value.
The type NotAvailable is defined for the numerical computation and the internal representation of the not Available variables. It can be used for any unknown variable.
Definition at line 54 of file STK_NotAvailable.h.
{ missing };
| enum STK::Sign |
| void STK::Chrono::start | ( | ) |
| Real STK::Chrono::elapsed | ( | ) |
Compute the elapsed time (in second) since last start() call.
Definition at line 57 of file STK_Chrono.cpp.
References STK::Chrono::t_end, and STK::Chrono::t_start.
| TYPE STK::sign | ( | TYPE const & | x, |
| TYPE const & | y = 1 |
||
| ) | [inline] |
templated sign value sign(x) * y: TYPE should be Integer , long, float or Real
| x | the sign value |
| y | the signed value to return |
Definition at line 59 of file STK_Misc.h.
Referenced by STK::compGivens(), STK::Svd::diag(), STK::EigenvaluesSymmetric::diagonalize(), STK::house(), and STK::RandBase::randGauss().
{ return( (x<0) ? -y : y); }
| void STK::swap | ( | TYPE & | x, |
| TYPE & | y | ||
| ) | [inline] |
templated swap method.
| x | the first value to swap |
| y | the second value to swap |
Definition at line 69 of file STK_Misc.h.
{
TYPE aux(x);
x = y;
y = aux;
}
| TYPE const& STK::min | ( | TYPE const & | x, |
| TYPE const & | y | ||
| ) | [inline] |
templated minimum for class having defined <.
| x | the first value |
| y | the second value |
Definition at line 83 of file STK_Misc.h.
Referenced by STK::Svd::bidiag(), STK::MatrixLowerTriangular::compLastHo(), STK::MatrixUpperTriangular::compLastVe(), STK::Qr::compQ(), STK::Stat::Univariate< Real, TContainer1D >::compQuantiles(), STK::Svd::compU(), STK::LocalVariance::computeAxis(), STK::BSplineCoefficients::computeKnots(), STK::dist(), STK::dot(), STK::Qr::eraseCol(), STK::ReadWriteCsv::firstVe(), STK::Law::Normal::icdf(), STK::Range::inf(), STK::Svd::init(), STK::Stat::Univariate< Real, TContainer1D >::initializeVariable(), STK::Stat::Univariate< Real, TContainer1D >::initializeVariableAndWeights(), STK::Qr::insertCol(), STK::ReadWriteCsv::lastVe(), STK::leftHouseholder(), STK::operator>>(), STK::Qr::qr(), STK::IArrayBase< TYPE * >::reallocPtrData(), STK::rightHouseholder(), STK::Range::sup(), STK::weightedDist(), and STK::weightedDot().
{ return( (x<y) ? x : y); }
| TYPE const& STK::max | ( | TYPE const & | x, |
| TYPE const & | y | ||
| ) | [inline] |
templated maximum for class having defined <.
| x | the first value |
| y | the second value |
Definition at line 93 of file STK_Misc.h.
Referenced by STK::Svd::bidiag(), STK::MatrixUpperTriangular::compFirstHo(), STK::MatrixLowerTriangular::compFirstVe(), STK::Stat::Univariate< Real, TContainer1D >::compQuantiles(), STK::MatrixUpperTriangular::compSizeHo(), STK::MatrixLowerTriangular::compSizeHo(), STK::MatrixUpperTriangular::compSizeVe(), STK::MatrixLowerTriangular::compSizeVe(), STK::BSplineCoefficients::computeKnots(), STK::dist(), STK::dot(), STK::ReadWriteCsv::firstVe(), STK::Range::inf(), STK::Stat::Univariate< Real, TContainer1D >::initializeVariable(), STK::Stat::Univariate< Real, TContainer1D >::initializeVariableAndWeights(), STK::Arithmetic< Real >::isInfinite(), STK::Arithmetic< Integer >::isNA(), STK::ReadWriteCsv::largestNumberOfRows(), STK::ReadWriteCsv::lastVe(), STK::Arithmetic< Integer >::max(), STK::maxLength(), STK::Arithmetic< Integer >::NA(), STK::normInf(), STK::operator>>(), STK::LocalVariance::prim(), STK::LocalVariance::setData(), STK::Range::sup(), STK::weightedDist(), STK::weightedDot(), STK::weightedNormInf(), and STK::ReadWriteCsv::writeSelection().
{ return( (x<y) ? y : x); }
| TYPE STK::abs | ( | TYPE const & | x | ) | [inline] |
templated absolute value: TYPE should be Integer , long, float or Real.
| x | the value |
Definition at line 103 of file STK_Misc.h.
Referenced by STK::Funct::betaRatio_cf(), STK::Funct::betaRatio_se(), STK::Funct::betaRatio_sr(), STK::Svd::bidiag(), STK::Law::Normal::cdf(), STK::Law::Cauchy::cdf(), STK::EigenvaluesSymmetric::compEstimates(), STK::compGivens(), STK::Stat::Univariate< Real, TContainer1D >::compStatistics(), STK::Stat::Bivariate< Real, Real, TContainer1D >::compWeightedCovariance(), STK::Stat::Univariate< Real, TContainer1D >::compWeightedStatistics(), STK::continuedFraction(), STK::Stat::covariance(), STK::Stat::covarianceWithFixedMean(), STK::Funct::dev0(), STK::Svd::diag(), STK::EigenvaluesSymmetric::diagonalize(), STK::dist(), STK::Funct::erf_raw(), STK::Funct::erfc_raw(), STK::Funct::expm1(), STK::Funct::g0(), STK::Funct::gamma(), STK::Funct::gammaLn(), STK::Funct::gammaRatio_cf(), STK::EigenvaluesSymmetric::ginv(), STK::Stat::Univariate< Real, TContainer1D >::initializeVariable(), STK::Stat::Univariate< Real, TContainer1D >::initializeVariableAndWeights(), STK::Svd::leftEliminate(), STK::Funct::log1p(), STK::Stat::mean(), STK::norm(), STK::Funct::normal_cdf_raw(), STK::normInf(), STK::RandBase::randGauss(), STK::Svd::rightEliminate(), STK::Stat::variance(), STK::Stat::varianceWithFixedMean(), STK::weightedDist(), and STK::weightedNormInf().
{ return( (x<0) ? -x : x); }
| Real STK::frand | ( | ) | [inline] |
frand() generate a Real uniform number.
This is a very basic method and should only be used when speed is necessary only.
Definition at line 111 of file STK_Misc.h.
{ return (Real)rand() / (RAND_MAX+1.0);}
| bool STK::isOdd | ( | Integer const & | x | ) | [inline] |
is x a odd number ?
This method return true if the rest of the euclidian division of x by 2 is 0.
| x | the value to test |
true if x is odd, false otherwise Definition at line 122 of file STK_Misc.h.
Referenced by STK::dot(), and STK::weightedDot().
{ return( (x%2) == 1 ); }
| bool STK::isEven | ( | Integer const & | x | ) | [inline] |
is x an even number ?
This method return true if the rest of the euclidian division of x by 2 is 1.
| x | the value to test |
true if x is even, false otherwise Definition at line 133 of file STK_Misc.h.
Referenced by STK::Funct::gamma().
{ return( (x%2) == 0 ); }
| Integer STK::round | ( | Real const & | x | ) | [inline] |
Computation of round off : return an Integer value.
| x | the value to round |
Definition at line 142 of file STK_Misc.h.
| Real STK::norm | ( | Real const & | x, |
| Real const & | y | ||
| ) | [inline] |
Computation of sqrt(x^2 + y^2) without underflow or overflow.
| x | first value |
| y | second value |
Definition at line 152 of file STK_Misc.h.
References STK::abs().
Referenced by STK::Svd::bidiag(), STK::Svd::diag(), STK::EigenvaluesSymmetric::diagonalize(), STK::gramSchmidt(), STK::Svd::leftEliminate(), STK::normTwo(), STK::normTwo2(), STK::Svd::rightEliminate(), and STK::weightedNormTwo2().
| bool STK::stringToType | ( | TYPE & | t, |
| String const & | s, | ||
| std::ios_base &(*)(std::ios_base &) | f = std::dec |
||
| ) |
convert a String to TYPE
This method return true if the String s could be converted into a correct TYPE t. http://www.codeguru.com/forum/showpost.php?p=678440&postcount=1 http://c.developpez.com/faq/cpp/?page=strings#STRINGS_is_type
The conversion is successful if it does not remain Char inside the String. The operator >> have been overloaded for each base type in order to return a NA value if fail.
| t | The value to get from the String |
| s | the String to convert |
| f | flags |
true if the conversion succeed, false otherwise Definition at line 82 of file STK_String_Util.h.
Referenced by STK::operator>>(), STK::DManager::readList(), and STK::Option::setValue().
{
istringstream iss(s);
Proxy<TYPE> wrapper_t(t);
bool flag1 = (iss >> f >> wrapper_t).fail();
iss >> std::ws;
// ok if the conversion success and the String is exhausted
return ( !flag1 && iss.eof() );
}
| String STK::typeToString | ( | TYPE const & | t, |
| std::ios_base &(*)(std::ios_base &) | f = std::dec |
||
| ) |
convert a TYPE to String
This method return the TYPE t into a String s.
| t | The value to convert to String |
| f | flags |
Definition at line 106 of file STK_String_Util.h.
Referenced by STK::ExportToCsv::setColumnsNames().
{
ostringstream oss;
oss << f << ConstProxy<TYPE>(t);
return oss.str();
}
| ostream& STK::operator<< | ( | ostream & | os, |
| const ConstProxy< TYPE > & | output | ||
| ) |
Overloading of the operator << for the type TYPE using a constant Proxy.
All output stream should use a ConstProxy in a STK application. For the enumerated types, we have also to define the standard output.
| os | the output stream |
| output | the value to send to the stream |
Definition at line 124 of file STK_String_Util.h.
References STK::STRING_NA.
{ if (Arithmetic<TYPE>::isNA(output))
return (os << STRING_NA);
else
return (os << static_cast<TYPE const &>(output));
}
| istream& STK::operator>> | ( | istream & | is, |
| Proxy< TYPE > & | input | ||
| ) |
Overloading of the operator >> for the type TYPE using a Proxy.
All input stream should use a Proxy in a STK application. For the enumerated and String types, we have to overload the method. Due to the instruction
is >> buff
this operator will only work for the fundamental C/C++ types. For the other types, the operator
operator >> (istream& is, TYPE& input);
have to be implemented.
| is | the input stream |
| input | the value to get from the stream |
Definition at line 150 of file STK_String_Util.h.
References STK::Arithmetic< TYPE >::NA(), STK::STRING_NA, and STK::STRING_NA_SIZE.
{
TYPE buff;
// get current position in the stream
typename std::ios::pos_type pos = is.tellg();
// If the standard Conversion failed
if ((is >> buff).fail())
{
// clear failbit state
is.clear(is.rdstate() & ~std::ios::failbit);
// clear eofbit state if necessary and rewind position
if (is.eof())
{
is.seekg(pos);
is.clear(is.rdstate() & ~std::ios::eofbit);
}
// in all case input is a NA object
input = Arithmetic<TYPE>::NA();
// get current position in the stream
pos = is.tellg();
// Create a String buffer
Char Lbuff[STRING_NA_SIZE+1];
// try to read a NA String
is.getline(Lbuff, STRING_NA_SIZE+1);
// if we don't get a NA String, rewind stream
if (!(STRING_NA.compare(Lbuff) == 0))
{ is.seekg(pos);}
}
else
{ input = buff;}
// return the stream
return is;
}
| istream & STK::operator>> | ( | istream & | is, |
| Proxy< String > & | input | ||
| ) |
Overloading of the istream >> for the type String.
| is | the input stream |
| input | the value to get from the stream |
Definition at line 42 of file STK_String_Util.cpp.
References STK::Arithmetic< TYPE >::NA(), and STK::STRING_NA.
| String & STK::toUpperString | ( | String & | s | ) |
convert the characters of the String to upper case
| s | The String to convert |
Definition at line 59 of file STK_String_Util.cpp.
Referenced by STK::DManager::checkStringToBoolean(), STK::IPage::findKeyword(), STK::IPage::IPage(), STK::Option::Option(), STK::IPage::option(), STK::ReadWritePages::p_page(), STK::IPage::processLine(), STK::DManager::StringToBoolean(), STK::StatModel::StringToTypeCriterion(), STK::Import::StringToTypeImport(), STK::Reduct::StringToTypeReduction(), STK::Regress::StringToTypeRegression(), and STK::toUpperString().
{
// iterate along the String
for (String::iterator it = s.begin(); it != s.end(); ++it)
{ *it = std::toupper(*it);}
// return upper cased string
return s;
}
| String STK::toUpperString | ( | String const & | s | ) |
convert the characters of the String to upper case
| s | The String to convert |
Definition at line 73 of file STK_String_Util.cpp.
References STK::toUpperString().
{
String res(s);
toUpperString(res);
return res;
}
const String STK::STRING_NA = String(_T(".")) [static] |
Representation of a Not Available value.
We represent a Not Available value of any type as a "." (like in (SAS(R))) for the end-user.
Definition at line 53 of file STK_String_Util.h.
Referenced by STK::operator<<(), STK::operator>>(), STK::Option::setDefaultValue(), and STK::ReadWriteCsv::writeSelection().
const int STK::STRING_NA_SIZE = 1 [static] |
Size (in number of Char) of a Not Available value.
We represent a Not Available value of any type as a "." (like in (SAS(R))) for the end-user.
Definition at line 61 of file STK_String_Util.h.
Referenced by STK::operator>>().