File tree Expand file tree Collapse file tree 1 file changed +3
-10
lines changed
Sofa/framework/Type/src/sofa/type Expand file tree Collapse file tree 1 file changed +3
-10
lines changed Original file line number Diff line number Diff line change @@ -112,21 +112,14 @@ class MatSym : public VecNoInit<D * (D + 1) / 2, real>
112112 // / Write access to element (i,j).
113113 inline real& operator ()(const int i, const int j)
114114 {
115- if (i >= j)
116- {
117- return this ->elems [(i * (i + 1 )) / 2 + j];
118- }
119- return this ->elems [(j * (j + 1 )) / 2 + i];
115+ return const_cast <real&>(std::as_const (*this )(i, j));
120116 }
121117
122118 // / Read-only access to element (i,j).
123119 inline const real& operator ()(const int i, const int j) const
124120 {
125- if (i >= j)
126- {
127- return this ->elems [(i * (i + 1 )) / 2 + j];
128- }
129- return this ->elems [(j * (j + 1 )) / 2 + i];
121+ const auto [a, b] = std::minmax (i, j);
122+ return this ->elems [(a * (a + 1 )) / 2 + b];
130123 }
131124
132125 // / convert matrix to sym
You can’t perform that action at this time.
0 commit comments