home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 13
/
mediashare_13.zip
/
mediashare_13
/
ZIPPED
/
PROGRAM
/
APR94_1.ZIP
/
GA.ZIP
/
SOURCE.ZIP
/
GRPHUTIL.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1994-01-10
|
1KB
|
55 lines
//Copyright (C) Man Machine Interfaces 1994. All rights reserved.
#include "stdafx.h"
//Headers needed for EOS programs
//You need EOS v1.1 to compile this code
#include "eos.h"
#include "eosutil.h"
//graph GA headers
#include "grphutil.h"
BYTE AllelesToByte(Allele *pAlleles, int from, int to)
{
BYTE temp = 0 ;
BYTE powOf2 = 1 ;
int count = 0 ;
for(int i=from; i<=to && count++ < 8;i++) {
if (pAlleles[i])
temp += powOf2 ;
powOf2<<=1 ;
}
return temp ;
}
uint AllelesToInt(Allele *pAlleles, int from, int to)
{
uint temp = 0 ;
uint powOf2 = 1 ;
int count = 0 ;
for(int i=from; i<=to && count++ < 16;i++) {
if (pAlleles[i])
temp += powOf2 ;
powOf2<<=1 ;
}
return temp ;
}
ulong AllelesToLong(Allele *pAlleles, int from, int to)
{
ulong temp = 0 ;
ulong powOf2 = 1 ;
int count = 0 ;
for(int i=from; i<=to && count++ < 32;i++) {
if (pAlleles[i])
temp += powOf2 ;
powOf2<<=1 ;
}
return temp ;
}
int GetNumBitsToEncode(int n)
{
return Max((int)ceil(log2(n)),1) ;
}