#include <IpSymTMatrix.hpp>
In the triplet format, the nonzeros elements of a symmetric matrix is stored in three arrays, Irn, Jcn, and Values, all of length Nonzeros. The first two arrays indicate the location of a non-zero element (as the row and column indices), and the last array stores the value at that location. Off-diagonal elements need to be stored only once since the matrix is symmetric. For example, the element would be stored only once, either with Irn[i]=1 and Jcn[i]=2, or with Irn[i]=2 and Jcn[i]=1. Both representations are identical. If nonzero elements (or their symmetric counter part) are listed more than once, their values are added.
The structure of the nonzeros (i.e. the arrays Irn and Jcn) 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 | |
SymTMatrix (const SymTMatrixSpace *owner_space) | |
Constructor, taking the corresponding matrix space. | |
~SymTMatrix () | |
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 |
Obtain pointer to the internal Index array irn_ without the intention to change the matrix data (USE WITH CARE!). | |
const Index * | Jcols () const |
Obtain pointer to the internal Index array jcn_ without the intention to change the matrix data (USE WITH CARE!). | |
Number * | Values () |
Obtain pointer to the internal Number array values_ with the intention to change the matrix data (USE WITH CARE!). | |
const Number * | Values () const |
Obtain pointer to the internal Number array values_ without the intention to change the matrix data (USE WITH CARE!). | |
Methods for providing copy of the matrix data | |
void | FillStruct (ipfint *Irn, ipfint *Jcn) const |
Copy the nonzero structure into provided space. | |
void | FillValues (Number *Values) const |
Copy the value data into provided space. | |
Protected Member Functions | |
Methods overloaded from matrix | |
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 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). |
SymTMatrix | ( | const SymTMatrixSpace * | owner_space | ) |
Constructor, taking the corresponding matrix space.
References SymTMatrixSpace::AllocateInternalStorage(), and SymTMatrix::Nonzeros().
~SymTMatrix | ( | ) |
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 the matrix space.
References Ipopt::IpBlasDcopy(), SymTMatrix::Nonzeros(), and TaggedObject::ObjectChanged().
Index Nonzeros | ( | ) | const [inline] |
Number of nonzero entries.
References SymTMatrixSpace::Nonzeros().
Referenced by SymTMatrix::FillStruct(), SymTMatrix::FillValues(), TripletHelper::GetNumberEntries(), SymTMatrix::HasValidNumbersImpl(), SymTMatrix::MultVectorImpl(), SymTMatrix::PrintImpl(), SymTMatrix::SetValues(), and SymTMatrix::SymTMatrix().
const Index * Irows | ( | ) | const [inline] |
Obtain pointer to the internal Index array irn_ without the intention to change the matrix data (USE WITH CARE!).
This does not produce a copy, and lifetime is not guaranteed!
References SymTMatrixSpace::Irows().
Referenced by SymTMatrix::FillStruct(), SymTMatrix::MultVectorImpl(), and SymTMatrix::PrintImpl().
const Index * Jcols | ( | ) | const [inline] |
Obtain pointer to the internal Index array jcn_ without the intention to change the matrix data (USE WITH CARE!).
This does not produce a copy, and lifetime is not guaranteed!
References SymTMatrixSpace::Jcols().
Referenced by SymTMatrix::FillStruct(), SymTMatrix::MultVectorImpl(), and SymTMatrix::PrintImpl().
Number * Values | ( | ) |
Obtain pointer to the internal Number array values_ with the intention to change the matrix data (USE WITH CARE!).
This does not produce a copy, and lifetime is not guaranteed!
References TaggedObject::ObjectChanged().
Referenced by TNLPAdapter::Eval_h().
const Number * Values | ( | ) | const |
Obtain pointer to the internal Number array values_ without the intention to change the matrix data (USE WITH CARE!).
This does not produce a copy, and lifetime is not guaranteed!
References DBG_ASSERT.
Copy the nonzero structure into provided space.
References DBG_ASSERT, fkinkryx::i, SymTMatrix::Irows(), SymTMatrix::Jcols(), and SymTMatrix::Nonzeros().
void FillValues | ( | Number * | Values | ) | const |
Copy the value data into provided space.
References DBG_ASSERT, Ipopt::IpBlasDcopy(), and SymTMatrix::Nonzeros().
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(), SymMatrix::Dim(), fkinkryx::i, SymTMatrix::Irows(), DenseVector::IsHomogeneous(), SymTMatrix::Jcols(), SymTMatrix::Nonzeros(), 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(), SymTMatrix::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, SymTMatrix::Irows(), SymTMatrix::Jcols(), SymTMatrix::Nonzeros(), Journalist::Printf(), and Journalist::PrintfIndented().