Use map::try_emplace() instead of map::emplace() to simplify some calls
By the way, remove a redundant Cluster{} constructor call.master
parent
7c6402cc34
commit
5ff503a964
|
@ -499,10 +499,10 @@ ConfigFile::addParallelConfFileElement(bool inNode, bool inCluster, const member
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
else
|
||||
follower_nodes.emplace(name, FollowerNode{computerName, port, minCpuNbr, maxCpuNbr, userName,
|
||||
password, remoteDrive, remoteDirectory, programPath, programConfig,
|
||||
matlabOctavePath, singleCompThread, numberOfThreadsPerJob,
|
||||
operatingSystem});
|
||||
follower_nodes.try_emplace(name, computerName, port, minCpuNbr, maxCpuNbr, userName,
|
||||
password, remoteDrive, remoteDirectory, programPath, programConfig,
|
||||
matlabOctavePath, singleCompThread, numberOfThreadsPerJob,
|
||||
operatingSystem);
|
||||
//! ADD CLUSTER
|
||||
else if (inCluster)
|
||||
if (minCpuNbr > 0 || maxCpuNbr > 0 || !userName.empty()
|
||||
|
@ -523,7 +523,7 @@ ConfigFile::addParallelConfFileElement(bool inNode, bool inCluster, const member
|
|||
{
|
||||
if (clusters.empty())
|
||||
firstClusterName = name;
|
||||
clusters.emplace(name, Cluster{member_nodes});
|
||||
clusters.emplace(name, member_nodes);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2363,7 +2363,7 @@ DynamicModel::computeChainRuleJacobian()
|
|||
assert(lag >= -1 && lag <= 1);
|
||||
if (eq >= nb_recursives && var >= nb_recursives
|
||||
&& !(one_boundary && lag != 0))
|
||||
blocks_jacobian_sparse_column_major_order[blk].emplace(pair{eq-nb_recursives, var-nb_recursives+static_cast<int>(!one_boundary)*(lag+1)*mfs_size}, d1);
|
||||
blocks_jacobian_sparse_column_major_order[blk].try_emplace({eq-nb_recursives, var-nb_recursives+static_cast<int>(!one_boundary)*(lag+1)*mfs_size}, d1);
|
||||
}
|
||||
blocks_jacobian_sparse_colptr[blk] = computeCSCColPtr(blocks_jacobian_sparse_column_major_order[blk], (one_boundary ? 1 : 3)*mfs_size);
|
||||
}
|
||||
|
|
|
@ -146,7 +146,7 @@ ModelTree::ModelTree(SymbolTable &symbol_table_arg,
|
|||
{
|
||||
// Ensure that elements accessed by writeParamsDerivativesFileHelper() exist
|
||||
for (const auto &ord : {pair{0, 1}, pair{1, 1}, pair{0, 2}, pair{1, 2}, pair{2, 1}, pair{3, 1}})
|
||||
params_derivatives.emplace(ord, decltype(params_derivatives)::mapped_type{});
|
||||
params_derivatives.try_emplace(ord);
|
||||
}
|
||||
|
||||
ModelTree::ModelTree(const ModelTree &m) :
|
||||
|
@ -880,7 +880,7 @@ ModelTree::computeDerivatives(int order, const set<int> &vars)
|
|||
|
||||
// Compute the sparse representation of the Jacobian
|
||||
for (const auto &[indices, d1] : derivatives[1])
|
||||
jacobian_sparse_column_major_order.emplace(pair{indices[0], getJacobianCol(indices[1], true)}, d1);
|
||||
jacobian_sparse_column_major_order.try_emplace({indices[0], getJacobianCol(indices[1], true)}, d1);
|
||||
jacobian_sparse_colptr = computeCSCColPtr(jacobian_sparse_column_major_order, getJacobianColsNbr(true));
|
||||
|
||||
// Higher-order derivatives
|
||||
|
|
|
@ -689,7 +689,7 @@ StaticModel::computeChainRuleJacobian()
|
|||
auto &[eq, var, lag] { indices };
|
||||
assert(lag == 0);
|
||||
if (eq >= nb_recursives && var >= nb_recursives)
|
||||
blocks_jacobian_sparse_column_major_order[blk].emplace(pair{eq-nb_recursives, var-nb_recursives}, d1);
|
||||
blocks_jacobian_sparse_column_major_order[blk].try_emplace({eq-nb_recursives, var-nb_recursives}, d1);
|
||||
}
|
||||
blocks_jacobian_sparse_colptr[blk] = computeCSCColPtr(blocks_jacobian_sparse_column_major_order[blk], blocks[blk].mfs_size);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue