genlogs.c

来自「通过C4.5 的实现可以进行构建决策树 来进行有效的分类」· C语言 代码 · 共 46 行

C
46
字号
/*************************************************************************//*									 *//*	Tabluate logs and log factorials (to improve speed)		 *//*	--------------------------------				 *//*									 *//*************************************************************************/#include "defns.i"#include "types.i"#include "extern.i"float	*LogItemNo;double	*LogFact;
#include <stdlib.h>
#include <malloc.h>/*************************************************************************//*									 *//*  Set up the array LogItemNo to contain the logs of integers and	 *//*  the array LogFact to contain logs of factorials (all to base 2)	 *//*									 *//*************************************************************************/ void   GenerateLogs()/*  ------------  */{    ItemNo i;    LogItemNo = (float *) malloc((MaxItem+100) * sizeof(float));    LogFact = (double *) malloc((MaxItem+100) * sizeof(double));    LogItemNo[0] = -1E38f;    LogItemNo[1] = 0;    LogFact[0] = LogFact[1] = 0;    ForEach(i, 2, MaxItem+99)    {	LogItemNo[i] =(float)( log((float) i) / Log2);	LogFact[i] = LogFact[i-1] + LogItemNo[i];    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?