Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

clang-format for Eigen matrix initialization

To inialize for example Eigen::Matrix3i we can use syntax:

Eigen::Matrix3i T;
T << 1, 0, 0,
     0, 2, 0,
     0, 0, 3;

However, when using clang-format (3.6 in my case) with Google style this nice initialization turns into:

Eigen::Matrix3i T;
T << 1, 0, 0, 0, 2, 0, 0, 0, 3;

Is there an easy way to avoid this? Is there a way to tell clang-format to skip something like this?

like image 751
niosus Avatar asked Apr 13 '16 10:04

niosus


1 Answers

It looks like your only option is to use a rather ugly clang-format switching syntax:

Eigen::Matrix3i T;
// clang-format off
T << 1, 0, 0,
     0, 2, 0,
     0, 0, 3;
// clang-format on
like image 177
yuyoyuppe Avatar answered Sep 29 '22 16:09

yuyoyuppe