/* Reference can be found in International table A. */ static int get_Delaunay_reduction( double red_lattice[3][3], SPGCONST double lattice[3][3], const double symprec ) { int i, j; double volume; double basis[4][3]; get_exteneded_basis(basis, lattice); while (1) { if (get_Delaunay_reduction_basis(basis, symprec)) { break; } } get_Delaunay_shortest_vectors( basis, symprec ); for ( i = 0; i < 3; i++ ) { for ( j = 0; j < 3; j++ ) { red_lattice[i][j] = basis[j][i]; } } volume = mat_get_determinant_d3( red_lattice ); if ( mat_Dabs( volume ) < symprec ) { warning_print("spglib: Minimum lattice has no volume (line %d, %s).\n", __LINE__, __FILE__); goto err; } if ( volume < 0 ) { /* Flip axes */ for (i = 0; i < 3; i++) { for ( j = 0; j < 3; j++ ) { red_lattice[i][j] = -red_lattice[i][j]; } } } #ifdef DEBUG debug_print("Delaunay reduction:\n"); debug_print_matrix_d3(red_lattice); double metric[3][3]; mat_get_metric( metric, red_lattice ); debug_print("It's metric tensor.\n"); debug_print_matrix_d3( metric ); #endif return 1; err: return 0; }
/* Return 0 if failed */ static int get_Delaunay_reduction(double red_lattice[3][3], SPGCONST double lattice[3][3], const double symprec) { int i, j; double volume, sum; double basis[4][3]; get_exteneded_basis(basis, lattice); sum = 0; for (i = 0; i < 4; i++) { for (j = 0; j < 3; j++) { sum += basis[i][j] * basis[i][j]; } } while (1) { if (get_Delaunay_reduction_basis(basis, symprec)) { break; } } get_Delaunay_shortest_vectors(basis, symprec); for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { red_lattice[i][j] = basis[j][i]; } } volume = mat_get_determinant_d3(red_lattice); if (mat_Dabs(volume) < symprec) { warning_print("spglib: Minimum lattice has no volume (line %d, %s).\n", __LINE__, __FILE__); goto err; } if (volume < 0) { /* Flip axes */ for (i = 0; i < 3; i++) { for (j = 0; j < 3; j++) { red_lattice[i][j] = -red_lattice[i][j]; } } } return 1; err: return 0; }