@@ -14,8 +14,15 @@ namespace math {
1414 * Return a vector with sum zero corresponding to the specified
1515 * free vector.
1616 *
17- * The sum-to-zero transform is defined using the inverse of the
18- * isometric log ratio transform (ILR)
17+ * The sum-to-zero transform is defined using a modified version of the
18+ * the inverse of the isometric log ratio transform (ILR).
19+ * See:
20+ * Egozcue, Juan Jose; Pawlowsky-Glahn, Vera; Mateu-Figueras, Gloria;
21+ * Barcelo-Vidal, Carles (2003), "Isometric logratio transformations for
22+ * compositional data analysis", Mathematical Geology, 35 (3): 279–300,
23+ * doi:10.1023/A:1023818214614, S2CID 122844634
24+ *
25+ * This is a linear transform, with no Jacobian.
1926 *
2027 * @tparam Vec type of the vector
2128 * @param y Free vector input of dimensionality K - 1.
@@ -26,7 +33,7 @@ template <typename Vec, require_eigen_col_vector_t<Vec>* = nullptr,
2633inline plain_type_t <Vec> sum_to_zero_constrain (const Vec& y) {
2734 const auto N = y.size ();
2835
29- plain_type_t <Vec> z = Eigen::VectorXd::Zero (N+ 1 );
36+ plain_type_t <Vec> z = Eigen::VectorXd::Zero (N + 1 );
3037 if (unlikely (N == 0 )) {
3138 return z;
3239 }
@@ -36,10 +43,10 @@ inline plain_type_t<Vec> sum_to_zero_constrain(const Vec& y) {
3643 typename plain_type_t <Vec>::Scalar sum_w (0 );
3744 for (int i = N; i > 0 ; --i) {
3845 double n = i;
39- auto w = y_ref (i- 1 ) * inv_sqrt (n * (n + 1 ));
46+ auto w = y_ref (i - 1 ) * inv_sqrt (n * (n + 1 ));
4047 sum_w += w;
4148
42- z.coeffRef (i- 1 ) += sum_w;
49+ z.coeffRef (i - 1 ) += sum_w;
4350 z.coeffRef (i) -= w * n;
4451 }
4552
@@ -50,10 +57,15 @@ inline plain_type_t<Vec> sum_to_zero_constrain(const Vec& y) {
5057 * Return a vector with sum zero corresponding to the specified
5158 * free vector.
5259 *
53- * The sum-to-zero transform is defined such that the first K-1
54- * elements are unconstrained and the last element is the negative
55- * sum of those elements. This is a linear transform, with no
56- * Jacobian.
60+ * The sum-to-zero transform is defined using a modified version of the
61+ * the inverse of the isometric log ratio transform (ILR).
62+ * See:
63+ * Egozcue, Juan Jose; Pawlowsky-Glahn, Vera; Mateu-Figueras, Gloria;
64+ * Barcelo-Vidal, Carles (2003), "Isometric logratio transformations for
65+ * compositional data analysis", Mathematical Geology, 35 (3): 279–300,
66+ * doi:10.1023/A:1023818214614, S2CID 122844634
67+ *
68+ * This is a linear transform, with no Jacobian.
5769 *
5870 * @tparam Vec type of the vector
5971 * @param y Free vector input of dimensionality K - 1.
@@ -71,10 +83,15 @@ inline plain_type_t<Vec> sum_to_zero_constrain(const Vec& y,
7183 * Return a vector with sum zero corresponding to the specified
7284 * free vector.
7385 *
74- * The sum-to-zero transform is defined such that the first K-1
75- * elements are unconstrained and the last element is the negative
76- * sum of those elements. This is a linear transform, with no
77- * Jacobian.
86+ * The sum-to-zero transform is defined using a modified version of the
87+ * the inverse of the isometric log ratio transform (ILR).
88+ * See:
89+ * Egozcue, Juan Jose; Pawlowsky-Glahn, Vera; Mateu-Figueras, Gloria;
90+ * Barcelo-Vidal, Carles (2003), "Isometric logratio transformations for
91+ * compositional data analysis", Mathematical Geology, 35 (3): 279–300,
92+ * doi:10.1023/A:1023818214614, S2CID 122844634
93+ *
94+ * This is a linear transform, with no Jacobian.
7895 *
7996 * @tparam Jacobian unused
8097 * @tparam Vec A type inheriting from `Eigen::DenseBase` or a `var_value` with
@@ -94,10 +111,15 @@ inline plain_type_t<Vec> sum_to_zero_constrain(const Vec& y,
94111 * Return a vector with sum zero corresponding to the specified
95112 * free vector.
96113 *
97- * The sum-to-zero transform is defined such that the first K-1
98- * elements are unconstrained and the last element is the negative
99- * sum of those elements. This is a linear transform, with no
100- * Jacobian.
114+ * The sum-to-zero transform is defined using a modified version of the
115+ * the inverse of the isometric log ratio transform (ILR).
116+ * See:
117+ * Egozcue, Juan Jose; Pawlowsky-Glahn, Vera; Mateu-Figueras, Gloria;
118+ * Barcelo-Vidal, Carles (2003), "Isometric logratio transformations for
119+ * compositional data analysis", Mathematical Geology, 35 (3): 279–300,
120+ * doi:10.1023/A:1023818214614, S2CID 122844634
121+ *
122+ * This is a linear transform, with no Jacobian.
101123 *
102124 * @tparam Jacobian unused
103125 * @tparam Vec A standard vector with inner type inheriting from
0 commit comments