tmp update
This commit is contained in:
parent
8f9213e53d
commit
03d9bc7024
@ -30,7 +30,7 @@
|
||||
|
||||
#include "../core/array.h"
|
||||
#include "../core/matrix.h"
|
||||
#include "../maths/mathfunc_t.h"
|
||||
#include "../maths/mathfunc.h"
|
||||
|
||||
namespace gctl
|
||||
{
|
||||
|
1273
lib/core/array.h
1273
lib/core/array.h
File diff suppressed because it is too large
Load Diff
@ -235,6 +235,17 @@ namespace gctl
|
||||
Ellipsoidal,
|
||||
Polar,
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief 范围约束类型
|
||||
*
|
||||
*/
|
||||
enum range_type_e
|
||||
{
|
||||
HardScale, // 所有数据按比例映射至min和max范围内
|
||||
SoftScale, // 所有数据按比例映射至max(min, min(arr))和min(max, max(arr))范围内
|
||||
CutOff, // 超过min和max范围数据直接设置为边界值
|
||||
};
|
||||
}
|
||||
|
||||
#endif // _GCTL_ENUM_H
|
@ -27,6 +27,17 @@
|
||||
|
||||
#include "mathfunc.h"
|
||||
|
||||
int gctl::random(int low, int hig)
|
||||
{
|
||||
return rand()%(hig - low + 1) + low;
|
||||
}
|
||||
|
||||
double gctl::random(double low, double hig)
|
||||
{
|
||||
double f = (double) rand()/RAND_MAX;
|
||||
return f*(hig-low) + low;
|
||||
}
|
||||
|
||||
bool gctl::isequal(double f, double v, double eps)
|
||||
{
|
||||
return fabs(f - v) < eps;
|
||||
|
@ -41,6 +41,30 @@
|
||||
namespace gctl
|
||||
{
|
||||
/**
|
||||
* @brief Return a random number in the range [low, hig]
|
||||
*
|
||||
* @note Call srand(seed) to initiate the random squence before using this function.
|
||||
*
|
||||
* @tparam T Value type
|
||||
* @param low Lower bound
|
||||
* @param hig Higher bound
|
||||
* @return T Random value
|
||||
*/
|
||||
int random(int low, int hig);
|
||||
|
||||
/**
|
||||
* @brief Return a random number in the range [low, hig]
|
||||
*
|
||||
* @note Call srand(seed) to initiate the random squence before using this function.
|
||||
*
|
||||
* @tparam T Value type
|
||||
* @param low Lower bound
|
||||
* @param hig Higher bound
|
||||
* @return T Random value
|
||||
*/
|
||||
double random(double low, double hig);
|
||||
|
||||
/**
|
||||
* @brief 比较两个浮点数。注意比较的精度为 eps 减一位,比如 eps 为1e-10则比较的精度为小数点后9位。
|
||||
*
|
||||
* @param f 第一个浮点数
|
||||
|
Loading…
Reference in New Issue
Block a user