📄 testic.c
字号:
/* program to test inversion of cmatrix *//* also includes modification of non-invertible matrices to make invertible and launches xv at end to display them both */#include "./ansi/r.h"#include "./ansi/rand.h"#include "./ansi/mynr.h"void main ( int argc, char *argv[] ){ unsigned char **B , **C, **A ; int i , j , N , per ; cm_inversion pr ; char junk[100] ; FILE *fp ; char pbm_aofile[50] = "A.pbm" ; char pbm_bofile[50] = "B.pbm" ; printf ( " N, num_per_row [0 means hand type] ?" ) ; inputi ( &N ) ; inputri ( &per ) ; printf ( "m3: %d ", malloc_verify() ) ;fflush(stdout) ; A = cmatrix ( 1 , N , 1 , N ) ; printf ( "m3: %d ", malloc_verify() ) ;fflush(stdout) ; B = cmatrix ( 1 , N , 1 , N ) ; printf ( "m3: %d ", malloc_verify() ) ;fflush(stdout) ; if ( per==0 ) typeincmatrix ( A , 1 , N , 1 , N ) ; else sparse_random_cmatrix2 ( A , per , N ) ; printf ( "m3: %d ", malloc_verify() ) ;fflush(stdout) ; allocate_cm_inversion ( A , 1 , N , B , &pr ) ; /* print_cm_inversion ( &pr ) ; */ while ( ( i = invert_cmatrix ( &pr ) ) == 0 ) { printf( "changing %d\n" , pr.i ) ; i = modify_cmatrix_row ( &pr ) ; } fp = fopen ( pbm_aofile , "w" ) ; cmatrix2pbm ( A , 1 , N , 1 , N , fp ) ; fclose ( fp ) ; sprintf ( junk , "xv %s -geometry +10+10 &" , pbm_aofile ) ; system ( junk ) ; fp = fopen ( pbm_bofile , "w" ) ; cmatrix2pbm ( B , 1 , N , 1 , N , fp ) ; fclose ( fp ) ; sprintf ( junk , "xv %s -geometry +400+10 &" , pbm_bofile ) ; system ( junk ) ; printf( "testing...\n" ) ; C = cmatrix ( 1 , N , 1 , N ) ; mult_cms ( A , B , C , 1 , N ) ; for ( i = 1 ; i <= N ; i ++ ) { for ( j = 1 ; j <= N ; j ++ ) { if (( i==j ^ C[i][j]==1 ) ) { printoutcmatrix( C , 1 , N , 1 , N ) ; pause_for_return () ; } } } printf ("done\n"); free_cm_inversion ( &pr ) ; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -