Commit fa049b29 authored by Kirill Terekhov's avatar Kirill Terekhov

Update

parent 46969853
......@@ -176,6 +176,15 @@ namespace INMOST
return success;
}
bool Model::PrepareIterations()
{
bool success = true;
for(std::vector< std::pair<std::string, AbstractSubModel *> >::const_iterator it = SubModels.begin();
it != SubModels.end(); ++it)
success &= it->second->PrepareIterations();
return success;
}
bool Model::FillResidual(Residual & R) const
{
bool success = true;
......
......@@ -202,7 +202,7 @@ namespace INMOST
/// @param order_singular_values
/// \warning Somehow result differ in auto-differential mode.
/// \todo Test implementation for auto-differentiation.
bool SVD(AbstractMatrix<Var> & U, AbstractMatrix<Var> & Sigma, AbstractMatrix<Var> & V, bool order_singular_values = true) const
bool SVD(AbstractMatrix<Var> & U, AbstractMatrix<Var> & Sigma, AbstractMatrix<Var> & V, bool order_singular_values = true, bool nonnegative = true) const
{
int flag, i, its, j, jj, k, l, nm;
int n = Rows();
......@@ -388,7 +388,7 @@ namespace INMOST
z = Sigma(k,k);
if (l == k)
{// convergence
if (z < 0.0)
if (z < 0.0 && nonnegative)
{// make singular value nonnegative
Sigma(k,k) = -z;
for (j = 0; j < (int)n; j++) V(j,k) = -V(j,k);
......
......@@ -2028,7 +2028,7 @@ namespace INMOST
mid = (l + r) / 2;
if (args[mid] > arg) r = mid - 1;
else if (args[mid] < arg) l = mid + 1;
else return mid;
else break;
}
mid = (l + r) / 2;
if (mid > static_cast<int>(size - 2)) mid = static_cast<int>(size - 2);
......
......@@ -24,6 +24,9 @@ namespace INMOST
virtual bool PrepareEntries(Model & P) = 0;
/// Initialize coupling and dependent unknowns.
virtual bool Initialize(Model & P) = 0;
/// Initialize data needed for FillResidual.
/// Called once before nonlinear iterations.
virtual bool PrepareIterations() {return true;}
/// Fill part of the residual related to my unknowns.
virtual bool FillResidual(Residual & R) const = 0;
/// Update solution.
......@@ -108,6 +111,9 @@ namespace INMOST
bool PrepareEntries();
/// Initialze all entries and submodels.
bool Initialize();
/// Initialize data needed for FillResidual.
/// Called once before nonlinear iterations.
bool PrepareIterations();
/// Compute the residual of the model.
bool FillResidual(Residual & R) const;
/// Update solution.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment