/* libit - Library for basic source and channel coding functions Copyright (C) 2005-2005 Vivien Chappelier, Herve Jegou This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Copyright (C) 2005 Herve Jegou */ #include #include #include #include /*---------------------------------------------------------------*/ int main( int argc, char ** argv ) { const char * filename = argv[1]; FILE * f = fopen( filename, "r" ); int cint, oldcint = 0, i; mat probatrans = mat_new_zeros( 27, 27 ); while( !feof(f) ) { cint = toupper( fgetc( f ) ) - 64; if( cint >= 26 || cint < 0 ) cint = 0; probatrans[oldcint][cint] += 1; oldcint = cint; } for( i = 0 ; i < 27 ; i++ ) if( vec_sum( probatrans[i] ) > 0 ) vec_normalize( probatrans[i], 1 ); fclose( f ); it_printf( "probatrans = \n #.5f\n", probatrans ); return 0; }