RanlibCPP.h

Go to the documentation of this file.
00001 // Contents: Wrapper for ranlib functions
00002 //           
00003 //
00004 // 
00005 //
00006 // Principal Author: Alexei Miasnikov (2002)
00007 //
00008 // Status: in progress
00009 //
00010 
00011 //
00012 //
00013 //   $Id: RanlibCPP.h,v 1.5 2006/11/16 23:30:06 amiasnik Exp $
00014 //
00015 //
00016 
00017 #ifndef _RANLIB_H_
00018 #define _RANLIB_H_
00019 
00020 
00021 #include "ranlib.h"
00022 #include "cdflib.h"
00023 #include <time.h>
00024 
00025 
00027 
00035 class RandLibURG
00036 {
00037  public:
00039 
00040   RandLibURG(long i1,long i2) {
00041     setall(i1,i2);
00042   }
00043 
00045   RandLibURG() {
00046     setall(time(NULL),time(NULL));
00047     long low = irand(0,2147483560);
00048     long high = irand(0,2147483560);
00049     setall(low,high);
00050   }
00051 
00053   void reset(long i1,long i2) {
00054     setall(i1,i2);
00055   }
00056 
00058   void reset(){
00059     setall(time(NULL),time(NULL));
00060     long low = irand(0,2147483560);
00061     long high = irand(0,2147483560);
00062     setall(low,high); 
00063   }
00064 
00066   void getseed( long& s1, long& s2 ){
00067     long iseed1,iseed2;
00068     getsd(&iseed1,&iseed2);
00069     s1 = iseed1; s2 = iseed2;
00070   }
00071 
00073   float rand() {
00074     return ranf(); 
00075   }
00076 
00077   
00079   float rand(float low,float high) {
00080     return genunf( low, high);
00081   }
00082 
00083   
00085   long irand(long low,long high){
00086    return  ignuin( low, high);
00087   }
00088 };
00089 
00090 
00092 class RandLib
00093 {
00094  public:
00096 
00097   static RandLibURG ur;
00098 
00099   
00101   static double chiPValue( int idf, double alpha ){
00102     int which = 2;
00103     double p = 1.0 - alpha;
00104     double q = alpha;
00105     double x;
00106     double df = idf;
00107     int status;
00108     double bound;
00109    
00110     cdfchi(&which,&p,&q,&x,&df,&status,&bound);
00111 
00112     return x;
00113   }
00114 
00115 };
00116 #endif

Generated on Sun Dec 3 10:58:57 2006 for CRyptography And Groups (CRAG) by  doxygen 1.4.6