void DenseSymMatrix::HighRankUpdate(bool trans, Number alpha, const DenseGenMatrix& V, Number beta) { DBG_ASSERT((!trans && Dim()==V.NRows()) || (trans && Dim()==V.NCols())); DBG_ASSERT(beta==0. || initialized_); Index nrank; if (trans) { nrank = V.NRows(); } else { nrank = V.NCols(); } IpBlasDsyrk(trans, Dim(), nrank, alpha, V.Values(), V.NRows(), beta, values_, NRows()); initialized_ = true; ObjectChanged(); }
bool DenseGenMatrix::ComputeCholeskyFactor(const DenseSymMatrix& M) { Index dim = M.Dim(); DBG_ASSERT(dim==NCols()); DBG_ASSERT(dim==NRows()); ObjectChanged(); // First we copy the content of the symmetric matrix into J const Number* Mvalues = M.Values(); for (Index j=0; j<dim; j++) { for (Index i=j; i<dim; i++) { values_[i+j*dim] = Mvalues[i+j*dim]; } } // Now call the lapack subroutine to perform the factorization Index info; IpLapackDpotrf(dim, values_, dim, info); DBG_ASSERT(info>=0); if (info!=0) { initialized_ = false; return false; } // We set all strictly upper values to zero // ToDo: This might not be necessary?!? for (Index j=1; j<dim; j++) { for (Index i=0; i<j; i++) { values_[i+j*dim] = 0.; } } factorization_ = CHOL; initialized_ = true; return true; }
void DenseGenMatrix::AddMatrixProduct(Number alpha, const DenseGenMatrix& A, bool transA, const DenseGenMatrix& B, bool transB, Number beta) { Index m = NRows(); DBG_ASSERT((transA && A.NCols()==m) || (!transA && A.NRows()==m)); Index n = NCols(); DBG_ASSERT((transB && B.NRows()==n) || (!transB && B.NCols()==n)); Index k; if (transA) { k = A.NRows(); } else { k = A.NCols(); } DBG_ASSERT((transB && B.NCols()==k) || (!transB && B.NRows()==k)); DBG_ASSERT(beta==0. || initialized_); IpBlasDgemm(transA, transB, m, n, k, alpha, A.Values(), A.NRows(), B.Values(), B.NRows(), beta, values_, NRows()); initialized_ = true; ObjectChanged(); }
inline void Vector::Copy(const Vector& x) { CopyImpl(x); ObjectChanged(); // Also copy any cached scalar values from the original vector // ToDo: Check if that is too much overhead TaggedObject::Tag x_tag = x.GetTag(); if (x_tag == x.nrm2_cache_tag_) { nrm2_cache_tag_ = GetTag(); cached_nrm2_ = x.cached_nrm2_; } if (x_tag == x.asum_cache_tag_) { asum_cache_tag_ = GetTag(); cached_asum_ = x.cached_asum_; } if (x_tag == x.amax_cache_tag_) { amax_cache_tag_ = GetTag(); cached_amax_ = x.cached_amax_; } if (x_tag == x.max_cache_tag_) { max_cache_tag_ = GetTag(); cached_max_ = x.cached_max_; } if (x_tag == x.min_cache_tag_) { min_cache_tag_ = GetTag(); cached_min_ = x.cached_min_; } if (x_tag == x.sum_cache_tag_) { sum_cache_tag_ = GetTag(); cached_sum_ = x.cached_sum_; } if (x_tag == x.sumlogs_cache_tag_) { sumlogs_cache_tag_ = GetTag(); cached_sumlogs_ = x.cached_sumlogs_; } }
void DenseSymMatrix::SpecialAddForLMSR1(const DenseVector& D, const DenseGenMatrix& L) { const Index dim = Dim(); DBG_ASSERT(initialized_); DBG_ASSERT(dim==D.Dim()); DBG_ASSERT(dim==L.NRows()); DBG_ASSERT(dim==L.NCols()); // First add the diagonal matrix const Number* Dvalues = D.Values(); for (Index i=0; i<dim; i++) { values_[i+i*dim] += Dvalues[i]; } // Now add the strictly-lower triagular matrix L and its transpose const Number* Lvalues = L.Values(); for (Index j=0; j<dim; j++) { for (Index i=j+1; i<dim; i++) { values_[i+j*dim] += Lvalues[i+j*dim]; } } ObjectChanged(); }
void MultiVectorMatrix::ScaleColumns(const Vector& scal_vec) { // Santiy checks DBG_ASSERT(scal_vec.Dim() == NCols()); // See if we can understand the data const DenseVector* dense_scal_vec = static_cast<const DenseVector*>(&scal_vec); DBG_ASSERT(dynamic_cast<const DenseVector*>(&scal_vec)); if (dense_scal_vec->IsHomogeneous()) { Number val = dense_scal_vec->Scalar(); for (Index i=0; i<NCols(); i++) { Vec(i)->Scal(val); } } else { const Number* values = dense_scal_vec->Values(); for (Index i=0; i<NCols(); i++) { Vec(i)->Scal(values[i]); } } ObjectChanged(); }
// PointRemoved void PathManipulator::PointRemoved(int32 index) { fSelection->Remove(index); ObjectChanged(fPath); }
inline void Vector::ElementWiseSqrt() { ElementWiseSqrtImpl(); ObjectChanged(); }
/** Method for retrieving one block from the compound matrix as a * non-const Matrix. Note that calling this method with mark the * CompoundMatrix as changed. Therefore, only use this method if * you are intending to change the Matrix that you receive. */ SmartPtr<Matrix> GetCompNonConst(Index irow, Index jcol) { ObjectChanged(); return Comp(irow, jcol); }
void GenTMatrix::SetValues(const Number* Values) { IpBlasDcopy(Nonzeros(), Values, 1, values_, 1); initialized_ = true; ObjectChanged(); }
/** Method for setting the positive low-rank update part. */ void SetV(const MultiVectorMatrix& V) { V_ = &V; ObjectChanged(); }
/** Return a particular component (non-const version). Note that * calling this method with mark the CompoundVector as changed. * Therefore, only use this method if you are intending to change * the Vector that you receive. */ SmartPtr<Vector> GetCompNonConst(Index i) { ObjectChanged(); return Comp(i); }
/** Get a Vector in a particular column as a non-const * Vector. This is fail if the column has currently only a * non-const Vector stored. */ inline SmartPtr<Vector> GetVectorNonConst(Index i) { ObjectChanged(); return Vec(i); }
inline SmartPtr<SymMatrix> SymScaledMatrix::GetUnscaledMatrixNonConst() { DBG_ASSERT(IsValid(nonconst_matrix_)); ObjectChanged(); return nonconst_matrix_; }
// PointChanged void PathManipulator::PointChanged(int32 index) { ObjectChanged(fPath); }
// PathClosedChanged void PathManipulator::PathClosedChanged() { ObjectChanged(fPath); }
inline void Vector::Axpy(Number alpha, const Vector &x) { AxpyImpl(alpha, x); ObjectChanged(); }
/** Method for setting the diagonal elements (as a Vector). */ void SetDiag(const Vector& D) { D_ = &D; ObjectChanged(); }
inline void Vector::ElementWiseSgn() { ElementWiseSgnImpl(); ObjectChanged(); }
/** Method for setting the negative low-rank update part. */ void SetU(const MultiVectorMatrix& U) { U_ = &U; ObjectChanged(); }
inline void Vector::ElementWiseDivide(const Vector& x) { ElementWiseDivideImpl(x); ObjectChanged(); }
inline void Vector::ElementWiseMultiply(const Vector& x) { ElementWiseMultiplyImpl(x); ObjectChanged(); }
inline void Vector::ElementWiseReciprocal() { ElementWiseReciprocalImpl(); ObjectChanged(); }
/** Retrieve the array for storing the matrix elements. This is * the non-const version, and it is assume that afterwards the * calling method will set all matrix elements. The matrix * elements are stored one column after each other. */ Number* Values() { ObjectChanged(); initialized_ = true; return values_; }
/** Constructor. */ TaggedObject() : Subject() { ObjectChanged(); }