#include <IpGenTMatrix.hpp>
In the triplet format, the nonzeros elements of a general matrix is stored in three arrays, Irow, Jcol, and Values, all of length Nonzeros. The first two arrays indicate the location of a non-zero element (row and column indices), and the last array stores the value at that location. If nonzero elements are listed more than once, their values are added.
The structure of the nonzeros (i.e. the arrays Irow and Jcol) cannot be changed after the matrix can been initialized. Only the values of the nonzero elements can be modified.
Note that the first row and column of a matrix has index 1, not 0.
Public Member Functions | |
Constructors / Destructors | |
GenTMatrix (const GenTMatrixSpace *owner_space) | |
Constructor, taking the owner_space. | |
~GenTMatrix () | |
Destructor. | |
Changing the Values. | |
void | SetValues (const Number *Values) |
Set values of nonzero elements. | |
Accessor Methods | |
Index | Nonzeros () const |
Number of nonzero entries. | |
const Index * | Irows () const |
Array with Row indices (counting starts at 1). | |
const Index * | Jcols () const |
Array with Column indices (counting starts at 1). | |
const Number * | Values () const |
Array with nonzero values (const version). | |
Number * | Values () |
Array with the nonzero values of this matrix (non-const version). | |
Protected Member Functions | |
Overloaded methods from Matrix base class | |
virtual void | MultVectorImpl (Number alpha, const Vector &x, Number beta, Vector &y) const |
Method for determining if all stored numbers are valid (i.e., no Inf or Nan). | |
virtual void | TransMultVectorImpl (Number alpha, const Vector &x, Number beta, Vector &y) const |
Method for determining if all stored numbers are valid (i.e., no Inf or Nan). | |
virtual bool | HasValidNumbersImpl () const |
Method for determining if all stored numbers are valid (i.e., no Inf or Nan). | |
virtual void | PrintImpl (const Journalist &jnlst, EJournalLevel level, EJournalCategory category, const std::string &name, Index indent, const std::string &prefix) const |
Method for determining if all stored numbers are valid (i.e., no Inf or Nan). |
GenTMatrix | ( | const GenTMatrixSpace * | owner_space | ) |
Constructor, taking the owner_space.
References GenTMatrixSpace::AllocateInternalStorage(), and GenTMatrix::Nonzeros().
~GenTMatrix | ( | ) |
void SetValues | ( | const Number * | Values | ) |
Set values of nonzero elements.
The values of the nonzero elements is copied from the incoming Number array. Important: It is assume that the order of the values in Values corresponds to the one of Irn and Jcn given to one of the constructors above.
References Ipopt::IpBlasDcopy(), GenTMatrix::Nonzeros(), and TaggedObject::ObjectChanged().
Index Nonzeros | ( | ) | const [inline] |
Number of nonzero entries.
References GenTMatrixSpace::Nonzeros().
Referenced by GenTMatrix::GenTMatrix(), TripletHelper::GetNumberEntries(), GenTMatrix::HasValidNumbersImpl(), GenTMatrix::MultVectorImpl(), GenTMatrix::PrintImpl(), GenTMatrix::SetValues(), and GenTMatrix::TransMultVectorImpl().
const Index * Irows | ( | ) | const [inline] |
Array with Row indices (counting starts at 1).
References GenTMatrixSpace::Irows().
Referenced by GenTMatrix::MultVectorImpl(), GenTMatrix::PrintImpl(), and GenTMatrix::TransMultVectorImpl().
const Index * Jcols | ( | ) | const [inline] |
Array with Column indices (counting starts at 1).
References GenTMatrixSpace::Jcols().
Referenced by GenTMatrix::MultVectorImpl(), GenTMatrix::PrintImpl(), and GenTMatrix::TransMultVectorImpl().
const Number* Values | ( | ) | const [inline] |
Array with nonzero values (const version).
Referenced by TNLPAdapter::Eval_jac_c(), and TNLPAdapter::Eval_jac_d().
Number* Values | ( | ) | [inline] |
Array with the nonzero values of this matrix (non-const version).
Use this method only if you are intending to change the values, because the GenTMatrix will be marked as changed.
References TaggedObject::ObjectChanged().
void MultVectorImpl | ( | Number | alpha, | |
const Vector & | x, | |||
Number | beta, | |||
Vector & | y | |||
) | const [protected, virtual] |
Method for determining if all stored numbers are valid (i.e., no Inf or Nan).
Implements Matrix.
References DBG_ASSERT, Vector::Dim(), fkinkryx::i, GenTMatrix::Irows(), DenseVector::IsHomogeneous(), GenTMatrix::Jcols(), Matrix::NCols(), GenTMatrix::Nonzeros(), Matrix::NRows(), Vector::Scal(), DenseVector::Scalar(), Vector::Set(), and DenseVector::Values().
void TransMultVectorImpl | ( | Number | alpha, | |
const Vector & | x, | |||
Number | beta, | |||
Vector & | y | |||
) | const [protected, virtual] |
Method for determining if all stored numbers are valid (i.e., no Inf or Nan).
Implements Matrix.
References DBG_ASSERT, Vector::Dim(), fkinkryx::i, GenTMatrix::Irows(), DenseVector::IsHomogeneous(), GenTMatrix::Jcols(), Matrix::NCols(), GenTMatrix::Nonzeros(), Matrix::NRows(), Vector::Scal(), DenseVector::Scalar(), Vector::Set(), and DenseVector::Values().
bool HasValidNumbersImpl | ( | ) | const [protected, virtual] |
Method for determining if all stored numbers are valid (i.e., no Inf or Nan).
Reimplemented from Matrix.
References DBG_ASSERT, Ipopt::IpBlasDasum(), Ipopt::IsFiniteNumber(), GenTMatrix::Nonzeros(), and SimTK::sum().
void PrintImpl | ( | const Journalist & | jnlst, | |
EJournalLevel | level, | |||
EJournalCategory | category, | |||
const std::string & | name, | |||
Index | indent, | |||
const std::string & | prefix | |||
) | const [protected, virtual] |
Method for determining if all stored numbers are valid (i.e., no Inf or Nan).
Implements Matrix.
References fkinkryx::i, GenTMatrix::Irows(), GenTMatrix::Jcols(), GenTMatrix::Nonzeros(), Journalist::Printf(), and Journalist::PrintfIndented().