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  

bseq.c

Go to the documentation of this file.
00001 #include "mrilib.h"
00002 
00003 #define NMAX 48
00004 static char * srle[NMAX+1] = {
00005      NULL ,
00006      NULL ,
00007      NULL ,
00008      "21" ,
00009      "211" ,
00010      "311" ,
00011      "1113" ,
00012      "1123" ,
00013      "12113" ,
00014      "42111" ,
00015      "22114" ,
00016      "112133" ,
00017      "1221114" ,
00018      "5221111" ,
00019      "2221115" ,
00020      "52221111" ,
00021      "225111121" ,
00022      "252211121" ,
00023      "441112221" ,
00024      "4111142212" ,
00025      "5113112321" ,
00026      "27221111121" ,
00027      "51221111233" ,
00028      "212121111632" ,
00029      "2236111112121" ,
00030      "337111121221" ,
00031      "21212111116322" ,
00032      "34313131211211" ,
00033      "34313131211212" ,
00034      "212112131313431" ,
00035      "551212111113231" ,
00036      "7332212211112111" ,
00037      "71112111133221221" ,
00038      "742112111111122221" ,
00039      "842112111111122221" ,
00040      "7122122111121111332" ,
00041      "3632311131212111211" ,
00042      "844211211111122221" ,
00043      "8442112111111122221" ,
00044      "82121121234321111111" ,
00045      "44412112131121313131" ,
00046      "343111111222281211211" ,
00047      "313131341343112112112" ,
00048      "1132432111117212112213" ,
00049      "525313113111222111211121" ,
00050      "82121121231234321111111" ,
00051      "823431231211212211111111" ,
00052      "923431231211212211111111" ,
00053      "3111111832143212221121121"
00054 } ;
00055 
00056 typedef struct {
00057   int num ;
00058   int * ss ;
00059 } SEQ ;
00060 
00061 SEQ * expand_rle( char * str )
00062 {
00063    SEQ * seq ;
00064    int * ss , ii , jj , vv ;
00065    char * cpt ;
00066 
00067    if( str == NULL ) return NULL ;
00068    for( ii=0,cpt=str ; *cpt != '\0' ; cpt++ )
00069       ii += (*cpt - '0') ;
00070 
00071    seq = (SEQ *) malloc( sizeof(SEQ) ) ;
00072    seq->ss = ss = (int *) malloc( sizeof(int) * ii ) ;
00073    seq->num = ii ;
00074 
00075    for( vv=1,ii=0,cpt=str ; *cpt != '\0' ; cpt++ ){
00076       jj = (*cpt - '0') ;
00077       for( jj=0 ; jj < (*cpt - '0') ; jj++ ) ss[ii++] = vv ;
00078       vv = -vv ;
00079    }
00080 
00081    return seq ;
00082 }
00083 
00084 int main( int argc , char * argv[] )
00085 {
00086    int ir , ii , num , sum , jj ;
00087    SEQ * seq ;
00088    int * ss ;
00089 
00090    if( argc < 2 || strcmp(argv[1],"-help") == 0 ) exit(0) ;
00091 
00092    ir = strtol( argv[1] , NULL , 10 ) ; if( ir < 3 ) exit(1) ;
00093 
00094    seq = expand_rle( srle[ir] ) ;
00095 
00096    printf("num = %d\n",seq->num) ;
00097    for( ii=0 ; ii < seq->num ; ii++ )
00098       printf(" %d",seq->ss[ii]) ;
00099    printf("\n") ;
00100 
00101    num = seq->num ; ss = seq->ss ;
00102    for( ii=0 ; ii < num-1 ; ii++ ){
00103       sum = 0 ;
00104       for( jj=0 ; jj < num-ii ; jj++ )
00105          sum += ss[jj] * ss[jj+ii] ;
00106       printf(" %d",sum) ;
00107    }
00108    printf("\n") ;
00109 
00110    exit(0) ;
00111 }
 

Powered by Plone

This site conforms to the following standards: