cann`t change the relation content of GMatrix

  • doityth777

    doityth777 - 2012-05-01

    a GMatrix with relation content set by setRation() function already. but i
    want to only change the relation name or certain name of attribute. how to do?

  • Mike Gashler

    Mike Gashler - 2012-05-01

    1- call "GMatrix::relation()" to obtain a smart_ptr (see GHolders.h) that
    references the relation.

    2- call "smart_ptr::get()" to obtain a pointer to the relation (GRelation*).

    3- call "GRelation::type()" to make sure that it is ARFF.

    4- cast to GArffRelation.

    5- call "setName" or "setAttrValueCount", etc. (Hmm, it looks like I have not
    provided a "setAttrName" method. Perhaps that should be added.)


    GRelation* pRel = mymatrix.relation().get();

    if(pRel->type() != GRelation::ARFF)

    ThrowError("Expected a GArffRelation. Got something else.");

    GArffRelation pArffRel = (GArffRelation)pRel;


    (disclaimer: I did not compile this.)

    (It seems that my use of smart pointers is what is causing the confusion. It
    might help to examine the "smart_ptr" class in GHolders.h, or read about smart



Cancel  Add attachments

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks