Example #1
0
const MV_Vector_double MV_Vector_double::operator()(const MV_VecIndex &I) const
{
    // check that index is not out of bounds
    //
    if (I.all())
        return MV_Vector_double(p_, dim_, MV_Vector_::ref);
    else
    {
      if ( I.end() >= dim_)
      {
        std::cerr << "MV_VecIndex: (" << I.start() << ":" << I.end() << 
                ") too big for matrix (0:" << dim_ - 1 << ") " << "\n";
        exit(1);
      }
      return MV_Vector_double(p_+ I.start(), I.end() - I.start() + 1,
            MV_Vector_::ref);
    }
}
Example #2
0
const MV_ColMat MV_ColMat::operator()(const MV_VecIndex &I, 
    const MV_VecIndex &J) const
{

    cerr << "Const operator()(MV_VecIndex, MV_VecIndex) called " << endl;

    // check that index is not out of bounds
    //
    if (I.end() >= dim0_  || J.end() >= dim1_)
    {
        cerr << "Matrix index: (" << I.start() << ":" << I.end()  
             << "," << J.start() << ":" << J.end()   
             << ") not a subset of (0:" << dim0_ - 1 << ", 0:" 
             << dim1_-1 << ") " << endl;
        exit(1);
    }

    // this automatically returns a reference.  we need to 
    // "cast away" constness here, so the &v_[] arg will
    // not cause a compiler error.
    //
    MV_ColMat *t =  (MV_ColMat*) this;
    return MV_ColMat(&(t->v_[J.start()*lda_ + I.start()]), 
            I.end() - I.start() + 1, 
            J.end() - J.start() + 1, lda_, MV_Matrix_::ref);
}
Example #3
0
MV_ColMat MV_ColMat::operator()(const MV_VecIndex &I, const MV_VecIndex &J)
{
    // check that index is not out of bounds
    //
    if (I.end() >= dim0_  || J.end() >= dim1_)
    {
        cerr << "Matrix index: (" << I.start() << ":" << I.end()  
             << "," << J.start() << ":" << J.end()   
             << ") not a subset of (0:" << dim0_ - 1 << ", 0:" 
             << dim1_-1 << ") " << endl;
        exit(1);
    }

    // this automatically returns a reference
    // 
    return MV_ColMat(&v_[J.start()*lda_ + I.start()], 
            I.end() - I.start() + 1, 
            J.end() - J.start() + 1, lda_, MV_Matrix_::ref);
}