74 const std::vector<AmvaSched>& type,
double tol = 1e-6,
77 const std::size_t M = L.
rows(), R = L.
cols();
78 if (N.size() != R)
throw InputError(
"pfqn_bs: L and N disagree on the class count");
79 if (!Z.empty() && Z.size() != R)
throw InputError(
"pfqn_bs: Z has the wrong length");
80 if (!type.empty() && type.size() != M)
throw InputError(
"pfqn_bs: type has the wrong length");
96 if (QN0.rows() != M || QN0.cols() != R)
97 throw InputError(
"pfqn_bs: QN0 has the wrong shape");
100 for (std::size_t i = 0; i < M; ++i)
101 for (std::size_t s = 0; s < R; ++s)
105 for (std::size_t it = 1; it <= maxiter; ++it) {
109 for (std::size_t cls = 0; cls < R; ++cls) {
110 if (N[cls] == zero) {
112 for (std::size_t i = 0; i < M; ++i) {
119 T ctot = Z.empty() ? zero : Z[cls];
120 for (std::size_t i = 0; i < M; ++i) {
121 CN(i, cls) = L(i, cls);
122 if (L(i, cls) == zero) {
126 for (std::size_t s = 0; s < R; ++s) {
128 CN(i, cls) += fcfs ? L(i, s) * r.
QN(i, s) : L(i, cls) * r.
QN(i, s);
130 CN(i, cls) += L(i, cls) * r.
QN(i, cls) * (N[cls] - one) / N[cls];
134 if (ctot == zero)
throw NumericError(
"pfqn_bs: zero total residence time");
135 r.
XN[cls] = N[cls] / ctot;
137 for (std::size_t cls = 0; cls < R; ++cls)
138 for (std::size_t i = 0; i < M; ++i) {
139 r.
QN(i, cls) = r.
XN[cls] * CN(i, cls);
140 r.
UN(i, cls) = r.
XN[cls] * L(i, cls);
145 for (std::size_t cls = 0; cls < R; ++cls) {
146 if (N[cls] == zero)
continue;
147 for (std::size_t i = 0; i < M; ++i) {
152 T((r.
QN(i, cls) - Qprev(i, cls)) / N[cls])));
153 if (d > delta) delta = d;
156 if (Qprev(i, cls) == zero) {
157 if (r.
QN(i, cls) == zero)
continue;
158 delta = std::numeric_limits<double>::infinity();
163 if (d > delta) delta = d;
172 for (std::size_t cls = 0; cls < R; ++cls)
173 for (std::size_t i = 0; i < M; ++i)
174 r.
RN(i, cls) = (N[cls] == zero) ? zero : r.
QN(i, cls) / r.
XN[cls];
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.