Message 30:
From otoole@utdallas.edu Sat Apr 27 14:24:38 1991
Received: by utdallas.edu (5.61/2.02)
	id AA21097; Sat, 27 Apr 91 14:24:51 -0500
Date: Sat, 27 Apr 91 14:24:51 -0500
From: "Alice O'Toole" <otoole@utdallas.edu>
To: elsberry@cse.uta.edu
Subject: Re:  MIND abstract, other stuff
Status: R


  

/* Associative matrix maker program for face simulations     
   
                      
  Names


     jmsim.names
     jfsim.names
     cmsim.names
     cfsim.names
  

    orig : Output  Ajm40.mat
    orig : Output  Ajf40.mat
    orig : Output  Acm40.mat
    orig : Output  Acf40.mat

Stats :

    orig : Output  Ajm40.stat
    orig : Output  Ajf40.stat
    orig : Output  Acm40.stat
    orig : Output  Acf40.stat

*/



#include <stdio.h> 
#include <math.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/uio.h>

#define nfaces 40
#define nlines 225
#define ncols  151
#define dim    ncols*nlines
#define nfnchars 35

typedef  float face[dim]; 
FILE     *fp_face,*fp_mat,*fp_stat, *fp_fileinfo;
face     face_ref, face_cur;
float    A[nfaces][nfaces];
char     sex,race;
char     filenames[nfaces][nfnchars];
char     filename[]= "/home/otoole/otoole/face/xxxx.face";
char     buffer[dim];
int      fh;

main( argc, argv)
int argc, *argv[];
   {
      int      i,j,index;
      face     face_ref,face_current,a_face;


      init_A();
      get_filenames(argv[1]);

     for (i=0; i < nfaces; i++)
      {
       get_file(i,face_ref);
       close(fh);
       normalize_face(face_ref);
    
       for (j=0; j < nfaces; j++)
         {
          if ( i==j ) A[i][j] = 1.000;
           else 
             {
              get_file(j,face_current);
              close(fh);
              normalize_face(face_current);
              for(index=0; index < dim; index++) 
                    A[i][j]  += face_ref[index]*face_current[index];
                printf("A i j %f\n",A[i][j]);
             }
         }
      }
      dump_A(argv[2]);
      dump_stats(argv[3]);

   }
/*===============================================================*/
/*===============================================================*/
/*           File and I/O   Routines                             */
/*===============================================================*/
/*===============================================================*/

get_filenames(fname)

char fname[];

{
  int i,j;
  char c;


  if( (fp_fileinfo = fopen(fname,"r"))==NULL)
    printf("Unable to open name file\n");
   else printf("Name file successfully open for read\n"); 



  for (j=0; j <  nfaces; j++)
   {
     for (i=0; i <  35; i++)filenames[j][i] = getc(fp_fileinfo);
     for (i=0; i <  35; i++)printf("%c",filenames[j][i]);
     getc(fp_fileinfo);
     printf("\n");
    }
   fclose (fp_fileinfo);

  }

/*===============================================================*/

get_file(which_face,a_face)

  int  which_face;
  face a_face;
  
{
   int   i,j,ierr;
   char  cbuf[ncols];
   char  buffer[dim];

     for (j=0; j < nfnchars; j++) filename[j] = filenames[which_face][j];
     for (j=0; j < nfnchars; j++) printf("%c",filename[j]);
                            printf("\n"); 

    if ( ( fh = open(filename,O_RDONLY))  < 1)
        printf("Unable to open face file\n");
       else printf("Face file successfully open for read\n");

    for (i=0; i < nlines; i++)
     {
          ierr= read(fh,cbuf,ncols);
          if(ierr != ncols) printf("Read  Error %d\n",ierr);
     
          for (j=0; j < ncols; j++)buffer[i*ncols + j] = cbuf[j];
     }

  
     for(j=0; j < dim; j++) 
       a_face[j] = (float) ( ((int) buffer[j] - 48)/2);
  /*
  for (j=0; j < 20; j++)printf("%f",a_face[j]);
                             printf("\n");  
*/
 }


/*===============================================================*/

dump_A(fname)

char fname[];

 {
    int i,j;

    if( (fp_mat = fopen(fname,"w"))==NULL)
    printf("Unable to open matrix file\n");
    else printf("File A successfully open for write\n");

    for(i=0; i < nfaces; i++)
     {     
      for(j=0; j < nfaces; j++)
       fprintf(fp_mat,"%5.3f "  ,A[i][j]);  
       fprintf(fp_mat,"\n"); 
      }
 
   fclose(fp_mat);


  }
/*===============================================================*/

dump_stats(fname)

char fname[];

 {
    int i,j;
    float mean,ss,sd;

    mean = ss = sd = 0.000;

    if( (fp_stat = fopen(fname,"w"))==NULL)
    printf("Unable to open matrix file\n");
    else printf("File A successfully open for write\n");

    for(i=0; i < nfaces; i++)
     {     
       mean = ss = sd = 0.000;
       for(j=0; j < nfaces; j++)
        {
          if (i != j)
           {
             mean +=  A[i][j] ; 
             ss   +=  A[i][j]*A[i][j] ; 
           }
        }
         sd =  sqrt((double ) 
               ((nfaces-1)*ss - mean*mean)
             / ((nfaces-1)*(nfaces-2))
                   ) ;


       fprintf(fp_stat,"%5d  %5.3f  %5.3f\n ",i,mean/(nfaces-1),sd);  
      }
 
   fclose(fp_stat);


  }

/*===============================================================*/
/*===============================================================*/
/*          Vector Routines                                      */
/*===============================================================*/
/*===============================================================*/
/*===============================================================*/

init_A()

  {
    int i,j;

    for(i=0; i < nfaces; i++)    
      for(j=0; j < nfaces; j++)  A[i][j] = 0.00000;
   }

/*===============================================================*/


normalize_face(a_face)

face a_face;

 {

    int   i,j;
    float ss;

      ss = 0.0000000;
      for (j=0; j <  dim; j++)  ss += a_face[j]*a_face[j];
      ss = sqrt(ss);
      for (j=0; j <  dim; j++)  a_face[j] /= ss;

   }

/*======================================================*/

Message 31:
From otoole@utdallas.edu Sat Apr 27 14:26:23 1991
Received: by utdallas.edu (5.61/2.02)
	id AA21103; Sat, 27 Apr 91 14:26:41 -0500
Date: Sat, 27 Apr 91 14:26:41 -0500
From: "Alice O'Toole" <otoole@utdallas.edu>
To: elsberry@cse.uta.edu
Subject: Re:  MIND abstract, other stuff
Status: R


Example of a run call with the three prog args.

assoc_lit cfsim.names Acf40sd.mat Acf40sd.stat

Message 32:
From otoole@utdallas.edu Sat Apr 27 14:34:45 1991
Received: by utdallas.edu (5.61/2.02)
	id AA21120; Sat, 27 Apr 91 14:35:03 -0500
Date: Sat, 27 Apr 91 14:35:03 -0500
From: "Alice O'Toole" <otoole@utdallas.edu>
To: elsberry@cse.uta.edu
Subject: Re:  MIND abstract, other stuff
Status: R



Program to extract eigenvectors of A


      INTEGER NM,NC,Nlambda
      PARAMETER(NM=100)
      PARAMETER(NC=151*225)
      DOUBLE PRECISION A(NM,NM),X(NC,NM)
      DOUBLE PRECISION Lambda(NM), Q(NM,NM),
     & P(NC,NM)
      DOUBLE PRECISION fv1(NM)
      INTEGER  IERR, nNM,nl
      DOUBLE PRECISION EPSI,lb,ub
C
C  NM: # of Faces  NC:# of pixel
      CHARACTER*80 Nom1,Nom2,nomval,nomvec
       Nlambda=NM
C
C      Output Eigenvectors 
C
       nomvec='/otoole/otoole/face/Vecj75c25sd.facetest'
C
C
C      Output  Eigenvalues
C
       nomval='/otoole/otoole/face/Valj75c25sd.facetest'
C
C      Input Associative Matrix
C
       Nom1='/otoole/otoole/face/Aj75c25sd.mat'
C
      CALL GETA(A,NM ,NM, Nom1) 
      print *, "Gotten A"
      CALL GET2X(X,NC,NM)
      print *, "Gotten X"
C
C
C
C   ***** Calling sequence for all the eigenvectors       
      ierr=0
      nl=Nlambda
      nNM=NM
C **** Warning the eigenvalues and eigenvectors
C       are ordered from the Smallest to the Largest
C ************ that's silly  , no ????
      CALL TRED2(NM,NM,A,Lambda,fv1,Q)
      CALL TQL2(NM,NM,Lambda,fv1,Q,ierr)
      IF (ierr .NE. 0) GO TO 9999
C
C  ****  Check that it does it  A=QLQ'
      
D      DO i=1 , NM
D          DO j=1,NM
D             Arec(i,j)=0.0
D             DO k=1,nl
D              Arec(i,j) = Arec(i,j)+(Lambda(k)*q(i,k)*q(j,k))
D             ENDDO
D          ENDDO
D      ENDDO  
D      OPEN(FILE='Arec.mat',UNIT=9)
D      WRITE(9,*) lb,ub
D      WRITE(9,*) nl
D      WRITE(9,*) nNM
D      WRITE(9,5)
D5     FORMAT('The Eigen Values')
D      DO i=1,nl
D        WRITE(9,*) Lambda(i)
D      ENDDO 
D      WRITE(9,6)
D6     FORMAT('The Eigen Vectors')
D
D      DO i=1,NM
D        WRITE(9,*) (Q(i,j),j=1, nl)
D      ENDDO
D      WRITE(9,7)
D7     FORMAT('A reconstituted')

D      DO i=1,NM 
D       WRITE(9,*) (Arec(i,j),j=1,NM)
D       ENDDO   

D      WRITE(9,15)
D15     FORMAT('The original A')

D      DO i=1,NM 
D       WRITE(9,*) (A(i,j),j=1,NM)
D      ENDDO 
C  ***** Find Nlpos: # of non-0 Eigenvalues
   
      Nlpos=0
      epsilon=1./(NM*1.)
      DO i=1,NM
        IF (Lambda(i) .GT. epsilon) Nlpos = Nlpos+1
      END DO
          
    
  
C  ***** Compute  P  Eigenvectors of XX'
C  Nlpos # of non 0 Eigenvalues
      ibidon=NM-Nlpos+1
      DO i=1,NC
      kk=0
        DO k= NM,ibidon,-1
        kk=kk+1
         DO il=1,NM
          P(i,kk)=p(i,kk)
     &        +( X(i,il)*Q(il,k) )
         END DO
          P(i,kk)=P(i,kk) / SQRT(Lambda(k))
        END DO
      END DO

C *****   Save the Eigenvectors and the eigenvalues as a File

      CALL PRINTEig(P,Lambda,NC,NM,nlpos,nomvec,nomval)

 
D      WRITE(9,16)
D16     FORMAT('The P eigenvectors!!!!!')

D      DO i=1,NC 
D       WRITE(9,*) (P(i,j),j=1,Nlpos)
D      ENDDO 

D      WRITE(9,17)
D17    FORMAT('Original Matrix X')

D      DO i=1,nc
D       WRITE(9,*) (X(i,j),j=1,nm)
D      ENDDO 

      IF (IERR .EQ. 0) GO TO 999
9999  OPEN(FILE='ErrorFromEis',UNIT=7)
      WRITE(7,1000) IERR
1000  FORMAT('An error occured in eispack subroutine number',i5)
      print *, "Finished"
 999     END



      SUBROUTINE GETA(A,Nrows,Ncol,NomDeFichier)
C
C
      DOUBLE PRECISION A(Nrows,Ncol)
       CHARACTER*80 NomDeFichier
      OPEN(FILE=NomDeFichier,UNIT=3)
      DO 200 I = 1, Nrows
       READ(3,*) (A(I,J),J=1,Ncol)
C      WRITE(7,*) (A(I,J),J=1,Ncol) 
  200 CONTINUE 
C
      RETURN
     END




      SUBROUTINE PRINTEig(P,l,NI,NJ,NL,nomvec,nomval)
C  Save the Eigenvectors and eigenvalues in a file
      DOUBLE PRECISION P(NI,NJ),l(nj),mult
      CHARACTER*80 nomvec,nomval

      mult=1000.
C *** Facteur de multiplication pour eviter valeurs trop petites
      OPEN(FILE=nomvec,UNIT=10)
      DO i=1,NI
        WRITE(10,*)(SNGL(P(i,j)*mult),j=1,nl)
      ENDDO
      OPEN(FILE=nomval,UNIT=11)
      ibidon=NJ-nl+1 
      DO i=NJ,ibidon,-1
         WRITE(11,*) l(i)
      END DO
      RETURN
      END  
   
C====================================================================

       SUBROUTINE GET2X(A,NPIXS,NFACES)
C
C      READS FILE PRODUCED BY SPLASH
C
      DOUBLE PRECISION A(NPIXS,NFACES),mult
      CHARACTER*50 FILENAME
      BYTE ROW(151)
      INTEGER*2 IROW(151)
      INTEGER*2 IX(33975)
      NROWS =  225
      NCOLS =  151
C
      OPEN(FILE='/fac3/otoole/eis/j75c25sd.names',UNIT=1)
C
      print *, "opened names file"
C
      DO 10, I = 1, NFACES 
C
C     Get the filename of face I to open it for processing
C
      READ(1,20) FILENAME
      WRITE(6,20) FILENAME
C
      OPEN(FILE=FILENAME,UNIT=8, ACCESS= 'DIRECT', FORM='UNFORMATTED',
     &RECL=NCOLS)
C
C     Read off one row 
C
      DO 15, II = 1, NROWS 
      READ(8,REC=II)ROW
C      WRITE(6,40) (ROW(J), J=1, 151)
C
C     translate the row read above
C
      DO 50, K = 1, NCOLS
      IROW (K) = ROW(K)
      INDEX = (II-1)*NCOLS + K
      IX (INDEX) =  (IROW(K) - 48)
C      IROW(K) =  (IROW(K) - 48)
 50   CONTINUE   
C      WRITE(6,60) (IROW(J), J=1, 50)
C
C     Go on to next row
C
 15   CONTINUE
      CLOSE(UNIT=8)
      print *, "Read Face " 
C
C     Translate to real and then normalize
C
      SS = 0.0
      DO 70, JJ = 1, NPIXS
      A(JJ, I) = IX(JJ)
      SS = SS + A(JJ,I)*A(JJ,I)
 70   CONTINUE
      SS = SQRT(SS)
      DO 80, JJ = 1, NPIXS
      A(JJ, I) = A(JJ, I)/SS
 80   CONTINUE
C
C     Go on to next face
C
 10   CONTINUE
C
C
      CLOSE(UNIT=2)
 20   FORMAT(A40)
 40   FORMAT(151A1)
 60   FORMAT(151I3)
      RETURN
      END


Message 33:
From otoole@utdallas.edu Sat Apr 27 14:35:27 1991
Received: by utdallas.edu (5.61/2.02)
	id AA21126; Sat, 27 Apr 91 14:35:45 -0500
Date: Sat, 27 Apr 91 14:35:45 -0500
From: "Alice O'Toole" <otoole@utdallas.edu>
To: elsberry@cse.uta.edu
Subject: Re:  MIND abstract, other stuff
Status: R

retinae% more Makefile
ejob2:	ejob2.o tred2.o tql2.o bisect.o tinvit.o trbak1.o   epslon.o pythag.o
	fc ejob2.o tred2.o tql2.o bisect.o tinvit.o trbak1.o   epslon.o pythag.o -o ejob2  


.f.o:
	fc -c $*.f


* requires eispack routines above

Message 34:
From otoole@utdallas.edu Sat Apr 27 15:51:32 1991
Received: by utdallas.edu (5.61/2.02)
	id AA21293; Sat, 27 Apr 91 15:51:48 -0500
Date: Sat, 27 Apr 91 15:51:48 -0500
From: "Alice O'Toole" <otoole@utdallas.edu>
To: elsberry@cse.uta.edu
Subject: Re:  MIND abstract, other stuff
Status: R


Program to test the quality of recall for the different face
types.



#include <stdio.h> 
#include <fcntl.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <math.h>

/*======================================================*/

#define jap 'J'
#define cauc 'C'
#define new_face 'N'
#define old_face 'O'
#define nfnchars 35


/*#define n_faces 40*/
#define n_faces 40
/*#define n_eigs  99 %^*&^*%#%$   */
#define n_eigs  50

#define nu_eigs  50  
#define n_rows 225

#define n_cols 151
#define dim n_rows*n_cols

/*======================================================*/

FILE      *o_fileinfo, *n_fileinfo, *fp_out,*fp_eigval;
FILE      *fp_histo;

/* cauc 95 jap 05 */ 
       char       eigfile[] = "/home/retinae/otoole/face/E0xx.cj1"; 


char   filename[]= "/home/retinae/otoole/face/xxxx.xxxx";
char   filenames[n_faces][nfnchars];

char  novelty[n_faces];
char  sex    [n_faces];
char  race   [n_faces];

/*======================================================*/
/*======================================================*/
/*                  Matrix defs                         */
/*======================================================*/
typedef  float face[dim]; 
 
float    eigvec[dim];
float    nj_cos_average, oj_cos_average;
float    nc_cos_average, oc_cos_average;
int      nj_new, nj_old; 
int      nc_new, nc_old; 
float    histo [n_faces][n_eigs];
float    sim [n_faces][n_faces];
/*======================================================*/


main( argc, argv)
int argc, *argv[];

   {

      int    i;
      face   cur_face, reb_face;

      nj_new = nj_old = 0;
      nc_new = nc_old = 0;
      nj_cos_average = oj_cos_average = 0.0000;
      nc_cos_average = oc_cos_average = 0.0000;
      get_filenames(argv[1]);
      setup_output(argv[2],argv[3]);
     /* setup_stuff();*/


      for (i=0; i < n_faces; i++)
        {
          printf ("Face %d   ",i);
          get_face(cur_face,i);
          normalize_face(cur_face);
          rebuild_face(i,cur_face);
       }   

 fprintf(fp_out,"Aver J Old  %f N  %d\n",oj_cos_average/(float) nj_old, nj_old);
 fprintf(fp_out,"Aver C Old  %f N  %d\n",oc_cos_average/(float) nc_old, nc_old);
 fprintf(fp_out,"Aver J New  %f N  %d\n",nj_cos_average/(float) nj_new, nj_new);
 fprintf(fp_out,"Aver C New  %f N  %d\n",nc_cos_average/(float) nc_new, nc_new);

    fclose(fp_out);

    make_sim();
    dump_histo();
    dump_histo_stats();
    fclose(fp_histo);

   }


/*======================================================*/

read_eig(eig)

  int eig;

{

   int tens,fh,i,j;
   short int ibuf[n_cols];


         tens = eig/10;
         eigfile[28] = (char) tens + 48;
         eigfile[29] = (char) eig - tens*10 + 48;

  /* for (i=0;i < 8; i++) printf("%c",eigfile[i]);
    printf("\n");*/

   if ( ( fh = open(eigfile, O_RDONLY))  < 1)
      printf("Unable to open eig file\n");
     /* else printf("Eig output file successfully open for read\n"); */

   for (i=0; i < n_rows; i++)
     {
      read(fh,ibuf,n_cols*2);
      for (j=0; j < n_cols; j++)
           eigvec[i*n_cols +j] = (float) ibuf[j]/100;
     }

 /*  for (i=0; i < 50; i++) printf("%f\n",eigvec[i]);*/

  close (fh);

}


/*======================================================*/
/*======================================================*/

normalize_eig()


{
   int i;
   double ss;

 
      ss=0.0000;
      for (i=0; i < dim; i++)  ss =  ss +  eigvec[i]*eigvec[i];
      ss= sqrt (ss);
      for (i=0; i < dim; i++)  eigvec[i] /= ss;
}


/*======================================================*/

get_filenames(fname)

char fname[];

{

  int i,j;
  char c,dummy;
 


 if( (o_fileinfo = fopen(fname,"r"))==NULL) 

/* Sims degraded */


    printf("Unable to open name file\n");
   else printf("Name file successfully open for read\n"); 



  for (j=0; j <  n_faces; j++)
   {
       
     fscanf(o_fileinfo,"%c%c%c%c",&novelty[j], &dummy,&dummy,&dummy);

     for (i=0; i <  nfnchars; i++)
       fscanf(o_fileinfo,"%c",&filenames[j][i]);

     sex [j] = filenames[j][26];
     race[j] = filenames[j][25];

     for (i=0; i <  nfnchars; i++)printf("%c",filenames[j][i]);
       fscanf(o_fileinfo,"%c",&dummy);
    printf("   Race  %c Condition %c\n",race[j], novelty[j]);
    }
   fclose (o_fileinfo);

  }

/*===============================================================*/
/*===============================================================*/

get_face(a_face,which_face)

  face a_face;
  int which_face;
  
{
   int j,ierr,fh,i;
   char cbuf[n_cols];
   char buffer [dim];


     for (j=0; j < nfnchars; j++) filename[j] = filenames[which_face][j];
     for (j=0; j < nfnchars; j++) printf("%c",filename[j]);
                           printf("\n");

    if ( ( fh = open(filename,O_RDONLY))  < 1)
        printf("Unable to open face file\n");
  
   for (i=0; i < n_rows; i++)
     {
      read(fh,cbuf,n_cols);
      for (j=0; j < n_cols; j++)buffer[i*n_cols +j] = cbuf[j];
     }

     for(j=0; j < dim; j++)
       { 
        a_face[j] = (float) ((int) buffer[j] - 48)/2;
  /*      printf("%f\n",a_face[j]);*/
       }
   close(fh);

 }


/*===============================================================*/
  float dot( a_face)
    face a_face;

     {
       int   i;
       float d;

      d=0.0000;
      for(i=0; i < dim; i++) 
          d += a_face[i] * eigvec[i];
     
      return (d);
      }

/*===============================================================*/
  
  normalize_face (a_face)

   face a_face;

   {
      int i;
      double dot_p;
      
      dot_p = 0.00000;
      for(i=0; i < dim; i++) dot_p += a_face[i]*a_face[i];
      dot_p = sqrt(dot_p);
      for(i=0; i < dim; i++) a_face[i] /= dot_p;

    }
     

/*===============================================================*/
/*===============================================================*/
  
  float cosine(face_1,face_2)

   face face_1,face_2;

   {
      int i;
      float dot_p;
      double norm1,norm2;
      
      dot_p =  norm1 = norm2 = 0.00000;

      for(i=0; i < dim; i++)
         {

          dot_p =  dot_p + face_1[i]*face_2[i];
          norm1 =  norm1 + face_1[i]*face_1[i];
          norm2 =  norm2 + face_2[i]*face_2[i];

          }
   
      norm1 = sqrt(norm1);
      norm2 = sqrt(norm2);
 

      return((float) (dot_p/(norm1*norm2)));

    }
/*======================================================*/

setup_stuff()


{

 
   if( (fp_eigval = fopen("Valj.facetest","r"))==NULL)
        printf("Unable to open X file\n");
   else printf("File of eigenvals successfully open for read\n");

 
}

/*======================================================*/
 rebuild_face(which_face,a_face)

  int   which_face;
  face  a_face;

    {
     face  face_estim;

     int i,k,eig;
     float weight,cosi,eigval;

     for (i=0; i < dim; i++) face_estim[i] = 0.000;
    

     for (eig=0; eig < nu_eigs;eig++)
        {
         read_eig(eig);
         normalize_eig();
      /*   fscanf(fp_eigval, "%f",&eigval);
           printf( " ** %f\n",eigval);*/
         weight =  dot(a_face); /*and the just read eigenvec */
         histo[which_face][eig] = weight;


         for (k=0; k < dim; k++) 
              face_estim[k] +=  weight*eigvec[k];

         }
  
 cosi = cosine(face_estim,a_face);

 if (novelty[which_face] == new_face) 
     {
       if (race[which_face] == jap) 
                                     {
                                      nj_new++; 
                                      nj_cos_average += cosi;
                                     }

      else
                                    {
                                      nc_new++; 
                                      nc_cos_average += cosi;
                                     }

     }
  else
       {
         if (race[which_face] == jap) 
                                     {
                                      nj_old++; 
                                      oj_cos_average += cosi;
                                     }

         else
                                    {
                                      nc_old++; 
                                      oc_cos_average += cosi;
                                     }
 
    
       }

 for (i=0; i <  nfnchars; i++)
  fprintf(fp_out,"%c  ",filenames[which_face][i]);
  fprintf(fp_out, " %c   %f\n",novelty[which_face],cosi);

    printf("Cosine %f\n", cosi);

    }


/*===============================================================*/

setup_output(fname1,fname2)

   char fname1[],fname2[];
  {

  /*  Cauc sd .cfsd */

  if( (fp_out = fopen(fname1,"w"))==NULL)
    printf("Unable to open cosine file\n");
   else printf("Name file successfully open for read\n"); 
  if( (fp_histo = fopen(fname2,"w"))==NULL)
    printf("Unable to open histo file\n");
   else printf("Histogram file successfully open for read\n"); 
   }



/*===============================================================*/
/*===============================================================*/
  
  float sim_cosine(face1,face2)

   int face1,face2;

   {
      int i;
      float dot_p;
      double norm1,norm2;
      
      dot_p =  norm1 = norm2 = 0.00000;

      for(i=0; i < nu_eigs; i++)
         {
         {

          dot_p =  dot_p + histo[face1][i]*histo[face2][i];
          norm1 =  norm1 + histo[face1][i]*histo[face1][i];
          norm2 =  norm2 + histo[face2][i]*histo[face2][i];

          }
   
      norm1 = sqrt(norm1);
      norm2 = sqrt(norm2);
 

      return((float) (dot_p/(norm1*norm2)));

    }
     

/*===============================================================*/
make_sim()

{
   int i,j;

   for (i=0; i < n_faces; i++)
   {
     for (j=0; j < n_faces; j++)
       sim[i][j] = sim_cosine(i,j);
    }


}



/*===============================================================*/
dump_histo()

{
   int i,j;

   for (i=0; i < nu_eigs; i++)
   {
     for (j=0; j < n_faces; j++)
       fprintf(fp_histo, " %9.3f",histo[j][i]);
     fprintf(fp_histo, "\n");
    }

   fprintf(fp_histo, "\n\nSimilarity\n");


   for (i=0; i < n_faces; i++)
   {
     for (j=0; j < n_faces; j++)
       fprintf(fp_histo, " %5.3f",sim[j][i]);
     fprintf(fp_histo, "\n");
    }

}


/*===============================================================*/


dump_histo_stats()
{
   int i,j;
   float mean,ss,sd;

 fprintf(fp_histo, "\n Histo  Stats - mean sd \n");

     
for (i=0; i < nu_eigs; i++)
  
   {
     mean = ss = sd = 0.000;
    for (j=0; j < n_faces; j++)
           {
             mean +=  histo[j][i] ; 
             ss   +=  histo[j][i]*histo[j][i] ; 
           }
      sd =  sqrt((double ) 
               ((n_faces)*ss - mean*mean)
             / ((n_faces)*(n_faces-1))
                   ) ;

 fprintf(fp_histo,"%5d  %5.3f  %5.3f\n ",i,mean/(n_faces),sd); 
   }


fprintf(fp_histo, "\n Histo Sim Stats - mean sd \n");


for (i=0; i < n_faces; i++)
   {
     mean = ss = sd = 0.000;
     for (j=0; j < n_faces; j++)
      {
          if (i != j)
           {
             mean +=  sim[i][j] ; 
             ss   +=  sim[i][j]*sim[i][j] ; 
           }
        }
      sd =  sqrt((double ) 
               ((n_faces-1)*ss - mean*mean)
             / ((n_faces-1)*(n_faces-2))
                   ) ;
 fprintf(fp_histo,"%5d  %5.3f  %5.3f\n ",i,mean/(n_faces-1),sd); 
   }

}

/*==============================================================*/

Message 35:
From otoole@utdallas.edu Sat Apr 27 15:59:34 1991
Received: by utdallas.edu (5.61/2.02)
	id AA21313; Sat, 27 Apr 91 15:59:52 -0500
Date: Sat, 27 Apr 91 15:59:52 -0500
From: "Alice O'Toole" <otoole@utdallas.edu>
To: elsberry@cse.uta.edu
Subject: Re:  MIND abstract, other stuff
Status: R


Hi -

 well I think I've sent you the bulk of it -
I'm not sure if it will be useful to you for more
than just getting a clear idea of what I did -

the main problem is that the data files are huge
and really need to be kept in a form that is
both appropriate for calculating on and for
displaying - so I made up my own format - I must pat
myself on the back since everything works really fast
- on the other hand - if one more person tells me
that I shoudl use something standard - I'll scream!
Anyway - it can be done much easier in something
likematlab if memory and speed are not an issue.


In any case - what you have is easy enough to rework
simply to do whatever you want with - again if the
size of your data are not outrageously large - there
is  no actual need to extract the eigenvecs -


Good luck!

Alice


