Doxygen Source Code Documentation
thd_entropy16.c File Reference
#include "mrilib.h"Go to the source code of this file.
Defines | |
| #define | SNUM 65536 |
Functions | |
| void | ENTROPY_setup (void) |
| void | ENTROPY_setdown (void) |
| void | ENTROPY_accumulate (int nbytes, void *var) |
| double | ENTROPY_compute (void) |
| double | ENTROPY_dataset (THD_3dim_dataset *dset) |
| double | ENTROPY_datablock (THD_datablock *blk) |
Variables | |
| int * | scount = NULL |
| int | snum = 0 |
Define Documentation
|
|
Definition at line 7 of file thd_entropy16.c. Referenced by ENTROPY_compute(), and ENTROPY_setup(). |
Function Documentation
|
||||||||||||
|
Definition at line 30 of file thd_entropy16.c. References ENTROPY_setup(), scount, snum, and var. Referenced by ENTROPY_datablock(), and main().
00031 {
00032 int nn = nbytes/2 , ii ;
00033 unsigned short * sar = (unsigned short *) var ;
00034
00035 if( scount == NULL ) ENTROPY_setup() ;
00036
00037 for( ii=0 ; ii < nn ; ii++ ) scount[sar[ii]]++ ;
00038 snum += nn ;
00039 }
|
|
|
Definition at line 45 of file thd_entropy16.c. References scount, SNUM, and snum. Referenced by ENTROPY_datablock(), and main().
00046 {
00047 register int ii ;
00048 register double sum ;
00049
00050 if( scount == NULL || snum == 0 ) return 0.0 ;
00051
00052 sum = 0.0 ;
00053 for( ii=0 ; ii < SNUM ; ii++ )
00054 if( scount[ii] > 0 ) sum += scount[ii] * log((double)scount[ii]) ;
00055
00056 sum = -(sum - snum*log((double)snum)) / ( log(2.0) * snum ) ;
00057 return sum ;
00058 }
|
|
|
Definition at line 72 of file thd_entropy16.c. References DBLK_ARRAY, DBLK_BRICK_BYTES, ENTROPY_accumulate(), ENTROPY_compute(), ENTROPY_setdown(), ENTROPY_setup(), ENTRY, THD_datablock::nvals, and RETURN. Referenced by ENTROPY_dataset(), and THD_write_datablock().
00073 {
00074 int iv ;
00075 double sum ;
00076
00077 ENTRY("ENTROPY_datablock") ;
00078
00079 ENTROPY_setup() ;
00080
00081 for( iv=0 ; iv < blk->nvals ; iv++ )
00082 ENTROPY_accumulate( DBLK_BRICK_BYTES(blk,iv) , DBLK_ARRAY(blk,iv) ) ;
00083
00084 sum = ENTROPY_compute() ;
00085 ENTROPY_setdown() ;
00086 RETURN(sum) ;
00087 }
|
|
|
Definition at line 62 of file thd_entropy16.c. References THD_3dim_dataset::dblk, DSET_load, DSET_LOADED, ENTROPY_datablock(), and ISVALID_DSET. Referenced by main().
00063 {
00064 if( !ISVALID_DSET(dset) ) return(0.0) ;
00065 DSET_load(dset) ;
00066 if( !DSET_LOADED(dset) ) return(0.0) ;
00067 return ENTROPY_datablock( dset->dblk ) ;
00068 }
|
|
|
Definition at line 23 of file thd_entropy16.c. References free, scount, and snum. Referenced by ENTROPY_datablock(), and main().
|
|
|
Definition at line 14 of file thd_entropy16.c. References malloc, scount, snum, and SNUM. Referenced by ENTROPY_accumulate(), ENTROPY_datablock(), and main().
|
Variable Documentation
|
|
Definition at line 9 of file thd_entropy16.c. Referenced by ENTROPY_accumulate(), ENTROPY_compute(), ENTROPY_setdown(), and ENTROPY_setup(). |
|
|
Definition at line 10 of file thd_entropy16.c. Referenced by ENTROPY_accumulate(), ENTROPY_compute(), ENTROPY_setdown(), and ENTROPY_setup(). |