Exemple #1
0
void testSimpleMatrixMultiplyInequalSize() {
    SimpleVector v = createSimpleVector(3);
    SimpleMatrix m = createSimpleMatrix(2, 2);

    try {
        m.multiplyLeft(v);
        BOOST_ERROR( "Exception should have been thrown!" );
    } catch (const char* e) {
    }

    try {
        m.multiplyRight(v);
        BOOST_ERROR( "Exception should have been thrown!" );
    } catch (const char* e) {
    }
}
Exemple #2
0
void testSimpleMatrixMultiplyLeft() {
    SimpleVector v = SimpleVector(3);
    SimpleMatrix m = createSimpleMatrix(3, 2);

    v.setElement(0, 3);
    v.setElement(1, 2);
    v.setElement(2, 1);

    // [3,2,1] * [0,1] = [0,6]
    //           [0,1]
    //           [0,1]
    Vector* res = m.multiplyLeft(v);

    BOOST_CHECK( res->size() == 2 );
    BOOST_CHECK( res->getElement(0) == 0 );
    BOOST_CHECK( res->getElement(1) == 6 );

    delete res;
}