/* This function checks if a matrix is orthogonal * returns -1 if it can't be checked * returns 0 if it isn't orthogonal * returns 1 if it is orthogonal */ int is_orthogonal(struct matrix m) { if(m.rows!=m.columns) { printf("This matrix isn't square\n"); return -1; } struct matrix c=traspose(m); c=matrix_multiplication(m,c); return compare_matrix(c,identity_matrix(c.rows)); }
int main(){ char *filename = "data_F.dat"; int n_col=2; int n_row = 884; float *file_data = load_matrix(filename, n_row); float *data = malloc(n_row*n_col*sizeof(float)); float *b = malloc(n_row*sizeof(float)); float *theta = malloc(n_row*sizeof(float)); make_data(file_data, data, b,theta, n_row); float *data_traspose = traspose(data,n_row,n_col); float *matrix = multiply(data_traspose,data, n_col,n_row,n_row,n_col); float *new_b = multiply(data_traspose,b, n_col, n_row, n_row, 1); float *U = malloc(n_col*n_col*sizeof(float)); float *L = malloc(n_col*n_col*sizeof(float)); lu_decomposition(matrix,new_b,U,L,n_col); float a1,a2; solve_upper_triangular(U,new_b,&a1,&a2); print_in_file(a1,a2); return 0; }