Ejemplo n.º 1
0
void DiagonalMatrixTemplate<T>::mulPseudoInverse(const VectorT& a, VectorT& b) const
{
  if(BaseT::n != a.n) FatalError(MatrixError_ArgIncompatibleDimensions);
  if(b.n == 0)
    b.resize(this->n);
  else if(b.n != this->n) FatalError(MatrixError_DestIncompatibleDimensions);
  
  ItT v=this->begin();
  VectorIterator<T> va=a.begin(),vb=b.begin();
  for(int i=0; i<this->n; i++, v++,va++,vb++)
    *vb = *va * PseudoInv(*v);
}
Ejemplo n.º 2
0
    MatrixT diag(VectorT const                 &v,
                 typename MatrixT::ScalarType  zero =
                     static_cast<typename MatrixT::ScalarType>(0))
    {
        MatrixT diag(v.size(), v.size(), zero);
        diag.set_zero(zero);
        //populate diagnals:
        std::vector<IndexType> indices;
        for (graphblas::IndexType ix = 0; ix < v.size(); ++ix) {
            indices.push_back(ix);
        }

        graphblas::buildmatrix(diag, indices.begin(), indices.begin(), v.begin(), v.size());
        return diag;
    }
Ejemplo n.º 3
0
 /** Greater-than operator (lexicographical comparison in order of increasing index). */
 bool operator>(VectorT const & rhs) const
 {
   return std::lexicographical_compare(rhs.begin(), rhs.end(), begin(), end());
 }