document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. // Read header
  2. char buf[1024];
  3. fgets(buf,1024,in);
  4. sscanf(buf,"%d %d %d", &M, &N, &K);    
  5.  
  6. // Read W
  7. for (int i=0; i<M; i++)      
  8.   for (int c=0; c<3; c++)
  9.     for (int k=0; k<K; k++)
  10.       fread(&(W[k][i*3+c]),sizeof(float),1,in)                 
  11.  
  12. // Read H
  13. float *_H = (float *)malloc(sizeof(float)*K*N);
  14. if ( K*N != fread(_H,sizeof(float),K*N,in) )
  15.   {
  16.     fprintf(stderr, "Unexpected EOF while reading file: %s\\n", argv[2]);
  17.     exit(1);
  18. }
  19. for (int i=0; i<K; i++)
  20.   for (int j=0; j<N; j++)
  21.     for (int c=0; c<3; c++)
  22.       H[i*N*3+j*3+c] = _H[i*N+j];
  23. free(_H);
');