本文整理汇总了C++中NCols函数的典型用法代码示例。如果您正苦于以下问题:C++ NCols函数的具体用法?C++ NCols怎么用?C++ NCols使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NCols函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: DBG_ASSERT
void
MultiVectorMatrix::AddRightMultMatrix(Number a,
const MultiVectorMatrix& U,
const Matrix& C,
Number b)
{
DBG_ASSERT(NRows()==U.NRows());
DBG_ASSERT(U.NCols()==C.NRows());
DBG_ASSERT(NCols()==C.NCols());
if (b==0.) {
FillWithNewVectors();
}
// ToDo: For now, we simply use MatrixVector multiplications, but
// we might be more efficient (at least in the non-parallel case)
// if we used Level 3 Blas
SmartPtr<const DenseVectorSpace> mydspace = new DenseVectorSpace(C.NRows());
SmartPtr<DenseVector> mydvec = mydspace->MakeNewDenseVector();
const DenseGenMatrix* dgm_C = static_cast<const DenseGenMatrix*>(&C);
DBG_ASSERT(dynamic_cast<const DenseGenMatrix*>(&C));
for (Index i=0; i<NCols(); i++) {
const Number* CValues = dgm_C->Values();
Number* myvalues = mydvec->Values();
for (Index j=0; j<U.NCols(); j++) {
myvalues[j] = CValues[i*C.NRows() + j];
}
U.MultVector(a, *mydvec, b, *Vec(i));
}
ObjectChanged();
}
开发者ID:BRAINSia,项目名称:calatk,代码行数:32,代码来源:IpMultiVectorMatrix.cpp
示例2: NRows
void DenseGenMatrix::PrintImpl(const Journalist& jnlst,
EJournalLevel level,
EJournalCategory category,
const std::string& name,
Index indent,
const std::string& prefix) const
{
jnlst.Printf(level, category, "\n");
jnlst.PrintfIndented(level, category, indent,
"%sDenseGenMatrix \"%s\" with %d rows and %d columns:\n",
prefix.c_str(), name.c_str(), NRows(), NCols());
if (initialized_) {
for (Index j=0; j<NCols(); j++) {
for (Index i=0; i<NRows(); i++) {
jnlst.PrintfIndented(level, category, indent,
"%s%s[%5d,%5d]=%23.16e\n",
prefix.c_str(), name.c_str(), i, j, values_[i+NRows()*j]);
}
}
}
else {
jnlst.PrintfIndented(level, category, indent,
"The matrix has not yet been initialized!\n");
}
}
开发者ID:alanfalloon,项目名称:ipopt-3.3.5,代码行数:26,代码来源:IpDenseGenMatrix.cpp
示例3: DBG_ASSERT
void DenseGenMatrix::HighRankUpdateTranspose(Number alpha,
const MultiVectorMatrix& V1,
const MultiVectorMatrix& V2,
Number beta)
{
DBG_ASSERT(NRows()==V1.NCols());
DBG_ASSERT(NCols()==V2.NCols());
DBG_ASSERT(beta==0. || initialized_);
if (beta==0.) {
for (Index j=0; j<NCols(); j++) {
for (Index i=0; i<NRows(); i++) {
values_[i+j*NRows()] = alpha*V1.GetVector(i)->Dot(*V2.GetVector(j));
}
}
}
else {
for (Index j=0; j<NCols(); j++) {
for (Index i=0; i<NRows(); i++) {
values_[i+j*NRows()] = alpha*V1.GetVector(i)->Dot(*V2.GetVector(j))
+ beta*values_[i+j*NRows()];
}
}
}
initialized_ = true;
ObjectChanged();
}
开发者ID:alanfalloon,项目名称:ipopt-3.3.5,代码行数:27,代码来源:IpDenseGenMatrix.cpp
示例4: NCols
void MultiVectorMatrix::PrintImpl(const Journalist& jnlst,
EJournalLevel level,
EJournalCategory category,
const std::string& name,
Index indent,
const std::string& prefix) const
{
jnlst.Printf(level, category, "\n");
jnlst.PrintfIndented(level, category, indent,
"%sMultiVectorMatrix \"%s\" with %d columns:\n",
prefix.c_str(), name.c_str(), NCols());
for (Index i=0; i<NCols(); i++) {
if (ConstVec(i)) {
DBG_ASSERT(name.size()<200);
char buffer[256];
Snprintf(buffer, 255, "%s[%2d]", name.c_str(), i);
std::string term_name = buffer;
ConstVec(i)->Print(&jnlst, level, category, term_name,
indent+1, prefix);
}
else {
jnlst.PrintfIndented(level, category, indent,
"%sVector in column %d is not yet set!\n",
prefix.c_str(), i);
}
}
}
开发者ID:BRAINSia,项目名称:calatk,代码行数:28,代码来源:IpMultiVectorMatrix.cpp
示例5: NRows
bool DenseGenMatrix::ComputeLUFactorInPlace()
{
Index dim = NRows();
DBG_ASSERT(dim==NCols());
DBG_ASSERT(factorization_==NONE);
ObjectChanged();
// create pivot space
delete [] pivot_;
pivot_ = NULL; // set to NULL so that destructor will not try to
// delete again if the new in following line fails
pivot_ = new Index[dim];
// call the lapack subroutine for the factorization (dgetrf )
Index info;
IpLapackDgetrf(dim, values_, pivot_, dim, info);
DBG_ASSERT(info>=0);
if (info!=0) {
delete [] pivot_;
pivot_ = NULL;
initialized_ = false;
return false;
}
else {
initialized_ = true;
}
factorization_ = LU;
return true;
}
开发者ID:BRAINSia,项目名称:calatk,代码行数:33,代码来源:IpDenseGenMatrix.cpp
示例6:
const DataMat& DataMat::operator *= (double d)
{
for (int i(0); i<NRows(); i++)
for(int j(0); j<NCols(); j++)
_V[i][j] *= d ;
return *this ;
}
开发者ID:karticsubr,项目名称:FAS2016,代码行数:7,代码来源:DataMat.cpp
示例7: Dim
void DenseSymMatrix::PrintImpl(const Journalist& jnlst,
EJournalLevel level,
EJournalCategory category,
const std::string& name,
Index indent,
const std::string& prefix) const
{
jnlst.Printf(level, category, "\n");
jnlst.PrintfIndented(level, category, indent,
"%sDenseSymMatrix \"%s\" of dimension %d (only lower triangular part printed):\n",
prefix.c_str(), name.c_str(), Dim());
if (initialized_) {
for (Index j=0; j<NCols(); j++) {
for (Index i=j; i<NRows(); i++) {
jnlst.PrintfIndented(level, category, indent,
"%s%s[%5d,%5d]=%23.16e\n",
prefix.c_str(), name.c_str(), i, j, values_[i+NRows()*j]);
}
}
}
else {
jnlst.PrintfIndented(level, category, indent,
"The matrix has not yet been initialized!\n");
}
}
开发者ID:RobotLocomotion,项目名称:ipopt-mirror,代码行数:26,代码来源:IpDenseSymMatrix.cpp
示例8: DBG_START_METH
void MultiVectorMatrix::LRMultVector(Number alpha, const Vector &x,
Number beta, Vector &y) const
{
DBG_START_METH("MultiVectorMatrix::LRMultVector(",
dbg_verbosity);
DBG_ASSERT(NRows()==x.Dim());
DBG_ASSERT(NRows()==y.Dim());
DBG_PRINT((1, "alpha = %e beta = %e\n", alpha, beta));
DBG_PRINT_VECTOR(2, "x", x);
if ( beta!=0.0 ) {
y.Scal(beta);
}
else {
y.Set(0.0);
}
DBG_PRINT_VECTOR(2, "beta*y", y);
for (Index i=0; i<NCols(); i++) {
DBG_PRINT_VECTOR(2, "ConstVec(i)", *ConstVec(i));
y.AddOneVector(alpha*ConstVec(i)->Dot(x), *ConstVec(i), 1.);
DBG_PRINT_VECTOR(2, "y mid", y);
}
}
开发者ID:BRAINSia,项目名称:calatk,代码行数:26,代码来源:IpMultiVectorMatrix.cpp
示例9: DBG_START_METH
bool CompoundMatrixSpace::DimensionsSet() const
{
DBG_START_METH("CompoundMatrixSpace::DimensionsSet", 0);
Index total_nrows = 0;
Index total_ncols = 0;
bool valid = true;
for (Index i=0; i<ncomps_rows_; i++) {
if (block_rows_[i] == -1) {
valid = false;
break;
}
total_nrows += block_rows_[i];
}
if (valid) {
for (Index j=0; j<ncomps_cols_; j++) {
if (block_cols_[j] == -1) {
valid = false;
break;
}
total_ncols += block_cols_[j];
}
}
if (valid) {
DBG_ASSERT(total_nrows == NRows() && total_ncols == NCols());
}
return valid;
}
开发者ID:MengbinZhu,项目名称:pfldp,代码行数:29,代码来源:IpCompoundMatrix.cpp
示例10: NRows
void GenTMatrix::PrintImplOffset(const Journalist& jnlst,
EJournalLevel level,
EJournalCategory category,
const std::string& name,
Index indent,
const std::string& prefix,
Index offset) const
{
jnlst.Printf(level, category, "\n");
jnlst.PrintfIndented(level, category, indent,
"%sGenTMatrix \"%s\" of dimension %d by %d with %d nonzero elements:\n",
prefix.c_str(), name.c_str(), NRows(), NCols(), Nonzeros());
if (initialized_) {
for (Index i=0; i<Nonzeros(); i++) {
jnlst.PrintfIndented(level, category, indent,
"%s%s[%5d,%5d]=%23.16e (%d)\n",
prefix.c_str(), name.c_str(), Irows()[i]+offset,
Jcols()[i], values_[i], i);
}
}
else {
jnlst.PrintfIndented(level, category, indent,
"%sUninitialized!\n", prefix.c_str());
}
}
开发者ID:RobotLocomotion,项目名称:ipopt-mirror,代码行数:25,代码来源:IpGenTMatrix.cpp
示例11: SymMatrix
DenseSymMatrix::DenseSymMatrix(const DenseSymMatrixSpace* owner_space)
:
SymMatrix(owner_space),
owner_space_(owner_space),
values_(new Number[NCols()*NRows()]),
initialized_(false)
{}
开发者ID:RobotLocomotion,项目名称:ipopt-mirror,代码行数:7,代码来源:IpDenseSymMatrix.cpp
示例12: minNR
const DataMat& DataMat::operator -= (const DataMat& D)
{
int minNR(min(NRows(), D.NRows())), minNC(min(NCols(), D.NCols())) ;
for (int i(0); i<minNR; i++)
for(int j(0); j<minNC; j++)
_V[i][j] -= D._V[i][j] ;
return *this ;
}
开发者ID:karticsubr,项目名称:FAS2016,代码行数:9,代码来源:DataMat.cpp
示例13: FillWithNewVectors
void MultiVectorMatrix::FillWithNewVectors()
{
SmartPtr<const VectorSpace> vec_space = owner_space_->ColVectorSpace();
for (Index i=0; i<NCols(); i++) {
non_const_vecs_[i] = vec_space->MakeNew();
const_vecs_[i] = NULL;
}
ObjectChanged();
}
开发者ID:BRAINSia,项目名称:calatk,代码行数:9,代码来源:IpMultiVectorMatrix.cpp
示例14: Matrix
DenseGenMatrix::DenseGenMatrix(const DenseGenMatrixSpace* owner_space)
:
Matrix(owner_space),
owner_space_(owner_space),
values_(new Number[NCols()*NRows()]),
initialized_(false),
factorization_(NONE),
pivot_(NULL)
{}
开发者ID:BRAINSia,项目名称:calatk,代码行数:9,代码来源:IpDenseGenMatrix.cpp
示例15: HasValidNumbersImpl
bool MultiVectorMatrix::HasValidNumbersImpl() const
{
for (Index i=0; i<NCols(); i++) {
if (!ConstVec(i)->HasValidNumbers()) {
return false;
}
}
return true;
}
开发者ID:BRAINSia,项目名称:calatk,代码行数:9,代码来源:IpMultiVectorMatrix.cpp
示例16: DBG_ASSERT
void DenseGenMatrix::LUSolveVector(DenseVector& b) const
{
DBG_ASSERT(NRows()==NCols());
DBG_ASSERT(b.Dim()==NRows());
DBG_ASSERT(initialized_);
DBG_ASSERT(factorization_==LU);
Number* bvalues = b.Values();
IpLapackDgetrs(NRows(), 1, values_, NRows(), pivot_, bvalues, b.Dim());
}
开发者ID:BRAINSia,项目名称:calatk,代码行数:11,代码来源:IpDenseGenMatrix.cpp
示例17: ConstVec
//@{
inline const Vector* ConstVec(Index i) const
{
DBG_ASSERT(i < NCols());
DBG_ASSERT(IsValid(const_vecs_[i]) || IsValid(non_const_vecs_[i]));
if (IsValid(non_const_vecs_[i])) {
return GetRawPtr(non_const_vecs_[i]);
}
else {
return GetRawPtr(const_vecs_[i]);
}
}
开发者ID:RobotLocomotion,项目名称:ipopt-mirror,代码行数:12,代码来源:IpMultiVectorMatrix.hpp
注:本文中的NCols函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论