コード例 #1
0
ファイル: tests.cpp プロジェクト: kupcimat/MI-NON
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) {
    }
}
コード例 #2
0
ファイル: tests.cpp プロジェクト: kupcimat/MI-NON
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;
}