From 811e6b353ee6e560fe6bd26e22dad49e7386cd54 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 13 Mar 2019 15:56:17 +0100 Subject: cell_tool: Reject singular transformation matrix --- src/cell_tool.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/cell_tool.c b/src/cell_tool.c index 95d5d3bc..652df885 100644 --- a/src/cell_tool.c +++ b/src/cell_tool.c @@ -339,6 +339,7 @@ static int transform(UnitCell *cell, const char *trans_str, const char *out_file) { RationalMatrix *trans; + Rational det; UnitCell *nc; trans = parse_cell_transformation(trans_str); @@ -351,7 +352,12 @@ static int transform(UnitCell *cell, const char *trans_str, STATUS("------------------> The transformation matrix:\n"); rtnl_mtx_print(trans); - STATUS("Determinant = %s\n", rtnl_format(rtnl_mtx_det(trans))); + det = rtnl_mtx_det(trans); + STATUS("Determinant = %s\n", rtnl_format(det)); + if ( rtnl_cmp(det, rtnl_zero()) == 0 ) { + ERROR("Singular transformation matrix - cannot transform.\n"); + return 1; + } STATUS("------------------> The transformed unit cell:\n"); cell_print(nc); -- cgit v1.2.3