void Gauge::Update(void) { _Current += (DestCurrent - _Current)*_Delay; float per = Per(); if (Direction == UP || Direction == DOWN) { _Size.y = _MaxSize*per; } else if (Direction == LEFT || Direction == RIGHT) { _Size.x = _MaxSize*per; } }
unsigned int Matrix::lup(Matrix& L, Matrix& U, Matrix& P) const { if (m_nrows != m_ncols) throw Error(" matrix is not square "); unsigned int permutations = 0; Matrix A = *this; Matrix Lf(m_nrows), dI(m_nrows), Per(m_nrows); dI = dI + dI; for (size_t i = 0; i < m_nrows - 1; i++) { if (Matrix::precision >= std::fabs(A(i, i))) { bool p = 0; for (size_t k = i + 1; k < m_nrows; k++) if (Matrix::precision >= std::fabs(A(k, i))) { A.swapRows(i, k); Per.swapRows(i, k); p = true; break; } if (!p) throw Error("matrix is not invertible"); else permutations++; } Matrix Lt(m_nrows); // gaussian matrix for (size_t j = i + 1; j < m_nrows; j++) Lt(j, i) = -A(j, i) / A(i, i); /* A = Lt * A; Lf = Lf * (dI - Lt); */ A = Lt.multiply(A); Lf = Lf.multiply((dI - Lt)); // dI-Lt is the inverse of Lt (gaussian matrix) } P = Per; U = A; L = Lf; return permutations; }