diff options
Diffstat (limited to 'meowpp/utility.h')
-rw-r--r-- | meowpp/utility.h | 121 |
1 files changed, 68 insertions, 53 deletions
diff --git a/meowpp/utility.h b/meowpp/utility.h index 4f3b36a..ec47225 100644 --- a/meowpp/utility.h +++ b/meowpp/utility.h @@ -40,59 +40,74 @@ namespace meow{ template<class T> inline double average(T const& beg, T const& end, T const& p, double sigs); - /******************************************************************* - @asciidoc - === meow:: *Functios* in utility.h - [options="header",width="100%",cols="1>s,5<,1<,10<",grid="rows"] - |============================================================== - |Name | Parameters | Return Type | Description - |stringPrintf |(char const * fmt, ...)|std::string | - Format print to C++ string and return it - |stringReplace |(std::string str, + - std::string const& from, + - std::string const& to) | std::string | - Return a string like `str`, but all `from` be replaced by `to` - |cstringEndWith |(char const* str, int n, ...) | bool | - Return whether `str` is end with one of the c-string you specify in - the parameters or not - |debugPrintf |(char const* fmt, ...) | void| - Print debug message (file name, line number, ...etc) when `DEBUG` is - defined - |messagePrintf |(int level_change, char const* fmt, ...) | void| - 階層式的訊息輸出 - |noEPS |(double value, double eps = 1e-9) | double | - 如果abs(輸入的數值) < eps, 則回傳0, 否則回傳輸入的數值 - |normalize |(double lower, double upper, + - double value) | double | - (value - lower) / (upper - lower) - |denormalize |(double lower, double upper, + - double ratio) | double | - lower + (upper - lower) * ratio - |ratioMapping |(double l1, double u1, + - double m1, double l2, + - double u2) - | double | - denormalize(l2, u2, normalize(l1, u1, m1)) - |inRange<T> |(T const& mn, T const& mx, + - T const& v) | T | - std::max(mn, std::min(mx, v)) - |squ<T> |(T const& x) | T| - x * x - |average<T>|(T const& beg, T const& end, + - double sigs)| T| - 只將 `sigs` 個標準差以內的數據拿來取平均 - |average<T>|(T const& beg, T const& end, + - T const& p, double sigs)| T| - 同上, 不過這次用 `p` 來加權平均 - |============================================================== - - [NOTE] - `stringReplace()` 不是用什麼好方法寫的因此執行效率很低請別虐待它. + - 額外附贈一個 `const double PI = 3.141592653589......` - -''' -@asciidoc- - ******************************************************************/ + //# === meow:: *Functios* in utility.h + //# [options="header",width="100%",cols="1>s,5<,1<,10<",grid="rows"] + //# |============================================================== + //# |Name | Parameters | Return_Type | Description + //# |stringPrintf |(char const * `fmt`, ...) | std::string + //# |Format print to C++ string and return it + + + //# |stringReplace |(std::string `str`,\ + //# std::string const& `from`,\ + //# std::string const& `to`) | std::string + //# |Return a string like `str`, but all `from` be replaced by `to` + + + //# |cstringEndWith |(char const* `str`,\int `n`, ...) | bool + //# |Return whether `str` is end with one of the c-string you specify in + //# the parameters or not + + + //# |debugPrintf |(char const* `fmt`, ...) | void + //# |Print debug message (file name, line number, ...etc) when `DEBUG` is + //# defined + + + //# |messagePrintf |(int `level_change`,\char const* `fmt`, ...) | void + //# |階層式的訊息輸出 + + + //# |noEPS |(double `value`, double `eps` = 1e-9) | double | + //# 如果abs(輸入的數值) < eps, 則回傳0, 否則回傳輸入的數值 + + + //# |normalize |(double `lower`, double `upper`, \ double value) + //# | double | `(value - lower) / (upper - lower)` + + + //# |denormalize |(double `lower`, double `upper`, + //# \ double `ratio`) | double | `lower + (upper - lower) * ratio` + + + //# |ratioMapping |(double `l1`, double `u1`, + //# \double `m1`, double `l2`,\double `u2`) + //# | double | `denormalize(l2, u2, normalize(l1, u1, m1))` + + + //# |inRange<T> |(T const& `mn`, T const& `mx`, \ T const& `v`) | T | + //# `std::max(mn, std::min(mx, v))` + + + //# |squ<T> |(T const& `x`) | T| `x * x` + + + //# |average<T>|(T const& `beg`, T const& `end`, \ double `sigs`)| T| + //# 只將 `sigs` 個標準差以內的數據拿來取平均 + + + //# |average<T>|(T const& `beg`, T const& `end`, + //# \ T const& `p`, double `sigs`)| T| 同上, 不過這次用 `p` 來加權平均 + //# |============================================================== + //# + //# [NOTE] + //# ==================================== + //# * `stringReplace()` 不是用什麼好方法寫的因此執行效率很低請別虐待它. + //# * 額外附贈一個 `const double PI = 3.141592653589......` + //# ==================================== + //# + //# ''' + //# } #include "utility.hpp" |