16#ifndef Domaine_Poly_tools_included
17#define Domaine_Poly_tools_included
25static inline DoubleTab prod(DoubleTab a, DoubleTab b)
30 for (i = 0; i < m; i++)
31 for (j = 0; j < n; j++)
32 for (k = 0; k < p; k++) r(i, k) += a(i, j) * b(j, k);
35static inline DoubleTab transp(DoubleTab a)
39 for (i = 0; i < m; i++)
40 for (j = 0; j < n; j++) r(j, i) = a(i, j);
59static inline double kersol(
const DoubleTab& M, DoubleTab& b,
double eps, DoubleTab *P, DoubleTab& x, DoubleTab& S)
61 int i, nk, m = M.
dimension(0), n = M.
dimension(1), k = std::min(m, n), l = std::max(m, n), w = 5 * l, info=-1, iP, jP;
65 DoubleTab A = M, U(m, m), Vt(n, n), W(w), iS(n, m);
67 F77NAME(dgesvd)(&a, &a, &n, &m, A.
addr(), &n, S.
addr(), Vt.addr(), &n, U.addr(), &m, W.addr(), &w, &info);
68 for (i = 0, nk = n; i < k && S(i) > eps * S(0); i++) nk--;
70 for (i = 0, jP = -1; i < n; i++)
71 if (i < k && S(i) > eps * S(0)) iS(i, i) = 1 / S(i);
73 for (iP = 0, jP++; iP < n; iP++) (*P)(iP, jP) = Vt(i, iP);
74 x = prod(transp(Vt), prod(iS, prod(transp(U), b)));
75 DoubleTab res = prod(M, x);
76 for (i = 0; i < m; i++) res2 += std::pow(res(i, 0) - b(i, 0), 2);
88#define CRIMP(a) a.nb_dim() > 2 ? a.resize(a.dimension(0) + 1, a.dimension(1), a.dimension(2)) : a.nb_dim() > 1 ? a.resize(a.dimension(0) + 1, a.dimension(1)) : a.resize(a.dimension(0) + 1), \
89 a.nb_dim() > 2 ? a.resize(a.dimension(0) - 1, a.dimension(1), a.dimension(2)) : a.nb_dim() > 1 ? a.resize(a.dimension(0) - 1, a.dimension(1)) : a.resize(a.dimension(0) - 1)
void resize(_SIZE_ n, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
_SIZE_ dimension(int d) const