permut.c

Go to the documentation of this file.
00001 /*
00002 *    Copyright (c) 2007. The BATI team. All right reserved.
00003 *
00004 *    This file is part of BATI library.
00005 *
00006 *    BATI library is free software: you can redistribute it and/or modify
00007 *    it under the terms of the GNU General Public License as published by
00008 *    the Free Software Foundation, either version 3 of the License, or
00009 *    (at your option) any later version.
00010 *
00011 *    BATI library  is distributed in the hope that it will be useful,
00012 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 *    GNU General Public License for more details.
00015 *
00016 *    You should have received a copy of the GNU General Public License
00017 *    along with BATI library.  If not, see <http://www.gnu.org/licenses/>.
00018 */
00019 
00020 #include <stdio.h>
00021 
00022 void permuteLong(char *a)
00023 {
00024   char tmp;
00025   tmp=a[0]; a[0]=a[7]; a[7]=tmp;
00026   tmp=a[1]; a[1]=a[6]; a[6]=tmp;
00027   tmp=a[2]; a[2]=a[5]; a[5]=tmp;
00028   tmp=a[3]; a[3]=a[4]; a[4]=tmp;
00029 }
00030 void permuteLongTab(unsigned long *a, int nb)
00031  {
00032      int i;
00033  
00034      for(i=0;i<nb;i++) permuteLong( (char *) &a[i]);
00035  }
00036 
00037 /**************************/
00038 void permuteInt(char *a)
00039 {
00040   char tmp;
00041   
00042   tmp=a[0]; a[0]=a[3]; a[3]=tmp;
00043   tmp=a[1]; a[1]=a[2]; a[2]=tmp;
00044 }
00045 void permuteIntTab(unsigned int *a, int nb)
00046 {
00047   int i;  
00048   for(i=0;i<nb;i++) 
00049     permuteInt( (char *) &a[i]);
00050 }
00051 
00052 /**************************/
00053 void permuteShort(char *a)
00054 {
00055   char tmp;
00056   
00057   tmp=a[0]; a[0]=a[1]; a[1]=tmp;
00058 }
00059 void permuteShortTab(short *a, int nb)
00060 {
00061   int i;  
00062   for(i=0;i<nb;i++) 
00063     permuteShort( (char *) &a[i]);
00064 }
00065 
00066 /**************************/
00067 void permuteFloat(char *a )
00068 {
00069   char tmp;
00070   tmp=a[0]; a[0]=a[3]; a[3]=tmp;
00071   tmp=a[1]; a[1]=a[2]; a[2]=tmp;
00072 }
00073 void permuteFloatTab(float *a, int nb)
00074 {
00075   int i;  
00076   for(i=0;i<nb;i++) 
00077     permuteFloat((char *) &a[i]);
00078 }

Generated on Tue Apr 22 13:31:03 2008 for donnee1D by  doxygen 1.5.3