本文整理汇总了C++中CoinPackedMatrix::transposeTimes方法的典型用法代码示例。如果您正苦于以下问题:C++ CoinPackedMatrix::transposeTimes方法的具体用法?C++ CoinPackedMatrix::transposeTimes怎么用?C++ CoinPackedMatrix::transposeTimes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CoinPackedMatrix
的用法示例。
在下文中一共展示了CoinPackedMatrix::transposeTimes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
int
lpHook::compute_rc(const VOL_dvector& u, VOL_dvector& rc)
{
rowMatrix_.transposeTimes(u.v, rc.v);
const int psize = rowMatrix_.getNumCols();
for (int i = 0; i < psize; ++i)
rc[i] = objcoeffs_[i] - rc[i];
return 0;
}
示例2: solve_numeric
//.........这里部分代码省略.........
for (it=binding.begin(); it!=binding.end(); ++it) {
b[k] = getRightHandSide()[*it];
k++;
}
double * b_Ac = new double[num_binding];
for (int i=0; i<num_binding; ++i) {
b_Ac[i] = b[i] - Ac[i];
}
// 5. solve AA^Ty=(b-Ac)
// 5.1 get AAt in lower triangular format
double ** AAt_dense = new double*[num_binding];
for (int i=0; i<num_binding; ++i) {
AAt_dense[i] = new double[num_binding]();
}
int const * AAt_cols = AAt->getIndices();
double const * AAt_value = AAt->getElements();
for (int i=0; i<num_binding; ++i) {
// get row i
int first = AAt->getVectorFirst(i);
int last = AAt->getVectorLast(i);
//int num_elem = last-first;
for (int j=first; j<last; ++j) {
AAt_dense[i][AAt_cols[j]] = AAt_value[j];
}
}
// 5.2 call lapack routine to solve the system
double * y = new double[num_binding];
lapack_solve(AAt_dense, b_Ac, y, num_binding);
// 6. compute d <- c+A^Ty
// in other words x <- c + A'(AA')^{-1}b - A'(AA')^{-1}Ac when
// we insert for y.
// 6.1 compute Aty
double * Aty = new double[num_cols];
A->transposeTimes(y, Aty);
// 6.2 compute d <- c+A^Ty
double * dir = new double[num_cols];
double const * cur_sol = getColSolution();
for (int i=0; i<num_cols; ++i) {
dir[i] = -obj[i] - Aty[i];
}
// 7. go along direction until we hit boundry, ie. compute step_size
double step_size = 0.0;
int num_cones = getNumCones();
imp_solution_ = new double[num_cols];
std::copy(cur_sol, cur_sol+num_cols, imp_solution_);
double * par_sol;
double * par_dir;
for (int i=0; i<num_cones; ++i) {
int cone_size = cones_[i]->size();
LorentzCone * con = dynamic_cast<LorentzCone*>(cones_[i]);
int const * members = con->members();
par_sol = new double[cone_size];
par_dir = new double[cone_size];
// 7.1 compute step size
// 7.2 compute a in ax^2+bx+c=0
// 7.3 compute b in ax^2+bx+c=0
// 7.4 compute c in ax^2+bx+c=0
for (int j=0; j<con->size(); j++) {
par_sol[j] = cur_sol[members[j]];
par_dir[j] = dir[members[j]];
}
double feas_i = par_sol[0]*par_sol[0]-std::inner_product(par_sol+1, par_sol+cone_size, par_sol+1, 0.0);
if (feas_i > options_->get_dbl_option(TOL)) {
delete[] par_sol;
delete[] par_dir;
continue;