Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

mdp_vector.h

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00015 class mdp_vector {
00016 public:
00017   int x[10];
00018   mdp_vector() {
00019     x[0]=x[1]=x[2]=x[3]=x[4]=0;
00020     x[5]=x[6]=x[7]=x[8]=x[9]=0;
00021   }
00022   mdp_vector(int x0,   int x1=0, int x2=0, int x3=0, int x4=0,
00023          int x5=0, int x6=0, int x7=0, int x8=0, int x9=0) {
00024     x[0]=x0; x[1]=x1; x[2]=x2; x[3]=x3; x[4]=x4;
00025     x[5]=x5; x[6]=x6; x[7]=x7; x[8]=x8; x[9]=x9;
00026   }
00027 };
00028 
00029 inline mdp_vector binary2versor(long a) {
00030   mdp_vector v((a)      & 0x1, 
00031            (a >> 1) & 0x1, 
00032            (a >> 2) & 0x1, 
00033            (a >> 3) & 0x1, 
00034            (a >> 4) & 0x1, 
00035            (a >> 5) & 0x1, 
00036            (a >> 6) & 0x1, 
00037            (a >> 7) & 0x1, 
00038            (a >> 8) & 0x1, 
00039            (a >> 9) & 0x1);
00040   return v;
00041 }
00042 
00043 inline int versor2binary(int x0,   int x1=0, int x2=0, int x3=0, int x4=0,
00044                          int x5=0, int x6=0, int x7=0, int x8=0, int x9=0) {
00045 #ifdef CHECK_ALL
00046   if((fabs(0.5-x0)>1) || (fabs(0.5-x1)>1) || 
00047      (fabs(0.5-x2)>1) || (fabs(0.5-x3)>1) ||
00048      (fabs(0.5-x4)>1) || (fabs(0.5-x5)>1) || 
00049      (fabs(0.5-x6)>1) || (fabs(0.5-x7)>1) ||
00050      (fabs(0.5-x8)>1) || (fabs(0.5-x9)>1)) error("versor2binary");                                 
00051 #endif
00052   return x0+2*x1+4*x2+8*x3+16*x4+32*x5+64*x6+128*x7+256*x8+512*x9;
00053 }
00054 
00055 inline long vector2binary(mdp_vector v) {
00056 #ifdef CHECK_ALL
00057   if((fabs(0.5-v.x[0])>1) || (fabs(0.5-v.x[1])>1) || 
00058      (fabs(0.5-v.x[2])>1) || (fabs(0.5-v.x[3])>1) ||
00059      (fabs(0.5-v.x[4])>1) || (fabs(0.5-v.x[5])>1) || 
00060      (fabs(0.5-v.x[6])>1) || (fabs(0.5-v.x[7])>1) ||
00061      (fabs(0.5-v.x[8])>1) || (fabs(0.5-v.x[9])>1) || 
00062      (fabs(0.5-v.x[2])>1)) error("vector2binary");
00063 #endif
00064   return v.x[0]+2*v.x[1]+4*v.x[2]+8*v.x[3]+16*v.x[4]+
00065     32*v.x[5]+64*v.x[6]+128*v.x[7]+256*v.x[8]+512*v.x[9];
00066 }

Generated on Sun Feb 27 15:12:21 2005 by  doxygen 1.4.1