133 const std::vector<SchedStrategy>& type,
double tol,
int maxiter,
136 const std::size_t M = L.
rows(), R = L.
cols();
137 if (N.size() != R)
throw InputError(
"pfqn_dmlin: L and N disagree on the class count");
140 std::vector<T> Zv(R, zero);
142 if (Z.
cols() != R)
throw InputError(
"pfqn_dmlin: Z has the wrong width");
143 for (std::size_t s = 0; s < R; ++s)
144 for (std::size_t k = 0; k < Z.
rows(); ++k) Zv[s] += Z(k, s);
151 res.
C.assign(R, zero);
152 res.
X.assign(R, zero);
156 for (std::size_t i = 0; i < M && allZero; ++i)
157 for (std::size_t s = 0; s < R; ++s)
158 if (L(i, s) != zero) {
162 if (M == 0 || allZero) {
163 for (std::size_t s = 0; s < R; ++s) {
165 for (std::size_t i = 0; i < M; ++i) res.
U(i, s) = res.
X[s] * L(i, s);
171 std::vector<Matrix<T> > Qs(R + 1);
172 for (std::size_t s = 0; s <= R; ++s) {
173 const std::vector<int> N1 =
oner(N, s);
174 std::vector<T> Nt(R, zero);
175 for (std::size_t c = 0; c < R; ++c) Nt[c] = num_traits<T>::from_int(N1[c]);
177 pfqn_bs(L, Nt, Zv, std::vector<AmvaSched>(), tol,
static_cast<std::size_t
>(maxiter),
183 std::vector<std::vector<std::vector<T> > > Delta(
184 M, std::vector<std::vector<T> >(R, std::vector<T>(R, zero)));
187 for (
int pass = 0; pass < npasses; ++pass) {
188 for (std::size_t s = 0; s <= R; ++s) {
189 const std::vector<int> N1 =
oner(N, s);
192 for (std::size_t i = 0; i < M; ++i)
193 for (std::size_t c = 0; c < R; ++c)
194 xis(i, c) = (s == 0) ? xi(i, c) : T(xi(i, c) - Delta[i][s - 1][c]);
195 const detail::DmlinCore<T> cr =
196 detail::dmlin_core(L, N1, Zv, Qs[s], xis, tol, maxiter - res.
totiter);
201 for (std::size_t i = 0; i < M; ++i)
202 for (std::size_t r = 0; r < R; ++r) {
203 if (N[r] == 1) Qs[r + 1](i, r) = zero;
204 for (std::size_t s = 1; s <= R; ++s) {
205 const long ns =
static_cast<long>(N[r]) - (r == s - 1 ? 1L : 0L);
206 if (N[r] > 0 && ns > 0)
212 Delta[i][r][s - 1] = zero;
215 for (std::size_t i = 0; i < M; ++i)
216 for (std::size_t c = 0; c < R; ++c) {
218 for (std::size_t r = 0; r < R; ++r) {
219 const long w =
static_cast<long>(N[r]) - (r == c ? 1L : 0L);
226 const detail::DmlinCore<T> fin =
227 detail::dmlin_core(L, N, Zv, Qs[0], xi, tol, maxiter - res.
totiter);
232 for (std::size_t i = 0; i < M; ++i)
233 for (std::size_t s = 0; s < R; ++s) res.
U(i, s) = res.
X[s] * L(i, s);
234 for (std::size_t s = 0; s < R; ++s)
235 res.
C[s] = (res.
X[s] == zero) ? zero
LinearizerResult< T > pfqn_dmlin(const Matrix< T > &L, const std::vector< int > &N, const Matrix< T > &Z, const std::vector< SchedStrategy > &type, double tol, int maxiter, const Matrix< T > &QN0, int npasses=3)
de Souza e Silva-Muntz Improved Linearizer (IL).
AmvaResult< T > pfqn_bs(const Matrix< T > &L, const std::vector< T > &N, const std::vector< T > &Z, const std::vector< AmvaSched > &type, double tol=1e-6, std::size_t maxiter=1000, const Matrix< T > &QN0=Matrix< T >())
Bard-Schweitzer approximate MVA.