Skip to content

AFNI/NIfTI Server

Sections
Personal tools
You are here: Home » AFNI » Documentation

Doxygen Source Code Documentation


Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Search  

exx.c File Reference

#include "mrilib.h"

Go to the source code of this file.


Defines

#define ASSIGN_DIRECTIONS

Functions

void getplane_byte (int nx, int ny, int nz, byte *vol, int fixdir, int fixijk, byte *im)
void putplane_byte (int nx, int ny, int nz, byte *vol, int fixdir, int fixijk, byte *im)
void swaptest (int nrep, int fixdir)
int main (int argc, char *argv[])

Define Documentation

#define ASSIGN_DIRECTIONS
 

Value:

do{ switch( fixdir ){                                          \
      default:                                                  \
      case 1:                \
         astep = nx ; bstep = nxy ; cstep = 1  ;                \
         na    = ny ; nb    = nz  ; nc    = nx ;                \
      break ;                                                   \
                                                                \
      case 2:                \
         astep = nxy ; bstep = 1  ; cstep = nx ;                \
         na    = nz  ; nb    = nx ; nc    = ny ;                \
      break ;                                                   \
                                                                \
      case 3:                \
         astep = 1  ; bstep = nx ; cstep = nxy ;                \
         na    = nx ; nb    = ny ; nc    = nz  ;                \
      break ;                                                   \
    } } while(0)

Definition at line 3 of file exx.c.

Referenced by getplane_byte(), putplane_byte(), and swaptest().


Function Documentation

void getplane_byte int    nx,
int    ny,
int    nz,
byte   vol,
int    fixdir,
int    fixijk,
byte   im
 

Definition at line 26 of file exx.c.

References ASSIGN_DIRECTIONS, nc, and nz.

Referenced by swaptest().

00028 {
00029    int bb , nxy=nx*ny ;
00030    register int aa , ijkoff , aoff,boff ;
00031    int astep,bstep,cstep , na,nb,nc ;
00032 
00033    if( fixijk < 0 ) return ;
00034 
00035    ASSIGN_DIRECTIONS ;
00036 
00037    if( fixijk >= nc ) return ;
00038 
00039    ijkoff = fixijk*cstep ;
00040 
00041    for( bb=0,boff=0 ; bb < nb ; bb++,boff+=na,ijkoff+=bstep )
00042       for( aa=0,aoff=0 ; aa < na ; aa++,aoff+=astep )
00043          im[aa+boff] = vol[aoff+ijkoff] ;
00044 
00045    return ;
00046 }

int main int    argc,
char *    argv[]
 

\** File : SUMA.c

Author:
: Ziad Saad Date : Thu Dec 27 16:21:01 EST 2001
Purpose :

Input paramters :

Parameters:
param  Usage : SUMA ( )
Returns :
Returns:
Support :
See also:
OpenGL prog. Guide 3rd edition , varray.c from book's sample code
Side effects :

Definition at line 109 of file exx.c.

References argc, and swaptest().

00110 {
00111    int nrep ;
00112 
00113    if( argc < 2 ){printf("Usage: exx nrep\n");exit(0);}
00114 
00115    nrep = strtol(argv[1],NULL,10) ;
00116    swaptest( nrep , 1 ) ;
00117    swaptest( nrep , 2 ) ;
00118    swaptest( nrep , 3 ) ;
00119    exit(0) ;
00120 }

void putplane_byte int    nx,
int    ny,
int    nz,
byte   vol,
int    fixdir,
int    fixijk,
byte   im
 

Definition at line 48 of file exx.c.

References ASSIGN_DIRECTIONS, nc, and nz.

Referenced by swaptest().

00050 {
00051    int bb , nxy=nx*ny ;
00052    register int aa , ijkoff , aoff,boff ;
00053    int astep,bstep,cstep , na,nb,nc ;
00054 
00055    if( fixijk < 0 ) return ;
00056 
00057    ASSIGN_DIRECTIONS ;
00058 
00059    if( fixijk >= nc ) return ;
00060 
00061    ijkoff = fixijk*cstep ;
00062 
00063    for( bb=0,boff=0 ; bb < nb ; bb++,boff+=na,ijkoff+=bstep )
00064       for( aa=0,aoff=0 ; aa < na ; aa++,aoff+=astep )
00065          vol[aoff+ijkoff] = im[aa+boff] ;
00066 
00067    return ;
00068 }

void swaptest int    nrep,
int    fixdir
 

Definition at line 70 of file exx.c.

References ASSIGN_DIRECTIONS, COX_cpu_time(), free, getplane_byte(), malloc, nc, nz, and putplane_byte().

Referenced by main().

00071 {
00072    double cputim ;
00073    int pp , nx=100,ny=100,nz=100,nxy=nx*ny , kk ;
00074    byte * vin , * vout  ;
00075    int astep,bstep,cstep , na,nb,nc ;
00076 
00077    if( nrep <= 0 ) nrep = 1 ;
00078 
00079    ASSIGN_DIRECTIONS ;
00080 
00081    /* setup bricks */
00082 
00083    vin = (byte *) malloc( sizeof(byte) * (nx*ny*nz) ) ;
00084    if( vin == NULL ) return ;
00085 
00086    vout = (byte *) malloc( sizeof(byte) * (na*nb*nc) ) ;
00087    if( vout == NULL ){ free(vin) ; return ; }
00088 
00089    for( kk=0 ; kk < nx*ny*nz ; kk++ ) vin[kk] = (byte) kk ;
00090 
00091    cputim = COX_cpu_time() ;
00092 
00093    for( pp=0 ; pp < nrep ; pp++ ){
00094 #if 0
00095       for( kk=0 ; kk < nc ; kk++ ){
00096          getplane_byte( nx,ny,nz , vin , fixdir , kk , vout + kk*na*nb ) ;
00097       }
00098 #else
00099       for( kk=0 ; kk < nz ; kk++ ){
00100          putplane_byte( nx,ny,nz , vout , fixdir , kk , vin + kk*nx*ny ) ;
00101       }
00102 #endif
00103    }
00104    cputim = COX_cpu_time() - cputim ;
00105    printf("fixdir = %d CPU time = %g (%g/rep)\n",fixdir,cputim,cputim/nrep) ;
00106    return ;
00107 }
 

Powered by Plone

This site conforms to the following standards: