tmp update

This commit is contained in:
张壹 2024-09-13 10:08:41 +08:00
parent 8f9213e53d
commit 03d9bc7024
5 changed files with 606 additions and 715 deletions

View File

@ -30,7 +30,7 @@
#include "../core/array.h"
#include "../core/matrix.h"
#include "../maths/mathfunc_t.h"
#include "../maths/mathfunc.h"
namespace gctl
{

File diff suppressed because it is too large Load Diff

View File

@ -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

View File

@ -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;

View File

@ -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-109
*
* @param f