本文整理汇总了C++中eigen::SparseMatrix::valuePtr方法的典型用法代码示例。如果您正苦于以下问题:C++ SparseMatrix::valuePtr方法的具体用法?C++ SparseMatrix::valuePtr怎么用?C++ SparseMatrix::valuePtr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eigen::SparseMatrix
的用法示例。
在下文中一共展示了SparseMatrix::valuePtr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convert_from_Eigen
ColCompressedMatrix convert_from_Eigen(const Eigen::SparseMatrix<double> &m)
{
assert(m.rows() == m.cols());
assert(m.isCompressed());
return ColCompressedMatrix(m.rows, m.nonZeros(),
m.valuePtr(), m.outerIndexPtr(), m.innerIndexPtr());
}
示例2: dx
/// Solve the linear system Ax = b, with A being the
/// combined derivative matrix of the residual and b
/// being the residual itself.
/// \param[in] residual residual object containing A and b.
/// \return the solution x
NewtonIterationBlackoilSimple::SolutionVector
NewtonIterationBlackoilSimple::computeNewtonIncrement(const LinearisedBlackoilResidual& residual) const
{
typedef LinearisedBlackoilResidual::ADB ADB;
const int np = residual.material_balance_eq.size();
ADB mass_res = residual.material_balance_eq[0];
for (int phase = 1; phase < np; ++phase) {
mass_res = vertcat(mass_res, residual.material_balance_eq[phase]);
}
const ADB well_res = vertcat(residual.well_flux_eq, residual.well_eq);
const ADB total_residual = collapseJacs(vertcat(mass_res, well_res));
Eigen::SparseMatrix<double, Eigen::RowMajor> matr;
total_residual.derivative()[0].toSparse(matr);
SolutionVector dx(SolutionVector::Zero(total_residual.size()));
Opm::LinearSolverInterface::LinearSolverReport rep
= linsolver_->solve(matr.rows(), matr.nonZeros(),
matr.outerIndexPtr(), matr.innerIndexPtr(), matr.valuePtr(),
total_residual.value().data(), dx.data(), parallelInformation_);
// store iterations
iterations_ = rep.iterations;
if (!rep.converged) {
OPM_THROW(LinearSolverProblem,
"FullyImplicitBlackoilSolver::solveJacobianSystem(): "
"Linear solver convergence failure.");
}
return dx;
}
示例3: to_mkl
ConvertToMklResult to_mkl(const Eigen::SparseMatrix<double> &Ain,
sparse_status_t &status) {
ConvertToMklResult result;
const int N = static_cast<int>(Ain.rows());
// const-cast to work with C-api.
int *row_starts = const_cast<int *>(Ain.outerIndexPtr());
int *col_index = const_cast<int *>(Ain.innerIndexPtr());
double *values = const_cast<double *>(Ain.valuePtr());
result.descr.type = SPARSE_MATRIX_TYPE_GENERAL; /* Full matrix is stored */
result.status =
mkl_sparse_d_create_csr(&result.matrix, SPARSE_INDEX_BASE_ZERO, N, N,
row_starts, row_starts + 1, col_index, values);
return result;
}