yat  0.20.3pre
Classes | Typedefs | Functions
theplu::yat::utility Namespace Reference

Miscellaneous functionality. More...

Classes

struct  abs
 
class  Aligner
 Aligning two sequences. More...
 
class  BasicMatrix
 
class  BasicStreamRedirect
 Redirect a stream to another stream. More...
 
class  BasicVector
 
class  BFGS
 
class  BFGS2
 
class  BinaryIstreamIterator
 
class  BinaryOstreamIterator
 
class  Bisection
 
class  Brent
 
class  BrentMinimizer
 
class  CigarIterator
 Iterator over a CIGAR. More...
 
class  cmd_error
 Class used for error reported from Commandline or Option. More...
 
class  ColumnStream
 
class  CommandLine
 Class for parsing the command line. More...
 
class  compose_f_gx
 
class  compose_f_gx_hx
 
class  compose_f_gx_hy
 
class  compose_f_gxy
 
class  Container2D
 Concept check for Container2D. More...
 
class  Container2DIterator
 Iterator for a Container2D. More...
 
class  DataIterator
 DataIterator. More...
 
class  DataIteratorConcept
 Concept check for Data Iterator. More...
 
class  DataWeight
 Holds a pair of data and associated weight. More...
 
class  DataWeightProxy
 Proxy class for DataWeight. More...
 
class  Deleter
 Functor that deletes an object. More...
 
struct  Dereferencer
 Adaptor between pointer and pointee interface. More...
 
class  DiagonalMatrix
 Diagonal Matrix. More...
 
class  DistanceConcept
 Concept check for a Distance. More...
 
class  errno_error
 Class that contains information reported via global variable errno. More...
 
struct  Exp
 
class  FalsePosition
 
class  FileUtil
 Checking file/directory existence and access permissions. More...
 
class  FletcherReevesConjugate
 
class  get_error
 error class used in get(const std::map<Key, Tp, Compare, Alloc>& m, const Key& k) More...
 
class  GetlineIterator
 Read from std::istream with std::getline. More...
 
class  GoldenSection
 
class  GSL_error
 Class for errors reported from underlying GSL calls. More...
 
struct  Identity
 Identity functor that returns its argument. More...
 
class  Index
 Class for storing indices of, e.g., a MatrixLookup. More...
 
class  invalid_argument
 Class used for all invalid arguments detected within yat library. More...
 
class  IO_error
 Class to report errors associated with IO operations. More...
 
struct  iterator_traits
 
class  KernelMatrix
 A KernelMatrix is a Container2D. More...
 
class  KernelPCA
 Principal Component Analysis on a Kernel Matrix. More...
 
class  kNNI
 kNNimpute More...
 
struct  less_nan
 Functor that behaves like std::less with the exception that it treats NaN as a number larger than infinity. More...
 
struct  less_nan< DataWeight >
 Specialization for DataWeight. More...
 
class  Log
 
class  Matrix
 Interface to GSL matrix. More...
 
class  MatrixBase
 
class  MatrixConstView
 
class  MatrixExpression
 An expression that can be converted to a Matrix. More...
 
class  MatrixMutable
 
class  MatrixView
 Interface to GSL matrix_view. More...
 
class  MatrixWeighted
 Weighted Matrix. More...
 
class  MergeIterator
 Iterate over several ranges as if ranges have been merged. More...
 
class  Minimizer
 Wrapper class around gsl_min_fminimizer in GSL. More...
 
class  MultiMinimizer
 Wrapper class around gsl_multimin_fminimizer in GSL. More...
 
class  MultiMinimizerDerivative
 Wrapper class around gsl_multimin_fdfminimizer in GSL. More...
 
class  Mutable_Container2D
 Concept check for Mutable Container2D. More...
 
class  NelderMeadSimplex
 
class  NelderMeadSimplex2
 
class  NelderMeadSimplex2Rand
 
class  Newton
 
class  NNI
 Interface class for nearest neighbour imputation (NNI) algorithms. More...
 
class  Option
 Container of variables for an option. More...
 
class  OptionArg
 Option with argument. More...
 
class  OptionFile
 Class for file related options. More...
 
class  OptionHelp
 Class for help option. More...
 
class  OptionInFile
 Class for file related options. More...
 
class  OptionOutFile
 Class for file related options. More...
 
class  OptionSwitch
 Class for switch option. More...
 
class  OptionVersion
 Class for version option. More...
 
class  OstreamIterator
 
struct  pair_value_compare
 Functor comparing pairs using second. More...
 
struct  PairFirst
 Functor that return std::pair.first. More...
 
struct  PairSecond
 Functor that return std::pair.second. More...
 
class  PCA
 Principal Component Analysis. More...
 
class  PolakRibiereConjugate
 
class  PriorityQueue
 Multi-thread safe priority queue. More...
 
class  QuadGolden
 
class  Queue
 Multi-thread safe queue. More...
 
class  Range
 A class for storing a shallow copy of a Range. More...
 
class  Ranking
 
class  RootFinder
 
class  RootFinderDerivative
 
class  runtime_error
 Class used for all runtime error detected within yat library. More...
 
class  Scheduler
 Handle a number of jobs and send them to threads. More...
 
class  Secant
 
class  Segment
 a class for a Segment or Interval More...
 
struct  SegmentCompare
 functor using compare More...
 
class  SegmentMap
 a map of Segments More...
 
class  SegmentSet
 a set of Segments More...
 
class  SegmentTree
 Base Class for SegmentSet and SegmentMap. More...
 
class  SmartPtr
 
class  SmithWaterman
 
class  SortedBuffer
 
class  SteepestDescent
 
class  Steffenson
 
class  StrideIterator
 Adaptor using a stride on underlying iterator. More...
 
class  SVD
 Singular Value Decomposition. More...
 
class  TrivialIterator
 Concept check for Trivial Iterator. More...
 
class  TypeInfo
 Wrapper class for storing std::type_info. More...
 
struct  unweighted_iterator_tag
 
class  Vector
 This is the yat interface to GSL vector. More...
 
class  VectorBase
 This is the yat interface to GSL vector. More...
 
class  VectorConstView
 Read-only view. More...
 
class  VectorExpression
 An expression that can be converted to a Vector. More...
 
class  VectorMutable
 This is the mutable interface to GSL vector. More...
 
class  VectorView
 This is the yat interface to gsl_vector_view. More...
 
struct  weighted_if_any2
 
struct  weighted_if_any3
 
struct  weighted_iterator_tag
 
struct  weighted_iterator_traits
 
class  WeightedIterator
 WeightedIterator. More...
 
class  WeightedIteratorArchetype
 
struct  WeightedIteratorArchetype_ctor_arg
 
class  WeightIterator
 WeightIterator. More...
 
class  WeNNI
 Weighted Nearest Neighbour Imputation. More...
 

Typedefs

typedef BasicStreamRedirect< char > StreamRedirect
 
typedef BasicStreamRedirect< wchar_t > wStreamRedirect
 

Functions

double NeedlemanWunsch (const MatrixBase &s, std::vector< std::pair< size_t, size_t > > &path, const double gap)
 
double SmithWaterman (const utility::Matrix &s, double gap, double open_gap)
 Local alignment following the Smith-Waterman algorithm. More...
 
double ssearch (std::string first, std::string second, double gap, double open_gap, double mismatch=0.0)
 
template<class T >
expression::ScaledMatrix< T > operator* (const BasicMatrix< MatrixExpression< expression::ScaledMatrix< T > > > &A, double k)
 
template<class T >
expression::ScaledMatrix< T > operator* (double k, const BasicMatrix< MatrixExpression< expression::ScaledMatrix< T > > > &A)
 
template<class T >
expression::ScaledMatrix< T > operator- (const BasicMatrix< MatrixExpression< expression::ScaledMatrix< T > > > &A)
 
int8_t cigar_table (unsigned char c)
 
template<typename T >
std::istream & getvector (std::istream &is, std::vector< T > &result, char delim, char newlinedelim='\n')
 
template<typename T >
std::istream & getvector (std::istream &is, std::vector< T > &result, const std::string &delim, char newlinedelim='\n')
 
template<class Iter >
void check_iterator_is_unweighted (Iter iter)
 check (at compile time) that iterator is unweighted. More...
 
template<class Container2D >
void merge (const Container2D &x, std::vector< std::string > &labels, Matrix &y)
 merge rows in a Container2D More...
 
template<class Container2D , class Functor >
void merge (const Container2D &x, std::vector< std::string > &labels, Matrix &y, Functor func)
 merge rows in a Container2D using a Functor More...
 
template<class Container2D , class Functor1 , class Functor2 >
void merge (const Container2D &x, std::vector< std::string > &labels, MatrixWeighted &y, Functor1 data_func, Functor2 weight_func)
 merge rows in a Container2D to a MatrixWeighted More...
 
template<typename InputIterator , typename OutputIterator , class Function , class Compare >
void multiprocess (InputIterator begin, InputIterator end, OutputIterator out, size_t cap1, size_t n_threads, size_t cap2, Function function, Compare compare)
 
template<typename InputIterator , typename OutputIterator , class Function >
void multiprocess (InputIterator begin, InputIterator end, OutputIterator out, size_t cap1, size_t n_threads, size_t cap2, Function function)
 
template<typename InputIterator , typename ForwardIterator >
void round (InputIterator first, InputIterator last, ForwardIterator result)
 Round a range. More...
 
template<typename T >
Segment< T > make_segment (T first, T last)
 
template<typename T , class Compare >
bool includes (const yat::utility::Segment< T, Compare > &lhs, const yat::utility::Segment< T, Compare > &rhs)
 
template<typename T , class Compare >
bool overlap (const yat::utility::Segment< T, Compare > &lhs, const yat::utility::Segment< T, Compare > &rhs)
 
template<typename InputIterator >
void sort_index (InputIterator first, InputIterator last, std::vector< size_t > &sort_index)
 
template<typename InputIterator , class Compare >
void sort_index (InputIterator first, InputIterator last, std::vector< size_t > &sort_index, Compare comp)
 
void split (std::vector< std::string > &result, const std::string &str, char delim)
 split a string into several substrings More...
 
void split (std::vector< std::string > &result, const std::string &str, const std::string &delim)
 split a string into substrings More...
 
template<typename T1 , typename T2 >
bool operator== (const Range< T1 > &, const Range< T2 > &)
 Equality comparison. More...
 
template<typename T1 , typename T2 >
bool operator!= (const Range< T1 > &, const Range< T2 > &)
 Based on operator==. More...
 
template<typename T1 , typename T2 >
bool operator< (const Range< T1 > &lhs, const Range< T2 > &rhs)
 Ordering relation. More...
 
template<typename T1 , typename T2 >
bool operator<= (const Range< T1 > &lhs, const Range< T2 > &rhs)
 
template<typename T1 , typename T2 >
bool operator> (const Range< T1 > &, const Range< T2 > &)
 
template<typename T1 , typename T2 >
bool operator>= (const Range< T1 > &, const Range< T2 > &)
 
template<typename T >
void clear (std::vector< T > &vec)
 reduce size and capacity to zero More...
 
template<typename Key , typename Tp , typename Compare , typename Alloc , typename Key2 >
const Tp & get (const std::map< Key, Tp, Compare, Alloc > &m, const Key2 &k)
 
template<typename InputIterator , typename Key , typename Comp >
void inverse (InputIterator first, InputIterator last, std::map< Key, std::vector< size_t >, Comp > &m)
 
template<typename Key , typename InputIterator , typename Comp >
void inverse (InputIterator first, InputIterator last, std::multimap< Key, size_t, Comp > &m)
 
template<typename InputIterator , typename Key , typename Comp >
void inverse (InputIterator first, InputIterator last, std::map< Key, size_t, Comp > &m)
 
template<typename T >
max (const T &a, const T &b, const T &c)
 
template<typename T >
max (const T &a, const T &b, const T &c, const T &d)
 
template<typename T >
max (const T &a, const T &b, const T &c, const T &d, const T &e)
 
template<typename T >
max (const T &a, const T &b, const T &c, const T &d, const T &e, const T &f)
 
template<class Iter >
boost::transform_iterator< PairFirst< typename boost::remove_reference< typename std::iterator_traits< Iter >::reference >::type >, Iter > pair_first_iterator (Iter i)
 
template<class Iter >
boost::transform_iterator< PairSecond< typename boost::remove_reference< typename std::iterator_traits< Iter >::reference >::type >, Iter > pair_second_iterator (Iter i)
 
template<typename Pointer , class Compare >
compose_f_gx_hy< Compare, Dereferencer< Pointer >, Dereferencer< Pointer > > make_ptr_compare (Pointer p, Compare compare)
 
template<typename Pointer >
compose_f_gx_hy< std::less< typename std::iterator_traits< Pointer >::value_type >, Dereferencer< Pointer >, Dereferencer< Pointer > > make_ptr_compare (Pointer p)
 
std::string & to_lower (std::string &s)
 Function converting a string to lower case.
 
std::string & to_upper (std::string &s)
 Function converting a string to upper case.
 
std::string basename (const std::string &fn)
 
template<typename T >
std::istream & binary_read (std::istream &is, T &x)
 
template<typename T >
void binary_write (std::ostream &os, T x)
 
template<typename InputIterator , typename OutputIterator >
bool binary_weight (InputIterator first, InputIterator last, OutputIterator result)
 
void chdir (const std::string &dir)
 
void chmod (const std::string &filename, mode_t mode)
 
template<typename charT , class Traits , class Allocator >
bool contains (const std::basic_string< charT, Traits, Allocator > &str, const std::basic_string< charT, Traits, Allocator > &substr)
 
template<typename charT , class Traits , class Allocator >
bool contains (const std::basic_string< charT, Traits, Allocator > &str, charT substr)
 since New in yat 0.20
 
template<typename charT , class Traits , class Allocator >
bool contains (const std::basic_string< charT, Traits, Allocator > &str, const charT *substr)
 since New in yat 0.20
 
template<typename T >
std::string convert (T input)
 convert T to a string More...
 
template<typename T >
convert (const std::string &s)
 convert string to (numerical) type More...
 
template<typename T >
bool convert_try (const std::string &s, T &t)
 try to convert More...
 
void copy_file (const std::string &source, const std::string &target)
 Copy file source to target. More...
 
std::string dirname (const std::string &fn)
 
template<typename charT , class Traits , class Allocator >
bool ends_with (const std::basic_string< charT, Traits, Allocator > &str, const std::basic_string< charT, Traits, Allocator > &suffix)
 
template<typename charT , class Traits , class Allocator >
bool ends_with (const std::basic_string< charT, Traits, Allocator > &str, charT suffix)
 since New in yat 0.20
 
template<typename charT , class Traits , class Allocator >
bool ends_with (const std::basic_string< charT, Traits, Allocator > &str, const charT *suffix)
 since New in yat 0.20
 
bool fnmatch (const std::string &pattern, const std::string &str, int flags=0)
 
std::string getcwd (void)
 current directory More...
 
void gsl_error_handler (const char *reason, const char *file, int line, int gsl_errno)
 
template<typename T >
bool is (const std::string &s)
 check if string is convertible to (numerical) type T More...
 
bool is_double (const std::string &)
 
bool is_equal (std::string s, std::string other)
 
bool is_float (const std::string &)
 
bool is_int (const std::string &)
 
bool is_nan (const std::string &s)
 
template<typename T >
void load (std::istream &is, std::vector< std::vector< T > > &vec, char sep='\0', char line_sep='\n', bool ignore_empty=false, bool rectangle=true)
 
template<typename T >
void load (std::istream &is, std::vector< T > &vec, char sep='\0')
 Fill a vector<T> with elements from istream. More...
 
template<typename T >
log2 (T x)
 
void mkdir (const std::string &dir, mode_t mode=0777)
 create a directory dir More...
 
void mkdir_p (const std::string &dir, mode_t mode=0777)
 
void print_what (const std::exception &error, std::ostream &out=std::cerr)
 recursively print exception what More...
 
void remove (const std::string &fn)
 
void rename (const std::string &from, const std::string &to)
 
void replace (std::string &full_str, const std::string &old_str, const std::string &new_str)
 
template<typename charT , class Traits , class Allocator >
bool starts_with (const std::basic_string< charT, Traits, Allocator > &str, const std::basic_string< charT, Traits, Allocator > &prefix)
 
template<typename charT , class Traits , class Allocator >
bool starts_with (const std::basic_string< charT, Traits, Allocator > &str, charT prefix)
 since New in yat 0.20
 
template<typename charT , class Traits , class Allocator >
bool starts_with (const std::basic_string< charT, Traits, Allocator > &str, const charT *prefix)
 since New in yat 0.20
 
template<typename Iterator >
double sum_weight (Iterator first, Iterator last)
 
void symlink (const std::string &path1, const std::string &path2)
 
void sort_index (std::vector< size_t > &sort_index, const VectorBase &invec)
 
void sort_smallest_index (std::vector< size_t > &sort_index, size_t k, const VectorBase &invec)
 
void sort_largest_index (std::vector< size_t > &sort_index, size_t k, const VectorBase &invec)
 
void shuffle (VectorMutable &invec)
 
void sort (VectorMutable &vec)
 
unsigned int major_version (void)
 
unsigned int minor_version (void)
 
unsigned int patch_version (void)
 
std::string version (void)
 

Detailed Description

Miscellaneous functionality.

Needed yat functionality that we don't know where to put usually ends up in the utility namespace until we figure out their proper namespace location.

Typedef Documentation

◆ StreamRedirect

Since
New in yat 0.6

◆ wStreamRedirect

Since
New in yat 0.6

Function Documentation

◆ basename()

std::string theplu::yat::utility::basename ( const std::string &  fn)

Same as posix C function with same name but works on std::string rather than char*.

See also
http://linux.die.net/man/3/basename
Returns
everything after last '/'
Since
New in yat 0.10

◆ binary_read()

template<typename T >
std::istream& theplu::yat::utility::binary_read ( std::istream &  is,
T &  x 
)

Read data from is into variable x. Data has typically been written with binary_write(std::ostream& os, T).

T is expected to be a native numerical type.

Returns
is
Since
New in yat 0.18

◆ binary_weight()

template<typename InputIterator , typename OutputIterator >
bool theplu::yat::utility::binary_weight ( InputIterator  first,
InputIterator  last,
OutputIterator  result 
)

For each element in resulting range assign it to 0.0 if corresponding element in input range is NaN else assign it to 1.0.

Returns
true if there is at least one NaN in input range [first, last).

Type Requirements:

Since
New in yat 0.5

◆ binary_write()

template<typename T >
void theplu::yat::utility::binary_write ( std::ostream &  os,
x 
)

Write value of x into ostream os in binary format. Since the data is written in the native binary format, it may not be portable between different architectures.

T is expected to be a native numerical type.

See also
binary_read(std::istream&, T&)
Since
New in yat 0.18

◆ chdir()

void theplu::yat::utility::chdir ( const std::string &  dir)

Same as C function chdir but throws on failure (instead of retrning non-zero).

Exceptions
runtime_errorif underlying chdir returns non-zero
See also
http://linux.die.net/man/3/chdir
Since
New in yat 0.10

◆ check_iterator_is_unweighted()

template<class Iter >
void theplu::yat::utility::check_iterator_is_unweighted ( Iter  iter)

check (at compile time) that iterator is unweighted.

This function only compiles if iterator iter is unweighted.

◆ chmod()

void theplu::yat::utility::chmod ( const std::string &  filename,
mode_t  mode 
)

same as C function chmod but throws on failure (instead of returning non-zero).

See also
http://linux.die.net/man/3/chmod
Since
New in yat 0.10

◆ cigar_table()

int8_t theplu::yat::utility::cigar_table ( unsigned char  c)

The inverse of BAM_CIGAR_STR[x], where BAM_CIGAR_STR is "MIDNSHP=XB".

Exceptions
ifinput is not one of "MIDNSHP=XB".
Since
New in yat 0.19

◆ clear()

template<typename T >
void theplu::yat::utility::clear ( std::vector< T > &  vec)

reduce size and capacity to zero

The standard provides a member function clear(void), which clears the contents of the vector i.e. sets the size to zero. However, the member function might leave the capacity unchanged and sometimes, when it's desiribale to save memory usage e.g., it preferable to use this function, which reduces the capacity to zero.

Since
new in yat 0.13

◆ contains()

template<typename charT , class Traits , class Allocator >
bool theplu::yat::utility::contains ( const std::basic_string< charT, Traits, Allocator > &  str,
const std::basic_string< charT, Traits, Allocator > &  substr 
)
Returns
true if string str contains s
See also
https://en.cppreference.com/w/cpp/string/basic_string/comtains
Since
New in yat 0.20

◆ convert() [1/2]

template<typename T >
std::string theplu::yat::utility::convert ( input)

convert T to a string

T is supposed to be a numerical type.

See also
std::to_string in C++11
Since
new in yat 0.8

◆ convert() [2/2]

template<typename T >
T theplu::yat::utility::convert ( const std::string &  s)

convert string to (numerical) type

Exceptions
runtime_errorif conversion fails

◆ convert_try()

template<typename T >
bool theplu::yat::utility::convert_try ( const std::string &  s,
T &  t 
)

try to convert

See also
is<T>
convert<T>
Returns
true if conversion was successful
Since
new in yat 0.15

◆ copy_file()

void theplu::yat::utility::copy_file ( const std::string &  source,
const std::string &  target 
)

Copy file source to target.

Exceptions
runtime_errorif read error of source or write error for target is encountered.

◆ dirname()

std::string theplu::yat::utility::dirname ( const std::string &  fn)

Same as posix C function with same name but works on std::string rather than char*.

See also
http://linux.die.net/man/3/dirname
Returns
everything prior last '/'.
Since
New in yat 0.10

◆ ends_with()

template<typename charT , class Traits , class Allocator >
bool theplu::yat::utility::ends_with ( const std::basic_string< charT, Traits, Allocator > &  str,
const std::basic_string< charT, Traits, Allocator > &  suffix 
)
Returns
true if string str ends with suffix
See also
https://en.cppreference.com/w/cpp/string/basic_string/ends_with
Since
New in yat 0.20

◆ fnmatch()

bool theplu::yat::utility::fnmatch ( const std::string &  pattern,
const std::string &  str,
int  flags = 0 
)
Returns
true if str matches pattern
See also
http://linux.die.net/man/3/fnmatch
Exceptions
runtime_errorif returned value from underlying fnmatch is neither zero nor FNM_NOMATCH.
Since
New in yat 0.10

◆ get()

template<typename Key , typename Tp , typename Compare , typename Alloc , typename Key2 >
const Tp & theplu::yat::utility::get ( const std::map< Key, Tp, Compare, Alloc > &  m,
const Key2 &  k 
)

Same functionality as map::operator[] but the function does not modify the map and the function throws if key does not exist in the map.

Type Requirment:

  • Key2 is convertible to Key
Returns
const reference to m[k]
Exceptions
get_errorif key k does not exist in map m

Similar to std::map::at(const Key& ) in c++11.

Since
New in yat 0.7

◆ getcwd()

std::string theplu::yat::utility::getcwd ( void  )

current directory

See also
​https://linux.die.net/man/3/getcwd
Since
New in yat 0.17

◆ getvector() [1/2]

template<typename T >
std::istream & theplu::yat::utility::getvector ( std::istream &  is,
std::vector< T > &  result,
char  delim,
char  newlinedelim = '\n' 
)

Read all elements is is until newlinedelim or end of stream. Elements seprated by delim are split and push_backed in result. If T is not std::string, elements are converted to T using convert<T>.

See also
convert<T>(const std::string&)
split(std::string, const std::string&, char delim)
Since
New in yat 0.15
Returns
is

◆ getvector() [2/2]

template<typename T >
std::istream & theplu::yat::utility::getvector ( std::istream &  is,
std::vector< T > &  result,
const std::string &  delim,
char  newlinedelim = '\n' 
)

Same as getvector(std::istream&, std::vector<T>&, char, char) but elements are delimited with either character in delim.

Since
New in yat 0.15

◆ gsl_error_handler()

void theplu::yat::utility::gsl_error_handler ( const char *  reason,
const char *  file,
int  line,
int  gsl_errno 
)

Function can be used as argument to gsl_set_error_handler, so it is called when by GSL when an error is detected. This will result in a GSL_error is thrown.

See also
https://www.gnu.org/software/gsl/doc/html/err.html
Since
New in yat 0.18

◆ includes()

template<typename T , class Compare >
bool theplu::yat::utility::includes ( const yat::utility::Segment< T, Compare > &  lhs,
const yat::utility::Segment< T, Compare > &  rhs 
)

Return true if (and only if) lhs.begin is not less than rhs.begin and rhs.begin is not less than lhs.end

Returns
true if lhs is inluded in rhs
Since
New in yat 0.15

◆ inverse() [1/3]

template<typename InputIterator , typename Key , typename Comp >
void theplu::yat::utility::inverse ( InputIterator  first,
InputIterator  last,
std::map< Key, std::vector< size_t >, Comp > &  m 
)

Creating a map from a range [first, last) such that m[key] returns a vector with indices of which element in [first, last) that is equal to key, or more technically: m[element].size() returns number of elements equal to element, and m[*element][i] = distance(first, element) for every element in [first, last) and i smaller than m[element].size().

Requirement: InputIterator's value type is assignable to Key

Since
New in yat 0.5

◆ inverse() [2/3]

template<typename Key , typename InputIterator , typename Comp >
void theplu::yat::utility::inverse ( InputIterator  first,
InputIterator  last,
std::multimap< Key, size_t, Comp > &  m 
)

In the created multimap each element e will fulfill: $ *(first + e->second) == e->first $

Requirement: InputIterator's value type is assignable to Key

Since
New in yat 0.5

◆ inverse() [3/3]

template<typename InputIterator , typename Key , typename Comp >
void theplu::yat::utility::inverse ( InputIterator  first,
InputIterator  last,
std::map< Key, size_t, Comp > &  m 
)

Create a map mapping from values in range [first, last) to the distance from first.

Post-condition: m[first[i]] == i (for all i that correspond to a unique element). For non-unique element behaviour is undefined.

Requirement: InputIterator's value type is assignable to Key

Since
New in yat 0.10

◆ is()

template<typename T >
bool theplu::yat::utility::is ( const std::string &  s)

check if string is convertible to (numerical) type T

Since
New in yat 0.5

◆ is_double()

bool theplu::yat::utility::is_double ( const std::string &  )
Returns
true if string is a double
Deprecated:
Provided for backward compatibility with the 0.4 API. Use is<double>(const std::string&)

◆ is_equal()

bool theplu::yat::utility::is_equal ( std::string  s,
std::string  other 
)

This function takes the first word (separated by whitespace) in s, replaces all upper case with lower case, and compares it with other.

Returns
true if processed s is equal to other. It returns false otherwise or if s contains more than one word.

◆ is_float()

bool theplu::yat::utility::is_float ( const std::string &  )
Returns
true if string is a float
Deprecated:
Provided for backward compatibility with the 0.4 API. Use is<float>(const std::string&)

◆ is_int()

bool theplu::yat::utility::is_int ( const std::string &  )
Returns
true if string is an int
Deprecated:
Provided for backward compatibility with the 0.4 API. Use is<int>(const std::string&)

◆ is_nan()

bool theplu::yat::utility::is_nan ( const std::string &  s)
Returns
true if string is "nan" (case-insensitive)

◆ load() [1/2]

template<typename T >
void theplu::yat::utility::load ( std::istream &  is,
std::vector< std::vector< T > > &  vec,
char  sep = '\0',
char  line_sep = '\n',
bool  ignore_empty = false,
bool  rectangle = true 
)

The std::istream will be interpreted as outlined here:

Lines are separated by character line_sep and rows are separated by character sep.

The first line is read into a stringstream, which is used to load the first vector (vec[0]) with elements using load(stringstream, vec[0], sep).

Therefore, column elements separation has two modes depending on the value of sep.

  • If sep is the default '\0' value then column elements are separated with white space characters except the new line character. Multiple sequential white space characters are treated as one separator.
  • Setting sep to something else than the default value will change the behaviour to use the sep character as the separator between column elements. Multiple sequential sep characters will be treated as separating elements with missing values.

If rectangle is true, rows must contain same number of elements or function will throw.

If ignore_empty is true empty lines are ignored.

See also
load(std::istream&, std::vector<T>&, char sep='\0')
Note
Requirement on T: utility::convert<T> must be supported (from yat 0.7 T=string is also supported)
Since
New in yat 0.6

◆ load() [2/2]

template<typename T >
void theplu::yat::utility::load ( std::istream &  is,
std::vector< T > &  vec,
char  sep = '\0' 
)

Fill a vector<T> with elements from istream.

Element separation has two modes depending on the value of sep.

  • If sep is the default '\0' value then elements are separated with white space characters. Multiple sequential white space characters are treated as one separator.
  • Setting sep to something else than the default value will change the behaviour to use the sep character as the separator between column elements. Multiple sequential sep characters will be treated as separating elements with missing values. Missing values are set to std::numeric_limits<T>::quiet_NaN
Note
Requirement on T: utility::convert<T> must be supported (from yat 0.7 T=string is also supported)
Since
New in yat 0.6

◆ log2()

template<typename T >
T theplu::yat::utility::log2 ( x)
Returns
base-2 logarithm of x

Implemented for float, double, and long double.

Since
New in yat 0.10

◆ major_version()

unsigned int theplu::yat::utility::major_version ( void  )
Returns
major version number of compiled yat library
Since
New in yat 0.5

◆ make_ptr_compare() [1/2]

template<typename Pointer , class Compare >
compose_f_gx_hy<Compare, Dereferencer<Pointer>, Dereferencer<Pointer> > theplu::yat::utility::make_ptr_compare ( Pointer  p,
Compare  compare 
)

Convenient function that creates a binary predicate that can be used to compare pointers when you want to compare them with respect to the objects they point to.

Example:

std::vector<MyClass*> vec(18);
...
std::sort(vec.begin(), vec.end(),
make_ptr_compare(vec[0], std::greater<MyClass>()));

Type Requirement:

Returns
a compose_f_gx_hy in which F is defined by compare and both G and H are Dereferencer functors.
See also
compose_f_gx_hy
Since
New in yat 0.7

◆ make_ptr_compare() [2/2]

template<typename Pointer >
compose_f_gx_hy<std::less<typename std::iterator_traits<Pointer>::value_type>, Dereferencer<Pointer>, Dereferencer<Pointer> > theplu::yat::utility::make_ptr_compare ( Pointer  p)

Same as make_ptr_compare(2) except that std::less is used to compare pointers.

Since
New in yat 0.7

◆ make_segment()

template<typename T >
Segment<T> theplu::yat::utility::make_segment ( first,
last 
)
Returns
Segment<T>
Since
ney in yat 0.15

◆ max() [1/4]

template<typename T >
T theplu::yat::utility::max ( const T &  a,
const T &  b,
const T &  c 
)
Returns
max of values

◆ max() [2/4]

template<typename T >
T theplu::yat::utility::max ( const T &  a,
const T &  b,
const T &  c,
const T &  d 
)
Returns
max of values

◆ max() [3/4]

template<typename T >
T theplu::yat::utility::max ( const T &  a,
const T &  b,
const T &  c,
const T &  d,
const T &  e 
)
Returns
max of values

◆ max() [4/4]

template<typename T >
T theplu::yat::utility::max ( const T &  a,
const T &  b,
const T &  c,
const T &  d,
const T &  e,
const T &  f 
)
Returns
max of values

◆ merge() [1/3]

template<class Container2D >
void theplu::yat::utility::merge ( const Container2D x,
std::vector< std::string > &  labels,
Matrix y 
)

merge rows in a Container2D

When two (or several) elements in labels are found, the corresponding rows in x are merged into one row vector. The vector of labels are modified to reflect the rows in the resulting container y. In this default implementation the merge is calculated as the (weighted) arithmetic mean.

x must be a Container2D and it works for both weighted and unweighted containers.

Parameters
xinput container to be merged.
labelstelling which rows to merge.
yresulting merged container.
Note
If x and y overlap in their underlying data structures, the result is undefined.
Since
New in yat 0.6

◆ merge() [2/3]

template<class Container2D , class Functor >
void theplu::yat::utility::merge ( const Container2D x,
std::vector< std::string > &  labels,
Matrix y,
Functor  func 
)

merge rows in a Container2D using a Functor

Same as merge(const Container2D&, std::vector<std::string>&, Matrix&) but instead of calculating the merged element as the (weighted) arithmetic mean, the merged element is calculated as defined by func.

Parameters
xinput container to be merged.
labelstelling which rows to merge.
yresulting merged container.
funcdefines how data values are calculated

Functor func has an operator()(Iterator first, Iterator last) const that calculates the merged value from range [first, last).

Type Requirements:

If Functor works on both unweighted and weighted iterators, merge works on both unweighted and weighted Container2D.

Note
If x and y overlap in their underlying data structures, the result is undefined.
Since
New in yat 0.6

◆ merge() [3/3]

template<class Container2D , class Functor1 , class Functor2 >
void theplu::yat::utility::merge ( const Container2D x,
std::vector< std::string > &  labels,
MatrixWeighted y,
Functor1  data_func,
Functor2  weight_func 
)

merge rows in a Container2D to a MatrixWeighted

When two (or several) elements in labels are found, the corresponding rows in x are merged into one row vector. The vector of labels are modified to reflect the rows in the resulting container y.

The data value of each element is calculated as defined by data_func and and the weight value is calculated as defined by weight_func.

x must be a Container2D. If Functor1 and Functor2 work on both unweighted and weighted iterators, merge works on both unweighted and weighted Container2D.

Parameters
xinput container to be merged.
labelstelling which rows to merge.
yresulting merged container.
data_funcdefines how data values are calculated
weight_funcdefines how weight values are calculated

Functor1 and Functor2 have an operator()(Iterator first, Iterator last) const that calculates the merged value and weight, respectively, from range [first, last).

Type Requirements:

If Functor1 and Functor2 work on both unweighted and weighted iterators, merge works on both unweighted and weighted Container2D.

Note
If x and y overlap in their underlying data structures, the result is undefined.
Since
New in yat 0.6

◆ minor_version()

unsigned int theplu::yat::utility::minor_version ( void  )
Returns
minor version number of compiled yat library
Since
New in yat 0.5

◆ mkdir()

void theplu::yat::utility::mkdir ( const std::string &  dir,
mode_t  mode = 0777 
)

create a directory dir

See also
http://linux.die.net/man/3/mkdir
Exceptions
runtime_errorif creation failed
Since
New in yat 0.10

◆ mkdir_p()

void theplu::yat::utility::mkdir_p ( const std::string &  dir,
mode_t  mode = 0777 
)

Similar to mkdir(const std::string&, mode_t).

No error if dir already exist. Make parent directories as needed.

Since
New in yat 0.10

◆ multiprocess() [1/2]

template<typename InputIterator , typename OutputIterator , class Function , class Compare >
void theplu::yat::utility::multiprocess ( InputIterator  begin,
InputIterator  end,
OutputIterator  out,
size_t  cap1,
size_t  n_threads,
size_t  cap2,
Function  function,
Compare  compare 
)

Same as multiprocess(begin, end, out, cap1, n_threads, cap2, function) but use compare instead of std::less<T>

Since
New in yat 0.19

◆ multiprocess() [2/2]

template<typename InputIterator , typename OutputIterator , class Function >
void theplu::yat::utility::multiprocess ( InputIterator  begin,
InputIterator  end,
OutputIterator  out,
size_t  cap1,
size_t  n_threads,
size_t  cap2,
Function  function 
)

Function reads the sorted range [begin, end), applies function on each element and if function returns true, element is copied into out and out is incremented.

This is done in n_threads + 2 threads. The reading of element from the sorted range is done in one range, the calling of function is done in n_threads threads, and the merging of the results from those calls and copying to out is done in one thread.

The communication between the threads are done in buffer containers and to avoid extreme memory usage, the sizes of these containers can be capped with parameter cap1 and cap2. There's a single container communicating between reader thread and worker threads, and cap1 limits the size of the container. Each worker has a container communicating with the writer thread, so there are n_threads such containers and the size of each container is limited by cap2.

Since
new in yat 0.19

◆ NeedlemanWunsch()

double theplu::yat::utility::NeedlemanWunsch ( const MatrixBase s,
std::vector< std::pair< size_t, size_t > > &  path,
const double  gap 
)

Function performing alignment following the Needleman-Wunch algorithm. The algorithm starts from the dot-matrix, s, where $ s_{ij} $ describes how well element $ i $ in the first sequence match to element $ j $ in the second sequence. A path through this matrix corresponds to an alignment of the two sequences, in which a diagonal step over a matrix element corresponds to a match between the corresponding sequnce elements and a vertical or a horizontal step corresponds to inserting a gap in one of the sequnces. The function maximizes $ \sum s_{ij}-n $ gap, where the first sum goes over all matches and the second term is a penalty term for inserting $ n $ gaps. Default is to have the gap cost set to zero. The vector path contains information about which elements that were matched. If the first element in the first sequence was matched to the first element in the second sequence, the last element in path is pair(0,0).

Returns
the global maximum alignment score.
See also
Aligner

◆ operator!=()

template<typename T1 , typename T2 >
bool theplu::yat::utility::operator!= ( const Range< T1 > &  lhs,
const Range< T2 > &  rhs 
)

Based on operator==.

Since
New in yat 0.5

◆ operator*() [1/2]

template<class T >
expression::ScaledMatrix<T> theplu::yat::utility::operator* ( const BasicMatrix< MatrixExpression< expression::ScaledMatrix< T > > > &  A,
double  k 
)

Specialization for ScaledMatrix

Since
New in yat 0.18

◆ operator*() [2/2]

template<class T >
expression::ScaledMatrix<T> theplu::yat::utility::operator* ( double  k,
const BasicMatrix< MatrixExpression< expression::ScaledMatrix< T > > > &  A 
)

Specialization for ScaledMatrix

Since
New in yat 0.18

◆ operator-()

template<class T >
expression::ScaledMatrix<T> theplu::yat::utility::operator- ( const BasicMatrix< MatrixExpression< expression::ScaledMatrix< T > > > &  A)

Specialization for ScaledMatrix

Since
New in yat 0.18

◆ operator<()

template<typename T1 , typename T2 >
bool theplu::yat::utility::operator< ( const Range< T1 > &  lhs,
const Range< T2 > &  rhs 
)

Ordering relation.

Using std::lexicographical_compare

Returns
true if lhs < rhs
Since
New in yat 0.5

◆ operator<=()

template<typename T1 , typename T2 >
bool theplu::yat::utility::operator<= ( const Range< T1 > &  lhs,
const Range< T2 > &  rhs 
)
Returns
! (rhs < lhs )
Since
New in yat 0.5

◆ operator==()

template<typename T1 , typename T2 >
bool theplu::yat::utility::operator== ( const Range< T1 > &  lhs,
const Range< T2 > &  rhs 
)

Equality comparison.

Returns
true iff underlying elements are equal
Since
New in yat 0.5

◆ operator>()

template<typename T1 , typename T2 >
bool theplu::yat::utility::operator> ( const Range< T1 > &  lhs,
const Range< T2 > &  rhs 
)
Returns
rhs < lhs
Since
New in yat 0.5

◆ operator>=()

template<typename T1 , typename T2 >
bool theplu::yat::utility::operator>= ( const Range< T1 > &  lhs,
const Range< T2 > &  rhs 
)
Returns
! (lhs < rhs )
Since
New in yat 0.5

◆ overlap()

template<typename T , class Compare >
bool theplu::yat::utility::overlap ( const yat::utility::Segment< T, Compare > &  lhs,
const yat::utility::Segment< T, Compare > &  rhs 
)

Return true if lhs is not less than rhs and rhs is not less than lhs

Returns
true if lhs and rhs overlap
Since
New in yat 0.15

◆ pair_first_iterator()

template<class Iter >
boost::transform_iterator< PairFirst<typename boost::remove_reference< typename std::iterator_traits<Iter>::reference >::type>, Iter> theplu::yat::utility::pair_first_iterator ( Iter  i)

Creates a transform_iterator that transforms an iterator with value type std::pair to an iterator with value type std::pair::first_type. This can be used, for example, to communicate between a std::map and std::vector

std::map<std::string, int> map;
...
std::vector<std::string> vec;
vec.resize(map.size());
std::copy(pair_first_iterator(map.begin()), pair_first_iterator(map.end()),
vec.begin());
Since
New in yat 0.5

◆ pair_second_iterator()

template<class Iter >
boost::transform_iterator< PairSecond<typename boost::remove_reference< typename std::iterator_traits<Iter>::reference >::type>, Iter> theplu::yat::utility::pair_second_iterator ( Iter  i)

Creates a transform_iterator that transforms an iterator with value type std::pair to an iterator with value type std::pair::second_type. This can be used, for example, to communicate between a std::map and std::vector

std::map<std::string, int> map;
...
std::vector<int> vec(map.size(),0);
std::copy(vec.begin(), vec.end(), pair_second_iterator(map.begin()));
Since
New in yat 0.5

◆ patch_version()

unsigned int theplu::yat::utility::patch_version ( void  )
Returns
patch version number of compiled yat library
Since
New in yat 0.5

◆ print_what()

void theplu::yat::utility::print_what ( const std::exception &  error,
std::ostream &  out = std::cerr 
)

recursively print exception what

Print what() of error to out. If error is nested, the exception that is nested in error is passed to print_what().

Note
If nested exception is null, function calls terminate (this behaviour might change in the future).
Since
new in yat 0.16

◆ remove()

void theplu::yat::utility::remove ( const std::string &  fn)

same as C function remove but throws errno_error at failure

See also
http://linux.die.net/man/3/remove
Since
New in yat 0.12

◆ rename()

void theplu::yat::utility::rename ( const std::string &  from,
const std::string &  to 
)

same as C function with same name but throws errno_error if error is encountered

See also
http://linux.die.net/man/3/rename
Since
New in yat 0.12

◆ replace()

void theplu::yat::utility::replace ( std::string &  full_str,
const std::string &  old_str,
const std::string &  new_str 
)

In full_str replace every sub-string old_str with new_str;

Since
New in yat 0.10
See also
boost::algorithm::replace_all(string&, const string&, const string&)

◆ round()

template<typename InputIterator , typename ForwardIterator >
void theplu::yat::utility::round ( InputIterator  first,
InputIterator  last,
ForwardIterator  result 
)

Round a range.

Round each element in [first, last) to the neighboring integer, such that the total difference is minimised, but with the condition that the sum of elements in [result, result+(last-first)) is equal to the sum of elements in the input range [first, last).

It is possible to round "in place"; it is permissible for first and result to point to the same value.

Since
New in yat 0.19

◆ shuffle()

void theplu::yat::utility::shuffle ( VectorMutable invec)

Randomly shuffles the elements in VectorMutable invec

◆ SmithWaterman()

double theplu::yat::utility::SmithWaterman ( const utility::Matrix s,
double  gap,
double  open_gap 
)

Local alignment following the Smith-Waterman algorithm.

Instead of looking at each sequence in its entirety the S-W algorithm compares segment of all possible lengths (LOCAL alignment) and chooses whichever maximises the similarity measure.

Returns
the similarity score that maximizes $ \sum_{i,j} A_{ij}s_{ij} - L*gap - N*open\textunderscore gap$, where $ A_{ij} $ is unity if element i in first sequence is aligned against element j in second sequence (zero otherwise); L is total length of gaps; and N is number of gaps.
Parameters
sscore matrix in which element $(i,j)$ is the score between element $i$ in first sequence and element $j$ in second sequence.
gapcost for having a gap (insertion or deletion)
open_gapcost for open up a gap in sequence, in other words, for a gap of length L the total cost is open_gap + L*gap.
Deprecated:
Provided for backward compatibility with 0.8 API. Use Aligner::smith_waterman() instead.

◆ sort()

void theplu::yat::utility::sort ( VectorMutable vec)

Sort the elements in the VectorMutable vec

NaNs are treated as infinity

◆ sort_index() [1/3]

template<typename InputIterator >
void theplu::yat::utility::sort_index ( InputIterator  first,
InputIterator  last,
std::vector< size_t > &  sort_index 
)

Create a vector sort_index containing the indeces of elements in a range [first, last). The elements of sort_index give the index of the range element which would have been stored in that position if the range had been sorted in place. The first element of sort_index gives the index of the least element in the range, and the last element of sort_index gives the index of the greatest element in the range. The function will not affect the range, i.e., InputIterator can be read-only.

Type Requirements:

Since
New in yat 0.5. In versions prior 0.13 function was restricted to Forward Iterator with value_type convertible to double.

◆ sort_index() [2/3]

template<typename InputIterator , class Compare >
void theplu::yat::utility::sort_index ( InputIterator  first,
InputIterator  last,
std::vector< size_t > &  sort_index,
Compare  comp 
)

Same as sort_index(InputIterator, InputIterator,std::vector<size_t>&), but objects are compared with comp rather than with operator<.

Type Requirements:

Since
New in yat 0.13

◆ sort_index() [3/3]

void sort_index ( std::vector< size_t > &  sort_index,
const VectorBase invec 
)

Create a vector sort_index containing the indeces of elements in a another VectorBase invec. The elements of sort_index give the index of the VectorBase element which would have been stored in that position if the VectorBase had been sorted in place. The first element of sort_index gives the index of the least element in invec, and the last element of sort_index gives the index of the greatest element in invec . The VectorBase invec is not changed.

◆ sort_largest_index()

void sort_largest_index ( std::vector< size_t > &  sort_index,
size_t  k,
const VectorBase invec 
)

Similar to sort_index but creates a VectorBase with indices to the k largest elements in invec.

◆ sort_smallest_index()

void sort_smallest_index ( std::vector< size_t > &  sort_index,
size_t  k,
const VectorBase invec 
)

Similar to sort_index but creates a VectorBase with indices to the k smallest elements in invec.

◆ split() [1/2]

void theplu::yat::utility::split ( std::vector< std::string > &  result,
const std::string &  str,
char  delim 
)

split a string into several substrings

Split str with respect to delim and place result in result. If str contains N delim, the resulting result will hold N+1 elements (given that it was empty to start with). If first or last character in str is delim, corresponding element in result will be empty string ("").

Since
New in yat 0.7

◆ split() [2/2]

void theplu::yat::utility::split ( std::vector< std::string > &  result,
const std::string &  str,
const std::string &  delim 
)

split a string into substrings

Same as void split(std::vector<std::string>&, const std::string&,char delim); but split if character matches any in delims, i.e., split(vec,"split,me;please", ",;") will be split into "split", "me", and "please".

Since
New in yat 0.10

◆ ssearch()

double theplu::yat::utility::ssearch ( std::string  first,
std::string  second,
double  gap,
double  open_gap,
double  mismatch = 0.0 
)

SSearch does a rigorous Smith-Waterman search for similarity between sequences. For long sequences this may be very expensive (both in time and space) and BLAST or FASTA is preferable.

Function calculates a score matrix with elements $ s_{ij} $ equal 1.0 when first[i] == second[j] and minus mismatch otherwise.

Returns
SmithWaterman score
Since
parameter mismatch available since yat 0.9
See also
Aligner

◆ starts_with()

template<typename charT , class Traits , class Allocator >
bool theplu::yat::utility::starts_with ( const std::basic_string< charT, Traits, Allocator > &  str,
const std::basic_string< charT, Traits, Allocator > &  prefix 
)
Returns
true if string str starts with prefix
See also
https://en.cppreference.com/w/cpp/string/basic_string/starts_with
Since
New in yat 0.20

◆ sum_weight()

template<typename Iterator >
double theplu::yat::utility::sum_weight ( Iterator  first,
Iterator  last 
)

Calculate sum of weights in range [first, last). The complexity is linear except in the important case when Iterator is unweighted and Random Access Iterator when complexity is constant.

Type Requirments:

Since
New in yat 0.13

◆ symlink()

void theplu::yat::utility::symlink ( const std::string &  path1,
const std::string &  path2 
)

same as C function symlink but throws errno_error at failure

Creates a symbolic link called path2 that contains the string pointed to by path1

See also
http://linux.die.net/man/3/symlink
Since
New in yat 0.16

◆ version()

std::string theplu::yat::utility::version ( void  )
Returns
version number of compiled yat library
Since
New in yat 0.5

Generated on Sat Feb 18 2023 03:31:45 for yat by  doxygen 1.8.14