aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2019-03-13 15:56:17 +0100
committerThomas White <taw@physics.org>2019-03-13 15:56:17 +0100
commit811e6b353ee6e560fe6bd26e22dad49e7386cd54 (patch)
tree8e0f95c627df1dfcfe7bb93bbb3482f0b205c49f
parent611eb719079c150a5e8db8196c21a2a08b0c6d6a (diff)
cell_tool: Reject singular transformation matrix
-rw-r--r--src/cell_tool.c8
1 files changed, 7 insertions, 1 deletions
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);